I have drawn some polygon on an image after using imshow
and hold on
, and filled it with white
as follows:
fill(x(k),y(k),[1 1 1])
How can I make the rest of the image black
while keeping the polygon white
? In other words, how can I make a binary image, where the polygon is white
, and the rest of the image is black
? Provided that the polygon is a bit complex.
Thanks.
Use roipoly
:
BW = roipoly( I, x(k), y(k) );
Where I
is your input image (you only need it to get the desired output size of the binary maxk BW
). y
and x
are the corners of your polygon.