What does a low RMSE value of an image determine?
조회 수: 5 (최근 30일)
이전 댓글 표시
Hi,
I am comparing two images and wanted to calculate the error.
Does a lower RMSE value show a small error?
Thanks
댓글 수: 0
답변 (1개)
Image Analyst
2015년 4월 12일
It means that the "test" image is close to the "reference" image on a pixel-by-pixel basis, if that's the RMSE method you used.
댓글 수: 1
Image Analyst
2015년 4월 12일
I assume b and N are images, then it's almost correct. You need to square the (a-b) before you take the mean. You can use mean2() instead of mean(mean()) if they are gray scale images. See this snippet from my attached demo
%------ PSNR CALCULATION ---------------------
% Now we have our two images and we can calculate the PSNR.
% First, calculate the "square error" image.
% Make sure they're cast to floating point so that we can get negative differences.
% Otherwise two uint8's that should subtract to give a negative number
% would get clipped to zero and not be negative.
squaredErrorImage = (double(grayImage) - double(noisyImage)) .^ 2;
% Display the squared error image.
subplot(2, 2, 3);
imshow(squaredErrorImage, []);
title('Squared Error Image', 'FontSize', fontSize);
% Sum the Squared Image and divide by the number of elements
% to get the Mean Squared Error. It will be a scalar (a single number).
mse = sum(squaredErrorImage(:)) / (rows * columns);
% Calculate PSNR (Peak Signal to Noise Ratio) from the MSE according to the formula.
PSNR = 10 * log10( 256^2 / mse);
% Alert user of the answer.
message = sprintf('The mean square error is %.2f.\nThe PSNR = %.2f', mse, PSNR);
msgbox(message);
Note that there are now built in functions for mse called immse() and PSNR caleld psnr().
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!