且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何检查RGB图像中的像素是否为绿色?

更新时间:2023-11-25 16:29:58

您可以使用InRange函数查找特定范围内的颜色,因为只有一个或几个像素值,您将无法从卫星上找到绿色。 InRange功能将帮助您找到一系列设置颜色(您应该设置绿色范围)并返回一个图像,其中绿色像素的坐标与原始图像相同。我已经通过示例和代码回答了类似的问题 HERE (虽然它不是python,你应该理解这些方法并在OpenCV项目中轻松实现它),你应该找到你需要的所有东西。

You could use InRange function to find colors in specific range, because you will not be able to find green color from satelites just with one or few values of pixels. InRange function will help you to find a range of set colors (you should set the range of green colors) and return an image with the coordinates of those green pixels ir the original image. I've answered a similar quiestion HERE with examples and code (although it is not python, you should understand the methods and easily implement it in your OpenCV project), you should find everything you need there.