MATLAB: How to create multiple ROI in the same figure? I’d like to manually draw multiple region on an image to create a mask of the drawn regions. I attached the code to do it using ellipse that does the job for 5 region, but only last region is displayed

image processing

I = imread('13170.jpg');
im = imshow(I);
e = imellipse(gca);% now pick ROI
BW = createMask(e,im);% get BW mask for that ROI
BW(:,:,2) = BW;
BW(:,:,3) = BW(:,:,1);
ROI = I;
ROI(BW == 0) = 255;
figure, imshow(ROI,'Border','tight');

Best Answer

You put a loop and call the code the number of times you want. Just call it multiple times and save all the regions.