Index exceeds matrix dimensions.

2 次查看(过去 30 天)
Hi,
I'm using a correlation function of Matlab corr2 to track markers in a sequence of images (the sequence is called X).
While running my program, I got the error I mentioned in the title
in this line : vtemp = [xtemp(k),ytemp(k)];
The code I wrote is below :
v = [Rx,Ry];
rects_input = calc_rects(v,CORRSIZE,X(:,:,1));
sub_input0 = imcrop(X(:,:,1),rects_input);
for i = 2:size(X,3)
clear 'r'
sub_input=sub_input0;
Mat_vtemp(1,:) = [Rx(1),Ry(1)];
for j = -CORRSIZE:CORRSIZE
for k = 1:length(Rx)
xtemp = Rx(k)+j;
ytemp = Ry(k)+j;
vtemp = [xtemp(k),ytemp(k)];
k,j,i
rects_input_i = calc_rects(Mat_vtemp(k,:),CORRSIZE,X(:,:,i));
sub_input_i = imcrop(X(:,:,i),rects_input_i(k,:));
Rx = round(Rx);
Ry = round(Ry);
r(Rx(k)+j,Ry(k)+j) = corr2(sub_input,sub_input_i);
end
Mat_vtemp(k,:) = vtemp;
Mat_rects_input_i = rects_input_i;
Mat_sub_input_i = sub_input_i;
end
r = abs(r);
[row,col] = find(r==max(max(r)));
figure, imagesc(X(:,:,i)), colormap gray, axis image
hold on
plot(row,col,'*g')
vopt = [row,col]; % vopt : vecteur optimal
end
Any help will be appreciated :)

采纳的回答

Richard Brown
Richard Brown 2012-4-23
The line you want is:
vtemp = [xtemp,ytemp];
xtemp and ytemp are numbers not vectors

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by