-
暗通道先验理论是在大气散射模型的基础上提出的。在计算机视觉领域,用于描述大气光散射的物理模型[12]为:
$$I(x) = J(x)t(x) + A(1 - t(x))$$ (1) 式中:
$I(x)$ 为输入有雾图像;$J(x)$ 为输出无雾图像;$t(x)$ 为透射率;$A$ 为全局大气光值,在同一幅图像中$A$ 通常是一个常量。He等提出的暗通道先验理论认为,对于绝大多数无雾图像的非高亮区域,在
$\{ r,g,b\} $ 颜色通道内,至少有一个通道的像素值是趋于0。则有:$${J^{dark}}(x) = \mathop {\min }\limits_{y \in \Omega (x)} (\mathop {\min }\limits_{c \in \{ r,g,b\} } {J^c}(y)) \to 0$$ (2) 式中:
${J^{dark}}(x)$ 为暗通道图像;${J^c}(y)$ 为无雾图像中某个颜色分量;$\Omega (x)$ 是以像素点$x$ 为中心的邻域。在公式(1)等号左右两边均取最小值滤波,得到:
$$\begin{split} & \mathop {\min }\limits_{y \in \Omega (x)} (\mathop {\min }\limits_{c \in \{ r,g,b\} } {I^c}(y) =\\ & \mathop {\min }\limits_{y \in \Omega (x)} (\mathop {\min }\limits_{c \in \{ r,g,b\} } {J^c}(y)t(x)) + A(1 - t(x)) \\ \end{split} $$ (3) 将公式(2)代入公式(3)得到透射率
$t(x)$ 的计算公式为:$$t(x) = 1 - \omega \dfrac{{{I^{dark}}(x)}}{A}$$ (4) 式中:
${I^{dark}}(x) = \mathop {\min }\limits_{y \in \Omega (x)} (\mathop {\min }\limits_{c \in \{ r,g,b\} } {I^c}(y))$ ;$\omega $ 为自适应常数($0 < $ $ \omega \leqslant 1$ )。结合公式(1)得到重建后的图像:$$J(x) = \frac{{I(x) - A}}{{t(x)}} + A$$ (5) 由公式(5)可知,透射率
$t(x)$ 的取值是影响重建后图像$J(x)$ 的关键。传统的暗通道去雾算法是基于无雾图像的统计规律计算
$t(x)$ 值,会产生以下2个问题:当图像中出现诸如天空等高亮区域时,由于高亮区域不符合暗通道先验的假设条件,会导致处理后图像在天空区域产生失真[13];当图像数据中出现跳变的区域时,对跳变区域进行最小值滤波,会导致图像部分细节信息缺失,从而形成块效应。 -
由于暗通道去雾算法常用于有RGB三颜色通道的彩色图像去雾,而红外图像是只有灰度信息的单通道图像,为了能够使用暗通道理论进行红外图像清晰化,对暗通道先验的假设条件进行了修正,将公式(2)改写为:
$${J^{dark}}(x) = \mathop {\min }\limits_{y \in \Omega (x)} (J(y)) \to 0$$ (6) 此时对公式(1)等号左右两边最小化得到:
$$ \mathop {\min }\limits_{y \in \Omega (x)} (I(y)) = \mathop {\min }\limits_{y \in \Omega (x)} (J(y)t(x)) + A(1 - t(x)) $$ (7) 为了减少或消除暗通道先验理论产生的块效应以及高亮区域的颜色失真,首先将公式(7)修正如下:
$$f(x) = \mathop {\min }\limits_{y \in \Omega (x)} (J(y)t(x)) + A(1 - t(x))$$ (8) 式中:
$f(x) = \mathop g\limits_{y \in \Omega (x)} (I(y))$ ,即采用输入的原始红外图像数据和其邻域数据进行非线性滤波,代替暗通道图像数据,避免在图像高亮区域所获的暗通道值过低。在公式(6)和(8)的基础上可以获得透射率$t(x)$ 的值为:$$t(x) = 1 - \omega \frac{{f(x)}}{A}$$ (9) 为了能够直观的看出所提算法的合理性,将所提算法获取的暗通道图像与He算法相比较,如图1所示。可以看出,He算法由于最小值滤波的影响在图像边缘处丢失了部分细节信息,如图1(b)方框所示。而所提算法在和邻域数据进行非线性滤波后,相比He算法有更加自然的灰度分布和更丰富的特征信息,如图1(c)方框所示。
-
由于天空等高亮区域不符合暗通道先验的假设条件,导致在这些区域计算的透射率值偏小,造成了颜色失真。根据公式(5),假设
$t(x) = t(x + 1)$ ,则有:$$\begin{split} &J(x + 1) - J(x) = \\ & \dfrac{{I(x + 1) - A}}{{t(x + 1)}} + A - \left( {\dfrac{{I(x) - A}}{{t(x)}} + A} \right) = \\ & \dfrac{{I(x + 1) - I(x)}}{{t(x)}} \\ \end{split} $$ (10) 由公式(10)可知处理后图像相邻像素值之差相比原始像素差值放大了
$1/t(x)$ 倍,当$I(x)$ 较大、$t(x)$ 较小时,图像数据相邻像素点即使相差很小,重建后的灰度值也会被放大。这就导致在图像数据发生跳变的时候,形成块效应,影响图像视觉效果。因此采用非线性函数
$h(x)$ 对$t(x)$ 的值进行修正得到修正后的透射率${t_1}(x)$ ,达到改善块效应的目的:$${t_1}(x) = h(x)t(x)$$ (11) 图2为修正前透射率与灰度级之间的关系,图3为修正后透射率与灰度级之间的关系。可以看出在灰度值较高的范围内,图3对
$t(x)$ 值做了约束,使其不再趋于0,而是一个逐渐增大的值,以减少或消除图像高亮区域对透射率的影响。在输入灰度级为0~255范围内,将透射率修正后的值放入16×16的查找表中,一方面可以得到优化后的精准透射率值,另一方面可以将查找表数据添加至硬件语言中,使得硬件算法能够直接获得优化后透射率值,从而降低硬件算法的运算量,更加有利于算法的硬件实现。
-
在充分考虑硬件资源的配置,取暗通道像素值为原始红外图像数据3*3窗口内滤波数据的平均值,取全局大气光值为当前灰度图像的最大值。改进算法的流程如下:
步骤1 对输入灰度图像数据取3×3窗口滤波数据的平均值作为暗通道像素值
$f(x)$ 。步骤2 在输入灰度级为0~255范围内,结合公式(9)和(11)对应灰度级计算出256个修正后
${1 / {t(x)}}$ 的值(存${1 / {t(x)}}$ 值是为了避免在硬件语言中使用除法器,以提高FPGA的运算速度),由此生成一个16×16的透射率查找表Tx_table。步骤3 利用暗通道图像数据的每一个像素值定位找出查找表中相应的透射率值
${{\rm{1}} / {t(x)}}$ = Tx_table[f(x)]。步骤4 取
$\omega $ 系数值为0.95,根据公式(5)计算出重建后灰度图像数据输出。选取有天空等高亮区域的图像验证所提算法的处理效果,结果如图4所示。在图4(b)中,由于暗通道像素取值过低以及透射率
$t(x)$ 采用定值的影响,He算法容易造成天空区域失真以及在图像边缘处产生块效应。图4(c)是在加入软抠图后,块效应得到改善,天空区域仍偏色严重。所提算法采用输入图像的滤波数据代替暗通道图像数据,并且在灰度级为0~255范围内对透射率值进行修正,解决了天空区域颜色失真的问题,处理后的图像过渡平滑、自然清晰。 -
对算法进行验证时,选取型号为XC7A100T的Xilinx ARTIX-7系列的FPGA芯片。在ISE14.7平台上,采用Synplify工具综合后,最高工作频率为188 MHz (如表1所示),远远超过了红外相机的工作频率27 MHz,因此所设计的红外图像清晰化硬件系统满足实时处理视频图像的需求。从表2可以看出所提算法综合后FPGA的资源占用情况,其中Block RAMs占用率为6%,Slice Registers占用率为1%,LUT占用率为4%,硬件资源利用率较少,这就大大降低了设计成本。
表 1 时钟周期
Table 1. Timing summary
Parameter Value Minimum period/ns 5.307 Maximum frequency/MHz 188.43 表 2 硬件实现方案比较
Table 2. Comparison of implementation results of the proposed work with the existing works
Logic utilization Ref.[14] Ref.[15] Proposed hardware algorithm Slice LUTs 307 of 28800 (1%) 6119 of 39600 (15%) 2678 of 63400 (4%) Block RAMs 16 of 60 (26%) 40% 9 of 135 (6%) I/O cells 82 of 480 (17%) * 24 of 285 (8%) Slice registers 493 of 28800 (1%) * 2257 of 126800 (1%) Time period/ms 0.9057 0.3 0.1185 将所提算法的硬件实现方案在逻辑资源占用、时钟周期等方面与其他方案做了对比分析,如表2所示。参考文献[14]通过对红外图像灰度值乘以一个比例因子达到图像增强的目的,所处理的数据量较少,占用了较少的LUT和寄存器资源。参考文献[15]提出使用导向滤波器进行红外图像增强方案需要计算多幅图像的均值和方差,因此LUT和内存资源消耗过多。所提算法将软件算法生成的透射率查找表添加至硬件语言中,使得硬件系统避免了复杂的求取透射率值的计算,占用了最少的RAM和I/O资源和较少的LUT资源。并且,所提算法在硬件测试时使用了最短的时间,更加适合实时的处理视频图像。
-
软件算法实验平台为Intel Core(TM) i7-7700, 3.6 GHz CPU, 内存8 GB,软件平台为Dev-C++5.11。软件算法所使用的图片由红外相机拍摄之后经图像采集卡捕获得到。
为验证所提算法在红外图像清晰化方面的有效性和可行性,将所得结果(包括软、硬件算法结果)与参考文献[3]中的自适应平台直方图均衡化算法、He算法进行对比分析。并从主客观角度对图像质量进行评价。
图7是一组具有丰富细节信息的近景图像,其中图7(a)为非制冷长波红外相机采集的原始红外图像,可以看出图中目标和背景的差别较小,边缘特征模糊。He算法处理后的图像存在块效应,在加入软抠图后,块效应得到改善,但仍存在图像整体偏暗的情况,分别如图7(b)和7(d)所示。Wan算法利用自适应平台直方图均衡化来进行增强,平衡了图像整体的灰度,但是没有突出更多的细节特征。图7(e)和7(f)分别为改进算法软、硬件处理后的红外图像,可以看出算法突出了目标景物的细节信息,如近处树叶的纹理特征、远处墙体的轮廓特征都得到增强,图像整体对比度提高。
图8是一组包含天空区域图像,可以看出所提算法在天空区域有较好的处理效果,这是因为对暗通道图像数据进行了非线性滤波以及修正透射率后的结果,而且硬件算法处理后的图像效果逼近软件算法。He算法在加入软抠图后,整体处理效果较优,但是在天空区域存在偏暗的情况。Wan算法在处理此类图像时,由于自适应参数选取较简单,导致图像处理效果不明显。
为了更加全面的判断图像质量,采用常见的客观评价指标进行验证。可见边对比度能够体现处理前后图像细节的清晰化程度[16],新增的可见边之比可以表示为:
$$e = \frac{{{n_r} - {n_o}}}{{{n_o}}}$$ (12) 式中:
${n_o}$ 为处理前图像中可见边的数目;${n_r}$ 为清晰化后图像中可见边的数目。$e$ 值越大,表明处理后图像有更多的边缘可见,则图像更清晰。峰值信噪比(Peak Signal to Noise Ratio, PSNR)是衡量图像是否失真的指标,其定义为:$${\rm{PSNR}} = 20{\log _{10}}\left(\dfrac{{255}}{{{\rm{MSE}}}}\right)$$ (13) 式中:MSE为图像的均方误差。一幅图像的PSNR值越高,表明图像的质量越好[17]。调用Matlab2019自带的PSNR函数,并添加一幅加噪图像测试改进算法处理后图像效果。从表3可以看出,所提算法处理后的图像相比其他的算法有更高的PSNR的值,
$e$ 值也不弱于其他算法,并且硬件算法处理后图像的PSNR和$e$ 的值均接近软件算法。因此,所提算法在丰富图像细节信息方面更具优势。表 3 红外图像不同算法处理定量评价结果
Table 3. Infrared image quantitative evaluation result of different algorithm processing
Image 1 Image 2 e PSNR e PSNR Original infrared image 0 22.7104 0 22.6584 He algorithm with block effect 2.1031 20.8784 4.7996 20.3565 Wan algorithm 0.0412 22.5418 0.1318 22.4613 He algorithm after soft mapping 2.0449 21.0164 3.8656 20.4240 Proposed software algorithm 2.6203 22.3909 3.3664 22.6171 Proposed hardware algorithm 1.1272 22.1199 2.0592 22.4859
Infrared image clarifying and FPGA implementation based on dark channel prior
-
摘要: 针对红外图像普遍存在目标与背景对比度低、细节模糊等问题,提出一种改进的基于暗通道先验理论的红外图像清晰化算法,并在FPGA平台加以设计实现。该算法通过对输入图像当前像素和邻域的数据进行非线性滤波得到暗通道图像数据,并利用修正函数对透射率进行优化生成透射率查找表。在此基础上,根据暗通道像素值在查找表中查找透射率,并结合大气光散射模型进行图像清晰化处理,从而减少或消除传统暗通道算法产生的块效应及天空等高亮区域的颜色失真。结果表明,处理后的红外图像细节特征丰富、明亮度适宜。所提算法基于FPGA硬件实现仅占用4%的LUT和8%的I/O资源,工作频率最高达188 MHz,远远高于所使用的红外相机工作频率27 MHz,能够满足实时处理视频图像的需求。Abstract: In order to solve the problem of low contrast between the target and the background and blurred details in infrared images, an improved infrared image clearing algorithm based on dark channel prior theory was proposed and FPGA was used to design the hardware system of the proposed algorithm. The dark channel image was obtained based on nonlinear filtering of the current pixel and the neighborhood data of the input image. Moreover, the correction function was used to optimize the transmission to generate a look_up table. Then the transmission was looked up in the look_up table and the proposed algorithm enhanced the image with the atmospheric scattering model, thereby reducing or eliminating the block effects and the color distortion of the sky or other bright areas generated by the traditional dark channel algorithm. The design of FPGA hardware could work with an estimated frequency of 188 MHz by occupying only 4% of LUT and 8% of I/O resources, which was much higher than the operating frequency of 27 MHz of the camera used. Therefore, the design was realized to meet the requirements of real-time application of video images.
-
Key words:
- infrared image /
- dark channel prior /
- transmission /
- FPGA
-
表 1 时钟周期
Table 1. Timing summary
Parameter Value Minimum period/ns 5.307 Maximum frequency/MHz 188.43 表 2 硬件实现方案比较
Table 2. Comparison of implementation results of the proposed work with the existing works
Logic utilization Ref.[14] Ref.[15] Proposed hardware algorithm Slice LUTs 307 of 28800 (1%) 6119 of 39600 (15%) 2678 of 63400 (4%) Block RAMs 16 of 60 (26%) 40% 9 of 135 (6%) I/O cells 82 of 480 (17%) * 24 of 285 (8%) Slice registers 493 of 28800 (1%) * 2257 of 126800 (1%) Time period/ms 0.9057 0.3 0.1185 表 3 红外图像不同算法处理定量评价结果
Table 3. Infrared image quantitative evaluation result of different algorithm processing
Image 1 Image 2 e PSNR e PSNR Original infrared image 0 22.7104 0 22.6584 He algorithm with block effect 2.1031 20.8784 4.7996 20.3565 Wan algorithm 0.0412 22.5418 0.1318 22.4613 He algorithm after soft mapping 2.0449 21.0164 3.8656 20.4240 Proposed software algorithm 2.6203 22.3909 3.3664 22.6171 Proposed hardware algorithm 1.1272 22.1199 2.0592 22.4859 -
[1] Ding Chang, Dong Lili, Xu Wenhai. Enhancement technique for infrared scene with maritime target [J]. Acta Optica Sinica, 2018, 38(6): 122-130. (in Chinese) [2] Zhu Qingfeng, Zhang Rui, Zhu Wenqing, et al. SWIR image enhancement based on wavelet transform and pairwise target contrast [J]. Semiconductor Optoelectronics, 2019, 40(5): 688-693. [3] Wan Minjie, Gu Guohua, Qian Weixian, et al. Infrared image enhancement using adaptive histogram partition and brightness correction [J]. Remote Sens, 2018, 10, 682: 1-34. [4] Cao Haijie, Liu Ning, Xu Ji, et al. Infrared image adaptive inverse histogram enhancement technology [J]. Infrared and Laser Engineering, 2020, 49(04): 0426003. (in Chinese) doi: 10.3788/IRLA202049.0426003 [5] Chen zheng. Design and implementation of infrared image detail enhancement algorithm based on FPGA [J]. Laser & Infrared, 2018, 48(7): 925-929. (in Chinese) [6] Li Yi, Zhang Yunfeng, Geng Aihui, et al. Infrared image enhancement based on atmospheric scattering model and histogram equalization [J]. Optics & Laser Technology, 2016, 83: 99-107. [7] He K M, Sun J, Tang X O. Single image haze removal using dark channel prior[C]//Computer Vision and Pattern Recognition, 2009, CVPR 2009. IEEE Conference on. IEEE, 2009: 1956-1963. [8] Yang Yan, Wang Zhiwei. Image restoration algorithm based on compensated transmission and adaptive haze concentration coefficient [J]. Journal on Communications, 2020, 41(1): 66-75. [9] Chia-Chi Tsai, Cheng-Yen Lin, Jiun-In Guo. Dark channel prior based video dehazing algorithm with sky preservation and its embedded system realization for ADAS applications [J]. Optics Express, 2019, 27(9): 11877-11901. doi: 10.1364/OE.27.011877 [10] Yuan Xiaoyan, Zhang Zhaofeng, Gu Zhenfei, et al. An infrared image enhancement method based on the atmospheric scattering model [J]. Chinese Journal of Electron Devices, 2019, 42(1): 147-156. (in Chinese) [11] Li Yi, Zhang Yunfeng, Zhang Qiang, et al. Infrared image contrast enhancement based on haze remove method [J]. Chinese Journal of Lasers, 2015, 42(1): 0113004. (in Chinese) doi: 10.3788/CJL201542.0113004 [12] Narasimhan S G, Nayar S K. Vision and the atmosphere [J]. International Journal of Computer Vision, 2002, 48(3): 233-254. doi: 10.1023/A:1016328200723 [13] Shi Zhenwei, Long Jiao, Tang Wei, et al. Single image dehazing in inhomogeneous atmosphere [J]. Optik, 2014, 125(15): 3868-3875. doi: 10.1016/j.ijleo.2014.01.170 [14] Memon F, Jameel F, Arif M, et al. Model based FPGA design of histogram equalization [J]. Sindh Univ Res Jour, 2016, 48(2): 435-440. [15] Liu Bin, Zhao Jianzhang, Kong Xiangxin, et al. HDR infrared image detail enhancement method based on the FPGA [J]. Acta Metrologica Sinica, 2018, 39(4): 493-497. (in Chinese) [16] Hautiere N, Tarel J P, Aubert D, et al. Blind contrast enhancement assessment by gradient ratioing at visible edges [J]. Image Analysis and Stereology Journal, 2008, 27(2): 87-95. [17] Li Fangzhou, Zhao Yaohong, Xiang Wei, et al. Infrared image mixed noise removal method based on improved NL-means [J]. Infrared and Laser Engineering, 2019, 48(S1): 169-179. (in Chinese) doi: 10.3788/IRLA201948.S128001