我尝试了这些命令:
im=imread('untitled_test1.jpg');
im1=rgb2gray(im);
im1=medfilt2(im1,[15 15]);
BW = edge(im1,'sobel');
msk=[0 0 0 0 0;
0 1 1 1 0;
0 1 1 1 0;
0 1 1 1 0;
0 0 0 0 0;];
B=conv2(double(BW),double(msk));
Ibw = im2bw(B);
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]);
else
Ibw([CC.PixelIdxList{i}]) = false;
end;
end;
(这里我有另一个命令行,但我想问题不是因为它们。)
labeledImage = bwlabel(binaryImage, 8); % Label each blob so we can make measurements of it
blobMeasurements = regionprops(labeledImage, Ibw, 'all');
numberOfBlobs = size(blobMeasurements, 1);
我收到此错误消息:
??? Error using ==> subsindex
Function 'subsindex' is not defined for values of class 'struct'.
Error in ==> test2 at 129
numberOfBlobs = size(blobMeasurements, 1);
怎么了?