如您所见,我有形状和白色边界。我想填充白色的形状。Matlab填充白色形状
输入是:
我想获得这个输出:
任何人可以帮助我,请与此代码?它不会将黑色椭圆更改为白色。 非常感谢:]
I = imread('untitled4.bmp');
Ibw = im2bw(I);
CC = bwconncomp(Ibw); %Ibw is my binary image
stats = regionprops(CC,'pixellist');
% pass all over the stats
for i=1:length(stats),
size = length(stats(i).PixelList);
% check only the relevant stats (the black ellipses)
if size >150 && size < 600
% fill the black pixel by white
x = round(mean(stats(i).PixelList(:,2)));
y = round(mean(stats(i).PixelList(:,1)));
Ibw = imfill(Ibw, [x, y]);
end;
end;
imshow(Ibw);
相关的http://stackoverflow.com/questions/10053651/获得像素属于一个形状 – Gray 2012-04-07 15:05:44