Starting from:

$29.99

Assignment 8 One plus one makes...

MATLAB Assignment 8
, Section A
Please submit this homework as a .m file, with suppressed output. 
** You can choose to do either/both of these questions. **
1. One plus one makes... (worth 2 points) The fourier transform allows us to transform
signals back and forth between the time and frequency domains. While this can be relatively
straightforward to imagine for time series signals (such as sound), what this means for other forms
of data might be more unclear. In this problem we will create a cool hybrid picture phenomena
that is possible through the fourier transform and hopefully as we go through the different parts,
you will get a sense of what the frequency domain means for images (and multi-dimensional data
in general). If you are in need of a reference, much of this question is similar to the image part
shown in lesson 7.
a. To begin, please download the two .png images located at github.com/guybaryosef/ECE210-
materials/tree/master/homeworks/hw8 and import them into your MATLAB script file.
b. Notice that these images are not the same size! As a preprocessing step, shrink the images so
that they have the same pixel dimensions. Note that to do this, you do not want to just delete
the first X rows and columns from the larger picture, because this will un-center the image.
Instead, if one picture is, for example, 50 pixels wider than the other, remove its first and last 25
columns, that way equalizing its size while still keeping it centered. At this point, also convert
your pixel values into a double type and normalize the values. Plot the two images side-by-side
using subplot and imshow. You should currently be seeing the fab-tastic faces of Marilyn
Monroe and Albert Einstein looking out at you.
c. Next we will like to create a 2-d lowpass filter. One popular option is called a gaussian filter
function, which unsurprisingly looks like a 3-d guassian distribution. The equation for this filter
is:
g(x, y) = exp −
(x − a)
2 + (y − b)
2

2
where σ is the standard deviation and (a, b) is the center of the function. Using a standard
deviation of 14, create this filter so that it has the same dimensions as the two images (Hint:
Use meshgrid). Note that you want the center of the filter, (a, b), to be the same as the center
of the images. Quickly plot your results using surf (titles and the like unnecessary), so that
you can see how this resembles a lowpass filter in the frequency domain. If your graph is black,
you should make your graph a variable and add the following line after it: set(your-graph’svariable-name, ’LineStyle’, ’none’).
1
d. Just as the above can be a lowpass filter, we can quickly make a highpass filter by calculating
g2(x, y) = 1 − g(x, y). Do so here.
e. Take the fast fourier transform of each image using fftshift(fft2(img)). Now we want to apply
the filters to the images: We do this by considering that we want to combine these two images
together. As such let’s filter each image such that we emphasize its characterstics.
Specifically Marilyn’s smooth, silky hair, can be brought to focus using a lowpass filter, which
has the effect of smoothing an image. In the same vain, Albert’s image has a lot more edges,
creases, and lines to it (I will avoid saying anything meaner) and so we could emphasize them
using a highpass filter to it. Remember that convolution in the time domain is multiplication
in the frequency domain and so all that is necessary here is element-wise multiplication. Create
another subplot, this one 2x2, with the original images in the frequency domain as well as the
filtered images in the frequency domain.
f. Using the inverse fft, return each image back to the time domain, and subplot them side by side.
As a bonus question, where is Albert?
g. Average the two images together, and you now have a hybrid photo! Gah! A little scary at first
sight! However look at it up close. Now back away from the screen and look at it again. Do
you see different faces peering up at you? If not, feel free to tweak around with the standard
deviation of the filters as well as the other parameters. This question was taken directly from
https://jeremykun.com/2014/09/29/hybrid-images/, which is an awesome blog full of cool and
informative ideas and concepts.
2. Girl look at that Bode! (worth 1 point) A continuous time system is characterized by the
following equation:
f = t
5
e
2t
sin(5t) + t
3
e
3
tcos(4t) + tcos(10t)
a. Take the Laplace Transform of the above equation. (Hint: Use the symbolic toolbox!)
b. Use numden and coeffs to extract the coefficients from the Laplace transform. Use double to
convert them to numeric form.
c. Create a bode plot for the equation you obtained above. As is customary with log-scaled axis
(to differentiate from the more standard linear spacing), turn the grid on.
2

More products