7
WAVELET SIGNAL AND IMAGE DENOISING E. Hoˇ s ˇ alkov´ a, A.Proch´ azka Institute of Chemical Technology Department of Computing and Control Engineering Abstract The paper deals with the use of wavelet transform for signal and image de-noising employing a selected method of thresholding of appropriate decomposition coef- ficients. The proposed technique is based upon the analysis of wavelet transform and it includes description of global modification of its values. The whole method is verified for simulated signals and applied for processing of biomedical signals representing EEG signals and MR images corrupted by additional random noise. 1 Introduction The wavelet transform (WT) is a powerful tool of signal processing for its multiresolutional possibilities. Unlike the Fourier transform, the WT is suitable for application to non-stationary signals with transitory phenomena, whose frequency response varies in time [2]. The wavelet coefficients represent a measure of similarity in the frequency content between a signal and a chosen wavelet function [2]. These coefficients are computed as a convolution of the signal and the scaled wavelet function, which can be interpreted as a dilated band-pass filter because of its band-pass like spectrum [5]. The scale is inversely proportional to radian frequency. Consequently, low frequencies correspond to high scales and a dilated wavelet function. By wavelet analysis at high scales, we extract global information from a signal called approximations. Whereas at low scales, we extract fine information from a signal called details. Signals are usually band-limited, which is equivalent to having finite energy, and therefore we need to use just a constrained interval of scales. However, the continuous wavelet transform provides us with lots of redundant information. The discrete wavelet transform (DWT) requires less space utilising the space-saving coding based on the fact that wavelet families are orthogonal or biorthogonal bases, and thus do not produce redundant analysis. The DWT corresponds to its continuous version sampled usually on a dyadic grid, which means that the scales and translations are powers of two [5]. In practise, the DWT is computed by passing a signal successively through a high-pass and a low- pass filter. For each decomposition level, the high-pass filter h d forming the wavelet function produces the approximations A. The complementary low-pass filter l d representing the scaling function produces the details D [3]. This computational algorithm shown in Fig. 1a is called the subband coding. The resolution is altered by the filtering process, and the scale is changed by either upsampling or downsampling by 2. This is described [4] by relations D 1 [n] = k=−∞ h d [k] x[2n - k] (1) A 1 [n] = k=−∞ l d [k] x[2n - k] (2) where n and k denote discrete time coefficients and x stands for the given signal.

WAVELET SIGNAL AND IMAGE DENOISING - vscht.czdsp.vscht.cz/konference_matlab/MATLAB06/prispevky/hostalkova_p... · WAVELET SIGNAL AND IMAGE DENOISING ... The paper deals with the use

Embed Size (px)

Citation preview

Page 1: WAVELET SIGNAL AND IMAGE DENOISING - vscht.czdsp.vscht.cz/konference_matlab/MATLAB06/prispevky/hostalkova_p... · WAVELET SIGNAL AND IMAGE DENOISING ... The paper deals with the use

WAVELET SIGNAL AND IMAGE DENOISING

E. Hostalkova, A.Prochazka

Institute of Chemical TechnologyDepartment of Computing and Control Engineering

Abstract

The paper deals with the use of wavelet transform for signal and image de-noisingemploying a selected method of thresholding of appropriate decomposition coef-ficients. The proposed technique is based upon the analysis of wavelet transformand it includes description of global modification of its values. The whole methodis verified for simulated signals and applied for processing of biomedical signalsrepresenting EEG signals and MR images corrupted by additional random noise.

1 Introduction

The wavelet transform (WT) is a powerful tool of signal processing for its multiresolutionalpossibilities. Unlike the Fourier transform, the WT is suitable for application to non-stationarysignals with transitory phenomena, whose frequency response varies in time [2].

The wavelet coefficients represent a measure of similarity in the frequency content betweena signal and a chosen wavelet function [2]. These coefficients are computed as a convolutionof the signal and the scaled wavelet function, which can be interpreted as a dilated band-passfilter because of its band-pass like spectrum [5].

The scale is inversely proportional to radian frequency. Consequently, low frequencies correspondto high scales and a dilated wavelet function. By wavelet analysis at high scales, we extractglobal information from a signal called approximations. Whereas at low scales, we extract fineinformation from a signal called details.

Signals are usually band-limited, which is equivalent to having finite energy, and therefore weneed to use just a constrained interval of scales. However, the continuous wavelet transformprovides us with lots of redundant information.

The discrete wavelet transform (DWT) requires less space utilising the space-saving coding basedon the fact that wavelet families are orthogonal or biorthogonal bases, and thus do not produceredundant analysis. The DWT corresponds to its continuous version sampled usually on a dyadicgrid, which means that the scales and translations are powers of two [5].

In practise, the DWT is computed by passing a signal successively through a high-pass and a low-pass filter. For each decomposition level, the high-pass filter hd forming the wavelet functionproduces the approximations A. The complementary low-pass filter ld representing the scalingfunction produces the details D [3]. This computational algorithm shown in Fig. 1a is calledthe subband coding.

The resolution is altered by the filtering process, and the scale is changed by either upsamplingor downsampling by 2. This is described [4] by relations

D1[n] =∞∑

k=−∞hd[k] x[2n − k] (1)

A1[n] =∞∑

k=−∞ld[k] x[2n − k] (2)

where n and k denote discrete time coefficients and x stands for the given signal.

Page 2: WAVELET SIGNAL AND IMAGE DENOISING - vscht.czdsp.vscht.cz/konference_matlab/MATLAB06/prispevky/hostalkova_p... · WAVELET SIGNAL AND IMAGE DENOISING ... The paper deals with the use

ld[n]

hd[n]

2

2

ld[n]

hd[n]

2

2

ld[n]

hd[n]

2

2

(a) 1D DWT

signal x[n]

details D

1

details D

2

details D

3

approx−imations

A3

low−passfilter

high−passfilter

0 200 400

(b) ECG SIGNAL

time

(c) ABS. DB4 DETAIL COEF.

time100 200 300 400 500

discontinuity

discontinuity

Figure 1: Discontinuity detection in the ECG signal applying wavelet analysis and presenting(a) one-dimensional wavelet subband coding scheme, (b) ECG signal with a discontinuity, and(c) absolute detail decomposition coefficients using the db4 wavelet function

Half-band filters form orthonormal bases, and therefore make the reconstruction easy. The syn-thesis consists of upsampling by 2 and filtering [4]:

x[n] =∞∑

k=−∞(D1[k] hr[2k − n] + A1[k] lr[2k − n]) (3)

The reconstruction filters lr and hr and identical with the decomposition filters ld and hd,respectively, except the reverse time course. These filters attain to produce perfect signal re-construction from the DWT coefficients provided that the signal is of finite energy, and thatthe wavelet satisfies the admissibility condition [1]. Both these conditions are satisfied withnatural signals and usual wavelets [2, 5].

The practical use of the DWT is to be discussed in later sections. We employ here two types ofwavelet functions, which are the Daubeschies wavelet db4 and the symlet wavelet (sym4). Bothfunctions are given by 8 coefficients and have similar properties [2].

2 Signal Analysis

In signal processing, wavelets are used for many purposes [2]. Such as denoising, detectingtrends, breakdown points, discontinuities in higher derivatives and self-similarity in signals. Atfirst, we focus on discontinuity detection.

For the Electrocardiogram (ECG) signal, Fig. 1 demonstrates the use of the db4 wavelet for im-pulse detection, i.e. detection of a discontinuity in frequency.

The impulse is generated artificially for our purposes. The db4 wavelet is chosen because of itsgood performance in this case. The decomposition runs up to level 3, which is enough to makethe discontinuity apparent.

Page 3: WAVELET SIGNAL AND IMAGE DENOISING - vscht.czdsp.vscht.cz/konference_matlab/MATLAB06/prispevky/hostalkova_p... · WAVELET SIGNAL AND IMAGE DENOISING ... The paper deals with the use

3 Signal Denoising

This section describes signal denoising with the application on the ECG signal.

3.1 Soft and Hard Thresholding

Signal denoising using the DWT consists of the three successive procedures, namely, signaldecomposition, thresholding of the DWT coefficients, and signal reconstruction. Firstly, wecarry out the wavelet analysis of a noisy signal up to a chosen level N . Secondly, we performthresholding of the detail coefficients from level 1 to N . Lastly, we synthesize the signal usingthe altered detail coefficients from level 1 to N and approximation coefficients of level N [2].However, it is generally impossible to remove all the noise without corrupting the signal.

As for thresholding, we can settle either a level-dependent threshold vector of length N or a globalthreshold of a constant value for all levels. According to D. Donoho’s method, the thresholdestimate δ for denoising with an orthonormal basis is given by [1]

δ = σ√

2 log L (4)

where the noise is Gaussian with standard deviation σ of the DWT coefficients and L is the num-ber of samples or pixels of the processed signal or image. This estimation concept is used byMatlab.

From another point of view, thresholding can be either soft or hard [1]. Hard thresholdingzeroes out all the signal values smaller than δ. Soft thresholding does the same thing, andapart form that, subtracts δ from the values larger than δ. In contrast to hard thresholding,soft thresholding causes no discontinuities in the resulting signal. In Matlab, by default, softthresholding is used for denoising and hard thresholding for compression [2].

3.2 Applications to ECG Signals

Denoising of the (ECG) signal is displayed in Fig. 2. The removing of artificially added randomnoise is carried out by thresholding of the DWT coefficients up to level 3. As a wavelet function,we choose the sym4, since in this application it performs better than the db4. As a thresholdingmethod, we use a soft global threshold δ of an estimated value given by Eq. (4). The results areleft to visual examination. The Matlab code is also enclosed.

%% ECG SIGNAL DENOISING BY THRESHOLDING ITS DWT COEFFICIENTS% ORIGINAL ECG SIGNAL

ecg=load(’ECG01.TXT’);ecg=detrend(ecg); % Remove a linear trendecg=ecg(100:611); L=length(ecg)

% NOISY ECG SIGNALecgN=ecg+160*randn(L,1);

%% WAVELET DECOMPOSITION% Default values for denoising using a wavelet

[THR,SORH,KEEPAPP]=ddencmp(’den’,’wv’,ecgN)level=3 % decomposition up to level 3

% De-noising by thresholding SYM4 detail coefficients[ecgC,CecgC,LecgC,PERF0,PERFL2]=wdencmp(’gbl’,ecgN,...

’sym4’,level,THR,SORH,KEEPAPP); % obtaining clean ECG signal ecgN

Page 4: WAVELET SIGNAL AND IMAGE DENOISING - vscht.czdsp.vscht.cz/konference_matlab/MATLAB06/prispevky/hostalkova_p... · WAVELET SIGNAL AND IMAGE DENOISING ... The paper deals with the use

DECOMPOSITION RECONSTRUCTION

(c) 1D DWT (SYM4)

LEVEL 1 LEVEL 2 LEVEL 3 LEVEL 1LEVEL 2LEVEL 3

D1

A1

D2

A2

D3

A3

D1

A1

D2

A2

D3

A3

0 200 400−500

0

500

1000

1500

(a) ORIGINAL AND NOISY ECG

0 200 400

0

500

1000

1500 (b) ORIGINAL AND ENHANCED ECG

time

original ECGnoisy ECGenhanced ECG

−2000

−1000

0

1000

2000

(d) DWT COEFFICIENTS

A3

D3

D2

D1

δ

−δ−1000

0

1000

2000

(f) ALTERED DWT COEFFICIENTS

A3

D3

D2

D1

(e) SOFT THRESHOLDING

δ

−δ

Figure 2: ECG signal de-noising by thresholding of wavelet detail coefficients up to the third levelpresenting (a) original and noisy ECG signal, (b) original and enhanced ECG signal, (c) decom-position and reconstruction up to the third level using the sym4 wavelet function, (d) waveletcoefficients of the noisy signal and the estimated threshold level δ, (e) principles of soft thresh-olding, and (f) altered wavelet coefficients for signal reconstruction

4 Image Denoising

In image processing, wavelets are used for instance for edges detection, watermarking, texturedetection, compression, denoising, and coding of interesting features for subsequent classifica-tion [2]. Image denoising by thresholding of the DWT coefficients is discussed in the followingsubsections.

4.1 Principles

The principles of image denoising using the DWT are analogous to that for signals describedabove. For images, we need to extend our work to two dimensions.

To compute the two-dimensional DWT of an image, we decompose the approximations at level jto obtain four matrixes of coefficients at level j + 1. These four matrixes for single level decom-position using db4 displayed in Fig. 3c are, clockwise, the approximations and the horizontal ,vertical and diagonal details of level 1.

Page 5: WAVELET SIGNAL AND IMAGE DENOISING - vscht.czdsp.vscht.cz/konference_matlab/MATLAB06/prispevky/hostalkova_p... · WAVELET SIGNAL AND IMAGE DENOISING ... The paper deals with the use

originalimage

Im(i,j)

ld[n]

hd[n]

2

2

ld[n]

hd[n]

ld[n]

hd[n]

2

2

2

2

(a) 2D DWTDECOMPOSITION RECONSTRUCTION

2

2

2

2

lr[n]

hr[n]

lr[n]

hr[n]

2

2

lr[n]

hr[n]

reconstr.image

Im(i,j)

ROWS COLUMNS COLUMNS ROWS (b) NOISY IMAGE

(c) DECOMPOSITION

−1

0

1

2

(e) DB4 COEFFICIENTS

A1

H1

V1

D1

δ

−δ −1

0

1

2

(f) ALTERED DB4 COEFFICIENTS

A1

H1

V1

D1

(d) RECONSTRUCTION

soft globalthresholding

Figure 3: MR image enhancement by thresholding of the wavelet decomposition coefficientspresenting (a) one-dimensional wavelet subband coding scheme, (b) noisy MR image, (c) firstlevel decomposition using the db4 wavelet function, (d) reconstructed and interpolated image,(e) absolute db4 decomposition coefficients, and (f) thresholded decomposition coefficients usedfor image reconstruction

As shown in the scheme in Fig. 3a, first, we convolve the rows of the image, or generallythe matrix of the approximations at level j, with a low-pass and a high-pass decompositionfilter ld[n] and hd[n], respectively. Then we downsample both resulting matrixes by 2 keepingevery even column. Second, we filter each of the matrixes by their columns using the previouslymentioned filters. Then we downsample all four resulting matrixes by 2 keeping every evenrow to obtain four matrixes of one-level decomposition coefficients, or generally four matrixesof (j+1)-level coefficients [2]. We can also reconstruct the image by using these coefficientsmatrixes, upsampling by 2 and the reconstruction filters lr[n] and hr[n].

4.2 Applications to MR Images

Magnetic Resonance (MR) image denoising by thresholding of the wavelet detail coefficientsis illustrated in Fig. 4. The programme code is also enclosed. The decomposition runs upto level 2 using the db4 wavelet function. The wavelet coefficient are altered with a soft globalthreshold δ estimated from Eq. (4). The reconstructed image is smoothed by cubic interpolation.The areas along the image boundaries are coloured with grey, hence these pixels would requiredifferent handling.

Page 6: WAVELET SIGNAL AND IMAGE DENOISING - vscht.czdsp.vscht.cz/konference_matlab/MATLAB06/prispevky/hostalkova_p... · WAVELET SIGNAL AND IMAGE DENOISING ... The paper deals with the use

%% MR IMAGE DENOISING BY THRESHOLDING ITS DWT COEFFICIENTS% GIVEN IMAGE DEFINITION

load(’MRpater004.mat’), A=im2double(A);A=A(64:191,64:191); % Image cut

% RANDOM NOISE ADDITIONAn=A+0.2*randn(size(A)); % Noisy image cut

% DB4 DECOMPOSITION TO LEVEL 2level=2;[c,s]=wavedec2(An,level,’db4’); % Decomposition vector c and the

% corresponding bookkeeping matrix s% Modify matriw s for generating indexes ind (below)

s2=s(2:level+1,1)’; s2=[s2; s2; s2]; s2=[s(1);s2(:)]; ss=s2.^2;% THRESHOLDING OF DWT DETAIL COEFFICIENTS

THR = ddencmp(’den’,’wv’,An) % Global threshold estimate% Leave out approximations from thresholding

for i=1:7, if i==1 thr(i)=0; else thr(i)=THR; end, end% Indexes dividing individual coefficients sets in vector c

ind(1)=0;for i=1:7, ind(i+1)=sum(ss(1:i)); end

% Soft thresholding of dwt coefficientsfor i=1:7k=find(abs(c(ind(i)+1:ind(i+1)))<=thr(i));k=k+ind(i); cd(k)=0;k=find(abs(c(ind(i)+1:ind(i+1)))>thr(i));k=k+ind(i); cd(k)=sign(c(k)).*(abs(c(k))-thr(i));

end;% IMAGE RECONSTRUCTION

Z=waverec2(cd,s,’db4’);% Cubic interpolation

Zinterp=interp2(Z,’*cubic’);% Display grey image boundaries

[m,n]=size(Z); Zmean=mean2(Z); Z([1:4,m-3:m],:)=Zmean;Z(:,[1:4,n-3:n])=Zmean; [m,n]=size(Zinterp);Zinterp([1:8,m-7:m],:)=Zmean; Zinterp(:,[1:8,n-7:n])=Zmean;

5 Conclusions

This work provides practical examples of signal and image enhancement and components detec-tion using the wavelet transform along with the enclosed Matlab code. The data we process area real biomedical ECG signal and a spinal MR image. Detection of signal and image componentscan be utilised for their classification.

6 Acknowledgments

The work has been supported by the research grant of the Faculty of Chemical Engineeringof the Institute of Chemical Technology, Prague No. MSM 6046137306.

Page 7: WAVELET SIGNAL AND IMAGE DENOISING - vscht.czdsp.vscht.cz/konference_matlab/MATLAB06/prispevky/hostalkova_p... · WAVELET SIGNAL AND IMAGE DENOISING ... The paper deals with the use

(a) NOISY IMAGE

0

2

4 (d) WAVELET COEFFICIENTS: 2 LEVELS, DB4

A2

H2

V2

D2

H1

V1

D1

δ

−δ

(b) DECOMPOSITION (c) RECONSTRUCTION

Figure 4: MR image de-noising by thresholding of the wavelet detail coefficients up to thesecond level presenting (a) MR image with the additional random noise, (b) decompositionup to the second level using the db4 wavelet function, (c) image reconstruction after the thresh-olding of wavelet coefficients, and (d) wavelet coefficients of the noisy image and the estimatedthreshold level δ

References

[1] T. Nguyen G. Strang. Wavelets and Filter Banks. Wellesley-Cambridge Press, 1996.

[2] G. Oppenheim J. M. Poggi M. Misiti, Y. Misiti. Wavelet Toolbox. The MathWorks, Inc.,Natick, Massachusetts 01760, April 2001.

[3] S. Mallat. A Wavelet Tour of Signal Processing. Academic Press, San Diego, USA, 1998.

[4] R. Polikar. Wavelet tutorial. eBook, March 1999. http://users.rowan.edu.

[5] C. Valens. A really friendly guide to wavelets. eBook, 2004. http://perso.wanadoo.fr.

[6] E. W. Weisstein. Mathworld. eBook, 2003. http://mathworld.wolfram.com.

Prof. Ales Prochazka, Ing. Eva HostalkovaInstitute of Chemical Technology, PragueDepartment of Computing and Control EngineeringTechnicka 1905, 166 28 Prague 6Phone: 00420-220 444 198, Fax: 00420-220 445 053E-mail: [email protected], [email protected]