Thursday 5 July 2012

Checking Image Quality Using MATLAB PSNR program

Checking Image Quality Using MATLAB PSNR program

PSNR or peak-to-noise ratio is used to evaluate the quality of the watermarked image after embedding the secret message in the image.

The PSNR value more than 30dB shows that the watermarked image quality is acceptable to human eyes. Basically, the larger the PSNR value, the better the quality of the watermarked image is. It means that the distortions created on the watermarked image is not really perceptible and difficult to be detected by the human visual system.

On the other hand, if the PSNR value is less than 30dB, the watermarked-image is most likely to give some 'noise' on the image. This 'noise' becomes perceptible to human eyes and so the watermarked-image is considered to have lesser quality.

The MATLAB code below lets you to compare the original (host) image and the watermarked image and then gives you the PSNR value.

MATLAB Code

clear all; close all; clc;

[filename1,pathname]=uigetfile('*.*','Select the original image'); 
image1=imread(num2str(filename1));

[filename2,pathname]=uigetfile('*.*','Select the watermarked image'); 
image2=imread(num2str(filename2));

figure(1);
imshow(image1); title('Original image'); 

figure(2);
imshow(image2); title('Watermarked image');    

[row,col] = size(image1)
size_host = row*col;

o_double = double(image1);
w_double = double(image2);
s=0;

for j = 1:size_host; % the size of the original image
s = s+(w_double(j) - o_double(j))^2 ; 
end

mes=s/size_host;
psnr =10*log10((255)^2/mes);
display 'Value of',psnr

Popular Posts