How to save stats values from matchScans?

1 visualizzazione (ultimi 30 giorni)
I'm using the matchScans function within a for loop and I want to be able to store the stats values (stats.Score) for each scan but I've found that at the end of the for loop it only saves the score for the last scan and I can't find a way to callback to any previous scores for other scans. This is the code I'm using to try and store the score;
for idx = K(1):K(numMatches)
[transform, stats] = matchScansGrid(currentScan, referenceScan);
Score = [idx stats.Score];
end
I've found that the code below added to the for loop will display the code for each scan but it only displays it and I have no way to save it.
if stats.Score / currentScan.Count < 1.0
disp(['Low scan match score for index ' num2str(idx) '. Score = ' num2str(stats.Score) '.']);
end
Is there a way I can store displayed results in an array or is there another way I can save the score from each scan (rather than just the last scan) in a single array? Thanks in advance.

Risposta accettata

Cam Salzberger
Cam Salzberger il 28 Gen 2019
Modificato: Cam Salzberger il 28 Gen 2019
Hello Amrik,
Yes, your code is close to what you are looking for, but you are replacing the value of Score every loop iteration, rather than appending to it. One common pattern of doing this you might have seen before is this:
Score = [];
for ...
Score = [Score stats.Score];
end
However, I would suggest pre-allocating your array for better performance. And if you are looking to to keep the index as well, you could do this:
Score = zeros(numMatches, 2);
for idx = 1:numMatches
[transform, stats] = matchScansGrid(currentScan, referenceScan);
Score(idx, :) = [K(idx) stats.Score];
end
Alternatively to an array, you could simply save all the stats to a structure array (if you care about anything other than the score).
Also, I'm making assumptions here on what you meant with your loop limits and indexing into K. If that's not correct, feel free to correct it.
-Cam

Più risposte (0)

Categorie

Scopri di più su Image Processing Toolbox in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by