OpenCV is the huge open-source library for computer vision, machine learning, and image processing and now it plays a major role in real-time operation which is very important in today’s systems. By using it, one can process images and videos to identify objects, faces, or even the handwriting of a human. When it integrated with various libraries, such as Numpuy, Python is capable of processing the OpenCV array structure for analysis.
Note: For more information, refer to OpenCV Python Tutorial
In Affine transformation, all parallel lines in the original image will still be parallel in the output image. To find the transformation matrix, we need three points from input image and their corresponding locations in the output image. Then cv2.getAffineTransform will create a 2×3 matrix which is to be passed to cv2.warpAffine.
Syntax: cv2.getPerspectiveTransform(src, dst)
src: Coordinates of quadrangle vertices in the source image.
dst: Coordinates of the corresponding quadrangle vertices in the destination image.
Syntax: cv2.warpAffine(src, M, dsize, dst, flags, borderMode, borderValue)
src: input image.
dst: output image that has the size dsize and the same type as src.
M: transformation matrix.
dsize: size of the output image.
flags: combination of interpolation methods (see resize() ) and the optional flag
WARP_INVERSE_MAP that means that M is the inverse transformation (dst->src).
borderMode: pixel extrapolation method; when borderMode=BORDER_TRANSPARENT, it means that the pixels in the destination image corresponding to the “outliers” in the source image are not modified by the function.
borderValue: value used in case of a constant border; by default, it is 0.
- Wand affine distort() function in Python
- Negative transformation of an image using Python and OpenCV
- Perspective Transformation - Python OpenCV
- Log transformation of an image using Python and OpenCV
- OpenCV - Facial Landmarks and Face Detection using dlib and OpenCV
- Transition from OpenCV 2 to OpenCV 3.x
- Python | Number Theoretic Transformation
- Python | Fast Fourier Transformation
- Python | Intensity Transformation Operations on Images
- Python | Inverse Fast Walsh Hadamard Transformation
- Python | Inverse Number Theoretic Transformation
- Python | Inverse Fast Fourier Transformation
- Box-Cox Transformation using Python
- NLP | Chunk Tree to Text and Chaining Chunk Transformation
- Piece-wise Linear Transformation
- OpenCV Python Program to blur an image
- Cartooning an Image using OpenCV - Python
- Opencv Python program for Face Detection
- Real-Time Edge Detection using OpenCV in Python | Canny edge detection method
- OpenCV Python Program to analyze an image using Histogram
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.