Calculating the RMSE value between two images

I calculated the RMSE value between two images of size 128 x 128 in .jpg format and I am getting the result above 1. I want the range to be between 0-1. I tried applying imadjust to normalize but it did not help. How can I normalize the image and get the required result between 0-1. I also tried to save the images in .mat file and normalize it but I am getting error as the image is being saved as type struct and not double. Please help.Thank you in advance.
I used the following line to calculate rmse:
rmse_val = sqrt(mean((ref(:)-a(:)).^2))

 채택된 답변

Image Analyst
Image Analyst 2022년 9월 19일
You forgot to attach your variables. I don't know if you can subtract structures like that so I think ref and (the badly-named) a are actually numerical arrays, not structures. If they are uint8 gray scale images, you should convert to double before subtracting, and use the rms function:
a = imread('cameraman.tif');
ref = a + 10;
% First method is to use rms on the difference array.
diffImage = double(ref) - double(a);
r = rms(diffImage(:))
r = 9.9975
% Alternate way is to use rmse
re = rmse(double(ref(:)), double(a(:)))
re = 9.9975

댓글 수: 4

Shourya
Shourya 2022년 9월 20일
@Image Analyst Thank you for the solution and explaination.Thank you for pointing out the variables details. Sorry I missed them. The groundtruth image is referred to as 'ref' and the test image is referred to as 'a'. Yes, they are uint8 gray scale images. I tried the above solution but I get the result as 5.69. I want it between 0-1 or how can I get the result in precentage.
You can divide either by the max value in your reference image, or divide by 255, depending on how you define percentage.
Shourya
Shourya 2022년 9월 20일
This is what I will get 5.69/255=0.0219. Is this right?
Yes

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기

질문:

2022년 9월 19일

댓글:

2022년 9월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by