how can i remove object bigger than x pixel
조회 수: 4 (최근 30일)
이전 댓글 표시
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???
댓글 수: 0
채택된 답변
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
Ankit Sahay
2020년 5월 8일
What does the second line do? The line where you have written:
BW = I>80;
추가 답변 (1개)
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
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Image Segmentation and Analysis에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!