简体   繁体   English

将白色像素区域合并为单个区域opencv c ++

[英]unite white pixels region into a single region opencv c++

I'm using opencv and I need to obtain a single region of white pixels starting from many regions, like in the image: 我正在使用opencv,我需要从许多区域开始获取白色像素的单个区域,如图像中所示:

有很多白色区域的图像

what I want to get is a single region of white pixels. 我想要得到的是单个白色像素区域。 can be that some regions have to be discarded, but is another point. 可能是某些区域必须丢弃,但这是另一点。 now I'd like to know if there is a way to unite all the regions, even in a not convex poly, because it can be done later. 现在,我想知道是否有一种方法可以将所有区域结合在一起,即使是在非凸多边形中也是如此,因为以后可以这样做。

I know that this is probably not the best way to do it but it's a way. 我知道这可能不是最佳方法 ,但这是一种方法。

As you said, the region you are interested in will always be squared. 如您所说,您感兴趣的区域将始终平方。 I suggest you take a look at the Square Detector application that ships with OpenCV. 我建议您看一下OpenCV附带的Square Detector应用程序。

If you are looking for demos, check this answer . 如果您正在寻找演示, 请查看此答案

Why don't you calculate the convex hull of your pixels? 为什么不计算像素的凸包? As far as I can see this is included in opencv. 据我所知,这是包含在opencv中。

在此处输入图片说明

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

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