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

📄 tu2.m

📁 该程序基于小波变换
💻 M
字号:
%装载并显示原始图象
load gatlin2;
subplot(2,2,1);
image(X);
colormap(map);
title('原始图象');
axis square;%装载并显示原始图象
A=imread('d:\1002513\e.jpg');
subplot(2,2,1);
image(A);
%colormap(map);
%colorbar;
title('原始图象');
axis square;
%=============================================
%转换为索引图
A=double(A);
Xrgb=0.2990*A(:,:,1)+0.5870*A(:,:,2)+0.1140*A(:,:,3);
Nbcolors=255;
X=wcodemat(Xrgb,Nbcolors);
map=pink(Nbcolors);
subplot(2,2,1);
image(X);
colormap(map);
%colorbar;
title('原始图象');
axis square;
%====================

%=============================================
%加噪并显示图象
init=2055615866;
rand('seed',init);
XX=X+40*randn(size(X));
subplot(2,2,2);
image(XX);
colormap(map);
title('含噪图象');
axis square;
%===============================================
%对图象消噪处理
%用coif2小波函数对XX进行2层分解
[c,l]=wavedec2(XX,2,'coif2');
n=[1,2];%设置尺度向量
p=[10.28,24.08];%设置阀值向量
%================================================
%对三个高频系数进行阀值处理
nc=wthcoef2('h',c,l,n,p,'s');
nc=wthcoef2('v',c,l,n,p,'s');
nc=wthcoef2('d',c,l,n,p,'s');
X1=waverec2(nc,l,'coif2');
subplot(2,2,3);
image(X1);
colormap(map);
title('第一次消噪后的图象');
axis square;
%================================================
%再次对三个高频系数进行阀值处理
mc=wthcoef2('h',c,l,n,p,'s');
mc=wthcoef2('v',c,l,n,p,'s');
mc=wthcoef2('d',c,l,n,p,'s');
X2=waverec2(mc,l,'coif2');
subplot(2,2,4);
image(X2);
colormap(map);
title('第二次消噪后的图象');
axis square;

⌨️ 快捷键说明

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