create multi mask using ROI Freehand

5 ビュー (過去 30 日間)
Amir Azadeh Ranjbar
Amir Azadeh Ranjbar 2021 年 12 月 29 日
回答済み: Amir Azadeh Ranjbar 2021 年 12 月 29 日
clc;clear;close all
im=imread("circlesBrightDark.png");
image=imshow(im);
for i=1:4
roi(i)=images.roi.AssistedFreehand(image);
draw(roi(i))
hold on
roi(i+1)=images.roi.AssistedFreehand(image);
draw(roi(i+1))
end
for i=1:2
for j=1:2
mask=roi(i).createMask | roi(i+j).createMask ;
end
end
  1 件のコメント
Amir Azadeh Ranjbar
Amir Azadeh Ranjbar 2021 年 12 月 29 日
This code that I wrote only makes 2 masks. I would be grateful if someone modifies the code so that they can make as many masks as they want.
If there is a code prepared for this purpose, please help

サインインしてコメントする。

採用された回答

DGM
DGM 2021 年 12 月 29 日
The way you're doing this is causing objects to be overwritten.
You can use the same method I showed in your prior question.
im = imread("coloredChips.png");
numROI = 6;
% create ROI objects and adjust them
imshow(im);
for k = 1:numROI
h(k) = drawassisted(gca);
end
% wait until the user is done
input('Press enter when done adjusting ROI objects');
% build mask
mask = false(size(im,1),size(im,2));
for k = 1:numROI
mask = mask | createMask(h(k));
end

その他の回答 (1 件)

Amir Azadeh Ranjbar
Amir Azadeh Ranjbar 2021 年 12 月 29 日
Yes thank you very much unfortunately I had not seen it

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by