0

我正在使用 MATLAB。这是我写的代码

 I = imread('image.tif');
 imshow(I);
 title('Original');
 eul = bweuler(I,8);
 CH = bwconvhull(BW);
bwlabel()

它给了我欧拉数,但没有给出凹面的数量。我知道我在最后一部分遗漏了一些东西。你能解释一下我错过了什么吗?

谢谢

4

1 回答 1

0

如果您正在寻找图像上每个对象中的孔数,我宁愿这样做(请参阅regionprops函数的手册):

I = imread('circles.png');  
% assuming that I is logical (binary) image
I = [ I fliplr(I) ; flipud(I) I];   % just to make image bigger

figure;
Props = regionprops(I,{'image','filledImage'});
NRegions = length(Props);
for k=1:NRegions
    DiffImage = Props(k).FilledImage-Props(k).Image;
    strT = sprintf('Region %d of %d',k,NRegions);
    subplot(2,2,1); imshow(Props(k).Image);       title([strT ': Original image']);
    subplot(2,2,2); imshow(Props(k).FilledImage); title([strT ': Filled image']);
    subplot(2,2,3); imshow(DiffImage);            title([strT ': Filled-Original image']);
    drawnow;
    pause(1); % allows to see the images
    [L, NHoles] = bwlabel(Props(k).FilledImage-Props(k).Image,8);
    fprintf('%s has %d holes\n',strT,NHoles);
end
于 2013-04-12T15:45:36.933 回答