Question
In python Example Code: Affine Transformation The Rotation operator multiplied the vector representing the coordinate by a matrix The affine transformation is quite similar but
In python
Example Code:
Affine Transformation
The Rotation operator multiplied the vector representing the coordinate by a matrix
The affine transformation is quite similar but the user defines the matrix
The example below creates a matrix mat that is altered from the rotation matrix, and the affine_transform function is then called that maps the coordinates according to this prescription
%matplotlib inline import matplotlib.pyplot as plt import imageio import scipy.ndimage as nd import numpy as np
def AffineExample(data): theta = 11 * np.pi/180 # 11 degrees in radians mat = np.array([[np.cos(theta), -np.sin(theta)], [np.sin(theta/4), np.cos(theta)]]) data2 = nd.affine_transform(data, mat) return data2
url = 'https://raw.githubusercontent.com/joefoxva1/CDS468/master/Lecture2_3_4/bird_js.jpg' adata = imageio.imread(url, as_gray=1)
plt.title('Original Image') plt.imshow(adata, cmap='gray') plt.show()
mg2 = AffineExample(adata)
plt.title('Affine Image') plt.imshow(mg2, cmap='gray') plt.show()
Create an image with an affine transformation of 45 degrees and 90 degrees. Explain the 90 degree resultStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started