Problem Set No. 2
By YOUR NAME

Part I: Plain old filtering

MATLAB code

For this part, implement a convolution in Matlab that will allow you to take an image and a kernel (a square one) and generate the new image that results from convolving the image with the kernel. For all the steps below, apply your code to two images. One is the Lena image (512x512), which is a straight TIFF image of the black and white classic image processing image (e.g. in the Burt and Adelson paper). The other is any image of your choosing. (Here is a 128x128 Lena image to try slow code on - use if your convolution code is really slow....)

Original
Images







1.Using a 7x7 boxcar (plain rectangle), filter the image. Be careful how you treat the edges. If your original image is NxN and you want an NxN image out, the edges require some thinking. If you're stuck on this, do help conv2 in Matlab and read about the edges.

Box Car
filter





2.Subtract the filtered image from the original, and look at the remainder. How would you describe it? (Remember, these images can go negative- use imagesc or roll your own method for displaying real-valued images.


YOUR ANSWER GOES HERE



Subtract
Box
Filter





3.Now, create a 7x7 kernel that is more like a Gaussian blob. (Don't forget to normalize your filter so it sums to one). Filter the images using that kernel.





7x7 filter
Gaussian





4.Subtract the Gaussian blur form the original. How does that compare to the image in step 2? What about as you vary the width of sigma in the Gaussian filter?



YOUR ANSWER GOES HERE

Subtract
Gaussian
Blur




5. Repeat the above steps using the Matlab routines conv2 or filter2. Which you use depends upon how you like to do things. Do you get the exact same results? Close? Where's the difference?



YOUR ANSWER GOES HERE


Box Car  
filter

Subtract
Box
Filter

7x7 filter
Gaussian

Subtract
Gaussian
Blur








PART II. Pyramids

MATLAB code



1.Create a Gaussian pyramid of both of your images. Choose a value for a (the parameter in the paper) that works well.




YOUR a=?



Gaussian Pyramid for Image 1

NOTE: This is just a sample template with the same image at different sizes. It is not the Gaussian pyramid that we expect your code to generate

Image 1



YOUR a=?


Gaussian Pyramid for Image 2

Image 2




2.Expand up all your pyramid levels so that they are the size of the original images. That is, end up with Gaussian pyramid but all images are the same size.



Level Image 1    Image 2
0   
1   
2   
3   
4   
5   
6   




3. Clearly each level of the Gaussian pyramid represents convolution with a bigger and bigger Gaussian. What is a simple way to empirically determine the effective size of the Gaussian at each level? (Remember: the kernel is also called the impulse response. What is an "impulse image"?)


YOUR ANSWER GOES HERE




4. Subtract each subsequent level from the one below it (ie subtract neighboring levels) using these same size Gaussians. What do those "band-pass" images look like?


YOUR ANSWER GOES HERE

Level Image 1    Image 2
0   
1   
2   
3   
4   
5   
6   




5. GRADUATE STUDENTS: In these band pass images, note that some areas you have an image whose value is near zero but whose intensity slope is reasonably steep. Threshold these subtracted images so that pixels that are near zero but have reasonable slope are set 1, everything else is set to zero. (These are zero crossings and are related to edge detection.)


YOUR ANSWER GOES HERE

Additional MATLAB code for this problem (if any)



Level Image 1    Image 2
0   
1   
2   
3   
4   
5   
6