How to compute P.S.N.R value for the below set of images?

I would request anybody to provide me with code to compute the PSNR value for the below pair of images. I want to compare output1.png with o.png, o2.png with output2.png? Please help?

 采纳的回答

If you have the image processing toolbox you can use the function:
peaksnr = psnr(A,ref)
where A is your output1 and ref is o.

5 个评论

A=imread('output1.png');
>> B=imread('o.png');
>> peaksnr = psnr(A,B);
??? Undefined function or method 'psnr' for input arguments of type 'uint8'.
I am using MATLAB R2010a version.
Can you please suggest what the problem is?
A=<540x960x3 uint8>
B=<540x960x3 uint8>
Can you run this:
v = ver;
any(strcmp('Image Processing Toolbox', {v.Name}))
and post results? What version of matlab do you have?
Edit: just read that you have 2010a, I don't think peaksnr is present in that build.
I suggest you try one of the following:
or you could code it yourself:
X = double(X);
Y = double(Y);
m = sum((X(:)-Y(:)).^2) / prod(size(X));
psnr = 10*log10(255*255/m);
However, instead of assuming the peak is 255, you should use max(X(:)) as the peak.
Thanks it is working and I am getting psnr as 28.241
Does this suggest that the second image(output1.png) is better than the first image(o.png)?
Of course not. psnr is a measure of how close two images are to each other, not an overall assessment of which image is "better".
OK then what does this 28.241 suggest? Can you please explain?

请先登录,再进行评论。

更多回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by