MATLAB Code : PSNR (Peak Signal to Noise Ratio) Calculation






%Name: www.sureshQ.Blogspot.in
%Course:   Digital Watermarking
%Project: Calculates the PSNR (Peak Signal to Noise Ratio)
% of images A and A', both of size MxN

function [A] = psnr(image,image_prime,M,N)

    % convert to doubles
    image=double(image);
    image_prime=double(image_prime);

    % avoid divide by zero nastiness
    if ((sum(sum(image-image_prime))) == 0)  
        error('Input vectors must not be identical')
    else
        psnr_num=M*N*max(max(image.^2));                % calculate numerator
        psnr_den=sum(sum((image-image_prime).^2));      % calculate denominator
        A=psnr_num/psnr_den;                            % calculate PSNR
    A=10*log10(A);
    end

return

MATLAB Code : PSNR (Peak Signal to Noise Ratio) Calculation MATLAB Code : PSNR (Peak Signal to Noise Ratio) Calculation Reviewed by Suresh Bojja on 7/23/2016 11:36:00 PM Rating: 5

Subjects & Labs

Theme images by sebastian-julian. Powered by Blogger.