赞
踩
目的:实现图像的批量读取、裁剪、写入指定的文件夹
import cv2 import glob i = 0 for jpgfile in glob.glob(r'G:\Image\*.jpg'): image = cv2.imread(jpgfile) print(image.shape) #print(image.shape[0]) #height(rows) of image #print(image.shape[1)) #width(colums) of image #print(image.shape[2]) #the pixels value is made up of three primary colors dst = image[0:175, 0:250] #cutting #cv2,imshow('image', dst) #cv2.waitKey() cv2.imwrite('G:\Image_Cutting\{}.jpg'.format(i), dst) i = i + 1
这段代码参考了很多同学的博客,在这里向他们表示感谢。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。