필터 지우기
필터 지우기

Index exceeds matrix dimensions.

조회 수: 1 (최근 30일)
K BV
K BV 2012년 4월 23일
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
  댓글 수: 1
K BV
K BV 2012년 4월 23일
Thanks for your answer ! It works !

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

추가 답변 (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