I tried these commands:
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;
(I have other command lines here, but I think the problem is not because of them.)
labeledImage = bwlabel(binaryImage, 8); % Label each blob so we can make measurements of it blobMeasurements = regionprops(labeledImage, Ibw, 'all'); numberOfBlobs = size(blobMeasurements, 1);
I got this error message:
??? Error using ==> subsindex Function 'subsindex' is not defined for values of class 'struct'. Error in ==> test2 at 129 numberOfBlobs = size(blobMeasurements, 1);
What will go wrong?
source share