5
$\begingroup$

There is a paper “Auto White Balance Based on the Similarity of Chromaticity Histograms” mention about automatic white balance. One of the key point of this algorithm is how to measure the similarity between three histograms (r, g, b channels). They choose Bhattacharrya distance to measure it.

Equation of Bhattacharrya distance for two histograms (1) $$d(H_1, H_2) = \sqrt{1 - p(H_1, H_2)}$$ $$p(H_1, H_2) = H_1(0) * H_2(0) + H_1(1) * H_2(1) + … + H_1(255) * H_2(255)$$

However, no matter how hard I try, I can't find a way to apply Bhattacharrya distance on three histograms.

Could I just alter the second equation to $$p(H1, H2, H3) = H_1(0) * H_2(0) * H_3(0) + H_1(1) * H_2(1) * H_3(1) + … + H_1(255) * H_2(255) * H_3(255)$$

$\endgroup$
1
  • 5
    $\begingroup$ I think it all starts with the question: How would you define the distance between 3 points? $\endgroup$ – Eskapp Nov 23 '16 at 15:18
0
$\begingroup$

Find similarity between RGB values separately, like I did.

float CTracker::calculate_similarity_colour (BlobPast* prev_blob, PositionArrays* curr_blob, int k)
{
    float total_red = 0;
    float total_blue = 0;
    float total_green = 0;
    float similarity = 0;
    float S_D_R = 0;
    float S_D_G = 0;
    float S_D_B = 0;

    for (int i = 0; i < 256; i++)
    {
        if ((prev_blob->colour_red[i] != NULL ) &&  (curr_blob->colours[i].colour_red != NULL))
        {
            S_D_R = sqrt (abs(  (prev_blob->colour_red[i]) *  (curr_blob->colours[k].colour_red[i])));
            total_red       = total_red + S_D_R;

            S_D_G = sqrt( abs (  ( prev_blob->colour_green[i]) *  (curr_blob->colours[k].colour_green[i])));
            total_green     = total_green + S_D_G;

            S_D_B  = sqrt( abs(  (prev_blob->colour_blue[i]) *   (curr_blob->colours[k].colour_blue[i])));
            total_blue = total_blue + S_D_B;
        }
    }

    similarity = (0.4 * total_red) + (0.3 * total_green) + (0.3 * total_blue);
    return similarity;
}

//Note the reason my similarity would be between 0-1 is I divided each each histograms each value by total number of pixels (i.e., normalizing)
$\endgroup$
2
  • 1
    $\begingroup$ The coefficients 0.4, 0.3, 0.3 look arbitrary. Could you provide a reference for them? $\endgroup$ – whuber Jul 14 '14 at 19:41
  • 2
    $\begingroup$ Like @whuber, I'd be curious to know what the source is for your weights (0.4, 0.3, 0.3). I would think that one of the "official" conversions would be better, like CIE 1931 (0.2126, 0.7152, 0.0722) or the Rec 601 (0.299, 0.587, 0.114). You'd have to deal with gamma expansion/compression too, if you wanted to be 100% correct, but that's verging into overkill. $\endgroup$ – Matt Krause Aug 16 '14 at 16:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.