﻿ 基于色彩平衡及校正的水下图像增强算法
 舰船科学技术  2021, Vol. 43 Issue (11): 154-159    DOI: 10.3404/j.issn.1672-7649.2021.11.029 PDF

Underwater image enhancement based on color balance and correction
WANG Zi-cheng, YIN Yong
Key Laboratory of Marine Simulation and Control, Dalian Maritime University, Dalian 116026, China
Abstract: Aiming at the problems of color deviation, blur, imbalance and abnormal illumination in some underwater environments, an underwater image enhancement algorithm based on color balance and correction is proposed. Firstly, the underwater image or video use automatic white balance algorithm to balance the color and tone problems. Then, the single-scale Retinex algorithm and CLAHE algorithm are used to remove the haze problem and enhance the contrast in underwater environment. Then, the adaptive gamma correction algorithm is used to adjust the brightness of R, G, B three channels. Finally, the R, G, B channels are fused to get the enhanced underwater image or video. Experimental results show that the algorithm has the visual characteristics suitable for human, and has relatively high image evaluation coefficients. The algorithm has good adaptability, effectively improves the color deviation and blur of the image, and improves the underwater image or video quality significantly.
Key words: underwater image enhancement     automatic white balance     retinex     CLAHE     adaptive power-law transformation
0 引　言

1 基于色彩平衡及校正的水下图像增强算法 1.1 自动白平衡算法

1)求取R，G，B三通道均值

 $\left[\begin{array}{c}{R}_{ave}\\ {G}_{ave}\\ {B}_{ave}\end{array}\right]=\left[\begin{array}{c}\displaystyle\frac{1}{M\times N}\sum _{i=0}^{M-1}\sum _{j=0}^{N-1}{f}_{R}(i,j)\\ \displaystyle\frac{1}{M\times N}\sum _{i=0}^{M-1}\sum _{j=0}^{N-1}{f}_{G}(i,j)\\ \displaystyle\frac{1}{M\times N}\sum _{i=0}^{M-1}\sum _{j=0}^{N-1}{f}_{B}(i,j)\end{array}\right] \text{。}$ (1)

2)求取图像灰度均值

 $K=\frac{1}{3}({R}_{ave}+{G}_{ave}+{B}_{ave})\text{。}$ (2)

3)求取三通道增益系数

 ${K}=\frac{1}{3}({{R}}_{{ave}}+{{G}}_{{ave}}+{{B}}_{{ave}}) \left[\begin{array}{c}{{K}}_{{r}}\\ {{K}}_{{g}}\\ {{K}}_{{b}}\end{array}\right]=\left[\begin{array}{c}\displaystyle\frac{{K}}{{{R}}_{{ave}}}\\ \displaystyle\frac{{K}}{{{G}}_{{ave}}}\\ \displaystyle\frac{{K}}{{{B}}_{{ave}}}\end{array}\right] \text{。}$ (3)

4)自动白平衡结果

 ${\left[\begin{array}{c}R\\ G\\ B\end{array}\right]}_{result}=\left[\begin{array}{ccc}{K}_{r}& 0& 0\\ 0& {K}_{g}& 0\\ 0& 0& {K}_{b}\end{array}\right]{\left[\begin{array}{c}R\\ G\\ B\end{array}\right]}_{original}\text{。}$ (4)
1.2 Retinex水下图像增强算法

E.Land以人类视觉的亮度和颜色感知模型，提出了一种颜色恒常知觉的计算理论-Retinex理论（视网膜大脑皮层理论）。在水下环境中，根据Retinex算法原理，水下被观测物体周围的光线和被观测物体对于周围光线的反射，决定了水下光学成像系统对于水下被观测物体的观测效果。图像采集设备采集到的图像与视频信息，经过自动白平衡算法预处理后，由Retinex算法进行增强。该过程利用数学模型表述如下：

 $I\left(x,y\right)=L\left(x,y\right)\times R\left(x,y\right)\text{，}$ (5)

1）将环境光照射分量与携带图像细节信息的目标物体的反射分量分离，故对该式两端取对数，一方面利于将乘法运算换算为减法运算，利于计算机进行处理；另一方面也可对图像中具有灰度值低的区域进行扩展拉伸, 进而补偿低曝光现象，即

 $\mathrm{log}\left[I\left(x,y\right)\right]=\mathrm{log}\left[L\left(x,y\right)\right]+\mathrm{log}\left[R\left(x,y\right)\right]\text{，}$ (6)

 $\mathrm{log}\left[R\left(x,y\right)\right]=\mathrm{log}\left[I(x,y)\right]-\mathrm{l}\mathrm{o}\mathrm{g}\left[L\right(x,y\left)\right]\text{。}$ (7)

2）利用二维高斯模板对原图像做卷积运算，二维高斯模板函数，即

 $G\left(x,y\right)=\frac{1}{2\text{π} {\sigma }^{2}}{e}^{-\frac{({x}^{2}+{y}^{2})}{2{\sigma }^{2}}} \text{，}$ (8)

 ${I}_{lowpass}\left(x,y\right)=I\left(x,y\right)*G(x,y) \text{。}$ (9)

3）在对数域，用原图像I(x,y)减去低通滤波后的图像，即可得到保留有高频分量的图像，即

 ${I}_{high-frequency}\left(x,y\right)=\mathrm{log}\left[I\left(x,y\right)\right]-\mathrm{log}\left[{I}_{lowpass}\left(x,y\right)\right]\text{。}$ (10)

4）对保留有高频分量的图像取反对数，即可得到R(x,y)，即

 $R\left(x,y\right)={e}^{{I}_{high-frequency}\left(x,y\right)}\text{。}$ (11)

5）对R(x,y)做对比度限制自适应直方图均衡(Contrast Limited Adaptive Histogram Equalization , CLAHE)[7]，即可得到经过Retinex算法增强后的水下图像或视频。

1.3 RGB通道自适应幂律校正

γ校正最早用于阴极射线显像管（Cathode Ray Tube , CRT）显示器，可使图像看起来符合人眼特征。γ对应不同值对应的曲线如图1所示，矩形窗在局部像素块中平移示意图如图2所示。

 图 1 γ对应不同值对应的曲线 Fig. 1 γ Curves corresponding to different values

 图 2 矩形窗在局部像素块中平移示意图 Fig. 2 Schematic diagram of translation of rectangular window in local pixel block

 $\mu \left(x,y\right)=\frac{1}{{s}^{2}}\left[\sum _{j=y-\frac{s}{2}}^{y+\frac{s}{2}}\left(\sum _{i=x-\frac{s}{2}}^{x+\frac{s}{2}}f(i,j)\right)\right] \text{。}$ (12)

 $\gamma ={\left(\frac{1}{\alpha }\right)}^{\left(\frac{128-\mu \left(x,y\right)}{128}\right)} \text{，}$ (13)
 $E\left(x,y\right)=255{\left(\frac{f(x,y)}{255}\right)}^{\gamma } \text{。}$ (14)

1.4 算法流程

1)采集图像或视频信息

 图 3 原始水下图像 Fig. 3 Original underwater image

2)自动白平衡算法

 图 4 经步骤2处理后R，G，B三通道图 Fig. 4 Three channel diagram of R, G and B after processing in step 2

 图 5 经步骤2处理后图像 Fig. 5 Image after processing in step 2

3)Retinex算法与CLAHE

 图 6 经步骤3处理后R，G，B三通道图 Fig. 6 Three channel diagram of R, G and B after processing in step 3

 图 7 经步骤3处理后图像 Fig. 7 Image after processing in step 3

4) 自适应幂律校正

 图 8 经步骤4处理后R，G，B三通道图 Fig. 8 Three channel diagram of R, G and B after processing in step 4

 图 9 经本文算法增强后的水下图像增强图 Fig. 9 Underwater image enhancement image enhanced by this algorithm

 图 10 基于色彩平衡及校正的水下图像增强算法流程图 Fig. 10 Flow chart of underwater image enhancement algorithm based on color balance and correction
2 实验过程、结果与分析

 图 11 结果1 Fig. 11 Result 1

 图 12 结果2 Fig. 12 Result 2

 图 13 结果3 Fig. 13 Result 3

 图 14 结果4 Fig. 14 Result 4

 图 15 结果5 Fig. 15 Result 5

1）由基于信息熵的清晰度评价函数Entropy的图像增强效果评价系数基本保持不变可以看出，本文提出的水下图像增强算法在图像增强处理前后图像信息保真度良好；

2）由基于平均梯度强度的图像增强效果评价系数可以看出，按平均梯度强度系数，本文算法>CLAHE>DCP>MSRCR>SSR>原图像，经过图像增强处理后的算法，图像细节、图像纹理特征、图像清晰度、图像层次相较于图像增强处理前的水下图像具有更好的视觉特性；

3）由对比度对比系数可以看出，本文算法在图像对比度上具有较高的提升，图像整体对于人类视觉角度而言更好。

3 结　语

 [1] 张薇, 郭继昌. 基于白平衡和相对全变分的低照度水下图像增强[J/OL]. 激光与光电子学进展: 1−15 [2] 王红茹, 张弓, 卢道华, 等. 基于背景光估计和颜色修正的水下图像增强[J/OL]. 计算机工程: 1−9[2020-08-18]. [3] 杨福豪, 史启超, 蓝方鸣, 等. 基于色彩衰减补偿和Retinex的水下图像增强[J]. 宁波大学学报(理工版), 2020, 33(1): 58-64. [4] Ahmad Shahrizan Abdul Ghani. Image contrast enhancement using an integration of recursive-overlapped contrast limited adaptive histogram specification and dual-image wavelet fusion for the high visibility of deep underwater image[J]. Ocean Engineering, 2018, 162. [5] 朱振杰, 王红茹. 基于暗原色先验原理的水下图像增强[J]. 图学学报, 2018, 39(3): 453-462. [6] 邹立, 卢俊彦, 胡易, 等. 非均匀光照条件下的水下图像增强算法[J]. 山东科技大学学报(自然科学版), 2020, 39(2): 118-125. [7] REZA A. Realization of the contrast limited adaptive histogram equalization (CLAHE) for real-time image enhancement[J]. Journal of VLST Signal Processing, 2004, 38(1): 35-44. DOI:10.1023/B:VLSI.0000028532.53893.82 [8] NICOLAS L., LISANI J-L, MOREL J-M, et al.. Simplest color balance[J]. Image Processing On Line, 2011, 1: 297-315. DOI:10.5201/ipol.2011.llmps-scb