how to save variables with increasing number for result of cross correlation images.
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
i have problem to do loop for cross correlation of images. from coding, it can displayed the result without being overlap. but i dont know how to save the same result at workspace using different number so that i can construct the rectangle for color indicator due to result of cross correlation. what i have now,
i = 1:10 ( i have 10images to be cross correlation with template image)
c = result of cross correlation.
%displayed on command window
c 1
c 2
until c10 %because have 10 images.
but at woskspace, the value of c is c10, its overlapping from first image until last image. so i cannot construct the rectangle. i have tried using eval method, but i dont know how to relate it with my calculation of cross correlation. i hope anyone can help me.
0 commentaires
Réponses (1)
Guillaume
le 14 Mai 2015
Modifié(e) : Guillaume
le 14 Mai 2015
The result of cross-correlating two images (matrices) is normally another matrix, not a scalar value.
Regardless, the easiest way to store the results of a for loop is to use a matrix of a higher dimension than your result. If the results are scalar, store these in a 1d array, if they are a vectors, store these in a 2d matrix, and if they're images store your images in a 3d matrix. That is assuming that all the results have the same size. If not, use a cell array instead.
numimages = 10; %number of images to process
c = zeros(10, 20, numimages); %replace 10 and 20 by whatever size your crosscorrelation create
for imgidx = 1:numimages
c(:, :, imgidx) = resultofcrosscorrelation;
end
Or using a cell array:
numimages = 10; %number of images to process
c = cell(numimages, 1);
for imgidx = 1:numimages
c{imgidx} = resultofcrosscorrelation;
end
4 commentaires
Guillaume
le 14 Mai 2015
While it is possible to create variables c1, c2, etc. in a loop, it is a really bad idea. The good way of doing it is as I have said to use an array.
I don't know what your c is (not just the result of a cross-correlation of two images for sure), but it looks like it's just a scalar (i.e. one number). So, to solve your problem:
numimages = 10;
c = zeros(numimages, 1);
for imgidx = 1:numimages
c(imgidx) = result of cross correlation;
end
Voir également
Catégories
En savoir plus sur Logical 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!