Removing small area from labeled image

1 view (last 30 days)
Syahrul Niezam
Syahrul Niezam on 30 Jan 2012
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.

Answers (0)

Categories

Find more on Images in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!