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.

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');

 Risposta accettata

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

5 Commenti

Hi...Thanks for replying my question. Like this? now I can draw multiple ellipse, but I dunno how to save all region.
I = imread('13170.jpg');
im = imshow(I);
e = imellipse(gca);% now pick ROI
position = wait(e);
BW = createMask(e,im);% get BW mask for that ROI
while sum(BW(:)) >= 5
BW(:,:,2) = BW;
BW(:,:,3) = BW(:,:,1);
ROI = I;
ROI(BW == 0) = 255;
e = imellipse(gca);
setColor(e, 'red');
position = wait(e);
BW = createMask(e,im);
end
figure, imshow(ROI,'Border','tight');
clc; clear all ;
N = 5 ;
I = imread('junk.jpg');
for i = 1:N
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(i)
imshow(ROI,'Border','tight');
end
Thank for helping me, but I am still cannot save all the regions. How to do for each region save to array, for each array draw it out, then for each object in array draw it out. Thanks
N = 5 ;
I = imread('13170.jpg');
im = imshow(I);
for i = 1:N
e = imellipse(gca);% now pick ROI
setColor(e, 'red');
position = wait(e);
BW = createMask(e,im);% get BW mask for that ROI
BW(:,:,2) = BW;
BW(:,:,3) = BW(:,:,1);
ROI = I;
ROI(BW == 0) = 255;
end
figure(i)
imshow(ROI,'Border','tight');
clc; clear all;
N = 5 ;
I = imread('junk.jpg');
iwant = cell(N,1) ;
for i = 1:N
im = imshow(I);
e = imellipse(gca);% now pick ROI
setColor(e, 'red');
% position = wait(e);
BW = createMask(e,im);% get BW mask for that ROI
BW(:,:,2) = BW;
BW(:,:,3) = BW(:,:,1);
ROI = I;
ROI(BW == 0) = 255;
iwant{i} = ROI ;
end
for i = 1:N
figure
imshow(iwant{i},'Border','tight');
end
Any Idea on how to draw multiple ROI's in 2 images which are place in 'montage' mode and obtain their feature points?
I am getting only one ROI point safter drawing it

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by