This is an old course web page from 2009
Old 2009 Course Web: Main / Written1
This written homework is due Wednesday, September 23.
Sample Solutions are up. For now it's just the answers. More detailed solutions coming.
If you write out the assignment by hand, you can either give the paper to the TA in class, or place it in her mailbox on the 5th floor (remember, the elevators are locked after 5pm).
If you type your answer, you can email them to the TA.
The goal of this assignment is to make sure you understand the concepts from class that you will need for the programming assignment (coming soon). If you can't do these simple examples, you may have a hard time writing code to do the operations on images.
Question 1: Discrete Convolution (1D) practice
Before implementing 2D convolutions, check to make sure that you understand how to do it in 1D. For this question assume that the signals are 0 outside the range specified, and that result may have non-zero values outside the range where the signals are defined. (that is - signal f has 17 numbers, but the answers will have 19 numbers)
f(x) = 2 2 2 0 0 0 4 4 4 0 0 0 2 0 2 0 2 defined for x = 0..16 g(x) = 1 -2 1 defined for x = -1..1 h(x) = 1 1 -1 defined for x = -1..1
1A: Compute f * g
1B: Compute f * h
Question 2: Convolution Boundaries
We went through a description of different ways to handle convolution boundaries quickly in class. There is a review on last year's class web page here. The book talks about it briefly on page 216.
When you implement 2D convolution, we'll ask for a particular version. But for now, let's look at the difference in a simple 1D case. In such a small example, its hard to have the effects come out.
Convolve the signals
f(x) = 5 0 5 0 5 0 5 0 for the range of x 0..7 g(x) = 1/5 1/5 1/5 1/5 1/5 for the range -2..2
Assume that g is zero outside of its range (-2 to 2 inclusive), but that f is only defined over the range 0 to 7.
Only consider the result over the range of f (f has 8 entries, so f*g should have 8 entries as well).
2A: Compute f*g assuming f is zero outside its range
2B: Compute f*g using clamping of f outside its range
2C: Compute f*g using mirroring (a.k.a. reflection)
2D: Compute f*g using kernel re-normalization
Question 3: 2D Convolutions and Seperability
Before implementing 2D convolutions, you might want to try doing one by hand. Unfortunately, doing them by hand is extremely tedious, so we can only do really small ones.
Doing it by hand or computer, the amount of work of doing a 2D convolution can be reduced if we can do it as 2 1D convolutions, one on the rows, one on the columns. This only works if we can "seperate" the 2D convolution into 1D parts. Fortunately, many important kernels have this property (called seperability).
You can think of doing the 1D convolution by treating each row of the image as a 1D signal, or you can think of it as a 2D convolution where the kernel is zero except for a stripe down the center. (then turn it vertically for the columns)
Here are 1D kernels that are the "seperations" of 2D kernels. That is, you apply each of these 1D kernels in the horizontal and vertical direction, and you get the same effect as doing a single 2D convolution. (which shouldn't be suprising, since convolutions are associative).
For each 1D kernel, give the equivalent 2D kernel (as applying the 1D kernel in each direction)
Notation note: the number (fraction) in front of a signal means multiply each element of the signal by that number.
3A: 1/5 [ 1 1 1 1 1 ]
3B: 1/16 [ 1 4 6 4 1 ]
3C: 1/2 [1 -1 2 -1 1]
Question 4: Resampling
You'll get to implement resampling in 2D soon enough. To practice, we'll do it by hand in 1D.
Here is a signal
f(x) = 0 0 0 4 4 4 4
(so f(0)=0, and f(2.5) is halfway between the last 0 and the first 4)
Compute samples of f for x=2.5, 2.75, 3, 3.5.
4A: using the unit box (g(t) = 1 if -.5 <= t < .5, 0 otherwise). In the book, this is r=1/2 for the box filter on page 203.
4B: using the unit tent filter (g(t) = (1+t) if -1 < t <= 0, 1-t if 0 < t <= 1, and 0 otherwise)
You can also write this as: g(t) = 1-|t| |t|<=1 This is r=1 for the equations on page 203 of the book