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

该博客介绍了如何使用Python和OpenCV库进行对比度受限自适应直方图均衡化(CLAHE)处理,以提升图像的对比度。代码示例展示了对多张图片应用CLAHE的过程,并展示处理前后的对比效果。用户还可以选择保存处理后的图像。

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值