Search for question
Question

Lab 5: Spatial Filter

Objectives: 1. Practice lowpass smoothing filter on a given image. 2. Practice highpass

filter on a given image. 3.Undestand the principle of geometric transformation; 4.

Practice geometric transformation using Matlab command.

A complete lab report including the following:

Summarized learning outcomes.

• Finish Exercises as results.

MATLAB scripts should be reported properly as appendix.

Exercise 1: (1) Research Matlab commands, fspecial, imfilter, filter2.

(2) Read the image testpattern 1024.tif. Use box filter of size 3 by 3, 11 by 11, and 21 by 21 on this

image. Observe the effects. Try different values, choose a box filter which is large enough to blur

the image so that the large letter "a" is barely readable, and the other letters are not.

(3) Read the image testpattern 1024.tif. Use Gaussian filter of size 21 by 21 with o = 3.5, and size

of 43 by 43 with o = 7 on this image. Observe the effects, compare with the results of box filter.

Try different values, choose a gaussian filter which is large enough to blur the image so that the

large letter "a" is barely readable, and the other letters are not.

Exercise 2: (1). Read the image blurry-moon.tif and sharpen it using the Laplacian kernel.

(2). Read the image blurry-moon.tif and sharpen it using unsharp masking. Use a Gaussian

lowpass kernel of your choice for the blurring step. Display your final result.

(3) Improve the sharpness of your result using highboost filtering. Display the final result.

Compare the results with (1) and (2).

Exercise 3: (1) Research Matlab commands, affine2d, imwarp, imrotate, imtranslate, imresize.

(2) Read the image, cameraman.tif. Scale the image in the following different ways. (a) 2 times of

x, 2 times of y. Here x is the horizontal direction (columns), y is the vertical direction (rows); (b)

2 times of x, 0.5 times of y; (c) 0.5 times of x, 1 time of y.

(3) Read the image, cameraman.tif. Rotate the image in 60°, -60°. Compare different interpolation

methods.

(4) Read the image, cameraman.tif. Translate the image to [10 20], [-20 50], [20, -30].

(5) Read the image, cameraman.tif. Choose your own values to create vertical and horizontal shear

effect.

Exercise 4: Based on the principle of affine transformation, write your own function to perform

image translation, translation(image, tx, ty), where image is a grayscale image and tx and ty are

translation factors (they can be any real number: positive, negative, or zero) in the x (horizontal)

and y (vertical) directions. The output image should be of the same size as the input, and its

background is black. Test your function by translating image cameraman.tif by half its height in

the positive vertical direction and by one-fourth of its width in the positive horizontal direction.

Fig: 1