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

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

답변 (1개)

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

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?
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.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기

질문:

2016년 7월 28일

댓글:

2016년 7월 29일

Community Treasure Hunt

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

Start Hunting!

Translated by