问题描述
CLAHE 是对比度受限的自适应直方图均衡,C 中的源代码可以在 找到http://tog.acm.org/resources/GraphicsGems/gemsiv/clahe.c
CLAHE is Contrast Limited Adaptive Histogram Equalization and a source in C can be found at http://tog.acm.org/resources/GraphicsGems/gemsiv/clahe.c
到目前为止,我只看到了一些关于在灰度图像上应用 CLAHE 的示例/教程,那么是否可以在彩色图像(例如 RGB 3 通道图像)上应用 CLAHE?如果是,怎么做?
So far I have only seen some examples/tutorials about applying CLAHE on grayscale images so is it possible to apply CLAHE on color images (such as RGB 3 channles images)? If yes, how?
推荐答案
将 RGB 转换为 LAB(L 表示亮度,a 和 b 表示绿色-红色和蓝色-黄色的颜色对手)将完成这项工作.将 CLAHE 应用于 LAB 格式的转换图像,仅适用于亮度分量,并将图像转换回 RGB.这是片段.
Conversion of RGB to LAB(L for lightness and a and b for the color opponents green–red and blue–yellow) will do the work. Apply CLAHE to the converted image in LAB format to only Lightness component and convert back the image to RGB.Here is the snippet.
bgr = cv2.imread(image_path)
lab = cv2.cvtColor(bgr, cv2.COLOR_BGR2LAB)
lab_planes = cv2.split(lab)
clahe = cv2.createCLAHE(clipLimit=2.0,tileGridSize=(gridsize,gridsize))
lab_planes[0] = clahe.apply(lab_planes[0])
lab = cv2.merge(lab_planes)
bgr = cv2.cvtColor(lab, cv2.COLOR_LAB2BGR)
bgr是应用CLAHE后得到的最终RGB图像.
bgr is the final RGB image obtained after applying CLAHE.
这篇关于如何在 RGB 彩色图像上应用 CLAHE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!