- use bwlabel() or bwconncomp() or regionprops() to find out how many blobs there are, and then pass 1 less as the number to keep with 'smallest'
- or you could do binimg - bwareafilt(binimg, 1, 'largest')
How do I measure the area of objects in a binary image, to be passed into the function bwareafilt?
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Stewart Tan
el 22 de Sept. de 2019
Comentada: darova
el 22 de Sept. de 2019
So i have a binary image below:

and what I want to do is to extract the two smaller rectangle-like object from the binary image using bwareafilt(). However, I'm required to input a certain range as required for bwareafilt() and i would like to know how to calculate the area of each object in the binary image before specifiying a range for bwareafilt(). In other words, I want to know if there is any built in function that returns the area of each object in the image. For now, i had to experiment with different range via hardcode where:
bw3 = bwareafilt(binimg, [100 30000]);
The range value of 100 to 30000 allows me to extract the two rectangles from the image, without the large one above. I'm looking for a method where i wouldn't have to exhaustively type in ranges, hoping to extract the wanted object from the image.
0 comentarios
Respuesta aceptada
Walter Roberson
el 22 de Sept. de 2019
regionprops() with the 'Area' option.
However, there is another approach:
bwareafilt(binimg, 2, 'smallest')
If what you want to do is get rid of the 1 largest when you do not know how many blobs there are, then there are several approaches:
2 comentarios
darova
el 22 de Sept. de 2019
Please accept the answer
Walter will lose his reputation without your help
Más respuestas (0)
Ver también
Categorías
Más información sobre Image Processing Toolbox en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!