Filtering binary image object based on area
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I have a binary image below:
and the four straight objects are trees which i want to keep and the blob below is an unwanted object in the binary image. I'm using bwareafilt to extract only the objects i want, which in this case would be the four trees. However, by using:
regionprops(binimg, 'Area')
I get:
and the unfortunate thing is that the area of fourth tree (3557), is lesser than the area of the unwanted blob below. Hence if i use:
newbw = bwareafilt(binimg, [3900 5000])
the fourth tree will be filtered out leaving only:
If the area of the unwanted object is larger than the object i want to keep in the binary image, how do i handle this?
0 Commenti
Risposte (1)
darova
il 27 Set 2019
What about centroid?
I = imread('Capture.png');
I1 = rgb2gray(I);
L = bwlabel(I1);
pp = regionprops(L,'centroid');
xy = cat(1, pp.Centroid); % concatenation
[~,n] = max(xy(:,2)); % find bottom label
I1(L==n) = 0; % fill bottom
imshow(I1)
hold on
plot(xy(:,1),xy(:,2),'or')
hold off
0 Commenti
Vedere anche
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!