File Exchange

image thumbnail

PSNR

version 1.0 (2.34 KB) by

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

3.31429
34 Ratings

38 Downloads

Updated

View License

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.

Comments and Ratings (38)

Nora

Nora (view profile)

dian_pratama

Greatful..

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

Sugel

Sugel (view profile)

ray mand

ray mand

hbu 

hbu  (view profile)

good

bigforg ‡

Aon S.

Muhammad Naveed Ahmed

Excellent and thanks

himanshu sharma

good

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?

Tiandi Duan

burepalli venkata srinivasarao

i want the psnr mat lab code

liu qiang

prabhat srivastava

justin lee

good thank u

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);

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.

Ramraj Pandey

good... we calculate PSNR with signals normalized.

ichi maeda

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

sankar kumar

its nice

jameer iqbal

bassem sheta

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

Feng Yang

great

Jeny Rajan

Simple and fast

VENKATA KARTHIK PRABALA

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

Michael Kleder

Nice. Well commented.

jonathan haffarei

very simple and effective

VEERAMALLY RAVIKUMAR

Din bhari

I highly Apprciate it

Wei Ting

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

susette dayanghirang

Joel Schaere

This is Ok, not perfect, but suitable for use

taufiq FEBRIAN

febrian taufiq

Shaikh Hussain

Updates

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

modifying description

MATLAB Release
MATLAB 7.2 (R2006a)
Acknowledgements

Inspired: PSNR for RGB images, mmvn_toolkit

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video