CS 370 Assignment 3 solution

$27.99

Original Work ?
Category: You will Instantly receive a download link for .ZIP solution file upon Payment

Description

5/5 - (4 votes)

4. Signal Processing (10 marks)
Sound samples of a train whistle are recorded at a rate of 8192 samples per second. The total
number of samples is N = 12880, and thus the length of the signal is 1.57 seconds. However,
the recording is polluted by the background noise of bird chirps. The signals of the train
whistle, bird chirps, and the polluted train whistle are shown below.
The polluted recording has been obtained simply by superimposing the two signals. As one
can see, in the time domain it would be rather difficult to separate the bird chirps from
the train whistle in the mixed signal. Your job is to denoise the polluted (noisy) signal by
using the discrete Fourier transform. The noisy signal is provided on the website in the file
train bird.mat. Use the load command to load the data into your workspace in MATLAB.
The file contains the signal, y, and the sampling rate, Fs. Once the data is loaded you can
hear the signal by using the command soundsc(y,Fs).
Write a MATLAB script to do the following:
(a) Load the data and plot the input signal.
(b) Compute the DFT of the original signal, and plot the power spectrum. (Hint: use the
fft and abs commands.)
(c) Implement a low-pass filter to isolate the train whistle, and a corresponding high-pass
filter to isolate the bird chirps. (Hint: study the power spectrum carefully, and use trial
and error.)
(d) Plot the denoised signal of the train whistle and its power spectrum.
Note: use the stem command to plot the power spectrums.
Submit the following:
• A hard copy of your code and the four figures produced by it. Present the plots of
the signals and the plots of the spectra side-by-side for comparison. (Hint: use the
subplot(2,2) command.)
• A brief description of your implementation and the results. In particular: (i) describe
what your code does, (ii) identify the frequency threshold you used to filter the signal,
and (iii) comment on the similarities and differences between the noisy and denoised
signals.
2
5. Image Compression (20 marks)
In this problem, we study the compression of gray-scale images. In Appendix F of the course
notes, Images in Matlab, you have the information needed to convert such images into a twodimensional array. Compression is obtained by dropping relatively small Fourier coefficients
on 8×8 pixel subblocks. By this we mean that if {fi,j} are the original pixel values in a given
subblock, and {Fk,`} are the corresponding DFT, then we drop any Fk,` satisfying
|Fk,`| < Fmax · tol.
Here Fmax is the maximum of {|Fk,`|} in each block and tol is our drop tolerance.
The file mountain.jpg, available on the course web site, contains an image to be used in this
question.
a) Compression
Create a MATLAB function, Compress.m, that has the following prototype:
[Y, drop] = Compress(X, tol)
It takes as inputs the original image, X, and the drop tolerance parameter, tol, and
outputs a compressed image Y. It also returns the drop ratio, drop, which is defined to
be:
drop ratio = Total number of Fourier coefficients dropped
Total number of pixels in the image .
If drop ratio = 0, then no Fourier coefficient is dropped; if drop ratio = 1, then all
Fourier coefficients are dropped. In general, it should be between 0 and 1.
Your MATLAB function needs to do the following:
• Compute the 2D Fourier coefficients (fft2) for every 8 × 8 subblock.
• For each subblock, set those Fourier coefficients having modulus less than the relative
tolerance level to 0.
• Record the number of coefficients dropped.
• Reconstruct the compressed 8 × 8 image array by using the inverse 2D Fourier transform (ifft2). Note: the reconstructed image array must be set to the real part
(real) of the inverse transform.
• Return the entire compressed image as Y and the drop ratio as drop, after all the
8 × 8 subblocks for all the components have been processed.
b) Compression Levels
Determine (by trial and error) four values of tol resulting in drop ratios of 0, 0.5, 0.7
and 0.95. Write a MATLAB script to do the following:
• Execute Compress.m with these set of tol values.
• Display the four compressed images (using subplot and subimage). Indicate the tol
value and the resulting drop ratio used for each image.
• Create a plot of: (the normalized mean square error (NMSE) between the original
image and the compressed image) vs (the drop ratio for the compressed image). (The
NMSE should be on the vertical axis, and the drop ratio on the horizontal.) Refer to
Appendix F in the course notes for normalized mean square error.
3
Submit the following:
(a) A hard copy of the function Compress.m.
(b) A hard copy of the matlab script.
(c) A figure with the 4 plots of the compressed images.
(d) The error plot.
(e) A brief commentary on your results.
4