Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Index exceeds matrix dimensions, error problem

조회 수: 2 (최근 30일)
shashikant khandagale
shashikant khandagale 2015년 1월 20일
마감: MATLAB Answer Bot 2021년 8월 20일
clc;
clear all;
tic; q=0;
f=dir('*.jpg');
srcfile=dir('D:\Project Work\Phase-2\Reconstruction\dice\*.jpg');
files={srcfile.name};
for eleimg = 1 : numel(files)
%filename = strcat('C:\Users\Admin\Documents\MATLAB\dice\',srcfile(eleimg).name);
eleimg1 = imread(files{eleimg});
currentimage2=rgb2gray(eleimg1);
look{q+eleimg,1}=currentimage2;
% figure, imshow(currentimage2);
[sx,sy] = size(currentimage2);
Nx=7;Ny=7;d=450;
cx=23.7;cy=15.6;f=20;L=2;
px=0.34;py=0.45;
shx=ceil((px * f * sx)/(d*cx));
shy=ceil((py * f * sy)/(d*cy));
look{q+eleimg,2}=shx;
look{q+eleimg,3}=shy;
grid_image=zeros(shx*(Nx-1)+sx,shy*(Ny-1)+sy,L*Nx*Ny);
grid_overlap_number=zeros(shx*(Nx-1)+sx,shy*(Ny-1)+sy,L*Nx*Ny);
end
for k=1:Nx*Ny*L
v1=uint16(cell2mat(look(k,2)));
v2=uint16(cell2mat(look(k,3)));
grid_image(v1:sx,v2:sy,k)=uint16(cell2mat(look(k,1)));%[1:sx,1:sy]
grid_overlap_number(v1:sx,v2:sy,k)=ones(sx,sy);
end
tic;
for l=1:L
overlap_image=sum(grid_image(:,:,Nx*Ny*(l-1)+1:Nx*Ny*l),3);
overlap_number=sum(grid_overlap_number(:,:,Nx*Ny*(l-1)+1:Nx*Ny*l),3);
slice_image= rdivide(overlap_image,overlap_number);
figure,imshow(uint8(slice_image));
end
toc;
when I run code the programme shows me
Index exceeds matrix dimensions.
Error in finalserialcode (line 28) v1=uint16(cell2mat(look(k,2)));
I cant figure it out.any one help?

답변 (1개)

Niels
Niels 2015년 1월 20일
Your variable look has a length of eleimg.
You are trying to access some value between 1 and Nx*Ny*L (which is equal to 98). I suspect that eleimg is smaller than 98.

이 질문은 마감되었습니다.

태그

Community Treasure Hunt

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

Start Hunting!

Translated by