Code

Image denoising - Bishrink method

Senthilkumar July 30, 2011 Coded in Matlab

This function used to denoise a noisy image using bishrink method

% function [X1_denoise,DENOISE_PSNR] = Bivariate_soft(X1,Y)
clear all;
close all;
clc;
x = imread('lena.tif');
X =double(x);
[M,N] = size(X);
W =wgn(M,N,25);
Y = X+W;
    
[CA,CH,CV,CD] = dwt2(Y,'haar');
[CA1,CH1,CV1,CD1] = dwt2(CA,'haar');
[CA2,CH2,CV2,CD2] = dwt2(CA1,'haar');
[m,n] = size(CA);
[m2,n2] = size(CA1);
[m1,n1] = size(CA2);

%
k =1;
for i = 1:1:m2
    for j = 1:1:n2
        Y2_CH([2*i-1:2*i+k-1],[2*j-1:2*j+k-1])=CH1(i,j);
        Y2_CV([2*i-1:2*i+k-1],[2*j-1:2*j+k-1]) =CV1(i,j);
        Y2_CD([2*i-1:2*i+k-1],[2*j-1:2*j+k-1]) =CD1(i,j) ;
        
    end
end

for i = 1:1:m1
    for j = 1:1:n1
        Y1_CH([2*i-1:2*i+k-1],[2*j-1:2*j+k-1])=CH2(i,j);
        Y1_CV([2*i-1:2*i+k-1],[2*j-1:2*j+k-1]) =CV2(i,j);
        Y1_CD([2*i-1:2*i+k-1],[2*j-1:2*j+k-1]) =CD2(i,j) ;
        
    end
end
T1 = bishrink_threshold(CD,CH);
T2 = bishrink_threshold(CD,CV);
T3 = bishrink_threshold(CD,CD);
% 
w1_ch = bishrink(CH,Y2_CH,T1);
w1_cv = bishrink(CV,Y2_CV,T2);
w1_cd = bishrink(CD,Y2_CD,T3);

T4 = bishrink_threshold(CD,CH);
T5 = bishrink_threshold(CD,CV);
T6 = bishrink_threshold(CD,CD);
% 
w1_ch1 = bishrink(CH1,Y1_CH,T4);
w1_cv1 = bishrink(CV1,Y1_CV,T5);
w1_cd1 = bishrink(CD1,Y1_CD,T6);
% 
X2 = idwt2(CA1,w1_ch1,w1_cv1,w1_cd1,'haar');
X1_denoise = idwt2(X2,w1_ch,w1_cv,w1_cd,'haar');

%modified estimate is used

T1 = bishrink_threshold1(CD,CH);
T2 = bishrink_threshold1(CD,CV);
T3 = bishrink_threshold1(CD,CD);
% 
w1_ch = bishrink(CH,Y2_CH,T1);
w1_cv = bishrink(CV,Y2_CV,T2);
w1_cd = bishrink(CD,Y2_CD,T3);

T4 = bishrink_threshold1(CD,CH);
T5 = bishrink_threshold1(CD,CV);
T6 = bishrink_threshold1(CD,CD);
% 
w1_ch1 = bishrink(CH1,Y1_CH,T4);
w1_cv1 = bishrink(CV1,Y1_CV,T5);
w1_cd1 = bishrink(CD1,Y1_CD,T6);
% 
X4 = idwt2(CA1,w1_ch1,w1_cv1,w1_cd1,'haar');
X3_denoise = idwt2(X4,w1_ch,w1_cv,w1_cd,'haar');

noisy_PSNR = PSNR(X,Y)
% DENOISE_PSNR = PSNR(X,X1_denoise)
X1_PSNR = PSNR(X,X1_denoise)
X3_PSNR = PSNR(X,X3_denoise)
X1_denoise = uint8(X1_denoise);
X3_denoise = uint8(X3_denoise);
imshow(x)
figure;
imshow(uint8(Y))
figure;
imshow(X1_denoise)
figure;
imshow(X3_denoise)