필터 지우기
필터 지우기

finding of mse and psnr

조회 수: 6 (최근 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)

채택된 답변

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