Search code examples
matlabimage-processingfind

How to parametrize the contour of an elliptic BW image


I am using MATLAB. I have a BW image of the edge of a figure. I am trying to find SEQUENTIALLY the coordinates (1s) of the edge using the function "find". Although, the function does not find the 1s sequentially, it just checks row by row if there are ones. Is there a way to find the sequence of 1s in order (like parametrization)? Thank you.

Here you can find the image of the edge. I have to find the 1s sequentially.

Edge

I simply tried to use find function:

[row_edge, col_edge] = find(frame_edge==1);


Solution

  • MATLAB's find function is not designed for this type of calculation. Instead, this is exactly what bwtraceboundary is for - you give it a grayscale image, a starting point, and a starting direction, and it follows the edge and returns the coordinates of that edge.

    There's an example here: https://www.mathworks.com/help/images/boundary-tracing-in-images.html