user3577807
user3577807

Reputation: 31

Comparing histograms without white color included OpenCV

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.

Upvotes: 0

Views: 871

Answers (1)

skm
skm

Reputation: 5649

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.

Upvotes: 1

Related Questions