Image scaling
Image scaling is used to modify the dimensions of the input image based on requirements. Three types of scaling operators are commonly used in OpenCV, and they are cubic, area, and linear interpolations.
How to do it...
- Create a new Python file and import the following packages:
# Scaling (Resizing) Images - Cubic, Area, Linear Interpolations # Interpolation is a method of estimating values between known data points # Import Computer Vision package - cv2 import cv2 # Import Numerical Python package - numpy as np import numpy as np
- Read the image using the built-in
imread
function:
image = cv2.imread('image_3.jpg')
- Display the original image using the built-in
imshow
function:
cv2.imshow("Original", image)
- Wait until any key is pressed:
cv2.waitKey()
- Adjust the image size based on the operator's command:
# cv2.resize(image, output image size, x scale, y scale, interpolation)
- Adjust the image size using cubic interpolation:
# Scaling using cubic interpolation scaling_cubic = cv2...