Image similarity criterion using HVS WPSNR

xiaoxiao2021-03-06  72

The following MATLAB program calculates the weighted peak signal to noise ratio of the two images. Compared to commonly used PSNR, the impact of HVS (Human Visual Sytem) is considered. Function f = WPSNR (A, B, VARARGIN)

% This function computes wpsnr (Weight Peak Signal-to-Noise Ratio) Between

% Two images. The Answer IS in Decibels (DB).

%

% Using Contrast Sensitivity Function (CSF) TO Weight Spatial Frequency

% of error Image.

%

% Using: WPSNR (A, B)

%

% Written by ruizhen liu, http://www.assuredigit.com

IF a == B

Error ('Images Are Identical: Psnr Has Infinite Value')

end

MAX2_A = Max (Max (a));

MAX2_B = max (max (b));

MIN2_A = Min (MIN (a));

MIN2_B = min (min (b));

IF max2_a> 1 | max2_b> 1 | min2_a <0 | min2_b <0

Error ('INPUT MATRICES MUST HAVE VALUES in The Interval [0,1]')

end

e = a - b;

IF Nargin <3

FC = CSF;% Filter Coefficients of CSF

Else

FC = varargin {1};

end

EW = filter2 (FC, E);% filtering error with csf

Decibels = 20 * log10 (1 / (SQRT (Mean (Mean (EW. ^ 2))))))))

% DISP (Sprintf ('WPSNR = % 5.2F ​​DB', DECIBELS))

f = Decibels;

% =============

Function FC = CSF ()

% =============

% Program to Compute CSF

% Compute Contrast Sensitivity Function Of HVS

%

% OUTPUT: FC --- Filter Coefficients of CSF

%

% Reference:

% Makoto Miyahara

% "Objective Picture Quality Scale (PQS) for Image Coding"

% IEEE TRANS. On Comm., Vol 46, No.9, 1998.

%

% Written by ruizhen liu, http://www.assuredigit.com

% Compute Frequency Response Matrix

FMAT = csfmat;

% Plot Frequency Response

% Mesh (FMAT); PAUSE

% Compute 2-D Filter Coefficient Using Fsamp2

FC = fsamp2 (fmat);

% Mesh (FC)

% ======================== Function SA = CSFFUN (U, V)

% ========================

% Contrast Sensitivity Function In Spatial Frequency

% This file compute the spatial frequency weighting of errors

%

% Reference:

% Makoto Miyahara

% "Objective Picture Quality Scale (PQS) for Image Coding"

% IEEE TRANS. On Comm., Vol 46, No.9, 1998.

%

% INPUT: U --- Horizontal Spatial Frequencies

% V - Vertical Spatial Frequencies

%

% OUTPUT: FREQUENCY RESPONSE

%

% Written by ruizhen liu, http://www.assuredigit.com

% Compute Sa - Spatial Frequency Response

% SYMS S W Sigma F u V

Sigma = 2;

f = SQRT (u. * u v. * v);

W = 2 * pi * f / 60;

SW = 1.5 * EXP (-Sigma ^ 2 * W ^ 2/2) -exp (-2 * sigma ^ 2 * w ^ 2/2);

% Modification In High Frequency

SITA = Atan (v ./ (u eps));

Bita = 8;

F0 = 11.13;

W0 = 2 * pi * f0 / 60;

OW = (1 Exp (Bita * (W-W0)) * (COS (2 * SITA)) ^ 4) / (1 Exp (Bita * (W-W0)));

% Compute Final Response

SA = SW * OW;

% ===================

Function FMAT = csfmat ()

% ===================

% Compute CSFFrequency Response Matrix

% Caling function csf.m

% Frequency Range

% The Rang of Frequency Seems To BE:

% w = pi = (2 * pi * f) / 60

% f = 60 * w / (2 * pi), About 21.2

%

min_f = -20;

MAX_F = 20;

STEP_F = 1;

u = min_f: step_f: max_f;

v = min_f: step_f: max_f;

N = Length (u);

Z = zeros (n);

For i = 1: nfor J = 1: N

Z (i, j) = csffun (u), v (j)));% calling function csffun

end

end

FMAT = z;

转载请注明原文地址:https://www.9cbs.com/read-92757.html

New Post(0)