How can I plot the mean squared errors being calculated by the imregister function?

조회 수: 6 (최근 30일)
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

답변 (1개)

Matt J
Matt J 2021년 11월 2일
편집: Matt J 2021년 11월 2일
MSE=norm(modified-fixed,'fro')^2/numel(fixed);
or
MSE=mean(abs(modified-fixed).^2,'all');
  댓글 수: 2
Matt J
Matt J 2021년 11월 3일
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
Matt J 2021년 11월 3일
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.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Point Cloud Processing에 대해 자세히 알아보기

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by