简体   繁体   English

使用opencv按颜色分组像素

[英]grouping pixels by color using opencv

I have grey scale images with objects darker than the background with each object and the background having the same shade throughout itself. 我有灰度图像,其对象比背景暗,每个对象和整个背景的阴影相同。 There are mainly 3-4 "groups of shades" in each picture. 每个图片中主要有3-4个“阴影组”。 I want to group these pixels to find the approximate background shade (brightness) to later extract it. 我想对这些像素进行分组,以找到近似的背景阴影(亮度)以稍后将其提取。

在此处输入图片说明

And a side question: How can I calculate the angles on a contour produced by findContours.or maybe the minimum angle on a contour. 还有一个侧面的问题:如何计算findContours.contours.es生成的轮廓上的角度,或者轮廓上的最小角度。

I think that you can set a range to group pixels. 我认为您可以设置一个范围来分组像素。 For example, all the pixel which have intensity value in the range (50 - 100) should have the intensity value 100. Similarly, all the pixels which have intensity value in the range (100-150) should have intensity value 150. And so on. 例如,强度值在(50-100)范围内的所有像素应具有强度值100。类似地,强度值在(100-150)范围内的所有像素应具有强度值150。因此上。

After doing the above procedure, you can have have only 3-4 fixed values for all pixels (as you have mentioned that there are 3-4 groups in each image.) 完成上述步骤后,所有像素只能有3-4个固定值(正如您提到的,每个图像中有3-4个组。)

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

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