Sale!

CENG 391 – Introduction to Image Understanding Homework 2

$30.00 $18.00

Category: You will Instantly receive a download link for .zip solution file upon Payment || To Order Original Work Click Custom Order?

Description

5/5 - (1 vote)

Exercise 1 2D Image Filtering

a. Write a new member function Image::filter 2d that takes an odd
integer n, and an n × n single-precision floating point matrix K. The
function should return a new image that is of size
(w() − n + 1) × (h() − n + 1)
and filtered by the kernel K.

Hint: If n is even you may take n as the largest odd number smaller than
n. Make sure to clamp the filter results to the range [0, 255]. The size of the
output is smaller so that you do not need to worry about the image borders.

Exercise 2 Image Derivatives

a. Write a new member function Image::deriv x that takes computes
the image derivative in the x direction using a filter of the form


−1 0 1
−2 0 2
−1 0 1

.
The results should be returned in a newly allocated array of type short
which can store negative values.

b. Write a new member function Image::deriv y that takes computes
the image derivative in the y direction using a filter of the form


−1 −2 −1
0 0 0
1 2 1

.

The results should be returned in a newly allocated array of type short
which can store negative values.
1

Exercise 3 Geometric Transforms

a. Write a new member function Image::warp affine that takes a twoby-two transform matrix A and a two-by-one translation vector t,
and an Image pointer out. After the function call finishes the image pointed by out should contain the result of applying the affine
transform
x
0 = Ax + t =

a11 a12
a21 a22
x +

t1
t2

with nearest neighbor sampling.

b. Add an option to perform bilinear sampling to the function Image::warp affine.
Hint: You must not change the size of the image out. Assume that the
matrix and vector entries are stored in the double-precision floating point
format and the matrix is stored in the column major order (Its entries are
stored in memory in the order [a11, a21, a12, a22]).
2