Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!