当前位置: 代码迷 >> 综合 >> 图像3通道检测-Python
  详细解决方案

图像3通道检测-Python

热度:42   发布时间:2024-03-06 06:15:49.0

基于python的图像3通道检测,使用openCV-cv2实现,运行结果输出非3通道图片路径。

import os
import numpy as np
import cv2if __name__ == '__main__':root_dir = r'D:\...'label = []label_an = []name = root_dir.split('\\')[-1]file_names = sorted(os.listdir(root_dir))for file in file_names:if file.endswith('.png'):img = cv2.imdecode(np.fromfile(os.path.join(root_dir, file), dtype=np.uint8), -1)size = img.shapeif size[2] != 3:print("通道"+ str(size[2]) + file)# os.remove(file)

 

  相关解决方案