18
6.003 (Fall 2018) November 13, 2018 Quiz #2 Name: Kerberos Username: Enter all answers in the boxes provided. Other work on pages with QR codes may be considered when assigning partial credit. You have two hours. This quiz is closed book, but you may use two 8.5 × 11 sheets of paper (four sides). No calculators, computers, cell phones, music players, or other electronic devices.

6.003 (Fall 2018) November 13, 2018 · 6.003 (Fall 2018) November 13, 2018 Quiz #2 Name: Kerberos Username: Enter all answers in the boxes provided. Other work on pages with QR codes

  • Upload
    others

  • View
    13

  • Download
    0

Embed Size (px)

Citation preview

Page 1: 6.003 (Fall 2018) November 13, 2018 · 6.003 (Fall 2018) November 13, 2018 Quiz #2 Name: Kerberos Username: Enter all answers in the boxes provided. Other work on pages with QR codes

6.003 (Fall 2018) November 13, 2018

Quiz #2

Name:Kerberos Username:

Enter all answers in the boxes provided.Other work on pages with QR codes may be considered when assigningpartial credit.

You have two hours.This quiz is closed book, but you may use two 8.5× 11 sheets of paper (four sides).No calculators, computers, cell phones, music players, or other electronic devices.

Page 2: 6.003 (Fall 2018) November 13, 2018 · 6.003 (Fall 2018) November 13, 2018 Quiz #2 Name: Kerberos Username: Enter all answers in the boxes provided. Other work on pages with QR codes

Quiz #2 / 6.003: Signal Processing (Fall 2018) 2

1. Shapes [25 points]Each of the images below was created by computing the inverse DFT on a 24-by-24 arrayof DFT coefficients, of which at most 5 were non-zero. In each of these images, blackrepresents a value of 0, and white represents a value of 1. The origin of each image is inits center, c increases to the right, and r increases downward.For each image, enter the locations (kr, kc) of all non-zero values in the associated DFT.If the image could not have been made from an array of the form described above, enterNone in the box instead.

A B C

D E F

G H I

J K L

Enter your answers on the facing page.

Page 3: 6.003 (Fall 2018) November 13, 2018 · 6.003 (Fall 2018) November 13, 2018 Quiz #2 Name: Kerberos Username: Enter all answers in the boxes provided. Other work on pages with QR codes

Quiz #2 / 6.003: Signal Processing (Fall 2018) 3

What are the locations of the nonzero values in the DFT associated with image A?

(1, 0), (-1, 0), (0, 0)

What are the locations of the nonzero values in the DFT associated with image B?

(-4, -2), (4, 2), (0, 0)

What are the locations of the nonzero values in the DFT associated with image C?

(0, -1), (0, 1), (0, 0), (-3, 0), (3, 0)

What are the locations of the nonzero values in the DFT associated with image D?

(0, 12), (0, 0), (12, 0)

What are the locations of the nonzero values in the DFT associated with image E?

(-1, -1), (1, 1), (0, 0)

What are the locations of the nonzero values in the DFT associated with image F?

(-2, -4), (2, 4), (0, 0)

What are the locations of the nonzero values in the DFT associated with image G?

(0, 0)

What are the locations of the nonzero values in the DFT associated with image H?

(0, -2), (0, 2), (0, 0), (4, 0), (-4, 0)

What are the locations of the nonzero values in the DFT associated with image I?

(0, 12), (0, 0)

What are the locations of the nonzero values in the DFT associated with image J?

(0, -3), (0, 3), (0, 0)

What are the locations of the nonzero values in the DFT associated with image K?

(1, 0), (-1, 0), (0, 0), (12, 0)

What are the locations of the nonzero values in the DFT associated with image L?

(0, -3), (0, 3), (0, 0), (-8, 0), (8, 0)

Page 4: 6.003 (Fall 2018) November 13, 2018 · 6.003 (Fall 2018) November 13, 2018 Quiz #2 Name: Kerberos Username: Enter all answers in the boxes provided. Other work on pages with QR codes

Quiz #2 / 6.003: Signal Processing (Fall 2018) 4

2. Convolution [25 points]Part 1. Consider a signal x, which is known to have the following values:

x[n] =

0 if n < 040 if n = 014 if n = 132 if n = 27 if n = 3

All other values of x are unknown.When x is the input to a linear, time-invariant (LTI) system whose unit sample responsef [n] is 0 for n < 0, its output is given by:

y[n] =

0 if n < 080 if n = 068 if n = 198 if n = 263 if n = 3

All other values of y are also unknown.

For what values of n can f [n] be unambiguously determined? Specify these values of n,as well as the associated values f [n], in the box below.

We can determine the first 4 values of the unit sample response unambiguously usingsuperposition.

We know that y[0] can only depend on x[0], so we must have y[0] = x[0]× h[0], whichimplies that h[0] = 2.

Then we know that 68 = 2× 14 + h[1]× 40, which tells us that h[1] = 1.

Similarly, 98 = 2× 32 + 1× 14 + h[2]× 40, which tells us that h[2] = 12 .

Finally, 63 = 2× 7 + 1× 32 + 12 × 14 + h[3]× 40, so h[3] = 1

4 .

Page 5: 6.003 (Fall 2018) November 13, 2018 · 6.003 (Fall 2018) November 13, 2018 Quiz #2 Name: Kerberos Username: Enter all answers in the boxes provided. Other work on pages with QR codes

Quiz #2 / 6.003: Signal Processing (Fall 2018) 5

Part 2. Let y1[n] represent the result of convolving an input signal x[n] with the unitsample response g[n] of an LTI system (that is different from the one in part 1):

y1[n] = (x ∗ g)[n]

and let y2[n] represent the result of convolving y1[n] with the unit-sample response g[n]of a second, identical LTI system,

y2[n] = (y1 ∗ g)[n]

as illustrated in the following figure:

g[n] g[n]x[n]y1[n]

y2[n]

We can think about this as convolving x with a different signal g2:

y2[n] = (y1 ∗ g)[n] = (x ∗ g2)[n]

When the input x[n] is equal to a unit-sample signal δ[n], the output y2[n] is

y2[n] = δ[n]− 2δ[n− 3] + δ[n− 6]

n

x[n]

0

1n

y2[n]

0

1 1

−2

Determine the frequency response of g2:

From direct application of the DTFT analysis equation:

G2(Ω) = 1− 2e−j3Ω + e−6jΩ

Determine a closed-form expression (no infinite sums) for g[n]:

We have g2 = (g ∗ g), so we must have G2 = G×G. Therefore, G =√G2 = 1− e−j3Ω.

Using the DTFT synthesis equation:

g[n] = δ[n]− δ[n− 3]

Page 6: 6.003 (Fall 2018) November 13, 2018 · 6.003 (Fall 2018) November 13, 2018 Quiz #2 Name: Kerberos Username: Enter all answers in the boxes provided. Other work on pages with QR codes

Quiz #2 / 6.003: Signal Processing (Fall 2018) 6

Determine the frequency response G3(Ω) of a new system that consists of three copies ofthe original system, such that

y3[n] = (y2 ∗ g)[n] = (x ∗ g3)[n]

g[n] g[n] g[n]x[n]y1[n] y2[n]

y3[n]

Enter a closed-form solution in the box below. You do not need to simplify your answercompletely.

g3 = (g ∗ g ∗ g), so:

G3(Ω) = (1− e−j3Ω)3

Page 7: 6.003 (Fall 2018) November 13, 2018 · 6.003 (Fall 2018) November 13, 2018 Quiz #2 Name: Kerberos Username: Enter all answers in the boxes provided. Other work on pages with QR codes

Quiz #2 / 6.003: Signal Processing (Fall 2018) 7

Part 3. Consider an LTI system whose unit sample response is given by the following:

h[n] = δ[n] + αδ[n−m] + α2δ[n− 2m] + α3δ[n− 3m] + . . .

where α is a real-valued constant whose magnitude is less than 1, and m is a positiveinteger. Determine a closed-form expression for the frequency response of this system,in terms of α and m.

H(Ω) = 11− αe−jmΩ

The magnitude of the frequency response is given by the following expression:

|H(Ω)| = 1√(1 + α2)− 2α cos(mΩ)

Each of the graphs below shows a plot of the magnitude of the frequency response forthis system, where α is either 0.5 or 0.9, and m is either 5 or 9.For each, indicate which values of α and m correspond to the graph, and also label theminimum and maximum values of |H(Ω)|, as well as the Ω values at which the minimumand maximum occur.

Ω

|H(Ω)|

π−πα = m =0.5 9

Ω

|H(Ω)|

π−πα = m =0.9 9

Ω

|H(Ω)|

π−πα = m =0.5 5

Ω

|H(Ω)|

π−πα = m =0.9 5

The maxima occur at integer multiples of 2πm , and the minima occur halfway between

them. The maxima have magnitude 11−α , and the minima have magnitude 1

1+α .

Page 8: 6.003 (Fall 2018) November 13, 2018 · 6.003 (Fall 2018) November 13, 2018 Quiz #2 Name: Kerberos Username: Enter all answers in the boxes provided. Other work on pages with QR codes

Quiz #2 / 6.003: Signal Processing (Fall 2018) 8

3. Smiley [25 points]The following image, m[r, c], is 9 pixels wide and 9 pixels tall. Black pixels represent avalue of 0 and white pixels represent a value of 1. The pixel in the center of the imageis at the origin (r = c = 0). r increases downward, and c increases to the right.

The DTFT of m[r, c] is given by the function M(Ωr,Ωc).

Each of the following images measures 18 pixels wide and 18 pixels tall, and was synthe-sized from a DTFT that can be expressed in terms of the function M.

Part 1. Image 1

Write an expression for this image’s DTFT, M1(Ωr,Ωc), in terms of the function M.

M1(Ωr,Ωc) = M(−Ωr,Ωc)

Part 2. Image 2

Write an expression for this image’s DTFT, M2(Ωr,Ωc), in terms of the function M.

M2(Ωr,Ωc) = M(Ωr,Ωc) · e−5jΩr+5jΩc

Page 9: 6.003 (Fall 2018) November 13, 2018 · 6.003 (Fall 2018) November 13, 2018 Quiz #2 Name: Kerberos Username: Enter all answers in the boxes provided. Other work on pages with QR codes

Quiz #2 / 6.003: Signal Processing (Fall 2018) 9

Part 3. Image 3

Write an expression for this image’s DTFT, M3(Ωr,Ωc), in terms of the function M.

M3(Ωr,Ωc) = M(Ωr,Ωc)e−5jΩr+5jΩc + M(−Ωr,Ωc)e5jΩr−5jΩc

Part 4. Image 4

Write an expression for this image’s DTFT, M4(Ωr,Ωc), in terms of the function M.

M4(Ωr,Ωc) = Re (M(Ωr,Ωc)) , or12 (M(Ωr,Ωc) + M(−Ωr,−Ωc))

Part 5. Image 5

Write an expression for this image’s DTFT, M5(Ωr,Ωc), in terms of the function M.

M5(Ωr,Ωc) = M(2Ωr, 2Ωc) ·(

1 + e−jΩr−jΩc + e−jΩr + e−jΩc

)

Page 10: 6.003 (Fall 2018) November 13, 2018 · 6.003 (Fall 2018) November 13, 2018 Quiz #2 Name: Kerberos Username: Enter all answers in the boxes provided. Other work on pages with QR codes

Quiz #2 / 6.003: Signal Processing (Fall 2018) 10

4. Filtering [25 points]Part 1.In lab 9b, Ben Bitdiddle wrote the following code to apply a “brick wall” low-pass filterto an image (under the assumption that the input image was square, with an odd numberof pixels in each dimension). The code below is a working implementation with no bugs(line numbers are shown to the left).

01 | import numpy02 | from image_utils import png_read, png_write03 | from math import pi, cos, sin, e04 |05 | bird = png_read(’bird.png’)06 | h, w = bird.shape07 |08 | assert h==w, ’Only works for square images’09 | assert h % 2 == 1, ’Only works for images with odd dimensions’10 |11 | def make_lo_pass_dft(size, omega_cutoff):12 | kernel = numpy.zeros((size, size), dtype=float)13 | for r in range(-size//2, size//2+1):14 | for c in range(-size//2, size//2+1):15 | distance_from_center = (r**2 + c**2)**0.516 | pixel_cutoff = omega_cutoff / (2 * pi) * h17 | if distance_from_center <= pixel_cutoff:18 | kernel[r, c] = 119 | return kernel20 |21 | output = ifft2(fft2(bird) * make_lo_pass_dft(h, pi/7))

When applying this filter to the image on the left (where 0 is black and 1 is white), Bensees the image on the right.

Ben is pleased that the bird looks blurry, but he is upset by the “ringing” artifacts henotices after applying his low-pass filter to the image above.In an effort to get rid of these artifacts, Ben decides to replace line 18 with the followingcode (leaving the other lines unchanged):

kernel[r, c] = cos((pi / 2) * distance_from_center / pixel_cutoff)

Page 11: 6.003 (Fall 2018) November 13, 2018 · 6.003 (Fall 2018) November 13, 2018 Quiz #2 Name: Kerberos Username: Enter all answers in the boxes provided. Other work on pages with QR codes

Quiz #2 / 6.003: Signal Processing (Fall 2018) 11

Will this change reduce the ringing artifacts in the output image produced by this code?Justify your answer with a brief explanation (2-4 sentences). If he is incorrect, whatshould he change to produce the desired result?

Yes, this change will substantially reduce the ringing artifacts. The key issue with theoriginal filter was the discontinuity in the frequency domain; any 1-d radial slice throughthe center of the frequency domain would look like a square pulse in frequency (or likea sinc in space). Convolving with a sinc leads to those oscillations.

Ben’s solution does largely mitigate this problem (though there is likely still some ring-ing) by removing the dicontinuity at the edge of the filter. This is very similar to thewindowing process we saw with DFT/spectrograms.

Each of the images below is normalized so that black represents the minimum value (notnecessarily 0) and white represents the maximum value (not necessarily 1).Which of the images below most closely matches the output Ben sees from running thecode after making the change described above?

B

A B C D

E F G H

I J K L

Page 12: 6.003 (Fall 2018) November 13, 2018 · 6.003 (Fall 2018) November 13, 2018 Quiz #2 Name: Kerberos Username: Enter all answers in the boxes provided. Other work on pages with QR codes

Quiz #2 / 6.003: Signal Processing (Fall 2018) 12

Part 2.Ben’s friend, Lem E. Tweakit, realizes that he can create a high-passed version of theimage by subtracting a low-passed version of the image from the original image. Hedecides to perform this operation in the spatial domain, using the following code:

01 | lo_pass_dft = make_lo_pass_dft(h, pi/7)02 | lo_pass_space = ifft2(lo_pass_dft)03 | hi_pass_space = 1 - lo_pass_space04 | hi_pass_dft = fft2(hi_pass_space)05 |06 | output = ifft2(fft2(bird) * hi_pass_dft)

Will this change result in a high-passed version of the original image? Justify youranswer with a brief explanation (2-4 sentences). If he is incorrect, what should he dodifferently to produce the desired result (still by working in the spatial domain)?

Lem’s statement is correct (subtracting a low-passed version of the image from theoriginal should give a high-passed version), but his implementation is not.

By subtracting the low-passed version from 1 everywhere in space, Lem has essentiallyreversed the colors in space, but he has not gotten rid of any of the low frequencies.

The correct operation would be to do Hhp[kx, ky] = 1 − Hlp[kx, ky] in the frequencydomain. The equivalent operation in space would be to create hi_pass_space by sub-tracting lo_pass_space from a delta of height w**2:

hhp[nx, ny] = w2δ[nx, ny]− hlp[nx, ny]

Which of the images from the previous page most closely matches the output Lem seeswhen running his code (assuming he uses Ben’s original make_lo_pass_dft function)?

E

Page 13: 6.003 (Fall 2018) November 13, 2018 · 6.003 (Fall 2018) November 13, 2018 Quiz #2 Name: Kerberos Username: Enter all answers in the boxes provided. Other work on pages with QR codes

Quiz #2 / 6.003: Signal Processing (Fall 2018) 13

Worksheet (intentionally blank)

Page 14: 6.003 (Fall 2018) November 13, 2018 · 6.003 (Fall 2018) November 13, 2018 Quiz #2 Name: Kerberos Username: Enter all answers in the boxes provided. Other work on pages with QR codes

Quiz #2 / 6.003: Signal Processing (Fall 2018) 14

Worksheet (intentionally blank)

Page 15: 6.003 (Fall 2018) November 13, 2018 · 6.003 (Fall 2018) November 13, 2018 Quiz #2 Name: Kerberos Username: Enter all answers in the boxes provided. Other work on pages with QR codes

Quiz #2 / 6.003: Signal Processing (Fall 2018) 15

Worksheet (intentionally blank)

Page 16: 6.003 (Fall 2018) November 13, 2018 · 6.003 (Fall 2018) November 13, 2018 Quiz #2 Name: Kerberos Username: Enter all answers in the boxes provided. Other work on pages with QR codes

Quiz #2 / 6.003: Signal Processing (Fall 2018) 16

Worksheet (intentionally blank)

Page 17: 6.003 (Fall 2018) November 13, 2018 · 6.003 (Fall 2018) November 13, 2018 Quiz #2 Name: Kerberos Username: Enter all answers in the boxes provided. Other work on pages with QR codes

Quiz #2 / 6.003: Signal Processing (Fall 2018) 17

Worksheet (intentionally blank)

Page 18: 6.003 (Fall 2018) November 13, 2018 · 6.003 (Fall 2018) November 13, 2018 Quiz #2 Name: Kerberos Username: Enter all answers in the boxes provided. Other work on pages with QR codes

Quiz #2 / 6.003: Signal Processing (Fall 2018) 18

Worksheet (intentionally blank)