How can I plot the mean squared errors being calculated by the imregister function?
6 views (last 30 days)
Show older comments
Hi,
'imregister' function is used to register two images. We define the optimization and metrics. Qualitative accuracy can be assessed by visual interpretation. But for quantitative accuracy, we need to show mean squared error on a plot. How can we extract the values being calculated in the below function. 'DisplayOptimization' does shows the MSE values in the command prompt, but I cant find a way to store them in a variable so that these values can be used later in plotting. Can you please help ?
% READ IMAGE AND METADATA FILE
f= 'location\img.tif';
fixed = imread(f);
worldfile = getworldfilename(f);
R = worldfileread(worldfile, 'geographic', size(fixed));
for i = 5
moving = imread('location\img_'+str(i)+'.tif');
% DEFINE METRICS
[optimizer,metric] = imregconfig('monomodal');
optimizer.MinimumStepLength = 5e-8; % default = 1e-5
optimizer.MaximumIterations = 300;
modified = imregister(moving,fixed,'rigid',optimizer,metric,'DisplayOptimization', true);
% SAVE FILE WITH METADATA
geotiffwrite('\location\img.tif',modified,R);
end
Thank you,
Mehak Jindal
0 Comments
Answers (1)
Matt J
on 2 Nov 2021
Edited: Matt J
on 2 Nov 2021
MSE=norm(modified-fixed,'fro')^2/numel(fixed);
or
MSE=mean(abs(modified-fixed).^2,'all');
2 Comments
Matt J
on 3 Nov 2021
Mehak Jindal's comment moved here
Hi Matt,
Thank you for your reply. This provides me a total MSE.
% READ IMAGE AND METADATA FILE
f= 'location\img.tif';
fixed = imread(f);
worldfile = getworldfilename(f);
R = worldfileread(worldfile, 'geographic', size(fixed));
for i = 5
moving = imread('location\img_'+str(i)+'.tif');
% DEFINE METRICS
[optimizer,metric] = imregconfig('monomodal');
modified = imregister(moving,fixed,'rigid',optimizer,metric,'DisplayOptimization', true);
MSE=norm(modified-fixed,'fro')^2/numel(fixed);
disp(MSE)
end
Output in the commmand promt window for MSE: 5.9549
I want to save the MSE of each iteration within the pyramid level. The 'DisplayOptimization' paramter prints the mse errors of each iteration in the commad prompt. I need to store all mse value in each pyramid level.
Pyramid Level: 1
Iteration Mean Square Error
1 12.3729
2 9.3047
3 7.4698
4 5.9299
5 4.7644
6 3.9978
7 3.9748
8 34.1381
9 27.2363
10 17.8811
11 6.4165
12 20.7420
...
Thanks & Regards,
Mehak Jindal
Matt J
on 3 Nov 2021
I think your only option is to capture the screen output of imregister using evalc. Then you can parse the string for the MSE data and convert it to doubles using str2double(). This will limit you to the 4-decimal precision to which the MSEs are printed on the screen, but for plotting purposes, I imagine that should be fine.
See Also
Categories
Find more on Point Cloud Processing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!