python选取图像的长和宽的最小值,把图像缩放成长和宽中最小的值

import glob as gb
import cv2




img_path = gb.glob("G:\\ZXWwork\\PYZ\\*\\*.jpg")
for path in img_path:
    img = cv2.imread(path)
    a=img.shape
    height = a[0]
    width = a[1]
    ##true = min(height, width)
    res = cv2.resize(img, (24,24), interpolation=cv2.INTER_CUBIC)
    cv2.imshow('Image', res)
    cv2.imwrite(path, res)
    cv2.waitKey(1000)

你可能感兴趣的:(python)