Python Resize图像

import cv2
import os

path = r"H:\ForestrySafetyPatrolAndWarningSystem\origin"
save_path = r'H:\ForestrySafetyPatrolAndWarningSystem\test2'
# 该文件夹下所有的文件(包括文件夹)
filelist = os.listdir(path)
count = 1
for file in filelist:
    print(file)
for file in filelist:   # 遍历所有文件
    file_path = os.path.join(path, file)   # 原来的文件路径
    im = cv2.imread(file_path)
    #[h,w]根据自己图片中目标的位置修改
    im = im[75:615,10:1280]
    save_path_file = os.path.join(save_path, str(count) + '.jpg')
    cv2.imwrite(save_path_file, im)
    count += 1

你可能感兴趣的:(Python,python,开发语言)