MATLAB: How to get mask from boundary()

boundarybwboundariesmaskMATLAB

Hi,
I have points that represents curve levels. With thoses, I can find the boundary (k) matrix:
x = [1 2 3 4 3 2];
y = [4 5 5 4 3 3];
k = boundary(x,y);
I would like to make a mask from this boundary, but the function "boundary" does not provide the same output that "bwboundaries" does. Therefore, I cannot make a mask.
So, how can I make a mask with this data?

Best Answer

x = [1 2 3 4 3 2]';
y = [4 5 5 4 3 3]';
k = boundary(x,y);
plot(x,y,'.r')
hold on
patch(x(k),y(k),'k')