Trace the boundary of an image starting from the reference.

Hello,
I have already obtained the reference point which is inside the circle as shown in the first picture labelled(d) below. From there, how do I trace along the boundary of the image as per the direction indicated by the arrow in picture(d) such that I obtain the graph as per picture (g) which is distance versus index of boundary pixels. Thank You.

 Accepted Answer

Did you try bwtraceboundary()?

3 Comments

Yes I have tried it. In fact I have used it inside a for loop which will loop through the rows and columns of the hand contour image to accumulate all the boundary pixels and determined the Euclidean distance of all the boundary pixels with respect to the reference point.
However, when I plotted the distance(y axis) versus boundary pixel (x axis) values, I am not getting the same graph as per picture (g).
I will be grateful if you could please advise.
Thank You.
bwtraceboundary should not be in a loop. It gets all the boundary pixels in one shot. If I were you though, I'd use bwboundaries() since it does not require you to specify a starting location and starting direction. As long as you don't care about that (most people don't), it's easier.
Thanks a lot. It works perfectly outside the loop.

Sign in to comment.

More Answers (0)

Categories

Community Treasure Hunt

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

Start Hunting!