Question

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.

Question image 1