Python+OpenCV:图像对比度受限自适应直方图均衡化(CLAHE, Contrast Limited Adaptive Histogram Equalization)

Python+OpenCV:图像对比度受限自适应直方图均衡化(CLAHE, Contrast Limited Adaptive Histogram Equalization)

####################################################################################################
# 图像对比度受限自适应直方图均衡化(CLAHE, Contrast Limited Adaptive Histogram Equalization)
def lmc_cv_image_clahe():
    """
        函数功能: 图像对比度受限自适应直方图均衡化(CLAHE, Contrast Limited Adaptive Histogram Equalization)。
    """

    stacking_images = []
    # 图像对比度受限自适应直方图均衡化(CLAHE, Contrast Limited Adaptive Histogram Equalization)
    image_file_name = ['D:/99-Research/Python/Image/Photo1.jpg', 'D:/99-Research/Python/Image/Photo2.jpg',
                       'D:/99-Research/Python/Image/Photo3.jpg', 'D:/99-Research/Python/Image/Lena.jpg']
    for i in range(len(image_file_name)):
        # 读取图像
        image = lmc_cv.imread(image_file_name[i])
        image = lmc_cv.cvtColor(image, lmc_cv.COLOR_BGR2GRAY)

        # create a CLAHE object (Arguments are optional).
        clahe = lmc_cv.createCLAHE(clipLimit=2.0, tileGridSize=(8, 8))
        clahe_image = clahe.apply(image)

        # stacking images side-by-side
        stacking_image = np.hstack((image, clahe_image))
        stacking_images.append(stacking_image)

    # 显示图像
    pyplot.figure('CLAHE, Contrast Limited Adaptive Histogram Equalization')
    for i in range(len(stacking_images)):
        pyplot.subplot(2, 2, i + 1)
        pyplot.imshow(stacking_images[i], 'gray')
        pyplot.xticks([])
        pyplot.yticks([])
    pyplot.show()

    # 根据用户输入保存图像
    if ord("q") == (lmc_cv.waitKey(0) & 0xFF):
        # 销毁窗口
        pyplot.close()
    return

你可能感兴趣的:(Python,OpenCV,opencv,python,计算机视觉)