How to get the coordinates of the contour of a binary image?

I have a binary image and I want to extract the outline coordinates of the binary image. The contour () built-in functions resulted in double values, but instead I want an array, that is, the (x, y) row of the contour. It's also okay if the coordinates are in polar form (x + iy). Can anyone help me?

+3


source to share


1 answer


You can get the outline mask by breaking the mask with a simple small structure element (disk / square)

con = BW & ~imerode( BW, [0 1 0; 1 1 1; 0 1 0] ); 
figure; imshow( con ); title('contour mask');
[cy cx] = find(con); %// get coordinates of contour pixels

      




With that in mind, there are several (related) functions to track the bounds of binary masks in the imaging toolbar.

Have you tried bwtraceboundary

or bwboundaries

?

+2


source







All Articles