如您所見,我有形狀和白色邊界。我想填充白色的形狀。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