Problem #1: DFT and DCT on images (50%+10%)
In this homework, we want to analyze the energy distributions of different types of images. A zip pack of the four images used for experiments can be downloaded here.
(a) [25%] First, convert the input M-by-N color image to the grayscale format. Plot the 2-D log magnitude of the 2D DFT and DCT of the grayscale image, with center shifted. Visually compare and comment on the similarity/differences among the images using the two transforms.
(b) [25%] Apply the truncation windows discussed in the class
to
keep 25% and 6.25% (1/4 and 1/16) of the DFT and DCT coefficients, i.e.
two differen ratios for each transform. This truncation is done by
keeping the coefficients of the lowest frequencies (those within a
centered smaller rectangle of (M/2)x(N/2) and (M/4)x(N/4) on the
shifted FFT, respectively). Apply the 2D inverse DFT to reconstruct the
image for each of the truncated spectra. Compute the
Signal-to-Noise-Ratio (SNR) value for each of the reconstructed images.
Plot the reconstructed images visually examine and comment on the
effects of truncation.
(d) [10% bonus] Discuss the differences between these two types of images, optionally extend or validate what you've observed here with new images of your own, i.e., natural photos vs. diagrams.
banboon | monkeyking** |
sunflower* | hexagon |
* from
http://www.flickr.com/photos/suneko/208994078/, reused with the
creative commons license.
** from
http://www.js.xinhuanet.com/zhuanlan/2005-05/19/content_4256139_3.htm,
cartoon production by Shanghai Animation Studio 1961
Problem #2 KL Transform and Faces (50%+10%)
Download the Rice ELEC301 eigen face database from here.
Align a 25x30 face images by stretching it out as a 750x1 facial vector and model it as a random vector (e.g, x = x(:); in matlab). Note that you will use the 80 images in the "train_25x30" folder to learn the eigen faces, and the "original" folder containts images in their original resolutions (250x300) for your viewing pleasure and posting on the report if needed.
(1) [25%] Use the 80 observations of such vector to construct a 1-D K-L transform on facial vectors, and implement the transform using Matlab. Include in the HW submission snipnets of your source code for doing 1-D K-L transform. This can be a function or a short code segment, with some matlab comments explaining which step does what.
(2) [25%] Each new basis vector can be converted back to a 25x30 matrix known as an “Eigen Face”. Find the
eigen faces corresponding to the 20 largest eigen values in K-L
transform. Find the associated 20 projection coefficients and compare
these coefficients for the six images taken on two subjects in the "prediction" subfolder. Discuss your
observations.
(3) [10% bonus] Take a digital picture of your own(**), tightly crop
and resize your face to 25x30 (imcrop, imresize in matlab if you don't
have a image editor) and save the face as a separate grayscale image.
Use the above-mentioned 20 coefficients and the corresponding basis
vectors to reconstruct your own facial image. Compute the MSE
(mean-squared-error) of the difference between the original and the
reconstructed images, plot them in the HW submission and visually
compare.
Hint: potentially useful Matlab functions –
“eig”, “cov”,
“reshape”, …
(**) you can also use any picture (under suitable permissions, e.g.
http://www.flickr.com/creativecommons/by-2.0/tags/) with at least one
upright frontal face of size 25x30.
(***) another possible dataset is a pre-processed version of the Yale
face database from this
link, it contains 15 frontal faces from different people. you can also play with eigen faces extracted from here
and see how well it models your face compared to the Rice dataset.