MATLAB: How to have a contour with 4-connectivity

contour 4-connectivityImage Processing Toolbox

Dear all,
I have a contour that shown below. Two of the corners are with 8-connectivity. Is there a way to make all the corners satisfy 4-connectivity?
Best,
Meshoo

Best Answer

Fill the image ( imfill). Use bwboundaries with conn = 4.
Related Question