PIL:
from PIL import Image
img = Image.open('test.jpg')
img.crop(50,60,170,150) # (left, upper, right, lower)
img.save('img_cro.jpg')
opencv:
import cv2
img = cv2.imread('test.jpg')
img_crop = img[60:150, 50:170] # 裁剪坐标为[y0:y1, x0:x1]
cv2.imwrite('img_crop.jpg')
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)