Download as pdf or txt
Download as pdf or txt
You are on page 1of 41

OpenStax-CNX module: m23011 1

Wavelet Denoising *

Jacob Fainguelernt
This work is produced by OpenStax-CNX and licensed under the
„
Creative Commons Attribution License 2.0

Abstract
Wavelets can be used in a wide range of applications, one of which is noise reduction. This module
shows a real-time implementation of a wavelet-based noise reduction in the DSK6713. A Simulink model
is created for simulation, and afterwards used for DSP code generation.

1 Introduction

Wavelets can be used in a range of applications, one of which is noise reduction.


This laboratory shows how to design a model of Wavelet Noise Reduction using Simulink and run it on
a Texas Instruments C6000 DSP.

1.1 Objectives
• Design a model of Wavelet Noise Reduction for the Texas Instruments C6000 family of DSP devices
using MATLAB® and Simulink®.
• Modify an existing Simulink demonstration model.
• Run the project on the Texas Instruments C6713 DSK with a microphone and computer loudspeakers
/ headphones.

1.2 Level
Intermediate. Assumes prior knowledge of MATLAB and Simulink. It also requires a theoretical under-
standing of wavelets and some knowledge of Texas Instruments DSPs.

1.3 Hardware and Software Requirements


This laboratory was originally developed using the following hardware and software:

• MATLAB R2006b with Embedded Target for TI C6000.


• Code Composer Studio (CCS) v3.1
• Texas Instruments C6713 DSK hardware.
• Microphone and computer loudspeakers / headphones.

* Version 1.1: May 6, 2009 8:50 am -0500


„ http://creativecommons.org/licenses/by/2.0/

http://cnx.org/content/m23011/1.1/
OpenStax-CNX module: m23011 2

1.4 Related Files


1
• Powerpoint Presentation WaveletDenoising.ppt
2
• Simulink Model for Simulation- WaveletDenoising.mdl
3
• Simulink Model for Real-Time WaveletDenoisingDSKC6713.mdl

2 Simulation

2.1 Simulink Model


The Simulink model described here is based on a MATLAB Demo.

2.1.1 Opening the Model


Open WaveletDenoising.mdl

Figure 1: Opening WaveletDenoising.mdl

2.1.2 Running the Model


Run the model. The colors change to show the dierent lter channels. Green = high frequency.

1 See the le at <http://cnx.org/content/m23011/latest/WaveletDenoising.ppt>


2 See the le at <http://cnx.org/content/m23011/latest/WaveletDenoising.mdl>
3 See the le at <http://cnx.org/content/m23011/latest/WaveletDenoisingDSKC6713.mdl>

http://cnx.org/content/m23011/1.1/
OpenStax-CNX module: m23011 3

Figure 2: Wavelet Model Showing Color Coding

2.1.3 Scope Output


The scope output shows how the random noise has been separated out (Residual).

http://cnx.org/content/m23011/1.1/
OpenStax-CNX module: m23011 4

Figure 3: Scope Output

2.1.4 Monitoring the Dyadic Filter Outputs


Add an extra scope as shown in Figure 4 to display the Diadic Filter Outputs.

http://cnx.org/content/m23011/1.1/
OpenStax-CNX module: m23011 5

Figure 4: Monitoring the Dyadic Filter Outputs

2.1.5 Analysis of Diadic Filter Outputs


It can be seen that the noise is on Out1, Out2 and Out3. The clean input signal is on Out4.

http://cnx.org/content/m23011/1.1/
OpenStax-CNX module: m23011 6

Figure 5: Noise Levels at Dyadic Filter Outputs

2.1.6 Modifying the Dead Zone


Double-click on the Soft Threshold block. This is the actual noise reduction stage. The elds are in order
Out1, Out2, Out3 and Out4.

http://cnx.org/content/m23011/1.1/
OpenStax-CNX module: m23011 7

Figure 6: Noise Levels at Dyadic Filter Outputs

Here Out1 has been given a threshold of 3. This means that only values > 3 are let through.
Out2, Out3 and Out4 have been given the value of 0. This means the whole signal is let through.
The output is shown in Figure 6. Note that the noise associated with Out2 and Out3 have not been
reduced.

http://cnx.org/content/m23011/1.1/
OpenStax-CNX module: m23011 8

Figure 7: Threshold only applied to Out1

2.1.7 Changing the Delay Alignment


Double-click on the Delay Alignment block. Temporarily remove the delays on Out1 and Out2.

http://cnx.org/content/m23011/1.1/
OpenStax-CNX module: m23011 9

Figure 8: Removing the Delay Alignments

Run the model to see the eect.

2.1.8 Summary of Simulation


From practical experimentation using the Simulink model, you should now understand how wavelet denoising
works.

http://cnx.org/content/m23011/1.1/
OpenStax-CNX module: m23011 10

3 Real-Time Model for TI C6713 DSK

3.1 Texas Instruments C6713 DSK Setup

Figure 9: Texas Instruments C6713 DSK Setup

3.2 Simulink Model for C6713 DSK


3.2.1 Starting Code Composer Studio
Start Code Composer Studio for C6713 DSK and use Debug -> Connect.

http://cnx.org/content/m23011/1.1/
OpenStax-CNX module: m23011 11

Figure 10: Startup Screen for Code Composer Studio (CCS)

3.2.2 Opening an Existing Model


Start MATLAB 7.3.0 R2006b:

Figure 11: Opening an Existing Demo

http://cnx.org/content/m23011/1.1/
OpenStax-CNX module: m23011 12

Click on Demos. The following screen will appear:

Figure 12: Selecting the Audio Demo Models

Highlight Embedded Target for TI C6000 DSP then Audio. Click on Wavelet Denoising.

3.2.3 Viewing the Wavelet Denoising Parent


The Wavelet Denoising model is now displayed. Double-click on the function() box.

http://cnx.org/content/m23011/1.1/
OpenStax-CNX module: m23011 13

Figure 13: Wavelet Denoising Parent

3.2.4 The Original Wavelet Noise Reduction Algorithm


The Wavelet Noise Reduction Algorithm model is now displayed.

http://cnx.org/content/m23011/1.1/
OpenStax-CNX module: m23011 14

Figure 14: Wavelet Denoising Algorithm

3.2.5 Copying the Model


For convenience, copy the model to the MATLAB Work directory where most models are stored.

http://cnx.org/content/m23011/1.1/
OpenStax-CNX module: m23011 15

Figure 15: Copying the Model to the MATLAB Work directory

3.2.6 Overview of the Modied Model


In order to run the model on the C6713 DSK and be able to compare the performance with and without
noise reduction, we will make some small modications to the demo model.

http://cnx.org/content/m23011/1.1/
OpenStax-CNX module: m23011 16

Figure 16: The Modied Algorithm

You will now update the existing model by dragging-and-dropping some library components onto the
model.

3.2.7 Changing the Input to Microphone


Double-click on the blue box to the left marked C6713 DSK ADC. The following options will appear.

http://cnx.org/content/m23011/1.1/
OpenStax-CNX module: m23011 17

Figure 17: Setting up the ADC for Microphone Input

Change the ADC source to Mic In and tick the Stereo box. If you have a quiet microphone, tick
the +20dB Mic gain boost box. When done, click on OK.

3.2.8 The DAC Settings


The DAC settings need to match those of the ADC. Check that they are the same.

http://cnx.org/content/m23011/1.1/
OpenStax-CNX module: m23011 18

Figure 18: Setting the DAC Parameters

3.2.9 Adding a DIP Switch and LED


To change between no wavelet denoising and with wavelet noise reduction, we will use a DIP switch of the
C6713 DSK.

http://cnx.org/content/m23011/1.1/
OpenStax-CNX module: m23011 19

http://cnx.org/content/m23011/1.1/
Figure 19: Adding a Switch and LED
OpenStax-CNX module: m23011 20

Select View -> Library Browser -> Embedded Target for TI C6000 DSP. Highlight C6713 DSK Board
Support.
Drag-and-drop the Switch block onto the model. Also drag-and-drop the LED block onto the model.

3.2.10 DIP Switch Settings


The DIP switch needs to be congured. Double-click on the Switch block.
Put at tick in all of the boxes and set Data type to Integer. The Sample time should also be set to
1.

Figure 20: Setting up the DIP Switch Value

3.2.11 Adding a Constant, Switch and Relational Operator


We now need to setup a way to switch between straight through without noise reduction and with wavelet
noise reduction.

http://cnx.org/content/m23011/1.1/
OpenStax-CNX module: m23011 21

Select View -> Library Browser -> Simulink. Highlight Commonly Used Blocks.
Drag-and-drop a Constant onto the model.
Drag-and-drop a Switch block onto the model.
Drag-and-drop a Relational Operator block onto the model.

http://cnx.org/content/m23011/1.1/
OpenStax-CNX module: m23011 22

http://cnx.org/content/m23011/1.1/
Figure 21: Selecting the Commonly Used Blocks
OpenStax-CNX module: m23011 23

3.2.12 Setting the Constant Value


The switch values lie between 0 and 15. We will use switch values 0 and 1. Double-click on the Constant
block. Set the Constant value to 1 and the Sample time to inf .

Figure 22: Setting the Echo Delay Gain

3.2.13 Setting the Constant Data Type


Click on the Signal Data Types tab. Set the Output data type mode to int16. This is compatible with
the DAC on the C6713 DSK. Click on OK.

http://cnx.org/content/m23011/1.1/
OpenStax-CNX module: m23011 24

Figure 23: Data Type Conversion to 16-bit Integer

3.2.14 Setting the Relational Operator Type


Double click on the Relational Operator block. Change the Relational operator to ==. Click on the
Signal Data Types tab.

http://cnx.org/content/m23011/1.1/
OpenStax-CNX module: m23011 25

Figure 24: Changing the Relational Operator

3.2.15 Setting the Relational Operator Data Type


Set the Output data type mode to Boolean.

http://cnx.org/content/m23011/1.1/
OpenStax-CNX module: m23011 26

Figure 25: Changing the Output Data Type

3.2.16 Joining the Blocks


Move the blocks and join them as shown in the Figure below.

http://cnx.org/content/m23011/1.1/
OpenStax-CNX module: m23011 27

Figure 26: Joining the Blocks

3.2.17 Checking the Dyadic Analysis Filter Bank


Double click on the Dyadic Analysis Filter Bank block. The values of the Dyadic Analysis Filter Bank are
shown below. You do not need to change them yet. Click on OK.

http://cnx.org/content/m23011/1.1/
OpenStax-CNX module: m23011 28

Figure 27: Checking the Dyadic Analysis Filter Bank

http://cnx.org/content/m23011/1.1/
OpenStax-CNX module: m23011 29

3.2.18 Checking the Delay Alignment


The delay alignment is shown below, with dierent delay times for the dierent frequencies.

Figure 28: Checking the Delay Alignment

3.2.19 Checking the Soft Threshold


The Soft Threshold sets the threshold below which noise is ignored for each of the four channels. Zero
means no noise reduction.

http://cnx.org/content/m23011/1.1/
OpenStax-CNX module: m23011 30

Figure 29: Checking the Thresholds

3.2.20 Checking the Dyadic Synthesis


Double-click on the Dyadic Synthesis Filter Bank. There is no need to change the values at this time. Click
on OK when done.

http://cnx.org/content/m23011/1.1/
OpenStax-CNX module: m23011 31

Figure 30: Checking the Dyadic Synthesis Filter Bank

http://cnx.org/content/m23011/1.1/
OpenStax-CNX module: m23011 32

3.2.21 Returning to the Parent System


From the Toolbar, select the Up Arrow icon. This returns you to the next higher level.

Figure 31: Returning to the Parent System

3.3 Building the Model


3.3.1 Selecting Real-Time Workshop
Select Tools -> Real-Time Workshop -> Build Model.

http://cnx.org/content/m23011/1.1/
OpenStax-CNX module: m23011 33

Figure 32: Building the Model

3.3.2 The Completed Model Running on Code Composer Studio


From the folders on the left, select the source code for the project.

http://cnx.org/content/m23011/1.1/
OpenStax-CNX module: m23011 34

Figure 33: The Completed Model Running under Code Composer Studio

3.4 Dierent Settings on the C6713 DSK


3.4.1 Microphone Straight Through to Loudspeakers
To check out the microphone and loudspeakers, set the DIP switches on the C6713 DSK as follows:

http://cnx.org/content/m23011/1.1/
OpenStax-CNX module: m23011 35

Figure 34: Switch Position 0

The microphone is fed directly to the loudspeakers. There is no noise reduction.

3.4.2 Switch Position for Wavelet Noise Reduction


To run the Wavelet Noise Reduction subsystem, set the DIP switch to 1.

Figure 35: Switch Position 1 for Wavelet Noise Reduction

3.5 Modifying the Model


The next stage is to modify the model. We will change the wavelet type to Symlets.

3.5.1 Changing the Filter Type


Double-click on the Dyadic Analysis Filter Bank block. Change the Filter eld to Symlets. Click on
OK.

http://cnx.org/content/m23011/1.1/
OpenStax-CNX module: m23011 36

Figure 36: Dyadic Analysis Filter Bank set to Symlets

http://cnx.org/content/m23011/1.1/
OpenStax-CNX module: m23011 37

3.5.2 Updating the Dyadic Synthesis Filter Bank


The wavelet type should be the same as that used in the Dyadic Analysis Filter Bank. Double-click on the
Dyadic Synthesis Filter Bank block. Change the Filter eld to Symlets. Click on OK.

http://cnx.org/content/m23011/1.1/
OpenStax-CNX module: m23011 38

Figure 37: Conguring the Dyadic Synthesis Filter Bank

http://cnx.org/content/m23011/1.1/
OpenStax-CNX module: m23011 39

3.5.3 Building the Model


Select Tools -> Real-Time Workshop -> Build Model.

Figure 38: Building the Model

3.5.4 Running the Updated Model


Run the updated model and listen to the eect of using dierent lter types.

4 Some Things to Try

You may wish to experiment with dierent settings. Here are some suggestions.

4.1 Change the Wavelet Types


Inside the Dyadic Analysis Filter Bank are dierent wavelet types. Which are suitable for wavelet denoising
and which are not? Note: you will also have to alter the values used in the Dyadic Synthesis Filter Bank.

http://cnx.org/content/m23011/1.1/
OpenStax-CNX module: m23011 40

Figure 39: Available Wavelet Types

http://cnx.org/content/m23011/1.1/
OpenStax-CNX module: m23011 41

4.2 Change the Delay Alignment Times


Experiment with the delay alignment times. Try higher and lower values.
What is the eect of completely removing the Delay Alignment block?

4.3 Change the Noise Reduction Thresholds


In the Soft Threshold block, change the values. The existing vector of [3, 2, 1, 0] reduces high frequency
noise, but does not aect low frequencies.

4.4 Create Your Own Subsystem


Add your own subsystem block controlled by the DIP switches and add your own wavelet denoising algorithm.
Choose your own wavelet, number of channels, sampling frequency and thresholds.

http://cnx.org/content/m23011/1.1/

You might also like