Monday, 10 November 2014

MATLAB Code For Calulating PSNR Of Image


%%%%.............>>>>>>>>>>>>
%%%%%%%%%%%%%% FOR CALCULATING PSNR......................
%...........EXAMPLE..............a=imread('image1.jpg');
%>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>b=imread('image2.jpg');....>> PSNR(a,b)
%%%%.......TESTED FORMULAE.............................

function psnr_Value = PSNR(A,B)
% PSNR (Peak Signal to noise ratio)

if (size(A) ~= size(B))
   error('The size of the 2 matrix are unequal')

   psnr_Value = NaN;
   return;
elseif (A == B)
   disp('Images are identical: PSNR has infinite value')

   psnr_Value = Inf;
   return;  
else

    maxValue = double(max(A(:)));

    % Calculate MSE, mean square error.
    mseImage = (double(A) - double(B)) .^ 2;
    [rows columns] = size(A);
   
    mse = sum(mseImage(:)) / (rows * columns)

    % Calculate PSNR (Peak Signal to noise ratio)
    psnr_Value = 10 * log10( 256^2 / mse);
    RMSE = sqrt(mse)                                   % RMSE

end

Download Project for B.E, B.Tech, BCA, MCA, M.E, M.Tech, B.Sc, M.Sc and Polytechnic from: http://lowpriceprojects.blogspot.in/


  1 comment:

Total Pageviews

CONTACT US

Prof. Roshan P. Helonde
Mobile / WhatsApp: +917276355704
Email: roshanphelonde@rediffmail.com

Contact Form

Name

Email *

Message *

Archive

Notes Planet Copyright 2018. Powered by Blogger.