Java颜色检测
我正在java中实现算法,选择图像的一部分作为标记。 我的问题是
1)选择标记区域后,如何获得RGB中标记颜色的具体平均值作为颜色差异较小的像素数。
2)如何根据之前的标记选择找到标记值,即颜色的阈值。
请提供一个算法,如果可能的话,请提供一个java实现。 提前致谢。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不确定您尝试了什么,以及您被困在哪里,但这里是:
要获得平均颜色,您最好的选择是尝试找到三个通道(R、G 和 B)的中值分别并用其作为平均值。由于 RGB 颜色空间的特定品质,均值很容易受到异常值的影响,而中值则不然。
我假设您想要选择与标记颜色相似的所有颜色。为此,您可以选择颜色较小的所有像素欧几里德距离到上面选择的中值 RGB 颜色。
如果这对您不起作用,您可以查看替代色彩空间。但我认为以上应该足够了。
I'm not sure what you tried, and where you're stuck, but here goes:
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.
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.