Ask Your Question
0

Separating elements

asked 2015-02-20 02:08:47 -0600

KansaiRobot gravatar image

updated 2015-02-20 02:13:06 -0600

Hello and thanks for your help and insights.

I have been trying several functions in OpenCV and learning about it. Now I have the following question:

The question

How to separate two areas that are touching each other?

The situation

Let's say I have two areas that are clearly (to the human eye) two separate elements but are touching each other. They can be anything but let's say something like the following

Touching elements

Actually these elements can be also circles or triangles, but for those separating them is kind of easy because the touching area is small. But how about the example in the figure, these elongated elements when touching each other have an area of contact that is quite large.

Any idea how can I separate them??? (the left one is simpler, the right one is a difficult version of the problem)

I have tried morphological operations like opening etc, but they don't work. Someone could say watersheding but then I would need markers situated in the center of each element and then the question would come to "how do I find those markers?" which is basically the same question: "how do I separate them?"

Thank you for any idea of insight that can point me in the right direction

edit retag flag offensive close merge delete

Comments

Please provide some original images to help us help you. Thanks.

Pedro Batista gravatar imagePedro Batista ( 2015-02-23 04:46:21 -0600 )edit

3 answers

Sort by ยป oldest newest most voted
3

answered 2015-02-20 04:56:49 -0600

theodore gravatar image

updated 2015-02-20 04:57:19 -0600

You question is really generic. For example are your objects from the beginning like that or your example image is the result of some pre-processing procedure (e.g. thresholding, findcontours, etc.)?

Because if it is the latter you should consider that in the original image there are some features that you not using and that could be really useful (e.g. edges of the overlapping, touching objects). In this case applying some distance transform in combination with watershed algorithm would solve your problem. Have a look here.

If your case is the former then you might need to follow a more advanced approach, that could be for example finding the convex hulls of the objects, or maybe some template matching, etc.

edit flag offensive delete link more

Comments

1

Thank you for your useful comment & sorry for the generality. About your comments, I considered what you wrote: (use some features of the image). I actually did that. Extracted some edges on the touching part thanks to thresholding some dark parts on the edge, and then applied distance transform then watershed. It worked well but unfortunately not for all cases. There were cases in which simply there were no noticeable features and the algorithm failed. To make things worse, there is the possibility that the images I am going to get are not going to contain any more these features

So I use a more generic way to ask about this problem. I am now thinking something along the lines of convex hulls and finding some diferences (Foobar talked about defects) and then using those to draw edges

KansaiRobot gravatar imageKansaiRobot ( 2015-02-22 23:38:39 -0600 )edit
1

answered 2015-02-20 05:01:47 -0600

You could have a look at convexityDefects: http://docs.opencv.org/modules/imgpro...

edit flag offensive delete link more

Comments

Thank you. I have been thinking about convex hulls, all weekend and if in some way they can help. I think I might try this approach thanks

KansaiRobot gravatar imageKansaiRobot ( 2015-02-22 23:30:40 -0600 )edit
0

answered 2015-02-23 03:46:49 -0600

KansaiRobot gravatar image

updated 2015-02-23 03:49:14 -0600

Following your advice I am thinking of the convex hull. So what if I get something like

image description

Over there I will get three points in the lower part but in the upper part only one "defect " region.

Now I am thinking how to get other three points in the upper part so that I can link up and down and separate the regions..

Any advice anyone??

edit flag offensive delete link more

Comments

How about trying to find local maxima on your contours in the smallest shape dimension? This should yield the 8 tips, resulting in you being able to pair them up?

StevenPuttemans gravatar imageStevenPuttemans ( 2015-02-23 06:05:30 -0600 )edit

Yes, now I am thinking on what criterion to pair them up, and I think if using the convex hull I define two extreme regions (up and down) I can pair each of these 8 points with the nearest point that does not belong to the same region What do you think?

KansaiRobot gravatar imageKansaiRobot ( 2015-02-25 18:22:02 -0600 )edit

That might work :P Go try it out!

StevenPuttemans gravatar imageStevenPuttemans ( 2015-02-26 06:29:50 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2015-02-20 02:08:47 -0600

Seen: 671 times

Last updated: Feb 23 '15