How to Calculate mse?

How to Calculate mse? This is correct mse = mean(mean((originalImage-embeddedImage).^2));

Answers (1)

Image Analyst
Image Analyst on 8 May 2015

0 votes

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

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
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 Convert Image Type in Help Center and File Exchange

Tags

Asked:

on 8 May 2015

Commented:

on 8 May 2015

Community Treasure Hunt

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

Start Hunting!