import cv2
for i in range(1,50):#批量处理照片
img = cv2.imread('E:\\opencv_picture\\stairs\\'+str(i)+'.jpg',cv2.IMREAD_GRAYSCALE)#读入照片,并转灰度
img1 = cv2.resize(img,(50,50))#调整大小
cv2.imwrite('E:\\opencv_picture\\stairs_Grayscale\\'+str(i)+'.jpg',img1)#保存图片
print('批量转灰度成功!')