finding of mse and psnr

8 ビュー (過去 30 日間)
Jitesh Bhanushali
Jitesh Bhanushali 2014 年 4 月 11 日
編集済み: Image Analyst 2014 年 4 月 11 日
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 件のコメント
Jitesh Bhanushali
Jitesh Bhanushali 2014 年 4 月 11 日
this is the code

サインインしてコメントする。

採用された回答

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