How to Calculate mse?

1 view (last 30 days)
Reem Al Shehri
Reem Al Shehri on 8 May 2015
Commented: Image Analyst on 8 May 2015
How to Calculate mse? This is correct mse = mean(mean((originalImage-embeddedImage).^2));

Answers (1)

Image Analyst
Image Analyst on 8 May 2015
No, only if they're floating point images, not integer images like uint8. You need to cast them to double so that your numbers don't get clipped at 0 if they would go negative.
You're best off using the built-in immse(). Otherwise if you want to do it yourself because you're missing the toolbox, see my attached code.
  2 Comments
Image Analyst
Image Analyst on 8 May 2015
Reem's "Answer" moved here:
function [PSNR]=psnr(originalImage,embeddedImage)
mse = mean(mean((originalImage-embeddedImage).^2));
MAXI=255; %MAXI is the maximum possible pixel value of the image.
%When the pixels are represented using 8 bits per sample, this is 255.
PSNR=10*log10(MAXI^2/mse);
end
This code
Image Analyst
Image Analyst on 8 May 2015
Not if they're typical images. Like I explained and showed you in the psnr.m file I attached for you, you need to case to double if they're uint8 which most images are.
mse = mean2((double(originalImage) - double(embeddedImage)).^2);

Sign in to comment.

Categories

Find more on Image Processing Toolbox in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!