how can i remove object bigger than x pixel

12 ビュー (過去 30 日間)
Lukasz Jarod
Lukasz Jarod 2014 年 12 月 18 日
コメント済み: Ankit Sahay 2020 年 5 月 8 日
i know that bwareaopen remove small elements , but how can i remove object bigger than x pixels???
i want to just the letter to stay so how can i remove that 2 big objects???

採用された回答

Sven
Sven 2014 年 12 月 18 日
編集済み: Sven 2014 年 12 月 18 日
Hi Lukasz,
Here's an example that removes all objects greater than 1000 pixels in area. You probably have your own BW image and your own threshold that you can use in a similar way.
I = imread('rice.png');
BW = I>80;
cc = bwconncomp(BW);
stats = regionprops(cc);
threshold = 1000;
removeMask = [stats.Area]>threshold;
BW(cat(1,cc.PixelIdxList{removeMask})) = false;
Did this help you out?
Thanks, Sven.
  2 件のコメント
Image Analyst
Image Analyst 2014 年 12 月 20 日
Lukasz's Flag removed and moved here as a comment:
Yes, it helped me.
Ankit Sahay
Ankit Sahay 2020 年 5 月 8 日
What does the second line do? The line where you have written:
BW = I>80;

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

その他の回答 (1 件)

William Kemp
William Kemp 2017 年 8 月 1 日
Its a little more compact if you use the built in function for it:
BW2 = bwpropfilt(BW,'Area',[0 x_pixels])
Where x_pixels is the maximum desired number of pixels in a BW object

カテゴリ

Help Center および File ExchangeImages についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by