Anda di halaman 1dari 19

Experiment No.

02
REPRESENTATION AND SIMPLE PROCESSING OF AUDIO AND IMAGE SIGNALS
1. Objective(s):
This activity aims to:
1. demonstrate how audio and image signals are represented as computer data; and
2. equip students with skills in simple processing of audio and image signals.
2. Intended Learning Outcomes (ILOs):
At the end of this activity, the students shall be able to:
1. import audio and image into LabVIEW;
2. understand how audio and image signals are represented as computer data; and
3. process audio and image signals
3. Discussion
An audio signal is an analog representation of sound, typically as an electrical voltage. Audio signals may
be synthesized directly, or may originate at a transducer such as microphone, musical instrument pickup,
phonograph cartridge, or tape head. Loudspeakers or headphones convert an electrical audio signal into
sound. (from http://en.wikipedia.org/wiki/Audio_signal, retrieved May 30, 2011). LabVIEW offers a variety of
ways to read and write audio files in WAV format. Using the Simple Read and Simple Write subVIs of
LabVIEW, an audio signal in a one-dimensional array can be retrieved and vise-versa. Then, various
operations can now be done to this signal using various VIs of LabVIEW, such as scaling, filtering, etc.
A digital image is a numeric representation (normally binary) of a two-dimensional image. Depending on
whether or not the image resolution is fixed, it may be of vector or raster type. Without qualifications, the
term digital image usually refers to raster images, also called bitmap images. Raster images have a finite
set of digital values, called picture elements or pixels. The digital image contains a fixed number of rows
and columns of pixels. Pixels are the smallest individual element in an image, holding quantized values that
represent the brightness of a given color at any specific point. Each pixel of a raster image is typically
associated to a specific position in some 2D region, and has a value consisting of one or more quantities
related to that position (from http://en.wikipedia.org/wiki/Digital_image, retrieved May 30, 2011).

Each pixel in a raster image contains information on the color of the pixel. The color in a digital image is
usually represented by the combination of red-green-blue colors or the RGB color model. The intensity of
each component value takes integer values from 0 255; thus a white has an RGB value of 255-255-255.
The color depth indicates how many bits represent each value 8-bit, 12-bit, 16-bit (Direct Color), 24-bit
(TrueColor) and Deep Color values are available.
The figure below shows a color chart, which specifies the numeric representation (in hexadecimal) of
colors. Note that each color is represented by 24 bits (6 hexadecimal digits).

4. Resources:
To perform this activity, a computer workstation with LabVIEW 8.6 or higher and any media player
(QuickTime or VLC) that can play WAV files installed. A headset can also be used to hear the output
sound.
5. Procedure:
Note: Before starting with the activity, obtain the Activity 2 Files folder from your instructor. This folder
contains the necessary files in performing the activities. Also, bring a headset so that the waveform
produced by the WAV file in Activity 2.1 can be heard.
Activity 2.1 Audio Signal Representation and Signal Processing
1. Create the act02-01.vi. This activity will demonstrate how to read WAV files into LabVIEW and how to
write it back to a WAV file.

2. Build the BD and FP as shown below.

On BD, place a Sound File Read Simple.vi. On the Path input of this VI, create a control. The
control that will appear is for a file path.
Place a Play Waveform VI. The Configure Play Waveform configuration window appears. Leaving
everything to its default settings, click the Test Device to hear whether it sends a beep sound into
the speaker (connect the headset to the sound adapter jock before doing this step). If a beep
sound is heard, then the input waveform to this VI will also be heard. Click OK. Wire the Data input
of this VI to the Data output of the Sound File Read Simple.vi.
On the FP, place a Waveform Graph. Configure this Waveform Graph so that the X-Scale is
Loose Fit, make the graph IgnoreTime Stamp and the Display Format of the Time (X-Axis) data
Type is Floating Point, using Digits of Precision with 2 Digits. Wire this to the Data of the Sound
File Read Simple.vi.
3. Save the VI. On the FP, click the Browse icon and point to the location of the file tone-noise.wav
inside the Activity 2 Files folder. Then Run the VI.
Q1.3(a): Adjust the time stamp of the Waveform graph to display the waveform from 0 to 0.02
seconds. What is being displayed in the Waveform graph? Relate this to the sound heard.
Q1.3(b): Adjust the time stamp of the Waveform graph to display the waveform from 1.20 to 1.21
seconds. What is being displayed in the Waveform graph? Relate this to the sound heard.
Q1.3(c): How did LabVIEW represented the audio signal?
Q1.3(d): Obtain some information on the audio file like the length of the file, total number of
samples, sampling rate, the number of channels and the number of bits per sample. Use Info.vi.
4. Play the left-right.wav file.
Q1.4(a): How did the audio sounded?
Q1.4(b): What was being displayed in the Waveform Graph? How many channels does this file
have?
5. Modify the BD and FP of act02-01.vi into what is shown below.

In BD, insert two Index Array nodes. Wire the Array inputs of this node to the Data output of
Sound File Read Simple.vi. On the first Index Array node, create a constant 0 on the Index input
and 1 on the other node.
Add a Flat Sequence Structure. Add two more frames after the first one by right-clicking the node
and choosing Add Frame After. Insert the first Play Waveform node (the one which plays the
original sound) in the first frame. Then add two more Play Waveform nodes (these will be
automatically named Play Waveform2 and Play Waveform3) and place each on the second and
third frame of the Flat Sequence Structure node, respectively. Wire the Data input of the Play

Waveform2 node to the output of Index Array with constant 0 and the Datainput of Play
Waveform3 to the other Index Array node.
Create two Waveform Graphs on the FP. Name them as Index 0 and Index1. Configure these
graphs the same way with the first graph. On BD, wire the Element outputs of the Index Array
nodes as shown.
6. Save and run the VI using the left-right.wav file.
Q1.6(a): What is the function of the Flat Sequence Structure?
Q1.6(b): Comment on the sound heard and its relationship to the graphs displayed. What did the
Index Array nodes do to the Output data of the file?
7. Edit the block diagram so that the sum of the two outputs of Index Array nodes can be played and
displayed on the graph. Refer to the BD below.

Q1.7(a): What happened to the waveform and to the sound?


8. A noise of white Gaussian type will be added to the appended signal. To do this, modify the BD as
shown:

Create the white Gaussian noise using the Create Analog Signal of the Signal Express module of
LabVIEW. When the Create Analog Signal configuration window appears, choose Noise Signal as
the Signal Type, the Noise Type as White (Gaussian), the Level(rms) as 0.25, the Sample Rate
(S/s) and the Block Size (samples) as the one obtained in the third step, fourth question using the
Info.vi. Click OK.
Place a Get Waveform Components node. Expand this upward so that the t0 and dt output
terminals appear. Wire the Waveform input terminal to the output of the Sum node.
Place a Build Waveform node. Expand this upward so that the t0 and dt output terminals appear.
Wire these to the t0 and dt terminals of the Get Waveform Components node, respectively. Wire
the Y terminal of the Build Waveform node to the white Gaussian noise output terminal of the
Create Analog Signal node.
Add the output of the Sum node and the Build Waveform node, using a Sum node. Create another
frame in the Flat Sequence structure, then add a Play Waveform (this will be automatically named
as Play Waveform3) node in this frame. Wire the output of the Sum node to the Data input of the
Play Waveform3 node. Create a Noisy waveform graph in the FP and wire the input of this to the
output of the Sum node.
9. Save and run the VI.
Q1.9(a): Comment on the waveform of the Noisy signal and the sound heard.
Q1.9(b): What is the function of the Get Waveform Components and Build Waveform nodes?
10. Modify the BD so that the output of the Noisy waveform can be written into a file called Noisy.wav.

Place a Build Array node. Connect the input of this node to the output of the Sum node which
generates the Noisy audio.
Place a Sound File Write Simple.vi node. Wire the output of the Build Array node to the Data
input of the Sound File Write Simple.vi. Then create a constant to the input Path terminal of this
VI. In the constant, type x\noisy.wav where x is the location where the noisy.wav file will be
written. Note: A folder can be created inside the Activity 2 Files and call it Output Files. Open this
folder and copy its location from its address bar to the created constant. This will be the location
where the noisy.wav will be placed. Example: C:\Users\tipqc\Desktop\Activity 2 Files\Output
Files\noisy.wav.
11. Save and run the VI. Open the folder where the noisy.wav file is located. If there is an available media
player in the workstations, play the wav file. This wav file now contains the appended array of the originally
channel-separated audio corrupted by white Gaussian noise.
Q1.11(a): Why is there a need for a Build Array node to be used when writing a waveform into a file?
12. Scale the appended signal (the Index 0 + Index 1 waveform) by multiplying it with a constant 2. Then
write the Index 0 + Index 1 waveform, as well as the scaled signal into a wav file. Call these as
original.wav and scaled.wav files, respectively. Place these files in the same location as the noisy.wav.
Also, display the waveform of the scaled signal into a Waveform Graph. Save and run the VI, and when
the files are generated, play them using a media player.
Q1.12(a): Compare the original and the scaled audio in terms of its waveform graph and how it
sounded? What is the effect of scaling or multiplying an audio signal by a constant?
Activity 2.2 Image Signal Representation and Signal Processing
1. Build the act02-02.vi VI as shown.

On the BD, place a Read PNG File.vi node. Create a constant on the Path to PNG File input
terminal of this node. On the path constant, type in the location of the image01.png located in the
Activity 2 Files. Example: C:\Users\tipqc\Desktop\Activity 2 Files\Output Files\image01.png.
Place a Draw Flattened Pixmap.vi node. Wire the Image Data input of this VI to the Image Data
output of the Read PNG File.vi node. Then create an Image indicator at the New Picture output
terminal of the VI.

Place an Unbundle By Name node. Wire the input of the Unbundle By Name node to the Image
Data output of the Read PNG File.vi. Expand this node so that the image depth, image, and
Rectangle data can be obtained. Create an indicator on the image depth data. Note: The
Rectangle data is another cluster. Unbundle it using another Unbundle By Name node, wire it to
the Rectangle terminal, expand it to display the left, top, right, and bottom data , then create an
indicator for each of the data.
Switch to FP. Place an Express Table into the FP. The Express Table node appears in the BD.
Wire the Signal input of this VI to the image data of the first Unbundle By Name node. Note: Upon
wiring, a Convert to Dynamic Data node appears.
In BD, double-click the Build Table express node. The Configure Build Table appears. Change
the Format the numbers to Hexadecimal (303A), then check the Clear data on each call option.
Click OK.
Q2.1(a): With regards to the image file, what does the image depth, the image, and the Rectangle
data indicate?
2. Save and run the VI.
Q2.2(a): What is being displayed in the table? How many rows does this table have? What does the
data on each cell indicate?
3. Modify the FP and BD as shown.

Place an Unflatten Pixmap.vi node. Wire the Image Data input terminal of this VI to the Image
Data output of the Read PNG File.vi.
Place another Express Table in the FP. Then on the BD, wire the input Signal terminal of the
express VI to the 24-bit pixmap output terminal of the Unflatten Pixmap.vi node. Configure this
Express Table in the same manner as that of the previous Express Table.
Q2.3(a): Why was the indicator connected to the 24-bit pixmap terminal of the Unflatten Pixmap.vi?
Will the output be also seen in the other terminals? Why?
4. Save and run the VI.
Q2.4(a): Compare the output of Table and Table 2. What does the value in each cell represent?
Note: Notice in the image that the color varies per column of pixel, while the data in the table varies per
row. LabVIEW reads the image per row (this is how a raster, or a bitmap, image is read) and places the
image data per column of the Express Table. Thus, the pixel map that is being seen in the table is actually
the transpose of the pixel map of the image. This can be seen when the image data is written on a
spreadsheet file.
5. Modify the BD as shown below. Insert the Write to Spreadsheet File.vi node and wire the 2D Data of
this VI to the 24-bit Pixmapoutput of the Unflatten Pixmap.vi node. Create a constant on the format (%d)
terminal of the Write to Spreadsheet File.vi node and change it to %x. Save and run the VI. The Write to
Spreadsheet File.vi will ask for the filename of the spreadsheet file where the image data will be saved.
Point first to the location of the Output Files folder (the one created in the previous activity) and type in
image01.xls as the filename. Open this file. Note: OpenOfficeCalc or MS Excel can be used to open this
file. A prompt may appear, informing that the file being saved is in a different format. Just click Yes or
Open.

Q2.5(a): What is being displayed in the image01.xls? How does it compare with the one displayed in
Table 2?
Note: The one displayed in the spreadsheet file is the true pixel map of the image. Notice that the exact
location of the color in the pixel map is depicted in the spreadsheet file.
Q2.5(b): What does the format %x mean? What other formats are available for use?
6. Place a Transpose 2D Array node and wire its 2D Array input into the 24-bit Pixmap output of the
Unflatten Pixmap.vi node. Then place a Draw Unflattened Pixmap.vi node and wire the Data (RGB
Format) input terminal of this node to the Transposed Array output terminal of the Transpose 2D Array
node. Create an indicator to the New Picture output of the Draw Unflattened Pixmap.vi node and name it
as Transposed Image.
Q2.6(a): How did the Transposed Image look like? What did the transposed operation do to the
image?
Q2.6(b): How did LabVIEW represented the image signal?
7. Modify the BD as shown below.
Insert two For Loop structures, one inside the other. Wire the Loop Count of the inner For Loop to
the right output terminal of the second Unbundle By Name node, while its bottom output terminal
must be wired with the outer For Loops Loop Count.

On the inner For Loop, insert a Random Number (0-1) node. The output of this node must be
multiplied to the constant 16777216(=224). The output of the two For Loops must be wired to an
Add node. The other input of the Add node is the 24-bit pixmap output of the Unflatten Pixmap.vi.
Place a Draw Unflattened Pixmap.vi. Wire the output of the Add node to the input Data (RGB
Format) of this VI. Then create an indicator called Noisy Image to the New Picture output of this
VI.
Disconnect the Write to Spreadsheet File.vi from the Unflatten Pixmap.vi and re-wire it to the
output of the Add node.
8. Save and run the VI. When prompted, save the spreadsheet file as image02.xls.
Q2.8(a): What happened to the image? How did this happen?
Q2.8(b): What is the purpose of the two For Loops and the Random Number multiplied to the
constant? Why is the constant chosen to be equal to 224?
Course:
Experiment No.:
Group No.:
Section:
Group Members:
Date Performed:
Date Submitted:
Instructor:
6. Data and Results:
Q1.3(a): Adjust the time stamp of the Waveform graph to display the waveform from 0 to 0.02
seconds. What is being displayed in the Waveform graph? Relate this to the sound heard.
_____________________________________________________________________________________
_____________________________________________________________________________________

_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
Q1.3(b): Adjust the time stamp of the Waveform graph to display the waveform from 1.20 to 1.21
seconds. What is being displayed in the Waveform graph? Relate this to the sound heard.
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
Q1.3(c): How did LabVIEW represented the audio signal?
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
Q1.3(d): Obtain some information on the audio file like the length of the file, total number of
samples, sampling rate, the number of channels and the number of bits per sample. Use Info.vi.
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
Q1.4(a): How did the audio sounded?
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________

_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
Q1.4(b): What was being displayed in the Waveform Graph? How many channels does this file
have?
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
Q1.6(a): What is the function of the Flat Sequence Structure?
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
Q1.6(b): Comment on the sound heard and its relationship to the graphs displayed. What did the
Index Array nodes do to the Output data of the file?
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
Q1.7(a): What happened to the waveform and to the sound?
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________

_____________________________________________________________________________________
_____________________________________________________________________________________
Q1.9(a): Comment on the waveform of the Noisy signal and the sound heard.
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
Q1.9(b): What is the function of the Get Waveform Components and Build Waveform nodes?
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
Q1.11(a): Why is there a need for a Build Array node to be used when writing a waveform into a file?
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
Q1.12(a): Compare the original and the scaled audio in terms of its waveform graph and how it
sounded? What is the effect of scaling or multiplying an audio signal by a constant?
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
Q2.1(a): With regards to the image file, what does the image depth, the image, and the Rectangle

data indicate?
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
Q2.2(a): What is being displayed in the table? How many rows does this table have? What does the
data on each cell indicate?
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
Q2.3(a): Why was the indicator connected to the 24-bit pixmap terminal of the Unflatten Pixmap.vi?
Will the output be also seen in the other terminals? Why?
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
Q2.4(a): Compare the output of Table and Table 2. What does the value in each cell represent?
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
Q2.5(a): What is being displayed in the image01.xls? How does it compare with the one displayed in
Table 2?

_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
Q2.5(b): What does the format %x mean? What other formats are available for use?
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
Q2.6(a): How did the Transposed Image look like? What did the transposed operation do to the
image?
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
Q2.6(b): How did LabVIEW represented the image signal?
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
Q2.8(a): What happened to the image? How did this happen?
_____________________________________________________________________________________
_____________________________________________________________________________________

_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
Q2.8(b): What is the purpose of the two For Loops and the Random Number multiplied to the
constant? Why is the constant chosen to be equal to 224?
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
7. Conclusion:

8. Assessment:
1. Record an audio (speech or any sound) and create a VI that would do some simple signal processing
task on the recorded audio. The signal processing task must not be the ones done in the activity. The basic
principles of the task must be fully explained and demonstrated. Call the VI for this activity as macpro0201.vi.
2. Take a color picture (use pictures with vivid colors) and create a VI that would perform some simple
signal processing algorithms on the picture other than the ones done in this activity. Explain the principles
of the algorithm. Call the VI for this activity as macpro02-02.vi.

Assessment rubric for the conduct of laboratory experiments


Performance Indicators
Conduct experiments in
accordance with good and
safe laboratory practice.

Operate equipment and


instruments with ease

Analyze data, validate


experimental values against
theoretical values to
determine possible
experimental errors, and
provide valid conclusions.

Members follow good


Members do not follow
and safe laboratory
good and safe laboratory
practice most of the time
practice in the conduct
in the conduct of
of experiments.
experiments.
Members are unable to
operate the equipment
and instruments.

The group has


incomplete data.

Members follow good


and safe laboratory
practice at all times in
the conduct of
experiments.

Members are able to


operate equipment and
instrument with
supervision.

Members are able to


operate the equipment
and instruments with
ease and with minimum
supervision.

The group has complete


data but has no analysis
and valid conclusion.

The group has complete


data, validates
experimental values
against theoretical
values, and provides
valid conclusion.
Total Score

Mean Score = (Total Score /3)


Percentage Score = (Total Score / 9) x 100%

Points

Anda mungkin juga menyukai