Starting from:

$25

CENG391 - Introduction to Image Understanding - Homework 2 - Solved

Download and extract the contents of ceng391 03T  image filtering.tar.gz.

         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

                                                                                                                                              −1     0    1

            the image derivative in the x direction using a filter of the form −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
 
−1 −2

      the image derivative in the y direction using a filter of the form  0                                                                          0

                                                                                                                                             1                                                                                                                                             2

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



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]).

More products