opencv2对彩色图像直方图均衡化时,利用YUN取出Y通道,单独对Y通道进行均衡(注意img_yuv[:,:,0])

关键步骤:

1、读取图像并转换为YUV色彩空间

img = cv2.imread('test.jpg')
img_yuv = cv2.cvtColor(img, cv2.COLOR_BGR2YUV)

2、获取Y通道,即yuv_img[:, :, 0]并对Y通道进行均衡化处理,

补充:'U channel', yuv_img[:, :, 1])和'V channel', yuv_img[:, :, 2])):

img_yuv[:,:,0] = cv2.equalizeHist(img_yuv[:,:,0])

3、再在转化为RGB,并输出即实现彩色图像直方图均衡化:

img_RGB = cv2.cvtColor(img_yuv, cv2.COLOR_YUV2BGR)

cv2.imshow('Histogram equalized',img_RGB )

你可能感兴趣的:(opencv2对彩色图像直方图均衡化时,利用YUN取出Y通道,单独对Y通道进行均衡(注意img_yuv[:,:,0]))