python+opencv实现图像自适应阈值的均衡化
内容涉及:列表遍历,图像均衡化,图像通道分离与合并
import cv2 import numpy as np import os for path in open("org_junheng.txt"): # 遍历目标图片列表 path = path.replace('\n', '') # 去除换行符 img = cv2.imread(path, 1) (b, g, r) = cv2.split(img) # 图像通道分割 clahe = cv2.createCLAHE(clipLimit=2.0,tileGridSize=(8,8)) # 建立均衡化实例 bb = clahe.apply(b) gg = clahe.apply(g) rr = clahe.apply(r) result = cv2.merge((bb, gg, rr)) # 图像通道合并 cv2.imwrite(path, result)