1 function y = denoising_dtdwt(x)
2 % Local Adaptive Image Denoising Algorithm
4 % y = denoising_dtdwt(x)
8 % y - the corresponding denoised image
10 % Set the windowsize and the corresponding filter
12 windowfilt = ones(1,windowsize)/windowsize;
19 L = length(x); % length of the original image.
20 N = L+2^J; % length after extension.
21 x = symextend(x,2^(J-1));
23 load nor_dualtree % run normaliz_coefcalc_dual_tree to generate this mat file.
25 % Forward dual-tree DWT
26 % Either FSfarras or AntonB function can be used to compute the stage 1 filters
27 [Faf, Fsf] = FSfarras;
30 W = cplxdual2D(x, J, Faf, af);
31 W = normcoef(W,J,nor);
34 % Noise variance estimation using robust median estimator..
36 Nsig = median(abs(tmp(:)))/0.6745;
42 % Noisy complex coefficients
44 Y_coef_real = W{scale}{1}{dir}{dir1};
46 Y_coef_imag = W{scale}{2}{dir}{dir1};
47 % The corresponding noisy parent coefficients
49 Y_parent_real = W{scale+1}{1}{dir}{dir1};
51 Y_parent_imag = W{scale+1}{2}{dir}{dir1};
52 % Extend noisy parent matrix to make the matrix size the same as the coefficient matrix.
53 Y_parent_real = expand(Y_parent_real);
54 Y_parent_imag = expand(Y_parent_imag);
56 % Signal variance estimation
57 Wsig = conv2(windowfilt,windowfilt,(Y_coef_real).^2,'same');
58 Ssig = sqrt(max(Wsig-Nsig.^2,eps));
60 % Threshold value estimation
61 T = sqrt(3)*Nsig^2./Ssig;
64 Y_coef = Y_coef_real+I*Y_coef_imag;
65 Y_parent = Y_parent_real + I*Y_parent_imag;
66 Y_coef = bishrink(Y_coef,Y_parent,T);
67 W{scale}{1}{dir}{dir1} = real(Y_coef);
68 W{scale}{2}{dir}{dir1} = imag(Y_coef);
75 W = unnormcoef(W,J,nor);
76 y = icplxdual2D(W, J, Fsf, sf);
79 ind = 2^(J-1)+1:2^(J-1)+L;