フィルターのクリア

removing area

6 ビュー (過去 30 日間)
Mohammad Golam Kibria
Mohammad Golam Kibria 2011 年 7 月 7 日
I have a code like this.
CC = bwconncomp(I2);
STATS = regionprops(CC,'Area');
idx = find([STATS.Area] <100);
I2(idx)=0;
figure,imshow(I2)
the objective of this code is to set zero value to those pixel whose area is less than 100.
I am not sure whether it is working properly. But perhaps Its not the correct way to achieve may objective.
can any one help how to do that? Thanks

採用された回答

Andrei Bobrov
Andrei Bobrov 2011 年 7 月 7 日
STATS = regionprops(CC,'PixelIdxList','Area');
I2(cell2mat(cellfun(@(x)x',{STATS([STATS.Area]<100).PixelIdxList},'un',0)))=0;

その他の回答 (2 件)

Image Analyst
Image Analyst 2011 年 7 月 10 日
Or you can just call bwareaopen with an argument of 100 before you even call bwconncomp at all.
I2 = bwareaopen(binaryImage, 100);
Then call bwconncomp on I2.
  1 件のコメント
Andrei Bobrov
Andrei Bobrov 2011 年 7 月 10 日
+1

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


Sean de Wolski
Sean de Wolski 2011 年 7 月 7 日
You don't even need regionprops!
CC = bwconncomp(I2);
idxkeep = cellfun('prodofsize',CC.PixelIdxList)>=100;
Ibigstuff = false(CC.ImageSize); %new image
Ibigstuff([CC.PixelIdxList{idxkeep}]) = true; %keep only good parts
regionprops doesn't actually contain the data in the region, CC does, so in order to manipulate regions you need CC.

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by