python常用代码记录24位转8位

# 8位
# 读取整个bacepath文件夹下的文件并且转换为8位保存到savepath
# import os
# import cv2
# bacepath = "./VOCdevkit/VOC2007/SegmentationClass/"
# savepath = './VOCdevkit/VOC2007/1/'

# f_n  = os.listdir(bacepath)
# print(f_n)
# for n in f_n:
#     imdir = bacepath + n
#     print(n)
#     img = cv2.imread(imdir)
 
#     cropped = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
#     cv2.imwrite(savepath + n, cropped)#NOT CAHNGE THE TYPE
# print('finish')

你可能感兴趣的:(python,opencv,计算机视觉)