OpenCV-Python系列·第十五集-2:直方图均衡化(彩色图像)

Tip:将颜色空间BGR转换到YUV。再单独作用Y通道即可均衡化彩色图像.

# -*- coding: utf-8 -*-
"""
Created on Sat Aug 25 16:47:44 2018

@author: Miracle
"""

import cv2

image = cv2.imread('../data/lena.jpg')
image_yuv = cv2.cvtColor(image,cv2.COLOR_BGR2YUV)
#直方图均衡化
image_yuv[:,:,0] = cv2.equalizeHist(image_yuv[:,:,0])
#显示效果
output = cv2.cvtColor(image_yuv,cv2.COLOR_YUV2BGR)
cv2.imshow('HistEqualize',output)
cv2.imshow('Original Image',image)
#停顿
if cv2.waitKey() & 0xFF == 27:
    cv2.destroyAllWindows()

OpenCV-Python系列·第十五集-2:直方图均衡化(彩色图像)_第1张图片

你可能感兴趣的:(OpenCV-Python)