Question

Is there a way that compares histograms but for example white color to be excluded and so white color doesn't affect onto the comparison.

Was it helpful?

Solution

White pixels have Saturation, S = 0. So, it is very easy to remove the white pixels from being counted while creating histogram. Do the following:

  • Convert your image from BGR to HSV
  • Then split your HSV image into three individual channels i.e. H, S and V
  • Then, access each pixel of channel S and if the pixel value = 0 (means S = 0) then it mean that it is a white pixel.
  • If the pixel is white then do not consider its Hue value to create histogram and if not...then put its hue value into the corresponding bin (normal procedure to build histogram).

Summary: you just need to find white pixels by checking their Saturation value, which is S = 0.

PS: Have a look at this link to understand the HSV model.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top