HW3 Image Processing
HW3 Image Processing
Assignment #3
Image Enhancement in Frequency Domain!
1. Fig.1 shows a sinusoidal pattern in the spatial domain (left) and its corresponding representation in the
frequency domain. According to the provided sample and your own knowledge about the Fourier
transform, generate the following sinusoidal patterns by initializing appropriate entries of a square matrix
and applying inverse Fourier transform on it. For each pattern, explain which entries must be manipulated
and where their effects show up. Note that all images are of size 100x100. Name the resultant images as
sin_patt_a.bmp to sin_patt_s.bmp and write them into output directory.
(a)
(b)
(c)
(d)
(e)
(g)
(f)
(h)
(i)
(k)
(j)
(m)
(l)
(o)
(n)
(p)
(r)
(q)
(s)
2 (a). Consider an image that is black except for a single pixel wide stripe from the top left to the bottom
right (Fig.2 top left). Can you explain its Fourier transform (Fig.2 bottom left)? Also, consider an image of
noise, i.e. every pixel has a random value, independent of all other pixels (Fig2. top right). Can you explain
its Fourier transform (Fig.2 bottom right)? What does the bright spot in the middle of the noise Fourier
transform image represent? Why does the Fourier transform of the noise appear dark gray?
Figure 2.
2 (b). Apply the Fourier transform on the following images (Fig.3) and precisely analyze their Fourier
spectra. Justify the relation between the images and their spectra, and provide a comprehensive
analytical report.
Figure 3.
2 (c). Load the images cameraman.bmp and redBloodCell.bmp. Apply Fourier transform on both
images and show the magnitude and phase of them. Swap the respective magnitudes and phase of
the images and apply the inverse Fourier transform to get the corresponding representations in the spatial
domain. What do you see? Explain the role of the magnitude and phase? Name the resultant images as
P2_output_a.bmp and P2_output_b.bmp and write them into the output directory.
Figure 4.
3. Find the Fourier transform of the following function and data by hand. Include sufficient and significant
calculation steps in your report.
a. f x, y sin4 x cos 3 y
c. Apply discrete Fourier transform on the following data. 1,2,3,4 .
d. Apply inverse discrete Fourier Transform on the results of the part b. Explain your observations.
b.
-0.3333
-0.5258
-0.1409
0.3333
0.5258
0.1409
0.3333
0.5258
0.1409
4. In this problem, you are supposed to get familiar with image enhancement in the frequency domain.
Provide well-commented codes and apply zero-padding before any operation, if necessary. You are not
allowed to use built-in MATLAB functions for frequency-based filtering in this problem.
a. Implement Ideal, Butterfly and Gaussian low-pass filters in the frequency domain. Verify your code
on taxiDriver.bmp for different values of the frequency cutoffs and filter-specific parameters, and
include some of them in your report. Do you see any ringing effect? For which method and for what
frequency cutoffs? Why? Provide a comprehensive comparison of qualitative performance between
all three methods. Using different settings of parameters, name the best result of each method as
TaxiDriver_ILPF_best.bmp, TaxiDriver_BLPF_best.bmp and TaxiDriver_GLPF_best.bmp respectively,
and save them into the output directory.
b. Apply Gaussian mean filter on the provided input image in the spatial domain. Change the
parameters to get the best performance and compare the best resultant image with those of methods
in part a (the best results) in terms of qualitative performance and runtime execution. Include the results
in your report.
c. Implement Ideal, Butterfly and Gaussian high-pass filters in the frequency domain. Verify your code
on ball.bmp for different values of filter-specific parameters and include some of them in your report.
Provide a comprehensive comparison of qualitative performance between all three methods. Using
different settings of parameters, name the best results of each method as ball_IHPF_best.bmp,
ball_BHPF_best.bmp and ball_GHPF_best.bmp respectively, and save them into the output
directory.
d. Write a program to apply unsharp masking in the frequency domain and verify your code on the
image moon.bmp. Name the resultant image as moon_unsharp.bmp and write it. Explain your
observations.
e. Load the image DIP.bmp and write a MATLAB program to generate the image in Fig.5 (right-side)
by employing the Fourier transform concepts. Name the resultant image as P4_DIP_output.bmp and
write it into the output directory. Explain the rationale behind the scheme you employ to generate the
desired output.
Figure 5.
5. If you have an image that suffers from variable illumination (dark in some sections, light in others), we
may wish to enhance the contrast locally and, in particular, to enhance the darker regions. You are
provided with an interesting image weird_moon.bmp which suffers from this kind of problem -certain
well-illuminated regions, and other regions in shadow that are dark. Well, obviously this is a very weird
looking moon!
a. Load the image weird_moon.bmp and write a program to perform homomorphic filtering on
this image, using a slightly-modified form of Gaussian High Pass Filter:
H u, v H L 1 e cD u ,v
D02
where constant c controls the steepness of slope, and L and H are the low gain and high gain
values (preferably L < 1 and H > 1 for better results). = D0 is assumed. Name the resultant
image as weird_moon_homomorph.bmp and write it into the output directory. Explain your
observations.
6. Frequency filters are quite useful when processing parts of an image which can be associated with
certain frequencies. The image house.bmp shows an image in which any part of the house is made of
stripes of a different frequency and orientation.
a. Computer the Fourier transform of the image and show it in your report. Explain the
correspondences between the spatial characteristics and main peaks in frequency domain.
b. we can smooth the vertical stripes (i.e. those components which make up the wall in the spatial
domain image) by multiplying the Fourier image with a frequency mask. In so doing, we can exploit
the provided mask mask_ver.bmp. Perform this task and include the result in your report. Explain
why the provided mask is appropriate for such a task. Repeat the preceding scheme for at least two
other components of the house and include the results in your report (design appropriate masks on
your own knowledge)
Figure 6.
c. Frequency filtering can also be used for pattern matching. Load the images text.bmp and
A.bmp, and write a MATLAB program to find the location of all the letters A in the provided text
image using the frequency domain concepts. Name the resultant image as A_detected.bmp and
A_detected_bin.bmp and write them into the output folder. Explain all what youve done and the
rationale behind the key steps of your algorithm. Describe the correspondence between pattern
matching in the frequency domain and spatial domain.
Tip: conj function (MATLAB built-in function) may be useful in this problem.
Figure 7.
7. (Optional-Extra Credit). Study the following paper which shows an example of applicability of Fourier
transform for high-level tasks in Image Processing and Computer Vision. Explain the pipeline of the
algorithm and implement it in MATLAB. Feed some arbitrary input images into your implemented code
(except those used in the reference paper) and include the best results in your report.
Hou, Xiaodi, and Liqing Zhang. "Saliency detection: A spectral residual approach."
Computer Vision and Pattern Recognition, 2007. CVPR'07. IEEE Conference on. IEEE, 2007.
APA
Good Luck,
Saeed Izadi