omitting objects dependent on their area in binary image
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
lotus whit
el 15 de Sept. de 2017
Comentada: lotus whit
el 19 de Sept. de 2017
Hi could you please help me , i am trying to remove any object has area more than 500, after drawing bounding box for it, below my code and image:
% %%
v=x11;% where x11 is image
[lab1 num1] =bwlabel(x11)
BW2=regionprops(lab1,'Area') ;% calculate the area for each object in dia
for y =1 : num1
[rl cl]=find(lab1== y)
if (BW2.Area(y)) > = 500
{
lab1(BW2.Area(y)) == 0;
}
end
figure ,imshow(lab1)
title(' object');
%%Measure properties of image regions
propied=regionprops(v,'BoundingBox');
BW2=regionprops(v,'Area');% calculate the area for each object in dia
hold on
%%Plot Bounding Box
for n=1:size(propied,1)
rectangle('Position',propied(n).BoundingBox,'EdgeColor','g','LineWidth',2)
figure ,imshow(v)
end
end

0 comentarios
Respuesta aceptada
Guillaume
el 15 de Sept. de 2017
Using BW2 as a variable name for the output of regionprops is extremely misleading. BW2 implies a binary image which is not at all what regionprops returns.
Anyway, the simplest way to filter objects by area is to use bwareafilt before the call to regionprops. In your case:
BW2 = bwareafilt(BW, [1 499]);
Más respuestas (0)
Ver también
Categorías
Más información sobre Image Segmentation and Analysis 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!