Comparing histograms without white color included OpenCV

独自空忆成欢 提交于 2019-12-25 02:53:39

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/23450664/comparing-histograms-without-white-color-included-opencv

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!