Borrar filtros
Borrar filtros

Index exceeds matrix dimensions.

2 visualizaciones (últimos 30 días)
K BV
K BV el 23 de Abr. de 2012
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 :)

Respuesta aceptada

Richard Brown
Richard Brown el 23 de Abr. de 2012
The line you want is:
vtemp = [xtemp,ytemp];
xtemp and ytemp are numbers not vectors
  1 comentario
K BV
K BV el 23 de Abr. de 2012
Thanks for your answer ! It works !

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Resizing and Reshaping Matrices en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by