thrselect.m

来自「小波图象去噪阈值的确定。呵呵」· M 代码 · 共 50 行

M
50
字号
function thr=thrselect(varargin)
%thr=thrselect(c,l)
%thr=thrselect(x,N,wanme)
%
%thr=[thr_birge  thr_bayes thr_all thr_sure thr_hthr thr_maxmin]
if errargn(mfilename,nargin,[2 3],nargout,[1]), error('*'), end
%
if nargin==3
    x    =varargin{1};N=varargin{2};wname=varargin{3};
    [c,l]=wavedec2(x,N,wname);
else
    c=varargin{1};l=varargin{2};
end

%
%yuzhi 
stde        =median(abs(c(prod(l(1,:))+1:end)))/0.6745;
stde
thr_birge   =wbmpen(c,l,stde,2);
%
varg        =mean(c(prod(l(1,:))+1:end).^2);
stdf        =sqrt(max(varg-stde^2,0));
thr_bayes   =stde^2/stdf;
%
n           =prod(size(x));
thr_all     =stde*sqrt(2*log(prod(n)));
%
t=x(:)';
sx2         = sort(abs(t)).^2;
risks       = (n-(2*(1:n))+(cumsum(sx2)+(n-1:-1:0).*sx2))/n;
[risk,best] = min(risks);
thr_sure    = stde*sqrt(sx2(best));
%
 hthr       = sqrt(2*log(n));
        eta = (norm(x).^2-n)/n;
        crit= (log(n)/log(2))^(1.5)/sqrt(n);
        if eta < crit
            thr_hthr= hthr;
        else
            thr_hthr = min(thselect(x,'rigrsure'),hthr);
        end
 %
  if n <= 32
            thr_maxmin = 0;
        else
            thr_maxmin= 0.3936 + 0.1829*(log(n)/log(2));
        end
thr=[thr_birge  thr_bayes thr_all thr_sure thr_hthr thr_maxmin];
o_thr={{'thr_birge='thr_birge},{'thr_bayes='thr_bayes},{'thr_all='thr_all},{'thr_sure='thr_sure},{'thr_hthr='thr_hthr},{'thr_maxmin='thr_maxmin}}
celldisp(o_thr);

⌨️ 快捷键说明

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