1
votes

I am trying to equalize a color image. I was told to convert it into HSB and then perform equalization on brightness channel before converting it back into RGB.

I have so far calculated the frequencies but I am having issues with the scale factor. As I understand, scale factors in the case of colors are usually 255/(height*width) of the image. Can anyone please help with what to do in the case of brightness? Thanks.

1

1 Answers

3
votes

You are correct when you say that you have to convert the RGB image to HSB (or HSV) color space to equalize a color image.

However, I don't understand what you mean by scale factor, so I will describe the algorithm:

  1. Convert the input image to HSB color space.

  2. Using the B (brightness) channel, compute the frequency of each pixel value. In fact, you are computing the gray level histogram of the image. If your image has 256 different brightness values, you can store the histogram in a vector H[0..255] where H[i] gives you the frequency of the i-th brightness value. To compute H[i], count the number of pixels with value i and divide by the number of pixels in the image. If you sum all the entries of H[i] you should get the value 1.0.

  3. Using your histogram H[i], compute a new vector CDF[i] where:

    CDF[0] = H[0] and CDF[i] = CDF[i - 1] + H[i].

    In fact, the CDF[i] vector stores cumulative distribution function of the brightness values over the input image.

  4. The last step consists in updating the B channel of your image: B'[x,y] = 255 * CDF[B[x,y]] where B[x,y] is the B value of the pixel at position (x,y) and B'[x,y] is the new B value of the pixel at position (x,y). Again, this assumes that your image has 256 different brightness values.