Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

2.8 Affine transformations. If interpolation is needed, use nearest-neighbor interpolation. See Table 2.3 for the definition of the constants and the direc- tions of coordinate

image text in transcribed

image text in transcribed

2.8 Affine transformations. If interpolation is needed, use nearest-neighbor interpolation. See Table 2.3 for the definition of the constants and the direc- tions of coordinate axes. (a)* Write a function g=image Translate4e(f,tx,ty, mode) for performing image translation, where f is a grayscale image and tx and ty are translation factors (they can be any real number: positive, negative, or zero) in the x (vertical) and y (horizontal) directions. The output image should be of the same size as the input, and its background in the area vacated by the trans- lated image is to be determined by mode. If mode = 'black', the background should be black (this is the default if mode is not included in the function call). If mode = 'white', the back- ground should be white. Test your function by translating image girl.tif by half its height in the positive vertical direction and by one- fourth of its width in the positive horizontal direction. Test both values of mode. (c) Write a function g = imageShear4e(f,sv,sh), where sv and sh are vertical and horizontal scalar shearing factors that can be any real numbers. Output g must be of the same size as f. The background of the sheared image should be black. (Hint: Combine the two shearing matrices into one composite shear- ing matrix.) Test your function by shearing image girl.tif using the following combination of values for (sv, sh): (0.5,0), (0, -0.75), and (0.5, -0.75). Transformation Name Affine Matrix, A Coordinate Equations TABLE 2.3 Affine transformations based on Eq. (2-45) Identity 1 0 0 X'= x y' = y 0 1 0 0 0 1 C 0 0 x' = cx y' =cy Scaling/Reflection (For reflection, set one scaling factor to - 1 and the other to 0) 0 0 0 0 1 0 Rotation (about the origin) cos 8-sin sin cose x' = x cos 0 - y sin e y' = xsin + y cose 0 0 0 1 Translation [104 0 1 LO 0 x' = x+1 y' =y+1, Shear (vertical) $ 0 1 LO0 0 0 x' = x+s,y y' = y 1 Shear (horizontal) 0 0 1 X'= x y' = 5 x + y 0 0 2.8 Affine transformations. If interpolation is needed, use nearest-neighbor interpolation. See Table 2.3 for the definition of the constants and the direc- tions of coordinate axes. (a)* Write a function g=image Translate4e(f,tx,ty, mode) for performing image translation, where f is a grayscale image and tx and ty are translation factors (they can be any real number: positive, negative, or zero) in the x (vertical) and y (horizontal) directions. The output image should be of the same size as the input, and its background in the area vacated by the trans- lated image is to be determined by mode. If mode = 'black', the background should be black (this is the default if mode is not included in the function call). If mode = 'white', the back- ground should be white. Test your function by translating image girl.tif by half its height in the positive vertical direction and by one- fourth of its width in the positive horizontal direction. Test both values of mode. (c) Write a function g = imageShear4e(f,sv,sh), where sv and sh are vertical and horizontal scalar shearing factors that can be any real numbers. Output g must be of the same size as f. The background of the sheared image should be black. (Hint: Combine the two shearing matrices into one composite shear- ing matrix.) Test your function by shearing image girl.tif using the following combination of values for (sv, sh): (0.5,0), (0, -0.75), and (0.5, -0.75). Transformation Name Affine Matrix, A Coordinate Equations TABLE 2.3 Affine transformations based on Eq. (2-45) Identity 1 0 0 X'= x y' = y 0 1 0 0 0 1 C 0 0 x' = cx y' =cy Scaling/Reflection (For reflection, set one scaling factor to - 1 and the other to 0) 0 0 0 0 1 0 Rotation (about the origin) cos 8-sin sin cose x' = x cos 0 - y sin e y' = xsin + y cose 0 0 0 1 Translation [104 0 1 LO 0 x' = x+1 y' =y+1, Shear (vertical) $ 0 1 LO0 0 0 x' = x+s,y y' = y 1 Shear (horizontal) 0 0 1 X'= x y' = 5 x + y 0 0

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems Design Implementation And Management

Authors: Peter Robb,Carlos Coronel

5th Edition

061906269X, 9780619062699

More Books

Students also viewed these Databases questions