How can I create a mask using multiple ROI?

I have measured the size of mushrooms in an image. Now I want to create a mask using multiple ROI. I use the mask=createMask(h) command, but I can only draw one circle. Is there a way to make all those circles into a mask?
load('CircleData.mat');
for img = 35:10:55
bw_img = zeros(400,400);
figure; imshow(bw_img);
x = xcoor(:,1);
y = ycoor(:,1);
r = Radii(:,1);
x = x(any(~isnan(x),2),:);
y = y(any(~isnan(y),2),:);
r = r(any(~isnan(r),2),:);
len = length(r);
mask = {1:len};
for count = 1:1:len
h = drawellipse('Center',[x(count) y(count)],'SemiAxes',[r(count) r(count)]);
mask = createMask(h)
imshow(mask);
end
end

 采纳的回答

len = length(r);
mask = false(size(bw_img));
for count = 1:len
h = drawcircle('Center',[x(count) y(count)],'Radius',r(count));
mask = mask | createMask(h);
imshow(mask);
end

更多回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by