- Hands-On Image Processing with Python
- Sandipan Dey
- 111字
- 2025-02-22 06:42:34
Inverse warping and geometric transformation using the warp() function
The scikit-image transform module's warp() function can be used for inverse warping for the geometric transformation of an image (discussed in a previous section), as demonstrated in the following examples.
Applying an Affine transformation on an image
We can use the SimilarityTransform() function to compute the transformation matrix, followed by warp() function, to carry out the transformation, as shown in the next code block:
im = imread("../images/parrot.png")
tform = SimilarityTransform(scale=0.9, rotation=np.pi/4,translation=(im.shape[0]/2, -100))
warped = warp(im, tform)
import matplotlib.pyplot as plt
plt.imshow(warped), plt.axis('off'), plt.show()
The following figure shows the output image generated by running the previous code snippet:
