Java color detection

主宰稳场 提交于 2019-12-11 02:57:18

问题


I am implementing algorithm in java which select a portion of image as marker. My problem is

1) After selecting the marker area, how do i get the specific mean value of marker color in RGB as the number of pixels with a small difference in color.

2) How can i find marker value, meaning the threshold value for the color, based on the previous marker selection.

Please provide an algorithm and if posssible, an implementation in java. Thanks in advance.


回答1:


I'm not sure what you tried, and where you're stuck, but here goes:

  1. To get a mean color your best bet is to try to find the median value for the three channels (R, G and B) separately and use that as the mean. Due to specific qualities of the RGB color space, the mean is very vulnerable to outliers, the median less so.

  2. I assume you want to select all colors that are similar to your marker color. To do that you could select all pixels where the color is less small euclidean distance to your median RGB color selected above.

If this does not work for you you could look into alternative colorspaces. But I think the above should be enough.



来源:https://stackoverflow.com/questions/7506579/java-color-detection

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