For loop for multiple figures

I have just started learning image proccesing and I was following the tutorial on math works which has the following link : https://www.mathworks.com/help/images/image-enhancement-and-analysis.html I wanted to change the following part:
grain = false(size(bw));
grain(cc.PixelIdxList{50}) = true;
imshow(grain);
with following code to obtain all grains in corresponding figure so I used the following code:
for a=1:95
grain(cc.PixelIdxList{a}) = true;
figure; imshow(grain);
end
However, each time for loop plots over the previous figure. What did I do wrong?

回答 (1 件)

Jan
Jan 2017 年 6 月 19 日

0 投票

Move the figure command and imshow outside the loop:
for a=1:95
grain(cc.PixelIdxList{a}) = true;
end
figure;
imshow(grain);

カテゴリ

ヘルプ センター および File ExchangeSpecialized Power Systems についてさらに検索

質問済み:

2017 年 6 月 19 日

回答済み:

Jan
2017 年 6 月 19 日

Community Treasure Hunt

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

Start Hunting!

Translated by