• 大小: 1KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-06-07
  • 语言: Matlab
  • 标签: 自适应  贝叶斯  

资源简介

自适应贝叶斯算法matlab源码

资源截图

代码片段和文件信息

%阈值用bayes+比例参数k小于1的自适应
clear all;
sig=imread(‘GOLDHILL.bmp‘);%miss2;BOAT
[M_sig N_sig]= size(sig);

sig=double(sig)/double(max(max(sig)));
sig_n=imnoise(sig‘gaussian‘);

title(‘图1 含噪图像‘);

% %平稳小波分解,分解层
[sign1_ll sign1_lh sign1_hl sign1_hh]=SWT2(sig_n3‘db4‘);

% % %求取HH1中的噪声方差

for n=1:3
delta(n)=0 ;
delta(n)=median(median(abs(sign1_hh(::n))))/0.6745;
delta(n)=delta(n)^2;
end
%%求各层信号的方差

for n=1:3
    sum_ll(n)=0;
        sum_lh(n)=0;
            sum_hl(n)=0;
                sum_hh(n)=0;                
    
    for i=1:M_sig
        for j=1:N_sig
            sum_hh(n)=sum_hh(n)+sign1_hh(ijn)^2;
            sum_lh(n)=sum_lh(n)+sign1_lh(ijn)^2;
            sum_hl(n)=sum_hl(n)+sign1_hl(ijn)^2;
            sum_ll(n)=sum_ll(n)+sign1_ll(ijn)^2;
        end
    end
    sum_ll(n)=sum_ll(n)/(M_sig*N_sig);
        sum_lh(n)=sum_lh(n)/(M_sig*N_sig);
            sum_hl(n)=sum_hl(n)/(M_sig*N_sig);
                sum_hh(n)=sum_hh(n)/(M_sig*N_sig);
                
                sigdelta_ll(n)=sqrt(max(sum_ll(n)-delta(n)1e-6));%%各层信号方差
                sigdelta_lh(n)=sqrt(max(sum_lh(n)-delta(n)1e-6));
                sigdelta_hl(n)=sqrt(max(sum_hl(n)-delta(n)1e-6));
                sigdelta_hh(n)=sqrt(max(sum_hh(n)-delta(n)1e-6));
end
%%
%求取各个小波系数的比例gama
p=1;
for n=1:3
    max_ll(n)=max(max(abs(sign1_ll(::n))));
    max_lh(n)=max(max(abs(sign1_lh(::n))));
    max_hl(n)=max(max(abs(sign1_hl(::n))));
    max_hh(n)=max(max(abs(sign1_hh(::n))));    
     
    for i=1:M_sig
        for j=1:N_sig            
             k_ll(ijn)=abs(sign1_ll(ijn)/max_ll(n))^p;
             k_lh(ijn)=abs(sign1_lh(ijn)/max_lh(n))^p;
             k_hl(ijn)=abs(sign1_hl(ijn)/max_hl(n))^p;
             k_hh(ijn)=abs(sign1_hh(ijn)/max_hh(n))^p;
            
            %各个小波系数的阈值阈值随小波系数的变化而变化,小波系数大,阈值小,反之阈值大
            Tgama_ll(ijn)=1/sqrt(1+k_ll(ijn));
             Tgama_lh(ijn)=1/sqrt(1+k_lh(ijn));
             Tgama_hl(ijn)=1/sqrt(1+k_hl(ijn));
            Tgama_hh(ijn)=1/sqrt(1+k_hh(ijn));   
             Tgama_ll(ijn)=0;
            T_ll(ijn)=Tgama_ll(ijn)*delta(n)/sigdelta_ll(n);
            T_lh(ijn)=Tgama_lh(ijn)*delta(n)/sigdelta_lh(n);
            T_hl(ijn)=Tgama_hl(ijn)*delta(n)/sigdelta_hl(n);
            T_hh(ijn)=Tgama_hh(ijn)*delta(n)/sigdelta_hh(n);
            
               
            
          
        end
    end
end

%计算不同层次,不同小波系数的阈值
scale=1;
for n=1:3
    for i=1:M_sig
        for j=1:N_sig
               %阈值处理
               if sign1_ll(ijn)==0
                   sign1_ll(ijn)=0;
               else
                   sign1_ll1(ijn)=(sign1_ll(ijn)/abs(sign1_ll(ijn)))*max((abs(sign1_ll(ijn))- scale*T_ll(ijn))0);
                   
               
               end
               
                if sign1_lh(ijn)==0
                   sign1_lh(ijn)=0;
             

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       4097  2010-03-28 11:12  scadaptiveBay.m

----------- ---------  ---------- -----  ----

                 4097                    1


评论

共有 条评论