dct_profile.m

来自「英文书《Digital Signal Processing with Examp」· M 代码 · 共 34 行

M
34
字号
function step=dct_profile(x,N,n)
% Computes quantizing profile for N-component DCT of x.
% The profile is based on avg. periodogram measured in octaves.
% Each component gets at least one bit, unless the component is zero.
% 
%
% Inputs:  x = any vector or waveform.
%          N = size of DCT (segment size when compressing x).
%          n = avg. number of bits/DCT component, >=1.
% Output:  step = vector of N step sizes to use when quantizing the
%                 DCT components.
%              

if nargin~=3,
    error('dct_profile must have 3 arguments.');
elseif N>length(x),
    error('length of x cannot be < segment size N.');
elseif n<1,
    error('n must be at least 1 bit per component.');
end
x=row_vec(x);
[P,Nseg,v]=pds(x,x,2*N,1,0);            %avg. periodogram of x.
P=resamp(P(1:N+1),N);                   %components of P at N freqs.
if min(P)==0,
    error('Power component =0 - step cannot process.');
elseif max(P)/min(P)>1000,
    error('Cannot process if power component ratio >1000.');
end
sp_fig(1);
plot(log2(P),'or'); grid;
step=P;


⌨️ 快捷键说明

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