error in Matlab Image Processing Toolbox 'M must be provided for packed erosion '

6 views (last 30 days)
I have error in this program
I={}
for k=133:135
jpgFileName=strcat('15min_', num2str(k), '.jpg')
matrix=imread(jpgFileName);
end
I=cell2mat(I)
text(732,501,'…',...
'FontSize',7,'HorizontalAlignment','right')
hy=fspecial('sobel');
hx=hy';
Iy=imfilter(double(I), hy, 'replicate');
Ix=imfilter(double(I), hx, 'replicate');
gradmag=sqrt(Ix.^2+Iy.^2);
se=strel('disk', 20);
Io=imopen(I, se);
Ie=imerode(I, se);
Iobr=imreconstruct(Ie, I);
Ioc=imclose(Io, se);
Iobrd=imdilate(Iobr, se);
Iobrcbr=imreconstruct(imcomplement(Iobrd), imcomplement(Iobr));
Iobrcbr=imcomplement(Iobrcbr);
fgm=imregionalmax(Iobrcbr);
I2=I;
I2(fgm)=255;
se2=strel(ones(5, 5));
fgm2=imclose(fgm, se2);
fgm3=imerode(fgm2, se2);
fgm4=bwareaopen(fgm, 240);
I3=I;
I3(fgm4)=255;
bw=im2bw(Iobrcbr, graythresh(Iobrcbr));
in next line
fgm2=imclose(fgm, se2);
error 'M must be provided for packed erosion '
Can you help me, please

Answers (1)

Walter Roberson
Walter Roberson on 28 Jul 2016
You have
I={}
for k=133:135
jpgFileName=strcat('15min_', num2str(k), '.jpg')
matrix=imread(jpgFileName);
end
I=cell2mat(I);
In that for loop, you overwrite matrix each time, so the end result is going to be as if you had only executed the last iteration of the loop. And your loop does not write to I at all, so after the loop I is going to be the {} that it was initialized to. So you are processing the empty image.
  2 Comments
Image Analyst
Image Analyst on 28 Jul 2016
Even if you get past that, the algorithm looks questionable. You get an edge image, then you do an opening which will shrink the edges and enlarge gaps. Then you do a big erosion on what's left. At that point you may have very little left in the image. After that it's a dizzying sequence of morphological operations and it's hard to tell what effect it would have without an actual image. What is this supposed to do anyway?
Iryna Mukanovska
Iryna Mukanovska on 29 Jul 2016
I want detection volume circle on images. For one image it working, but do not working for few images...In this archive i send 3 images, m-file with name 'one' and figure. You can see what i want to do.

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!