0
点赞
收藏
分享

微信扫一扫

批量局部直方图均衡化

at小涛 2022-03-12 阅读 92

局部直方图均衡化是图像处理的重要部分    下面是代码  大家可以参考

import cv2
import  os

path = 'C:\\Users\\guowan\\Desktop\\train'
all = os.walk(path)
for path, dir, filelist in all:
    for filename in filelist:
        if filename.endswith('.jpg'):
            filepath = os.path.join(path, filename)
            img = cv2.imread(filepath,1)
            img_yuv = cv2.cvtColor(img, cv2.COLOR_BGR2YUV)

            calhe = cv2.createCLAHE(clipLimit=2.0,tileGridSize=(10,10))
            img_yuv[:,:,0] = calhe.apply(img_yuv[:,:,0])
            imgLoaclEhist = cv2.cvtColor(img_yuv,cv2.COLOR_YUV2BGR)
            # cv2.imshow('local hist',imgLoaclEhist)

            cv2.imwrite(filepath,imgLoaclEhist)
            cv2.waitKey(0)

 (^-^)V

举报

相关推荐

0 条评论