A list,

Wavelet image denoising based on MATLAB neighborhood

Ii. Source code

% based on neighborhood wavelet denoising, the window selection is respectively3*3and5*5% -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- % (1) based on neighborhood wavelet denoising, the window is selected as3*3When % -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- the clear; f=imread('graylena.bmp');
%f=imread('cameraman.tif');
%f=imread('liftingbody.png');
%f=imread('rice.png');
fnoisy=imnoise(f,'gaussian'.0.0.01); Add white Gaussian noise figure,subplot(121),imshow(f,[]),title('Original image')
subplot(122),imshow(fnoisy,[]),title('Noisy image'[c,s]=wavedec2(fnoisy,3.'db8');

[cH2,cV2,cD2]=detcoef2('all',c,s,2);
[cH1,cV1,cD1]=detcoef2('all',c,s,1);
delta=median(abs(cD1(:)))/0.6745;
n=size(f,1);
thr=delta*sqrt(2*log(n^2)); % threshold % Processes H, V and D components at all levels. % MOV_win is a sliding window function, which determines whether the coefficient in the center of the window is shrinking or zeroed according to the sum of squares of the wavelet coefficients in the neighborhood window.3,thr);
cH2=mov_win(cH2,3,thr);
cH1=mov_win(cH1,3,thr);
cV3=mov_win(cV3,3,thr);
cV2=mov_win(cV2,3,thr);
cV1=mov_win(cV1,3,thr);
cD3=mov_win(cD3,3,thr);
cD2=mov_win(cD2,3,thr);
cD1=mov_win(cD1,3,thr);

m1=size(cA3,1); m2=size(cA3,2);
m=m1*m2;
dnc0(1:m)=cA3(:);

m1=size(cH3,1); m2=size(cH3,2);
m=m1*m2;
dnc1(1:m)=cH3(:);

m1=size(cH2,1); m2=size(cH2,2);
m=m1*m2;
dnc2(1:m)=cH2(:);

m1=size(cH1,1); m2=size(cH1,2);
m=m1*m2;
dnc3(1:m)=cH1(:);

m1=size(cV3,1); m2=size(cV3,2);
m=m1*m2;
dnc4(1:m)=cV3(:);

m1=size(cV2,1); m2=size(cV2,2);
m=m1*m2;
dnc5(1:m)=cV2(:);

m1=size(cV1,1); m2=size(cV1,2);
m=m1*m2;
dnc6(1:m)=cV1(:);

m1=size(cD3,1); m2=size(cD3,2);
m=m1*m2;
dnc7(1:m)=cD3(:);

m1=size(cD2,1); m2=size(cD2,2);
m=m1*m2;
dnc8(1:m)=cD2(:);

m1=size(cD1,1); m2=size(cD1,2);
m=m1*m2;
dnc9(1:m)=cD1(:);

dnc10=[dnc0 dnc1 dnc4 dnc7 dnc2 dnc5 dnc8 dnc3 dnc6 dnc9];
dnc=waverec2(dnc10,s,'db8'); DNC = % reconstruction uint8 (DNC); figure,subplot(121),imshow(dnc,[]),title('3*3 Neighborhood denoised image ')

f=imread('graylena.bmp');
%f=imread('cameraman.tif');
%f=imread('liftingbody.png');
%f=imread('rice.png');
f=double(f);
dnc=double(dnc); Psnr3 = cacupsnr (f, DNC) % -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- % (2) based on neighborhood wavelet denoising, the window is selected as5*5
%----------------------------------------------------------
f=imread('graylena.bmp');
%f=imread('cameraman.tif');
%f=imread('liftingbody.png');
%f=imread('rice.png');
fnoisy=imnoise(f,'gaussian'.0.0.01); [c,s]=wavedec2(fnoisy,3.'db8');
cA3=appcoef2(c,s,'db8'.3); % Low frequency component THR =delta*sqrt(2*log(n^2)); % threshold % Processes H, V and D components at all levels. % MOV_win is a sliding window function, which determines whether the coefficient in the center of the window is shrinking or zeroed according to the sum of squares of the wavelet coefficients in the neighborhood window.5,thr);
cH2=mov_win(cH2,5,thr);
cH1=mov_win(cH1,5,thr);
cV3=mov_win(cV3,5,thr);
cV2=mov_win(cV2,5,thr);
cV1=mov_win(cV1,5,thr);
cD3=mov_win(cD3,5,thr);
cD2=mov_win(cD2,5,thr);
cD1=mov_win(cD1,5,thr);

m1=size(cA3,1); m2=size(cA3,2);
m=m1*m2;
dnc0(1:m)=cA3(:);

m1=size(cH3,1); m2=size(cH3,2);
m=m1*m2;
dnc1(1:m)=cH3(:);

m1=size(cH2,1); m2=size(cH2,2);
m=m1*m2;
dnc2(1:m)=cH2(:);

m1=size(cH1,1); m2=size(cH1,2);
m=m1*m2;
dnc3(1:m)=cH1(:);

m1=size(cV3,1); m2=size(cV3,2);
m=m1*m2;
dnc4(1:m)=cV3(:);

m1=size(cV2,1); m2=size(cV2,2);
m=m1*m2;
dnc5(1:m)=cV2(:);

m1=size(cV1,1); m2=size(cV1,2);
m=m1*m2;
dnc6(1:m)=cV1(:);

m1=size(cD3,1); m2=size(cD3,2);
m=m1*m2;
dnc7(1:m)=cD3(:);

m1=size(cD2,1); m2=size(cD2,2);
m=m1*m2;
dnc8(1:m)=cD2(:);


dnc10=[dnc0 dnc1 dnc4 dnc7 dnc2 dnc5 dnc8 dnc3 dnc6 dnc9];
dnc=waverec2(dnc10,s,'db8'); DNC = % reconstruction uint8 (DNC); subplot(122),imshow(dnc,[]),title('5*5 Neighborhood denoised image 'Function y=cacupsnr(f,g) %1); n=size(f,2);
d=f-g;
d=d.^2; r=g.^2;
mse=sum(d(:))/m/n;

psnr=10*log10(255^2/mse);
snr=10*log10(sum(r(:))/m/n/mse); y.MSE=mse; y.RMSE=rmse; y.PSNR=psnr; y.SNR=snr;Copy the code

Third, the operation result

Fourth, note

Version: 2014 a