Resizing and Cropping

Resize

import cv2
import numpy as np

img = cv2.imread("Resources/woman.jpg")
print(img.shape)

imgResize = cv2.resize(img, (300, 300))
print(imgResize.shape)

cv2.imshow("Woman", img)
cv2.imshow("Image resized", imgResize)
cv2.waitKey(0)

In OpenCV function widht comes first, then height.

Cropping

imgCropped = img[0:200, 200:500]
cv2.imshow("Image Cropped", imgCropped)

Last updated