Running Bjontegaard function: error line 30?

조회 수: 8 (최근 30일)
Fungai Kusema
Fungai Kusema 2018년 12월 4일
Dear Support Community,
I'm trying to understand the Bjontegaard function as coded by Giuseppe Valenzise without success.
Running the function defining code generates the an error at line 30 (highlighted in bold and italics in code below).
And running function after defining it with Giuseppe Valenzise sample values returned errros in the code execution at line 13.
Has anyone been able to test/use this code?
function avg_diff = bjontegaard(R1,PSNR1,R2,PSNR2,mode)
%BJONTEGAARD Bjontegaard metric calculation
% Bjontegaard's metric allows to compute the average gain in PSNR or the
% average per cent saving in bitrate between two rate-distortion
% curves [1].
% Differently from the avsnr software package or VCEG Excel [2] plugin this
% tool enables Bjontegaard's metric computation also with more than 4 RD
% points.
%
% R1,PSNR1 - RD points for curve 1
% R2,PSNR2 - RD points for curve 2
% mode -
% 'dsnr' - average PSNR difference
% 'rate' - percentage of bitrate saving between data set 1 and
% data set 2
%
% avg_diff - the calculated Bjontegaard metric ('dsnr' or 'rate')
%
% (c) 2010 Giuseppe Valenzise
%
% References:
%
% [1] G. Bjontegaard, Calculation of average PSNR differences between
% RD-curves (VCEG-M33)
% [2] S. Pateux, J. Jung, An excel add-in for computing Bjontegaard metric and
% its evolution
% convert rates in logarithmic units
lR1 = log(R1); % line 30
lR2 = log(R2);
switch lower(mode)
case 'dsnr'
% PSNR method
p1 = polyfit(lR1,PSNR1,3);
p2 = polyfit(lR2,PSNR2,3);
% integration interval
min_int = min([lR1; lR2]);
max_int = max([lR1; lR2]);
% find integral
p_int1 = polyint(p1);
p_int2 = polyint(p2);
int1 = polyval(p_int1, max_int) - polyval(p_int1, min_int);
int2 = polyval(p_int2, max_int) - polyval(p_int2, min_int);
% find avg diff
avg_diff = (int2-int1)/(max_int-min_int);
case 'rate'
% rate method
p1 = polyfit(PSNR1,lR1,3);
p2 = polyfit(PSNR2,lR2,3);
% integration interval
min_int = min([PSNR1; PSNR2]);
max_int = max([PSNR1; PSNR2]);
% find integral
p_int1 = polyint(p1);
p_int2 = polyint(p2);
int1 = polyval(p_int1, max_int) - polyval(p_int1, min_int);
int2 = polyval(p_int2, max_int) - polyval(p_int2, min_int);
% find avg diff
avg_exp_diff = (int2-int1)/(max_int-min_int);
avg_diff = (exp(avg_exp_diff)-1)*100;
end

답변 (0개)

카테고리

Help CenterFile Exchange에서 Descriptive Statistics에 대해 자세히 알아보기

태그

제품


릴리스

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by