标题:【求助】小波分析实现数字图像去噪,怎么用matlab实现??
只看楼主
zlalx
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2006-4-30
 问题点数:0 回复次数:3 
【求助】小波分析实现数字图像去噪,怎么用matlab实现??

如题,请高手帮帮忙!!
能有源程序嘛?

搜索更多相关主题的帖子: matlab 图像 数字 
2006-04-30 20:47
sagiltarivs
Rank: 1
等 级:新手上路
帖 子:18
专家分:0
注 册:2006-5-12
得分:0 

%%给一个dwt的swt应该比这个简单。
clear;
clc;
close all;
I = imread('f:\test\chinalake.bmp','bmp');
I_temp = double(I); % read the image
[height,width] = size(I_temp); % get the size of the image

% dwt decomposition
[CA1 ,CH1 ,CV1 ,CD1] = dwt2(I_temp,'bior2.2');
[CA2 ,CH2 ,CV2 ,CD2] = dwt2(CA1,'bior2.2');
[CA3 ,CH3 ,CV3 ,CD3] = dwt2(CA2,'bior2.2');
[CA4 ,CH4 ,CV4 ,CD4] = dwt2(CA3,'bior2.2');

% store the low-frequency signal in the array CA
CA{1,1} = CA1;
CA{1,2} = CA2;
CA{1,3} = CA3;
CA{1,4} = CA4;

% store the horizon component in the array CH
CH{1,1} = CH1;
CH{1,2} = CH2;
CH{1,3} = CH3;
CH{1,4} = CH4;


% store the vertical component in the array CV
CV{1,1} = CV1;
CV{1,2} = CV2;
CV{1,3} = CV3;
CV{1,4} = CV4;

% store the digonal component in the array CD
CD{1,1} = CD1;
CD{1,2} = CD2;
CD{1,3} = CD3;
CD{1,4} = CD4;

%wavelet soft-restrict to de-noise
for i = 1:4
thr = median(median(abs(CH{1,i})));
thr = thselect(CH{1,i},'sqtwolog')*thr/0.6745;
CH{1,i} = wthresh(CH{1,i},'h',thr);
end
for i = 1:4
thr = median(median(abs(CV{1,i})));
thr = thselect(CV{1,i},'sqtwolog')*thr/0.6745;
CV{1,i} = wthresh(CV{1,i},'h',thr);
end
for i =1:4
thr = median(median(CD{1,i}));
thr = thselect(CD{1,i},'sqtwolog')*thr/0.6745;
CD{1,i} = wthresh(CD{1,i},'h',thr);
end

% reconstruction the image
%A = mean(CA4);
%flag = 0;


% the first layer
[row,cow] = size(CA4);
[r,c] = size(CH{1,4});
if row > r
A4(row,:) = [];
end
if cow > c
A4(:,cow) = [];
end
A4 = idwt2(CA4,CH{1,4},CV{1,4},CD{1,4},'bior2.2');
%figure(2);
%imshow(uint8(A4));

% the second layer
[row,cow] = size(A4);
[r,c] = size(CH{1,3});
if row > r
A4(row,:) = [];
end
if cow > c
A4(:,cow) = [];
end
A3 = idwt2(A4,CH{1,3},CV{1,3},CD{1,3},'bior2.2');
%figure(3);
%imshow(uint8(A4));

% the third layer
[row,cow] = size(A3);
[r,c] = size(CH{1,2});
if row > r
A3(row,:) = [];
end
if cow > c
A3(:,cow) = [];
end
A2 = idwt2(A3,CH{1,2},CV{1,2},CD{1,2},'bior2.2');


% the fourth layer
[row,cow] = size(A2);
[r,c] = size(CH{1,1});
if row > r
A2(row,:) = [];
end
if cow > c
A2(:,cow) = [];
end

A1 = idwt2(A2,CH{1,1},CV{1,1},CD{1,1},'bior2.2');
d_min = min(min(A1));
d_max = max(max(A1));
A1 = (A1 - d_min)/(d_max - d_min);
figure;
imshow(A1);
%imshow(uint8(A1));
%figure(2);
%imshow(I);


2006-05-12 21:26
sagiltarivs
Rank: 1
等 级:新手上路
帖 子:18
专家分:0
注 册:2006-5-12
得分:0 

%%给一个dwt的swt应该比这个简单。
clear;
clc;
close all;
I = imread('f:\test\chinalake.bmp','bmp');
I_temp = double(I); % read the image
[height,width] = size(I_temp); % get the size of the image

% dwt decomposition
[CA1 ,CH1 ,CV1 ,CD1] = dwt2(I_temp,'bior2.2');
[CA2 ,CH2 ,CV2 ,CD2] = dwt2(CA1,'bior2.2');
[CA3 ,CH3 ,CV3 ,CD3] = dwt2(CA2,'bior2.2');
[CA4 ,CH4 ,CV4 ,CD4] = dwt2(CA3,'bior2.2');

% store the low-frequency signal in the array CA
CA{1,1} = CA1;
CA{1,2} = CA2;
CA{1,3} = CA3;
CA{1,4} = CA4;

% store the horizon component in the array CH
CH{1,1} = CH1;
CH{1,2} = CH2;
CH{1,3} = CH3;
CH{1,4} = CH4;


% store the vertical component in the array CV
CV{1,1} = CV1;
CV{1,2} = CV2;
CV{1,3} = CV3;
CV{1,4} = CV4;

% store the digonal component in the array CD
CD{1,1} = CD1;
CD{1,2} = CD2;
CD{1,3} = CD3;
CD{1,4} = CD4;

%wavelet soft-restrict to de-noise
for i = 1:4
thr = median(median(abs(CH{1,i})));
thr = thselect(CH{1,i},'sqtwolog')*thr/0.6745;
CH{1,i} = wthresh(CH{1,i},'h',thr);
end
for i = 1:4
thr = median(median(abs(CV{1,i})));
thr = thselect(CV{1,i},'sqtwolog')*thr/0.6745;
CV{1,i} = wthresh(CV{1,i},'h',thr);
end
for i =1:4
thr = median(median(CD{1,i}));
thr = thselect(CD{1,i},'sqtwolog')*thr/0.6745;
CD{1,i} = wthresh(CD{1,i},'h',thr);
end

% reconstruction the image
%A = mean(CA4);
%flag = 0;


% the first layer
[row,cow] = size(CA4);
[r,c] = size(CH{1,4});
if row > r
A4(row,:) = [];
end
if cow > c
A4(:,cow) = [];
end
A4 = idwt2(CA4,CH{1,4},CV{1,4},CD{1,4},'bior2.2');
%figure(2);
%imshow(uint8(A4));

% the second layer
[row,cow] = size(A4);
[r,c] = size(CH{1,3});
if row > r
A4(row,:) = [];
end
if cow > c
A4(:,cow) = [];
end
A3 = idwt2(A4,CH{1,3},CV{1,3},CD{1,3},'bior2.2');
%figure(3);
%imshow(uint8(A4));

% the third layer
[row,cow] = size(A3);
[r,c] = size(CH{1,2});
if row > r
A3(row,:) = [];
end
if cow > c
A3(:,cow) = [];
end
A2 = idwt2(A3,CH{1,2},CV{1,2},CD{1,2},'bior2.2');


% the fourth layer
[row,cow] = size(A2);
[r,c] = size(CH{1,1});
if row > r
A2(row,:) = [];
end
if cow > c
A2(:,cow) = [];
end

A1 = idwt2(A2,CH{1,1},CV{1,1},CD{1,1},'bior2.2');
d_min = min(min(A1));
d_max = max(max(A1));
A1 = (A1 - d_min)/(d_max - d_min);
figure;
imshow(A1);
%imshow(uint8(A1));
%figure(2);
%imshow(I);


2006-05-12 21:27
xdj159
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2006-6-5
得分:0 

效果很差 哪个大侠给我看看
load woman
OrigImage=X;
NoiseLev=20;
%
subplot(221);
image(OrigImage);colormap(map);
title('original image');
axis square;

init=2055615866; randn('seed',init);
NoisedImage = OrigImage + NoiseLev*randn(size(OrigImage));
subplot(222);image(NoisedImage);colormap(map);
title('noised image');
axis square;

[C,S]=wavedec2(NoisedImage,5,'sym4');
A=appcoef2(C,S,'sym4',5);
%提取各个尺度上的各个方向的高频系数
for i=1:5
cdh{i}=detcoef2('h',C,S,i);
cdv{i}=detcoef2('v',C,S,i);
cdd{i}=detcoef2('d',C,S,i);
end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for i=1:5
thr = median(median(abs(cdh{i})))/0.6745;
T(1,i) = thselect(cdh{i},'sqtwolog')*thr;

thr = median(median(abs(cdv{i})))/0.6745;
T(2,i) = thselect(cdv{i},'sqtwolog')*thr;

thr = median(median(abs(cdd{i})))/0.6745;
T(3,i) = thselect(cdd{i},'sqtwolog')*thr;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Thh=T(1,:);
Thv=T(2,:);
Thd=T(3,:);

n=[1:5];
NC=wthcoef2('h',C,S,n,Thh,'s');
NC=wthcoef2('v',NC,S,n,Thv,'s');
NC=wthcoef2('d',NC,S,n,Thd,'s');
DenoisedImage=waverec2(NC,S,'sym4');

subplot(223);image(DenoisedImage);colormap(map);
title('denoised image');
axis square;

2006-06-05 16:48



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-61372-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.049603 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved