⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bivashrink23.m

📁 基于小波的去噪算法,实验高斯加性白噪声的去噪
💻 M
字号:
function y = BivaShrink23(x)
% Local Adaptive Image Denoising Algorithm
%---这里用父层系数y2和邻域系数y3---
% Usage :
%        y = BivaShrink23(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');
        Ssig = sqrt(max(Wsig-Nsig.^2,eps));
        
        % Threshold value estimation 
        T = sqrt(3)*Nsig^2./Ssig;
        
        % Bivariate Shrinkage---邻域系数,父层系数---
        R  = sqrt(abs(Y_parent).^2 + abs(Y_adjacent).^2);
        R = R - T;
        R  = R .* (R > 0);
        W{scale}{dir} = Y_coefficient .* R./(R+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); 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -