Image Shearing in Y-Axis
When shearing is done in the y-axis direction, the boundaries of the image that are parallel to the y-axis keep their location, and the edges parallel to the x-axis change their place depending on the shearing factor.
M = np.float32([[1, 0, 0], [0.5, 1, 0], [0, 0, 1]]) sheared_img = cv.warpPerspective(img, M, (int(cols*1.5), int(rows*1.5)))
Python3
import numpy as np import cv2 as cv img = cv.imread( 'girlImage.jpg' , 0 ) rows, cols = img.shape M = np.float32([[ 1 , 0 , 0 ], [ 0.5 , 1 , 0 ], [ 0 , 0 , 1 ]]) sheared_img = cv.warpPerspective(img, M, ( int (cols * 1.5 ), int (rows * 1.5 ))) cv.imshow( 'sheared_y-axis_out.jpg' , sheared_img) cv.waitKey( 0 ) cv.destroyAllWindows() |
Output:
Image Transformations using OpenCV in Python
In this tutorial, we are going to learn Image Transformation using the OpenCV module in Python.
Contact Us