实验目标
- 完成图像的载入和显示
- RGB三通道分离并显示
- RGB三通道均衡化并显示
- 实现锐化
- 实现伽马校正(非线性)
- 实现对比度和亮度校正(线性)
- 色彩空间转化 RGB 2 HSV
- 伪彩色变化
实验效果
亮度对比度调整——线性校正(下图)
伽马校正——非线性校正(下图)
实验代码
# 关于版本
# numpy 1.16.6
# opencv-python 4.2.0.34
import cv2 as cv
import numpy as np
# 导入图像
srcImage = cv.imread('C:\\Users\\MRSANG\\Desktop\\CV_test\\test_1\\1.jpg')
if srcImage is None:
print('Could not open or find the image: ')
exit(0)
else:
print('loading ... successfully')
cv.imshow('origin_win', srcImage)
# rgb三通道分离 并显示
ori_channel_r, ori_channel_g, ori_channel_b = cv.split(srcImage)
cv.imshow("ori_channel_r", ori_channel_r)
cv.imshow("ori_channel_g", ori_channel_g)
cv.imshow("ori_channel_b", ori_channel_b)
# rgb三通道均衡化
equ_channel_r = cv.equalizeHist(ori_channel_r)
equ_channel_g = cv.equalizeHist(ori_channel_g)
equ_channel_b = cv.equalizeHist(ori_channel_b)
equ_Image = cv.merge((equ_channel_r, equ_channel_g, equ_channel_b))
# 均衡化显示
cv