图像过曝或曝光不足时需要曝光处理,
这里以曝光不足举例。
直方图均衡法:
通过RGB通道的直方图均衡达到处理曝光不足的效果。
代码:
underexpose = cv2.imread("exposure_test.jpg")
#underexpose = cv2.cvtColor(underexpose, cv2.COLOR_BGR2RGB)
equalizeUnder = np.zeros(underexpose.shape, underexpose.dtype)
equalizeUnder[:, :, 0] = cv2.equalizeHist(underexpose[:, :, 0])
equalizeUnder[:, :, 1] = cv2.equalizeHist(underexpose[:, :, 1])
equalizeUnder[:, :, 2] = cv2.equalizeHist(underexpose[:, :, 2])
cv2.imshow(equalizeUnder)
CNN方法
Learning Multi-Scale Photo Exposure Correction(CVPR2021)
paper
python版github地址
按github配置环境,下载weight.
with torch.no_grad():
MSPEC_net = MSPEC_Net().cuda()
MSPEC_net =torch.nn.DataParallel(MSPEC_net)
MSPEC_net.load_state_dict(torch.load('./snapshots/MSPECnet_woadv.pth'))
MSPEC_net.eval()
data_input = cv2.imread('test.jpg')
output_image = down_correction(MSPEC_net,data_input) #在mspect_test.py中
if output_image.dtype == 'uint8':
cv2.imwrite( "output.jpg",output_image)
else:
cv2.imwrite( "output.jpg",output_image*255)