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