简体   繁体   English

OpenCV:区分两个非常相似的轮廓

[英]OpenCV: Differentiate between two very similar contours

I use openCV to find contours in images.我使用 openCV 来查找图像中的轮廓。 The problem is, that some of the contours are just some artifacts I do not want to identify.问题是,一些轮廓只是我不想识别的一些伪影。 In the following image you see an example:在下图中,您会看到一个示例: 在此处输入图像描述

I am interested in the countours 20 and 21. 19 should be ignored.我对计数 20 和 21 感兴趣。应该忽略 19。

UPDATE: I am not interested in the size of the contours, the pixels within the contiour is what differntiates them.更新:我对轮廓的大小不感兴趣,contiour 中的像素是它们的区别。 here is another example:这是另一个例子: 在此处输入图像描述

Countour 18 is kindy blurry, has no "sharp contours" within it. Countour 18 有点模糊,里面没有“尖锐的轮廓”。 Countour 16 has clearer edges and the colorintensity is focused in the center. Countour 16 的边缘更清晰,色彩强度集中在中心。 I would like to know if there is a way to identify contours like that?我想知道是否有办法识别这样的轮廓? I tried it with blurry detection ( see here ) but the output between the multiple images was very very differnet...我尝试使用模糊检测( 请参见此处),但多个图像之间的 output 非常不同...

Thanks for any help!谢谢你的帮助!

after finding contours you can find the area of that individual contour and set a if else condition to select that contours找到轮廓后,您可以找到该单个轮廓的区域并将 if else 条件设置为 select 轮廓

(contours, hierarchy) = cv2.findContours(control, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
 for pic, contour in enumerate(contours):
      area = cv2.contourArea(contour)
            if (area > 200):

in a program i used that contours whose are more than 200 you can also use this在一个程序中,我使用了超过 200 个的轮廓,您也可以使用它

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

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