OpenCV Q&A Forum - RSS feedhttp://answers.opencv.org/questions/OpenCV answersenCopyright <a href="http://www.opencv.org">OpenCV foundation</a>, 2012-2018.Mon, 08 Feb 2016 06:25:31 -0600Finding intersections of objects in a single contourhttp://answers.opencv.org/question/86657/finding-intersections-of-objects-in-a-single-contour/ Hello,
I have an image of leaves (seen from above) that can partly recover each other.
http://img11.hostingpics.net/pics/793244img2.jpg
I found the contour of the image (in red on the image) and what I want to do now is to find where two leaves intersect. What I've done so far is to:
- consider a point with index i in the contour c, say c[i], which has two coordinates x and y,
- compute the angle of the vector (c[i-1], c[i]) with the half line (x > 0), which I denote ang[i], this returns an angle between 0 and 360,
- do the previous step for the B angles ang[i], ang[i-1], ang[i-2] and average the result, this gives me the mean direction *before* c[i],
- do the same for the B angles ang[i+1], ang[i+2], ang[i+3], etc. and average the result, this gives me the mean direction *after* c[i],
- flag (in blue on the image) c[i] as a potential intersection if the difference between the mean direction after and before is greater than a deviation angle D.
I've tried many values of B and D, but due to the different natures of the intersections between leaves, I never manage to recover them all, and uniquely them. Here is an example of output:
http://img11.hostingpics.net/pics/381717fillednewedge6130J21C1S179Sha.jpg
Is something wrong with the method I tried?
Is there any other approach less naive and more robust I could try?
Many thanks.Thu, 04 Feb 2016 11:44:32 -0600http://answers.opencv.org/question/86657/finding-intersections-of-objects-in-a-single-contour/Comment by PlapPlop for <p>Hello,</p>
<p>I have an image of leaves (seen from above) that can partly recover each other.</p>
<p><a href="http://img11.hostingpics.net/pics/793244img2.jpg">http://img11.hostingpics.net/pics/793...</a></p>
<p>I found the contour of the image (in red on the image) and what I want to do now is to find where two leaves intersect. What I've done so far is to:</p>
<ul>
<li>consider a point with index i in the contour c, say c[i], which has two coordinates x and y,</li>
<li>compute the angle of the vector (c[i-1], c[i]) with the half line (x > 0), which I denote ang[i], this returns an angle between 0 and 360,</li>
<li>do the previous step for the B angles ang[i], ang[i-1], ang[i-2] and average the result, this gives me the mean direction <em>before</em> c[i],</li>
<li>do the same for the B angles ang[i+1], ang[i+2], ang[i+3], etc. and average the result, this gives me the mean direction <em>after</em> c[i],</li>
<li>flag (in blue on the image) c[i] as a potential intersection if the difference between the mean direction after and before is greater than a deviation angle D.</li>
</ul>
<p>I've tried many values of B and D, but due to the different natures of the intersections between leaves, I never manage to recover them all, and uniquely them. Here is an example of output:</p>
<p><a href="http://img11.hostingpics.net/pics/381717fillednewedge6130J21C1S179Sha.jpg">http://img11.hostingpics.net/pics/381...</a></p>
<p>Is something wrong with the method I tried?
Is there any other approach less naive and more robust I could try?</p>
<p>Many thanks.</p>
http://answers.opencv.org/question/86657/finding-intersections-of-objects-in-a-single-contour/?comment=87025#post-id-87025Hello Steve, thanks for the suggestion, how do you think I could perform this first step of skeletization? Is there something useful already implemented in OpenCV? I failed to find any so far.Mon, 08 Feb 2016 06:25:31 -0600http://answers.opencv.org/question/86657/finding-intersections-of-objects-in-a-single-contour/?comment=87025#post-id-87025Comment by StevenPuttemans for <p>Hello,</p>
<p>I have an image of leaves (seen from above) that can partly recover each other.</p>
<p><a href="http://img11.hostingpics.net/pics/793244img2.jpg">http://img11.hostingpics.net/pics/793...</a></p>
<p>I found the contour of the image (in red on the image) and what I want to do now is to find where two leaves intersect. What I've done so far is to:</p>
<ul>
<li>consider a point with index i in the contour c, say c[i], which has two coordinates x and y,</li>
<li>compute the angle of the vector (c[i-1], c[i]) with the half line (x > 0), which I denote ang[i], this returns an angle between 0 and 360,</li>
<li>do the previous step for the B angles ang[i], ang[i-1], ang[i-2] and average the result, this gives me the mean direction <em>before</em> c[i],</li>
<li>do the same for the B angles ang[i+1], ang[i+2], ang[i+3], etc. and average the result, this gives me the mean direction <em>after</em> c[i],</li>
<li>flag (in blue on the image) c[i] as a potential intersection if the difference between the mean direction after and before is greater than a deviation angle D.</li>
</ul>
<p>I've tried many values of B and D, but due to the different natures of the intersections between leaves, I never manage to recover them all, and uniquely them. Here is an example of output:</p>
<p><a href="http://img11.hostingpics.net/pics/381717fillednewedge6130J21C1S179Sha.jpg">http://img11.hostingpics.net/pics/381...</a></p>
<p>Is something wrong with the method I tried?
Is there any other approach less naive and more robust I could try?</p>
<p>Many thanks.</p>
http://answers.opencv.org/question/86657/finding-intersections-of-objects-in-a-single-contour/?comment=86722#post-id-86722How about doing some skeletization first on the segmentation and then looking for joints as a starter? Then project those joints towards the edge in a closest distance manner?Fri, 05 Feb 2016 06:03:10 -0600http://answers.opencv.org/question/86657/finding-intersections-of-objects-in-a-single-contour/?comment=86722#post-id-86722