MATLAB: How to make the ROI show on top of the image after drawing ROI with roipoly

Image Processing Toolboxmaskingroiroipoly

Hi, Guys,
I draw a ROI with roipoly. After drawing, the blue ROI will disappear. How to still display this ROI on top of the image after drawing? Please see the following example.
im = imread('cameraman.tif');
figure(1)
imagesc(im);
axis image off; colormap gray;
title('Please Draw ROI');
% This is the image
% Draw ROI
roi=roipoly;
% During drawing ROI
% After drawing ROI (by double clicking the first point), the blue ROI disappears
My question is How to make the ROI still display on top of the image after drawing? Many thanks!

Best Answer

Try this:
im = imread('cameraman.tif');
imagesc(im);
axis image off;
colormap gray;
title('Please Draw ROI');
% Draw ROI
[binaryMask, x, y] = roipoly;
hold on;
plot(x, y, 'r.-', 'MarkerSize', 15);