Removing small area from labeled image

1 次查看(过去 30 天)
I tried to execute this codes to remove small labeled area, but the result is not much change compared to original labeled image.
a=imread('image1_118.jpg');
subplot(2, 3, 1);
imshow(a);
b=im2bw(a, 0.45);
subplot(2, 3, 2);
imshow(b);
c=bwlabel(b, 8);
subplot(2, 3, 3);
imshow(c, []);
subplot(2, 3, 4);
[B,L] = bwboundaries(c);
imshow(L)
hold on
for k = 1:length(B)
boundary = B{k};
plot(boundary(:,2), boundary(:,1), 'y', 'LineWidth', 2)
end
stats=regionprops(c, 'area');
num=size(stats);
for k=1:num
areas=stats(k).Area;
end
areas2=[stats.Area];
x=areas2<100;
y=find(x);
L=ismember(c, y);
d=bwlabel(L, 8);
subplot(2, 3, 5);
imshow(d, []);
This is the generated image result;
Is there any mistake or suggestion to improve the codes, especially the last part.I would like to remove the below the human image.

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Images 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by