⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 psnrmetric.m

📁 This is a file for calculating the weighted PSNR in matlab
💻 M
字号:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                          Maribel Madueno                            %
%                         Computer Vision Group                        %
%                               19/03/01                               %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Calculates PSNR in dB for two images of the same size and same format
% (0:255).

% Copyright (c) 2001, University of Geneva
% 
%  Permission to use, copy, modify, and distribute this software and its
%  documentation for any non-commercial purpose and without fee is hereby
%  granted (GPL), provided that the above copyright notice appear in all
%  copies and that both that copyright notice and this permission notice
% appear in supporting documentation. This software is provided "as is" 
% without express or implied warranty. The authors shall not be held
% liable in any event for incidental or consequential damages in
% connection with, or arising out of, the furnishing, performance, or
% use of this program.
% 
% If you use the Checkmark software package for your research, please cite:
%
% Shelby Pereira, Sviatoslav Voloshynovskiy, Maribel Madue駉, St閜hane Marchand-Maillet
% and Thierry Pun, Second generation benchmarking and application oriented evaluation,
% In Information Hiding Workshop, Pittsburgh, PA, USA, April 2001.
%
%  http://cui.unige.ch/~vision/Publications/watermarking_publications.html
%
%  
%
% See the also the "Copyright" file provided in this package for
% copyright information about code used in the Checkmark package.
%
function [PSNR,wPSNR]=psnrMetric(a,b,type)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Inputs: 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% a:
% b:
% type:
% type=1 -> psnr
% type=2 -> nsG
% type=3 -> sgG
% type=4 -> psnr,nsG
% type=5 -> psnr,sgG
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
wPSNR=[];
if (a==b)
    out=inf;
else
    if size(a,3)==3 % if colour image then
        a=[a(:,:,1) a(:,:,2) a(:,:,3)]; 
        b=[b(:,:,1) b(:,:,2) b(:,:,3)];
    end    
    if type>=1 & type<=5
        if type==2 | type==4
            statistics='nsG';
        else
            statistics='sgG';
        end
        NVF=nvf(a,statistics,150);
        %size(NVF)
        NVF=NVF/max(NVF(:));
        c=NVF.*(a-b).^2;
    end
    c=(a-b).^2;             % squared difference of images
    PSNR=10*log10(255^2*prod(size(a))/sum(c(:)));
    c=NVF.*c;
    wPSNR=10*log10(255^2*prod(size(a))/sum(c(:)));        
end   

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -