$24
Image decimation and interpolation: read the given 420x560 gray-scale image – “building.jpg” and store it as a variable xc. Perform the following image processing and see the effects by your own eyes (see also, textbook Fig. 6.36).
Downsampling and linear (i.e., bilinear or bicubic) interpolation: Sample xc by
taking every 5th pixel horizontally and vertically to create a downsampled image x with its size = 84x112. Interpolate x to the size 420x560 to obtain xs. Display images xc, xs, and x and comment on their appearance.
The interpolation can be done with MATLAB function, imresize() with bilinear interpolation or bicubic interpolation or similar MATLAB functions.
Decimation (i.e., antialiasing filtering + downsampling) and linear (i.e., bilinear or bicubic) interpolation: First blur the image xc using an anti-aliasing LPF to obtain
filtered image yc, then sample it by taking every 5th pixel horizontally and vertically to create a downsampled image y of size 84x112, and finally linearly interpolate y to the size 420x560 to obtain ys. Display images yc, ys, and y. Compare their appearance with those in (a) and comment on the antialiasing effects and any other effects if there is any (explained in the class) you observe.
Note that you have to design a proper anti-aliasing filter for the downsampling being performed. You can design the antialiasing filter with the help of the MATLAB function fir1() which provides you the finite impulse response of a 1-D digital filter. Please extend the 1-D filter generated by the fir1() to a 2-D filter by the concept taught in Topic 2 (see slide 100 and slide 101 in Topic2_ReviewOfFreqDomainAnalysis_Part2_HandWriting0406_2017.pdf), and then perform the 2D filtering with MATLAB function conv2().
The frequency response of the designed filter can be verified by the MATLAB function freqz() if needed. Please justify how you design the FIR filter and how you determine the required length of the impulse response of the FIR filter (i.e., how you determine the cutoff frequency and order of the FIR filter. Filter length = filter order + 1.).
Implement your own interpolator, i.e., low pass filtering the upsampled signal. For example, upsample x in (a) and y in (b) to the size 420x560 to obtain xu and yu,
1/2
respectively (see the provided sample codes), and then low pass filter xu and yu to obtain xs and ys, respectively. Please design the 2D anti-image LPF with the help of the MATLAB function fir1(), as you did in (b). Justify how you determine the filter parameters, i.e., cutoff frequency and order for fir1(). Repeat (a) and (b) with your own interpolator, compare and comment on the results.
Interpolate xc to the size 630x840 to obtain xi. Display images xc and xi, and comment on their appearance. Note that no MATLAB interpolation function can be used. Please specify how you implement the interpolation and the specification of your low pass filter as well if there is any.
Please leverage and modify the sample codes provided in HW1 to perform 2D Fourier analysis over xc, xs, yc, ys, and xi. The 2D Fourier analysis simply needs to be done at the fundamental frequency range. You may also try to perform the 2D Fourier analysis over multiple fundamental frequency ranges. Please justify your finding over the 2D Fourier spectra of the 5 images. Via the 2D Fourier analysis, please verify whether aliasing distortion occurs or not for the 5 images, respectively (see also, textbook Fig. 6.34). You may need to perform log-conversion of the magnitude spectrum in order to visualize the changes in details.
Below are some useful MATLAB pseudo-codes:
figure
LogConvertedSpectrum = 20*log10(2D magnitude spectrum/max(max(2D magnitude spectrum)));
imagesc(LogConvertedSpectrum);
shg
colormap(gray); % or try colormap(jet)
Notice:
Please hand in your solution files to the LMS elearning system, including your word file of the detailed solutions, the associated Matlab codes, and all the related materials. It would be nice that you can put your codes with comments side by side along with your answer in the word file.
Name your solution files “EE3660_HW4_StudentID.doc” and “EE3660_HW4_StudentID.m”, and archive them as a single zip file: EE3660_HW4_StudentID.zip.
The first line of your word or Matlab file should contain your name and some brief description, e.g., % EE 3660 王小明 u9612345 HW4 MM/DD/2017
2/2