Impact-Site-Verification: dbe48ff9-4514-40fe-8cc0-70131430799e

Search This Blog

Signal Denoising using MATLAB

Thresholding is a technique used for signal and image denoising. The discrete wavelet transform uses two types of filters: (1) averaging filters, and (2) detail filters. When we decompose a signal using the wavelet transform, we are left with a set of wavelet coefficients that correlates to the high frequency sub bands. These high frequency sub bands consist of the details in the data set. If these details are small enough, they might be omitted without substantially affecting the main features of the data set. Additionally, these small details are often those associated with noise; therefore, by setting these coefficients to zero, we are essentially killing the noise. This becomes the basic concept behind thresholding-set all frequency sub band coefficients that are less than a particular threshold to zero and use these coefficients in an inverse wavelet transformation to reconstruct the data set.

After implementing the double-density DWT, and double-density complex DWT for 1-D signals, we can develop two different methods using these DWTs to remove noise from an image. The double-density DWT method will be discussed first.

MATLAB Program for 1-D double-density DWT denoising method

function y = double_S1D(x,T)

% x: noise signal
% T: threshold


[af, sf] = filters1;
J = 4;
w = double_f1D(x,J,af);
% loop through scales
for j = 1:J
    % loop through subbands
    for s = 1:2
       w{j}{s} = soft(w{j}{s},T);
    end
end
y = double_i1D(w,J,sf);

MATLAB Program for 1-D double-density complex DWT denoising method

function y = doubledual_S1D(x,T)

% x - noise signal
% T - threshold


[Faf, Fsf] = FSdoubledualfilt;
[af, sf] = doubledualfilt;
J = 4;
w = doubledualtree_f1D(x,J,Faf,af);
% loop thru scales:
for j = 1:J
    % loop thru subbands
    for s1 = 1:2
        for s2 = 1:2
            w{j}{s1}{s2} = soft(w{j}{s1}{s2},T);
        end
    end
end
y = doubledualtree_i1D(w,J,Fsf,sf);


MATLAB Program for Signal denoising example using double-density DWT method

s1 = double(imread('peppers.jpg')); % load image as a double
s = s1(:,4,3);                      % convert 3-D image to a 1-D signal
subplot (3,1,1), plot(s)            % plot the original signal
title('Original Signal')
axis([0 512 -100 300])
x = s + 20*randn(size(s));          % add Gaussian noise to the original signal
subplot (3,1,2), plot(x)            % plot the noisy signal
title('Noisy Signal')
axis([0 512 -100 300])
T = 20;                             % choose a threshold of 20
y = double_S1D(x,T);            % denoise the noisy image using Double-Density Dual-Tree DWT
subplot (3,1,3), plot(y)            % plot the denoised signal
title('Denoised Signal')
axis([0 512 -100 300])



MATLAB Program for Signal denoising example using double-density complex DWT method

s1 = double(imread('peppers.jpg')); % load image as a double
s = s1(:,4,3);                      % convert 3-D image to a 1-D signal
subplot (3,1,1), plot(s)            % plot the original signal
title('Original Signal')
axis([0 512 -100 300])
x = s + 20*randn(size(s));          % add Gaussian noise to the original signal
subplot (3,1,2), plot(x)            % plot the noisy signal
title('Noisy Signal')
axis([0 512 -100 300])
T = 20;                             % choose a threshold of 20
y = doubledual_S1D(x,T);            % denoise the noisy image using Double-Density Dual-Tree DWT
subplot (3,1,3), plot(y)            % plot the denoised signal
title('Denoised Signal')
axis([0 512 -100 300])

MATLAB Program to Compute RMS error vs. threshold point for double-density DWT method


function e = double_den1(s,x,t)

% EXAMPLE:
% s1 = double(imread('peppers.jpg'));
% s = s1(:,:,3);
% x = s + 20*randn(size(s));
% t = 0:5:45;
% e = double_den1(s,x,t);
% plot(t,e);

N = length(t);
for k = 1:N
    y = double_S1D(x,t(k));
    e(k) = sqrt(mean(mean((y-s).^2)));
end



MATLAB Program to Compute RMS error vs. threshold point for double-density complex DWT method

function e = double_dual1(s,x,t)

% EXAMPLE:
% s1 = double(imread('peppers.jpg'));
% s = s1(:,:,3);
% x = s + 20*randn(size(s));
% t = 0:5:45;
% e = double_dual1(s,x,t);
% plot(t,e);


N = length(t);
for k = 1:N
    y = doubledual_S1D(x,t(k));
    e(k) = sqrt(mean(mean((y-s).^2)));
end

MATLAB Program for Plot RMS error vs. threshold point

s1 = double(imread('peppers.jpg')); % load image as a double
s = s1(:,2,3);          % convert to a 2-D image
x = s + 20*randn(size(s));      % add Gaussian noise to the original image
t = 0:5:45;                     % threshold range (0-45), increment by 5
e = double_den1(s,x,t);         % using double-density method
de = double_dual1(s,x,t);       % using double-density dual-tree method
figure(1)
plot(t,e,'blue')            % plot double-density (in blue)
hold on
plot(t,de,'red')            % plot double-density dual-tree (in red)
title('RMS Error vs. Threshold Point')
xlabel('Threshold Point');
ylabel('RMS Error');
legend('Double-Density 1-D','Double-Density Dual-Tree 1-D',0);

MATLAB Program for Soft thresholding

function y = soft(x, T)

y = max(0, x - T) - max(0, - x - T);



1 comment:

  1. How to denoise image using dwt(such db1..N, haar etc). this code which is provided by you is not executed in my pc

    ReplyDelete

Popular Posts