find intersection of boundary points

I have set of boundary points which has been acquired through bwboundaris function( it is almost square). Now how to find 4 vertices of the shape.

 Accepted Answer

Use convhull().

4 Comments

but how to get vertex coordinates thanks
OK, admit it, you never even looked at the documentation, did you? Well if you do, you'll see this example:
xx = -1:.05:1;
yy = abs(sqrt(xx));
[x,y] = pol2cart(xx,yy);
k = convhull(x,y);
plot(x(k),y(k),'r-',x,y,'b*')
And of course x(k) and y(k) are the vertices. If you want coordinates that are not the convex hull, then see my shape recognition demo.
I have already got vertices from boundaries command but now how to get corner location ? youe demo doesnt work it say something else found as its not regular square.
If you have more than 4 convex hull points, then you'll have to figure out which of those are the corner points. Use my demo where I computed the distance away from the centroid and then found the peaks.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!