⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 waveletuse.m

📁 小波分解墨和分解低频系数和高频系数重构程序
💻 M
字号:
function waveletuse(OpenPath,IN1,IN2,kind,nflag,n)
%IN1--->'den',进行小波去噪运算
%IN1--->'cmp',进行小波压缩运算
%IN2 is 'wv' for wavelet or 'wp' for wavelet packet.
%filepath--->数据文件所在路径(十进制的文本稳当数据文件(一维)或图象格式)
%nflag--->数据维数
%n为程度
 
%读取信号
if(nflag==1)
    fid = fopen(OpenPath,'r');
    X=fscanf(fid,'%g');
elseif(nflag==2)
    
     [X,map]=imread(OpenPath);
     X=double(X); 
    
else
   error('please input 1-D or 2-D signal');
end

%处理过程
if IN2=='wv'
    [thr,sorh,keepapp]=ddencmp(IN1,IN2,X);
    [xc,cxc,lxc,perf0,perfl2]=wdencmp('gbl',X,kind,n,thr,sorh,keepapp);
elseif IN2=='wp'
    [thr,sorh,keepapp,crit]=ddencmp(IN1,IN2,X);
    [xc,treed,perf0,perfl2] =wpdencmp(X,sorh,n,kind,crit,thr,keepapp);
    figure(1),plot(treed);
else
    error('The version is not correct');
end


    
%显示结果
if nflag==1
    if IN1=='den'
        subplot(211),plot(X),title('原始信号');
        subplot(212),plot(xc),title('去噪后信号');
%         subplot(413),plot(treed),title(' Decomposition Tree');
    else
        subplot(211), plot(X), title('原始信号');
        subplot(212), plot(xc), title('压缩后信号'); 
%         subplot(413),plot(treed),title('Decomposition Tree');
        xlab1 = ['2-norm rec.: ',num2str(perfl2)];
        xlab2 = [' %  -- zero cfs: ',num2str(perf0), ' %'];
        xlabel([xlab1 xlab2]);
    
    end
else
     if IN1=='den'
        figure(2), image(X),colormap(map), title('原始图像');
        figure(3), image(xc),colormap(map), title('去噪后图像');
%         subplot(4,1,3), plot(treed),title(' Decomposition Tree');
     else
        figure(2), image(X),colormap(map),title('原始图像');
        figure(3),image(xc),colormap(map),title('压缩后图像'); 
%         subplot(4,1,3),plot(treed),title(' Decomposition Tree');
        xlab1 = ['压缩后图像剩余能量百分比:',num2str(perfl2),' %'];
        xlab2 = ['小波分解系数中置0的系数个数百分比:',num2str(perf0), ' %'];
        xlabel([xlab1 xlab2]);
     
     end
end
    
    

   
   

⌨️ 快捷键说明

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