简体   繁体   English

使用PIL / Pillow过滤图像中的红色像素

[英]Filter red pixels in an image with PIL/Pillow

currently I am trying to detect red pixels inside a small picture (about 360*360 pixels). 目前,我正在尝试检测小图片(约360 * 360像素)内的红色像素。

The images have a broad range of red-values which is why I can't just iterate over all pixels and check for a certain rgb-value. 图像具有广泛的红色值,这就是为什么我不能仅遍历所有像素并检查某个rgb值的原因。

What would some efficient ways be to analyze such a picture to get the percentage of pixels which are perceived as red by humans? 有什么有效的方法来分析此类图片,以获得人类感知为红色的像素百分比?

Thanks in advance. 提前致谢。

Convert the image into HSV color space. 将图像转换为HSV颜色空间。 Then the croma will be determined just by the H value. 然后仅由H值确定色度。 So you could put a threshold only on H to get red color. 因此,您可以仅对H设置阈值以获得红色。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM