what function do i use to remove large object ?

11 ビュー (過去 30 日間)
Priyanka Roy
Priyanka Roy 2015 年 6 月 2 日
コメント済み: Image Analyst 2020 年 11 月 2 日
In matlab we use bwareaopen(I,n) function to remove object smaller than n pixel from image I.
Is there any function to remove object greater than m pixel from image I ?
what should i do to remove bigger object from image I?

回答 (3 件)

Image Analyst
Image Analyst 2015 年 6 月 2 日
You can do it with bwareaopen():
bigBlobs = binaryImage - bwareaopen(binaryImage, n);
A nice versatile function for extracting the N largest or smallest blobs is contained in my attached demo.
  5 件のコメント
Xihao Han
Xihao Han 2020 年 11 月 2 日
@Image Analyst hahaha "3" in Chinese is pronounced like "than" while "Q" is like "k you"
Image Analyst
Image Analyst 2020 年 11 月 2 日
Thanks for the explanations on the cryptic Chinese textspeak.
Regarding the original question, since MATLAB Release R2014b there is a function called bwareafilt(), as the others have mentioned. Here is how you would use it to "remove object greater than m pixel from image I ?"
% Remove objects greater than m pixels in area from image I.
bigBlobs = bwareafilt(I, [1, m]); % Keep only blobs from 1 pixel to m pixels in area.
I really recommend you use more descriptive vatiable names. No one wants to look at an alphabet soup of a program with single letter variables, where it's not clear what they are. I'd recommend you not use I (eye) because it looks too much like 1 (one) and l (ell). I recommend you call it either binaryImage or mask. And instead of m, call it maxAllowableBlobSize. Then, someone reading that code will instantly know what the variables are.

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


Walter Roberson
Walter Roberson 2018 年 8 月 27 日
bwareafilt()

Romana Akhter
Romana Akhter 2020 年 9 月 18 日
You can use bwareafilt(image, range). Here rang is the size of the objects you want to keep. See the link for details.
https://www.mathworks.com/help/images/ref/bwareafilt.html

カテゴリ

Help Center および File ExchangeGet Started with Image Processing Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by