April 2020
Intermediate to advanced
438 pages
12h 2m
English
Perform the following steps to apply an affine transformation to an image using the scipy.ndimage module functions:
img = rgb2gray(imread('images/humming.png'))w, h = img.shape
mat_identity = np.array([[1,0,0],[0,1,0],[0,0,1]])img1 = ndi.affine_transform(img, mat_identity)
mat_reflect = np.array([[1,0,0],[0,-1,0],[0,0,1]]) @ np.array([[1,0,0],[0,1,-h],[0,0,1]])img1 = ndi.affine_transform(img, mat_reflect) # offset=(0,h)
s_x, s_y = 0.75, 1.25mat_scale = np.array([[s_x,0,0],[0,s_y,0],[0,0,1]]) ...
Read now
Unlock full access