视频编解码质量评价---BDBR与BD-PSNR

   Bjøntegaard delta bit rate (BDBR) 表示了在同样的客观质量下,两种方法的码率节省情况(Rate/distortion curves 画一条水平线)

   Bjøntegaard delta peak signal-to-noise rate (BD-PSNR)表示了在给定的同等码率下,两种方法的PSNR-Y的差异(Rate/distortion curves 画一条垂直线)

  参考:点击打开链接

matlab代码如下:

  程序运行结果:

  

testBjontegaard.m

% test Bjontegaard metric

% 测试例子
R1 = [686.760000000000;309.580000000000;157.110000000000;85.9500000000000];
R2 = [893.340000000000;407.800000000000;204.930000000000;112.750000000000];
PSNR1 = [40.2800000000000;37.1800000000000;34.2400000000000;31.4200000000000];
PSNR2 = [40.3900000000000;37.2100000000000;34.1700000000000;31.2400000000000];

[row,col] = size(R1);
%预分配空间
rate1=zeros(1,row);
psnr1=zeros(1,row);
rate2=zeros(1,row);
psnr2=zeros(1,row);

% 绘制曲线1
for i=1:row          
        rate1(:,i) = R1(i,1);
        psnr1(:,i) = PSNR1(i,1);
end
plot(rate1,psnr1,'r-*');
xlabel('Rate/kbps');
ylabel('PSNR/dB');
grid on;
hold on;

% 绘制曲线2
for i=1:row          
    rate2(:,i)=R2(i,1);
    psnr2(:,i)=PSNR2(i,1);
end
plot(rate2,psnr2,'b-+');

title('率失真曲线');
legend('曲线1','曲线2',4);    %最后一个参数,1~4表示位置
 
% 计算BDPSNR:
% Bj?ntegaard delta bit rate (BDBR) 表示了在同样的客观质量下,
% 两种方法的码率节省情况(Rate/distortion curves 画一条水平线)
avg_diff_psnr = bjontegaard(R1,PSNR1,R2,PSNR2,'dsnr');

% 计算BDBR:(注意结果是变化百分比)
% Bj?ntegaard delta peak signal-to-noise rate (BD-PSNR)表示了在
% 给定的同等码率下,两种方法的PSNR-Y的差异(Rate/distortion curves 画一条垂直线)。
avg_diff_bitrate = bjontegaard(R1,PSNR1,R2,PSNR2,'rate');

bjontegaard.m

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);
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



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

rs勿忘初心

您的鼓励将是我的最大创动原动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值