[SOLVED] CENG391 - Introduction to Image Understanding - Homework 2

30.00 $

Programming resource
Digital learning resource
Category:
✓ Practical programming resource
✓ Suitable for guided study and reference
✓ Tutor guidance available when needed

Description

5/5 - (1 vote)

Exercise 1           2D Image Filtering

  1. 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

  1. 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

  1. 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

with nearest neighbor sampling.

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

Resource details

Understand the Task Before You Use the Resource

Review the requirements, identify the programming concepts involved, study the implementation and test your understanding with your own examples and modifications.