Effacer les filtres
Effacer les filtres

finding of mse and psnr

6 vues (au cours des 30 derniers jours)
Jitesh Bhanushali
Jitesh Bhanushali le 11 Avr 2014
Modifié(e) : Image Analyst le 11 Avr 2014
sir i have attached a code . i want to find mse and psnr of the original image(I) and reconstruted image (y). i have used following code but it gives me error. how to find this parameters??
D = abs(I-y).^2; MSE = sum(D(:))/numel(I)
PSNR=10*log10(255*255/MSE)
  1 commentaire
Jitesh Bhanushali
Jitesh Bhanushali le 11 Avr 2014
this is the code

Connectez-vous pour commenter.

Réponse acceptée

Image Analyst
Image Analyst le 11 Avr 2014
Modifié(e) : Image Analyst le 11 Avr 2014
Did you cast y and (the badly named) I do double before you did the subtraction? Otherwise negative values will get clipped to zero. For example (7-9).^2 = 0^2 = 0, not 2^2 = 4 like you probably expect. See my attached demo, which you can use if you don't have the new built-in psnr() function that Spandan told us about. Here's the key lines in a snippet:
squaredErrorImage = (double(grayImage) - double(noisyImage)) .^ 2;
% 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(sum(squaredErrorImage)) / (rows * columns);
% Calculate PSNR (Peak Signal to Noise Ratio) from the MSE according to the formula.
PSNR = 10 * log10( 256^2 / mse);

Plus de réponses (1)

Spandan Tiwari
Spandan Tiwari le 11 Avr 2014
There's a function named psnr() in Image Processing Toolbox in R2014a for computing PSNR. MSE is also computed on the way to computing PSNR.
BTW, what error do you get with your code? What parameters do you want to find?

Community Treasure Hunt

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

Start Hunting!

Translated by