-
Notifications
You must be signed in to change notification settings - Fork 12
Assignment 5
For this assignment you will be given partially completed skeleton code that contains some of the logic you will need. All areas that you need to add or modify code to to complete the assignment requirements will be marked with a TODO
comment and some more specific instructions. It is not necessary to add or modify code outside these sections.
Create a 31x31 filter array containing the sharpening filter that was described in class. The filter has two components: U and G.
- U is a unit impulse filter, which is all zeros except for the center value which is one.
- G is a 2D Gaussian filter where each position
(x, y)
has the valueg(x)*g(y)
whereg
is the provided 1D Gaussian.
The final filter should be computed as 2 * U - G
.
Make a copy of the filter which has zeros added to the outside so that it is the same shape as the input image.
Use the numpy fft2 function to transform both the padded filter and input image into the Fourier space.
Use the Convolution Theorem to apply the filter in the Fourier domain.
Use the numpy ifft2 function and convert the result from above back to a real-valued image with valid (0-255) intensity values.
Use the cv2.filter2D function to apply the original filter to the image directly with a convolution. This should produce the same result as the steps above.
This assignment will involve some more advanced use of numpy indexing to build the filter. You will probably want to read about some of the advanced features that are available to avoid long and complex for-loops:
You will also need to use Fast Fourier Transform functions and a filtering function: