Project 3 - Image Enhancement - Spatial vs. Frequency Domain Filters (Due 10/03)
Tasks
- Task 1: In-depth understanding of the Fourier transform
- Task 1.1: Generate a filled white square (at the center of the
image) and display its Fourier transform. You are required to
write a code (square.cpp) that is flexible enough to generate any
size of squares so that you can observe the different
effect. Here are two sample
codes,
testfft.cpp, on how to use
fft() and ifft() and how to do the padding.
- Task 1.2: Generate a vertical line (line.cpp) and display its
Fourier transform. Similar flexibility requirement as Task 1.1,
i.e., you can change the location and width of the line.
- Task 2: Low-pass filters (Spatial-domain
vs. Frequency-domain). Use the square version of the wizardofoz as
the (Test image).
- Task 2.1: Filtering in the spatial domain. Apply a Gaussian
average filter and a median filter to smooth the image. Change the
kernel size from 3x3 to 5x5 and 7x7 and observe the result. Use a
fixed
sigma=1.5. See handout on
how to generate Gaussian average spatial filters of different
size. You need to write a code, as
flexible as possible, to implement the convolution operator
(conv.cpp). Put the functions for both Gaussian average and median
in spatialFilter.cpp.
- Task 2.2: Filtering in the frequency domain. Design a
lowpass frequency filter (try both butterworth and Gaussian) to
smooth the image (choose appropriate radius). Calculate the power
ratio. Put both butterworth and Gaussian functions in freqFilter.cpp
- Task 3: High-pass filters (Spatial-domain
vs. Frequency-domain). Use
the checkerboard
image, where noise has been added, as the test image.
- Task 3.1: Spatial domain filtering: Apply unsharp masking,
Sobel edge detector, and Laplace edge detection in the spatial
domain to highlight the edges in the image. Put all three
functions to spatialFilter.cpp
- Task 3.2: Frequency domain filtering: Design a highpass
frequency (use both butterworth and Gaussian) filter in the
frequency domain to highlight the edges in the image. Add the two
functions to freqFilter.cpp. Calculate the power ratio.
- Task 4: Convolution and correlation in the spatial and the
frequency domain. There are two ways to implement spatial filters. One
is to apply convolution. The other one is through multiplication in
the frequency domain. The latter is more computationally
efficient. This task servers the purpose of showing this. Use
"cameraman" as the testing image.
- Task 4.1: Apply a 5x5 average filter in the spatial
domain.
- Task 4.2: Perform this enhancement in the frequency
domain. Here's sample code for
padding, testfft_pad.cpp. Follow
the following steps:
- pad both the original image and the kernel
- transform both the padded original original image and the kernel
- perform multiplication
- perform inverse transform
- cut the useful content of the transformed image
- Task 4.3 (572 only): Generate the autocorrelation of the test image
using the spatial and the frequency domain methods
respectively. Measure and compare the computation time. (Hint,
if you've written the convolution code in the spatial domain,
autocorrelation is just a convolution with itself)
- Bonus: (+10/+10) Apply the homomorphic
filter to enhance the image (justify gamma_H and gamma_L, as well as
the shape of the filter). Use either the catbone or the dogbone X-ray
image
What to turn in
- a tar file or a zip file with the following items:
- square.cpp, line.cpp
- conv.cpp
- spatialFilter.cpp, freqFilter.cpp
- README
- Makefiles
- (3) Completeness of the above listed files
- a pdf file with the written report that includes the following
- (10 pt) Task 1
- (2/2 pt) Comment on the different Fourier transforms generated from
very small square (say, 1 pixel) to large square (say, side of the
square equals to half of the image size). Need to provide FT
pairs in each case.
- (2/2 pt) Change the location and width of the vertical line and comment
on the difference. Need to provide FT pairs in each case.
- (0/3 pt 572 only) According to the properties of the
Fourier transform, the FT of an impulse should be a white
surface. However, the FT that you generated in a) of an image with
a bright pixel at the center does not in any way looks like a
solid surface. Explain.
- (6/3 pt) Correctness of line.cpp and square.cpp and results from Task 1
-
- (30 pt) Task 2
- (2 pt) Show the Gaussian kernel of 5x5 and 7x7
- (2 pt) Compare the performance between the Gaussian average
and the median filter with different kernel size. Comment on how
the difference in the results is affected by the fact that
Gaussian is a linear filter but median filter is nonlinear.
- (2 pt) Comment on the kind of the relationship between D_0 (in
the frequency domain) and kernel size (in the spatial
domain). Ajust the "D_0" parameter in the frequency filter which
is equivalent to changing the kernel size in the frequency
domain. Pick three D_0 values, better correspond to the three
kernel sizes in the spatial domain.
- (2 pt) Based on Tasks 2.1 and 2.2, do you think by justifying
the parameters, you can generate the same denoising result using the
frequency domain filters as that by the spatial filter? how about
between using the linear filters and nonlinear filters?
- Correctness and flexibility of the code
- (6 pt) Correctness and flexibility of conv.cpp so that it can accept
any size kernel in the spatial domain.
- (8 pt) Correctness and flexibility of Image median(Image,
kernelSize) (5 pts) and Image lpGaussian(Image) (3 pts). You can try
to make Gaussian as flexible as possible by having the kernelsize
parameter but it's not required. Three sets of image outputs using
three different kernels specified above.
- (8 pt) Correctness and flexibility of lpButterworth(D_0, n) and
lpGaussian(D_0, n). Provide three sets of results using three
different kernels corresponding to the kernel size from the spatial domain.
- (30 pt) Task 3 (Similar requirements as Task 2)
- (3 pt) Comment on difference between laplacian and sobel
- (3 pt) Comment on different effects generated by um with different kernel size
- (2 pt) Comment on the different power ratio from the frequency-domain result.
- Correctness and flexibility of the code
- (16 pt) Correctness and flexibility of Image um(Image,
kernelSize), laplacian() - no need for flexible kernel size, sobel() -
no need to change kernel size. Show to different sets of um results
with two kernels. Show results from laplacian and sobel.
- (6 pt) Correctness and flexibility of hpButterworth(D_0, n) and
hpGaussian(D_0, n). Provide two sets of results using three
different kernels corresponding to the kernel size from spatial domain.
- (30 pt) Task 4
- (5) Show results in both the spatial and the frequency domain
- (5) Compare the time spent in both the spatial and the frequency domain
- (5) Show the difference image between time-domain method and
frequency-domain method
- (5) Correctness of implementation in the frequency domain
- (10/0) Do the same by using a 25x25 average kernel and compare
the time spent.
- (0/10) Correctness and time comparison in implementation of
autocorrelation in both the spatial and frequency domain