How to save stats values from matchScans?
1 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
采纳的回答
Cam Salzberger
2019-1-28
编辑:Cam Salzberger
2019-1-28
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
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Processing Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!