import cv2 as cv
import os
import numpy as np
# def cut_photo(norm_img,cut_img): #把cut_img裁成和norm_img形状相同的图片
# H,W,*_ = norm_img.shape
def cut_photo(H, W, cut_img): # 设置输出固定形状的图片
H, W = H, W
h, w, *c = cut_img.shape
size = 1 if [] == c else 3 # c是空c=1,其它c=3
if H / h < W / w:
img2 = cv.resize(cut_img, (int(w * (H / h))
用python将图片裁剪为固定大小
最新推荐文章于 2024-06-24 00:16:35 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)