BCS 222
Lab Assignment 1
(Due: 2/11)
Part 1:
Write a Matlab function to compute a 2D convolution. It should take two arguments as input, an image and a 2D kernel (these should both be 2D arrays), and return as output the result of convolving the input image with the kernel. The output image should have the same dimensions as the input image. At points in the image where the kernel overlaps with the edge of the image, you should treat the regions outside the image as containing 0’s. By convention, the center of an NxN kernel is the point (N/2,N/2). When N is odd, it is the point ((N+1)/2, (N+!)/2).
The format for calling your function should be
output_image = myconv2D (input_image, kernel),
where input_image is an LxM dimensional array and kernel is an NxN array. output_image should be LxM.
Part 2:
Use your 2D convolution routine to simulate the output of an astigmatic eye, that is, with a point spread function that is stretched more in one direction than another. Model the point spread function as a 2D Gaussian kernel that is stretched more in one direction than the other.
Read in the image letters.bmp and filter the image with the astigmatic filter kernel. Play with the parameters of the Gaussian used to create the kernel to find a set of values that creates significant blurring of the image. Answer the following two questions –
1. Which letters are most confusable for an astigmatic eye that blurs more in the horizontal direction than the vertical direction. Demonstrate by displaying images of the filtered letters image.
2. Which letters are most confusable for an astigmatic eye that blurs more in the vertical direction than the horizontal direction. Demonstrate by displaying images of the filtered letters image.
Note: Be sure the create a kernel in which the peak of the Gaussian is centered in the middle of the 2D array that you use to represent the kernel.
Turn in two files. The first, named myconv2D.m, should contain the definition of your myconv2D function. The second should be a scratch file in which you answer part 2 of the lab exercise.