BivaShrink123.m
资源名称:小波去噪.rar [点击查看]
上传用户:sla11nk8
上传日期:2013-03-09
资源大小:21k
文件大小:2k
源码类别:
其他
开发平台:
Matlab
- function y = BivaShrink123(x)
- % Local Adaptive Image Denoising Algorithm
- %---同时用到父层系数和邻域系数信息,是一种三维的萎缩函数---
- % Usage :
- % y = BivaShrink123(x)
- % INPUT :
- % x - a noisy image
- % OUTPUT :
- % y - the corresponding denoised image
- % Adjust windowsize and the corresponding filter
- windowsize = 7;
- windowfilt = ones(1,windowsize)/windowsize;
- windowfilt2=[1 1 1;1 0 1;1 1 1]/8;
- % Number of Stages
- L = 6;
- % symmetric extension
- N = length(x);
- N = N+2^L;
- x = symextend(x,2^(L-1));
- % forward transform
- [af, sf] = farras;
- W = dwt2D(x,L,af);
- % Noise variance estimation using robust median estimator..
- tmp = W{1}{3};
- Nsig = median(abs(tmp(:)))/0.6745;
- for scale = 1:L-1
- for dir = 1:3
- % noisy coefficients
- Y_coefficient = W{scale}{dir};
- % noisy parent
- Y_parent = W{scale+1}{dir};
- % extent Y_parent to make the matrix size be equal to Y_coefficient
- Y_parent = expand(Y_parent);
- %----计算邻域系数值----
- Y_adjacent=conv2((Y_coefficient).^2,windowfilt2,'same');
- Y_adjacent=sqrt(Y_adjacent);
- % Signal variance estimation
- Wsig = conv2(windowfilt,windowfilt,(Y_coefficient).^2,'same');%---用Gauss分布的ML估计系数方差----
- %Wsig_ = conv2(windowfilt,windowfilt,abs(Y_coefficient),'same');%---用Laplace分布的ML估计系数方差----
- %Wsig=(Wsig_*sqrt(2)).^2;
- Ssig = sqrt(max(Wsig-Nsig.^2,eps));
- % Threshold value estimation
- T = sqrt(3)*Nsig^2./Ssig;
- % trivariate Shrinkage
- W{scale}{dir} = trishrink1(Y_coefficient,Y_adjacent,Y_parent,T);
- end
- end
- % Inverse Transform
- y = idwt2D(W,L,sf);
- % Extract the image
- y = y(2^(L-1)+1:2^(L-1)+512,2^(L-1)+1:2^(L-1)+512);