Code covered by the BSD License  

Highlights from
PSNR

3.46875

3.5 | 33 ratings Rate this file 78 Downloads (last 30 days) File Size: 2.34 KB File ID: #135

PSNR

by

 

09 Oct 1998 (Updated )

This function displays the PSNR (peak signal-to-noise ratio) between two images.

| Watch this File

File Information
Description

This function displays the PSNR (peak signal-to-noise ratio) between two images. The answer is in decibels (dB).

PSNR is very common in image processing. A sample use is in the comparison between an original image and a coded/decoded image. Typical quoted PSNR figures are in the range +25 to +35dB.

The syntax for this file is PSNR(A,B), where A and B are MATLAB Intensity Images, with matrix-elements in the interval [0,1]

The function can be adapted for images with 256 gray levels.

Acknowledgements

This file inspired Mmvn Toolkit and Psnr For Rgb Images.

MATLAB release MATLAB 7.2 (R2006a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (37)
19 Jul 2014 Nora  
12 Mar 2013 MathLab_Work Community

Greatful..

19 Nov 2012 priya das

Can any one pls mail me the code to plot the graph between bit per pixel and psnr..my mail id is prettypriya1205@gmail.com

24 Oct 2012 Sugel  
03 Jun 2011 ray mand  
03 Jun 2011 ray mand  
18 Jul 2009 hbu 

good

06 Dec 2008 bigforg ‡  
13 Oct 2008 Aon S.  
20 Jul 2008 Muhammad Naveed Ahmed

Excellent and thanks

04 Dec 2007 himanshu sharma

good

05 Nov 2007 Luren Jia

img1 = im2double(imread('img1.bmp'));
img2 = im2double(imread('img2.bmp'));

PSNR = 10*log10(1/mean((img1(:)-img2(:)).^2));

compare mine coding with yours which one is correct?

03 Nov 2007 Tiandi Duan  
05 Jun 2007 burepalli venkata srinivasarao

i want the psnr mat lab code

20 Mar 2007 liu qiang  
01 Mar 2007 prabhat srivastava  
30 May 2006 justin lee

good thank u

11 May 2006 weiss Pierre

I don't have time to do something better, but rather use that code, which may not be perfect, but which is already more general :

%function [SNR,MSE]=PSNR(u0,u)
function [SNR,MSE]=PSNR(u0,u)

[ny,nx]=size(u0);
A=max(max(u0(:)),max(u(:)));
dif=u0(:)-u(:);

MSE=mean(dif.^2);

SNR=10*log(A*A/MSE)/log(10);

11 May 2006 weiss Pierre

Very poor implementation. It just works for images, peak is fixed to one. Rather than max(max(A)), the author should prefer max(A(:)) which works for images in any dimension.

09 Nov 2005 Ramraj Pandey

good... we calculate PSNR with signals normalized.

02 Apr 2005 ichi maeda

This PSNR is not accurate!!
Peak is always fixed at 1.

07 Feb 2005 sankar kumar

its nice

28 Dec 2004 jameer iqbal  
31 Aug 2004 bassem sheta

what if the two images are not between [0,1]

29 Aug 2004 Feng Yang

great

17 Aug 2004 Jeny Rajan

Simple and fast

16 Jul 2004 VENKATA KARTHIK PRABALA

easy to understand and implement. good idea to can this.

03 Jul 2004 Michael Kleder

Nice. Well commented.

27 May 2004 jonathan haffarei

very simple and effective

01 Apr 2004 VEERAMALLY RAVIKUMAR  
12 Mar 2004 Din bhari

I highly Apprciate it

11 Dec 2003 Wei Ting

3 PSNR values are shown.
Are they the PSNR of YUV or RGB?

20 May 2003 susette dayanghirang  
24 Feb 2003 Joel Schaere

This is Ok, not perfect, but suitable for use

15 Jan 2003 taufiq FEBRIAN  
15 Jan 2003 febrian taufiq  
28 Aug 2002 Shaikh Hussain  
Updates

modifying description

30 Jan 2008

Improved some code, to prevent M-Lint messages in MATLAB's Code Metrics.

Contact us