Peak-Signal to Noise Ratio (PSNR)
1. The PSNR is most commonly used as
a measure of quality of reconstruction of lossy compression codec’s (e.g., for image compression).
2. The signal in this case is the
original data, and the noise is the error introduced by compression.
3. When comparing compression
codec’s it is used as an approximation
to human perception of reconstruction quality, therefore in some cases one
reconstruction may appear to be closer to the original than another, even
though it has a lower PSNR (a higher PSNR would normally indicate that the
reconstruction is of higher quality).
The PSNR is calculated by using
following formula.
MAXI=Maximum value of pixel in Original image
m=No. of Row in Original image
n= No. of Column in Original
image
Procedure:
1. Read Original Image from current directory.
2. Read Noisy Image from current directory.
3. If Original Image is equal to Noisy Image then PSNR is 100%.
4. Find out difference between Original Image & Noisy
Image.
5. Find out Mean Square Error by using above formula.
6. Find out maximum value of Pixel in Original
Image.
7. Find out Peak Signal to Noise Ratio.
Program:
Function
of PSNR
function
[psnr]=PSNR(I,K)
I=double(I);
K=double(K);
if (I==K)
psnr=100;
else
[r c p]=size(I);
d=0;
for i=1:r
for j=1:c
d=d+(I(i,j)-K(i,j))^2;
end
end
mse=d/(r*c);
maximum=max(I(:));
psnr=10*log10(maximum^2/mse);
end
|
Test Application:
clc
[file path]=uigetfile('*.*');
I=imread(file);
K = imnoise(I,'salt & pepper', 0.01);
figure;
subplot(1,2,1);imshow(I);title('Original Image')
subplot(1,2,2);imshow(K);title('Noisy Image')
[psnr]=PSNR(I,K);
if(psnr<=30)
helpdlg('Image having low quality','Image Quality check box')
elseif(psnr>=30
&& psnr<=60)
helpdlg('Image having Medium quality','Image Quality check box')
else
helpdlg('Image having good quality','Image Quality check box')
end
|
Outputs:
Image Quality check box:
psnr = 25.1560


thanks for this post...:)
ReplyDeleteCan we calculate PSNR of 1-D signal? How to do that?
ReplyDeleteThanks
yes we can.....its vary simple
Delete1. first find the MSE of 1D signal
2. psnr=10log10(MAX^2/MSE) use this formula for finding PSNR
In this case, The MAX is the maximum value in the 1D Signal ??
DeleteYa MAX is Maximum value in 1D signal...
DeleteOkk, but the maximum in the original signal ? or the noisy one ? or in both ?
DeleteThank You !
Maximum from Original Signal...
DeleteThank you a lot !
DeleteOne last question
how can I compute SSIM (Structural Similarity index) for 1D Signals in matlab?
pls send d (.m) file
ReplyDeleteWhat is Your Email ID?
Deletesir plz send me the code at sangwan_sudesh@yahoo.com as soon as possible.....
Deletesir pease send me code for image quality metrics psnr mse ssim etc with read me file at shrepadzambodker88@gmail.com
ReplyDeleteall the image quality metrics codes average diffrence normalised absolute error
ReplyDeletesir please send me the full code at e.ramya19@gmail.com
ReplyDeletesir, please send me the full code at azlinazmahad@gmail.com.
ReplyDeleteThank you
What is the maximum value in the equation of psnr in case of color images>
ReplyDelete