## Description

EE 569 Digital Image Processing: Homework #3

EE 569: Homework #3

General Instructions:

1. Read Homework Guidelines and MATLAB Function Guidelines for the information about homework

programming, write-up and submission.

2. If you make any assumptions about a problem, please clearly state them in your report.

3. You need to understand the USC policy on academic integrity and penalties for cheating and

plagiarism. These rules will be strictly enforced.

In the first two problems, you will apply geometric modification and spatial warping techniques to do

some interesting image processing tricks. During this process, you may need to solve some linear

equations to get the matrix parameters.

Problem 1: Geometric Image Modification (25%)

Design and implement a spatial warping technique that transforms an input square image into an output

image of a disk-shaped image, out of the square image. An example is given in Figure 1.

Figure 1: Warp the original image to disk-shaped image.

The warped image should satisfy the following three requirements:

• Pixels that lie on boundaries of the square should still lie on the boundaries of the circle.

• The center of original images should be mapped to the center of warped images.

• The mapping should be reversible, i.e. it is a one-to-one mapping.

EE 569 Digital Image Processing: Homework #3

Professor C.-C. Jay Kuo Page 2 of 6

Apply the same developed spatial warping algorithm to Dog in basket, Forky and Twenty-two images in

Figure 2.

Figure 2: Dog in basket, Forky, and Twenty-two images.

(1) Describe your approach as clearly as possible and show the resulting images.

(2) Apply the reverse spatial warping to each warped image to recover its original image.

(3) Compare the recovered square image with the original square image. Is there any difference between

two images? If any, explain sources of distortion in detail.

Problem 2: Homographic Transformation and Image Stitching (25%)

One can use homographic transformation and image stitching techniques to create panorama that

consisting of multiple images. One example (Taken from MATLAB examples [1]) is shown in Figure. 3.

The left image were taken with an uncalibrated smart phone camera by sweeping the camera from left to

right along the horizon to capture all parts of the building. The right panorama is the desired output by

stitching transformed images.

Figure 3: An example of image stitching to make panorama [1].

EE 569 Digital Image Processing: Homework #3

Professor C.-C. Jay Kuo Page 3 of 6

This example involves five images to composite. However, the basic principle is to process in

terms of consecutive pair of images. It could be achieved by following these steps:

• Select control points from both images. You can use SIFT/SURF feature detection and FLANN

feature matching to detect control points. You are allowed to use OpenCV source ONLY for

selecting control points, online source refer to [2] and [3].

• Apply homographic transformation to find a homograph mapping (described below).

• Wrap one image onto the other using the estimated transformation.

• Create a new image big enough to hold the panorama and composite the wrapped image into it.

You can composite by simply averaging the pixel values where the two images overlap.

The homographic transformation procedure is stated below. Images of points in a plane, from

two different camera viewpoints, under perspective projection (pin hole camera models) are

related by a homography:

where � is a 3×3 homographic transformation matrix, �% and �” denote the corresponding image

points in homogeneous coordinates before and after the transform, respectively. Specifically, we

have

To estimate matrix H, you can proceed with the following steps:

• Fix �– = 1 so that there are only 8 parameters to be determined.

• Select four point pairs in two images to build eight linear equations.

• Solve the equations to get the 8 parameters of matrix H.

• After you determine matrix H, you can project all points from one image to another by

following the backward mapping procedure and applying the interpolation technique.

Implement above homographic transformation and stitching techniques to composite the room

images in Figure 4. Show the results and make discussion on the following questions.

(1) How many control points were used? Show the corresponding control points between left and

middle pair, middle and right pair.

(2) How did you select control points? Clearly specify how you use matched feature from

SURF/SIFT to create panorama.

EE 569 Digital Image Processing: Homework #3

Professor C.-C. Jay Kuo Page 4 of 6

Figure 4. The lunchroom images (left, middle, right) [4]

Problem 3: Morphological processing (50%)

In this problem, you will implement three morphological processing operations: shrinking, thinning, and

skeletonizing. A pattern table (patterntables.pdf) is attached for your reference. Please show outputs for

all following parts in your report and discuss them thoroughly. Please state any assumptions you make in

your solution.

(a) Basic morphological process implementation (15%)

Please apply the “shrinking”, “thinning”, and “skeletonizing” filters to the pattern images (spring,

flower, jar) below. Show your results, including intermediate processing result and give reasonable

explanation.

Figure 5: spring, flower, jar [5]

EE 569 Digital Image Processing: Homework #3

Professor C.-C. Jay Kuo Page 5 of 6

(b) Solution to the maze (15%)

Please apply morphological processing to find a solution to the maze below. Explain your method.

Figure 6: maze.

(c) Defect detection and count (20%)

A binary image of a horse is shown in Figure 7. The horse image is supposed to be all white; however,

there are black artifacts of different sizes all over the horse. Please apply morphological processing

algorithm for automatic defect count and detection. For each question, please explain your method and

include intermediate results if there are any:

(1) Count the total number of disconnected defects in the image.

(2) How many different defect sizes are present in the image? What is the frequency of these defect

sizes?

(Hint: Plot the histogram of the defect size with respect to frequency. The defect size is the number

of pixels in a defect. Please state any further assumption you take regarding defect size.)

(3) Correct the defects and show the clear horse image.

(4) Other than basic morphological filters, can you think of other method to do question (1) and (2)?

Explain your algorithm clearly and show your result (Hint will be given in discussion section.)

Figure 7: horse with defect [5].

EE 569 Digital Image Processing: Homework #3

Professor C.-C. Jay Kuo Page 6 of 6

Appendix:

Problem 1: Geometric Image Modification

Dog.raw 329×329 24-bit color (RGB)

Forky.raw 329×329 24-bit color (RGB)

22.raw 329×329 24-bit color (RGB)

left.raw 322×483 24-bit color (RGB)

middle.raw 325×487 24-bit color (RGB)

right.raw 325×489 24-bit color (RGB)

Problem 2: Morphological processing

spring.raw 252×252 8-bit greyscale

flower.raw 247×247 8-bit greyscale

jar.raw 252×252 8-bit greyscale

maze.raw 343×343 8-bit greyscale

horse.raw 422×322 8-bit greyscale

Note: “322×483” means “width=322, height=483”.

References

[1] Matlab panorama example: https://www.mathworks.com/help/vision/ug/feature-based-panoramicimage-stitching.html

[2] Matlab SURF Feature detection example:

https://www.mathworks.com/help/vision/ref/detectsurffeatures.html

[2] OPENCV feature matching example:

https://docs.opencv.org/3.4/d5/d6f/tutorial_feature_flann_matcher.html

[3] lunchroom from “PASSTA Datasets”, Cvl.isy.liu.se, 2016.

Available: http://www.cvl.isy.liu.se/en/research/datasets/passta/

[4] MPEG-7 Shape dataset: http://www.dabi.temple.edu/~shape/MPEG7/dataset.html