finding of mse and psnr

5 次查看(过去 30 天)
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)

采纳的回答

Image Analyst
Image Analyst 2014-4-11
编辑:Image Analyst 2014-4-11
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);

更多回答(1 个)

Spandan Tiwari
Spandan Tiwari 2014-4-11
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