1

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.

andrea
  • 1,326
  • 7
  • 31
  • 60
  • If you add the tag of a programming language your question will get better visibility. – karlphillip Dec 14 '11 at 11:13
  • Is this always going to be a squared region? – karlphillip Dec 14 '11 at 11:20
  • once you exclude the outliers it will be always squared. I tried cvfindcontours, but it only find 10 contours in that image, so some of the regions are not seen by that function – andrea Dec 14 '11 at 11:25
  • I didn't get, what you want to achieve. Do you want to separate the white block in the center from the rest? Or do you want the region which is outlined by all the single pixels around the white block? – halirutan Dec 14 '11 at 11:36
  • I have to create a region that groups all the points, except the two on the right border in this case – andrea Dec 14 '11 at 12:18
  • i have a problem like this but i want to remove any shape like the squared region above using opencv, do you have an idea of opencv methods which do that? – chostDevil Apr 21 '12 at 21:50

2 Answers2

1

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.

Community
  • 1
  • 1
karlphillip
  • 92,053
  • 36
  • 243
  • 426
  • I'll have a look, just one quick question. it can find a square even if is inclined respect to the image borders? – andrea Dec 14 '11 at 11:51
  • Are you talking about a square that has some inclination/rotation? yes. – karlphillip Dec 14 '11 at 12:09
  • @andrea By the way, if take a look at [this question](http://stackoverflow.com/questions/7800905/affine-transform-simple-rotation-and-scaling-or-something-else-entirely) one of the images shows a region that has a red square drawed around it. That region was detected through this technique as well, and it's rotated. :) – karlphillip Dec 14 '11 at 12:27
0

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

halirutan
  • 4,281
  • 18
  • 44