?? tu2.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 + -