Crop operation in OpenCV is very simple. You should first read the image. Then the values x, y, h, w must be determined to specify the region to be cropped. You can do this using the code below.
import cv2
image = cv2.imread('image.jpg')
y=10
x=20
h=200
w=250
crop = image[y:y+h, x:x+w]
cv2.imshow('Image', crop)
cv2.waitKey(0)

Comments
Post a Comment