当前位置:   article > 正文

批量局部直方图均衡化_cv2.createclahe (cliplimit = 2.0, tilegridsize=(10

cv2.createclahe (cliplimit = 2.0, tilegridsize=(10, 10))

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

  1. import cv2
  2. import os
  3. path = 'C:\\Users\\guowan\\Desktop\\train'
  4. all = os.walk(path)
  5. for path, dir, filelist in all:
  6. for filename in filelist:
  7. if filename.endswith('.jpg'):
  8. filepath = os.path.join(path, filename)
  9. img = cv2.imread(filepath,1)
  10. img_yuv = cv2.cvtColor(img, cv2.COLOR_BGR2YUV)
  11. calhe = cv2.createCLAHE(clipLimit=2.0,tileGridSize=(10,10))
  12. img_yuv[:,:,0] = calhe.apply(img_yuv[:,:,0])
  13. imgLoaclEhist = cv2.cvtColor(img_yuv,cv2.COLOR_YUV2BGR)
  14. # cv2.imshow('local hist',imgLoaclEhist)
  15. cv2.imwrite(filepath,imgLoaclEhist)
  16. cv2.waitKey(0)

 (^-^)V

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Monodyee/article/detail/78912
推荐阅读
相关标签
  

闽ICP备14008679号