andrea
andrea

Reputation: 1358

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:

image with many white regions

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.

Upvotes: 1

Views: 835

Answers (2)

halirutan
halirutan

Reputation: 4341

Why don't you calculate the convex hull of your pixels? As far as I can see this is included in opencv.

enter image description here

Upvotes: 0

karlphillip
karlphillip

Reputation: 93410

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.

If you are looking for demos, check this answer.

Upvotes: 1

Related Questions