Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Use the functions you defined in the Problem 2 to construct a single matrix which performs the following sequence of transformations ( in order )

Use the functions you defined in the Problem 2 to construct a single matrix which performs the following sequence of transformations (in order) when acting on an image.
Stretch the image vertically by a factor of 2.
Rotate the image pi/4 radians clockwise.
Reflect the image over the line 2y=-3x .
Stretch the image horizontally by a factor of 1/2.
save the resulting 2x2 matrix as comp_matrix.
Funcitons defined in problem 2:
# This function should take a matrix of coordinates, and output a matrix which corresponds to the image that has been stetched in the
# horizantal direction by a factor of a and in the verticle direction by a factor of b.
def stretch(image, a, b):
A = np.array([[a,0],
[0, b]])
return np.dot(A, image)
# This function should take a matrix of coordinates, and output a matrix which corresponds to the image that has been sheared by a horizantal factor of a and
# a vertical factor of b
def shear(image, a, b):
A = np.array([[1, a],
[b,1]])
return np.dot(A, image)
# This function should take a matrix of coordinates, and output a matrix which corresponds to the image that has been reflected in the
# line spanned by the vector [a,b]^T
def reflect(image, a, b):
A = np.array([[a**2- b**2,2*a*b],
[2*a*b, b**2- a**2]])/(a**2+ b**2)
return np.dot(A, image)
# This function should take a matrix of coordinates, and output a matrix which corresponds to the image that has been rotated in the
# counterclockwise direction by an angle of theta radians.
def rotate(image, theta):
A = np.array([[np.cos(theta),-np.sin(theta)],
[np.sin(theta), np.cos(theta)]])
return np.dot(A, image)

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 Processing

Authors: David Kroenke

11th Edition

0132302675, 9780132302678

More Books

Students also viewed these Databases questions

Question

16.8 Explain the typical steps in a grievance procedure.

Answered: 1 week ago

Question

16.4 Outline the five steps in the labour relations process.

Answered: 1 week ago