Index exceeds matrix dimensions.
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 :)
0 commentaires
Réponse acceptée
Richard Brown
le 23 Avr 2012
The line you want is:
vtemp = [xtemp,ytemp];
xtemp and ytemp are numbers not vectors
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Resizing and Reshaping Matrices dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!