Attempted to access x2(131,1); index out of bounds because size(x2)=[1,512]
Info
This question is closed. Reopen it to edit or answer.
Show older comments
Hi I'm trying to execute a program but i keep getting this error. Is someone ready to help me?
here is the code
function y=check_loseblock(mri,mri2,mri3,pic_path,p_check,pa_sarea,pa_larea,pa_sbar,pa_lbar,avg_gray,p_filter,p_top,p_bottom)
for name=16:16
img_pic_num1=int2str(name);
x1=mri;
x200=mri2;
x300=mri3;
x=double(x1);
x2=double(x200);
x3=double(x300);
%figure,imshow(x1);
[h,w]=size(x);
L=bwlabel(x,4);
t=max(L(:));
for i1=1:t
min_y=520;
max_y=0;
for m=1:h
for n=1:w
if (L(m,n)==i1)
if(m>max_y)
max_y=m;
end
if(m<min_y)
min_y=m;
end
end
end
end
block(i1,1)=min_y;
block(i1,2)=max_y;
end
for i1=1:t-1
for i2=i1+1:t
if (block(i1,1)>=block(i2,1))
tmp1=block(i1,1);
tmp2=block(i1,2);
block(i1,1)=block(i2,1);
block(i1,2)=block(i2,2);
block(i2,1)=tmp1;
block(i2,2)=tmp2;
end
end
end
lose_count=1;
if(block(1,1)>p_check)
lose_block(lose_count,1)=0;
lose_block(lose_count,2)=block(1,1);
lose_count=lose_count+1;
end
for i1=1:t-1
dis=abs(block(i1,2)-block(i1+1,1));
if(dis>p_check)
lose_block(lose_count,1)=block(i1,2);
lose_block(lose_count,2)=block(i1+1,1);
lose_count=lose_count+1;
end
if((i1+1)==t)
if(w-block(i1+1,2)>p_check)
lose_block(lose_count,1)=block(i1+1,2);
lose_block(lose_count,2)=w;
lose_count=lose_count+1;
end
end
end
pic_finish=mri;
pic_otsu=x3;
if(lose_count>1)
sq=[1 1 1;1 1 1;1 1 1];
for b1=1:lose_count-1
pic1=[];
pic_y=1;
for i1=1:h
if(i1>=lose_block(b1,1) && i1<=lose_block(b1,2))
for j1=1:w
pic1(pic_y,j1)=x2(i1,j1);
end
pic_y=pic_y+1;
end
end
pic1=imerode(imerode(imdilate(imdilate(pic1,sq),sq),sq),sq);
end
Answers (1)
Torsten
on 15 Oct 2015
0 votes
Arrays mri and mri2 don't seem to be of the same size, as required by check_loseblock.
Check the array sizes.
Best wishes
Torsten.
This question is closed.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!