<div data-v-9084f7ac="" data-element="root" class="am-engine" data-selection-="%7B%22path%22%3A%5B%5B243%2C1%2C1%2C0%2C9%5D%2C%5B243%2C1%2C1%2C0%2C9%5D%5D%2C%22uuid%22%3A%22%22%2C%22active%22%3Atrue%7D"><blockquote data-id="bb9e798ec-34094513999df1fd7fc59" style="margin-top: 5px; margin-bottom: 5px; padding-left: 1em; margin-left: 0px; border-left: 3px solid rgb(238, 238, 238); opacity: 0.6;">摘要:详细介绍图像去雾算法,经过图像增强后的图像也能应用于目标检测、图像分类或物联网检测等领域,并且效果更好。</blockquote><p data-id="p54dc77fe-34095975880757e2ce923" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><br></p><p data-id="peafa0b28-34094513999289810e725" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;">本文分享自华为云社区《​<a href="https://bbs.huaweicloud.com/blogs/302935?utm_source=51cto&utm_medium=bbs-ex&utm_campaign=other&utm_content=content" target="_blank">​图像预处理之图像去雾详解​</a>​》,作者: eastmount。</p><h2 style="line-height: 1.5;" id="h301ae07a-34094513999ac9452c123" data-id="h301ae07a-34094513999ac9452c123"><strong>一.图像去雾</strong></h2><p data-id="peafa0b28-34094513999411c5980da" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;">随着社会的发展,环境污染逐渐加剧,越来越多的城市频繁出现雾霾,这不仅给人们的身体健康带来危害,还给那些依赖图像信息的计算机视觉系统造成了不良影响,因为在雾天采集到的图像对比度和饱和度均较低,颜色易发生偏移与失真等。因此,寻找一种简单有效的图像去雾方法,对计算机视觉的后续研究至关重要。</p><p data-id="peafa0b28-34096040525f28e638c53" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><br></p><p data-id="peafa0b28-3409451399902c478ab83" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;">该部分主要从下列几篇论文摘取对图像去雾算法进行普及,引用及参考中文论文:</p><ul data-id="ub57b5d59-34094513999524728ed66"><li data-id="le74fd7c4-34094513999553c208e06">魏红伟, 等. 图像去雾算法研究综述[J]. 软件导刊, 2021.</li><li data-id="le74fd7c4-34094513999af41e2f2ac">王道累, 等. 图像去雾算法的综述及分析[J]. 图学学报, 2021.</li><li data-id="le74fd7c4-340945139991a911bb4c6">​<a href="https://blog.csdn.net/Eastmount/article/details/114706950" target="_blank">​OpenCV图像增强万字详解(直方图均衡化、局部直方图均衡化、自动色彩均衡化)- Eastmount​</a>​</li></ul><p data-id="p62a2a324-34096062309a61713743c" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><br></p><p data-id="peafa0b28-34094514000a571d88cd5" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;">图像增强(Image Enhancement)是指按照某种特定的需求,突出图像中有用的信息,去除或者削弱无用的信息。图像增强的目的是使处理后的图像更适合人眼的视觉特性或易于机器识别。 在医学成像、遥感成像、人物摄影等领域,图像增强技术都有着广泛的应用。图像增强同时可以作为目标识别、目标跟踪、特征点匹配、图像融合、超分辨率重构等图像处理算法的预处理算法。</p><p data-id="peafa0b28-34096063487de1d0438d6" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><br></p><p data-id="peafa0b28-340945140003957d55be5" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><img src="https://s4.51cto.com/images/blog/202110/13110935_61664def40d3154291.jpg" alt="" title="" style="visibility: visible; width: 654px; height: 243px;"></p><p data-id="p6045d4b2-340960654703115eef677" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><br></p><p data-id="peafa0b28-340945140005e3db70e97" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;">近些年来,出现了众多的单幅图像去雾算法,应用比较广泛的有:</p><ul data-id="ub57b5d59-3409451400020897baef5"><li data-id="le74fd7c4-34094514000ed2ecd5403">直方图均衡化去雾算法</li><li data-id="le74fd7c4-3409451400051558521bb">Retinex去雾算法</li><li data-id="le74fd7c4-34094514000c7417ec824">暗通道先验去雾算法</li><li data-id="le74fd7c4-340945140006418623bc3">基于卷积神经网络的DehazeNet去雾算法</li></ul><p data-id="pbfa4d11e-340960669197ba969d8c3" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><br></p><p data-id="peafa0b28-34094514000286fac899d" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;">其主要可以分为 3 类:基于图像增强的去雾算法、基于图像复原的去雾算法和基于 CNN 的去雾算法。</p><h3 style="line-height: 1.5;" id="he5f05f26-340945140007d1a5d4795" data-id="he5f05f26-340945140007d1a5d4795"><strong>(1) 基于图像增强的去雾算法</strong></h3><p data-id="peafa0b28-340945140005c7664462b" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;">通过图像增强技术突出图像细节,提升对比度,使之看起来更加清晰,这类算法的适用性较广。具体的算法有:</p><p data-id="peafa0b28-340960702403edef1bdae" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><br></p><ul data-id="ub57b5d59-34094514000953e0bf2ea"><li data-id="le74fd7c4-340945140002e0dad6e40">Retinex 算法<br>根据成像原理,消除了反射分量的影响,达到了图像增强去雾的效果</li><li data-id="le74fd7c4-340945140007605352113">直方图均衡化算法<br>使图像的像素分布更加均匀,放大了图像的细节</li><li data-id="le74fd7c4-340945140003cdfa6037b">偏微分方程算法<br>将图像视作一个偏微分方程,通过计算梯度场提高对比度</li><li data-id="le74fd7c4-3409451400052ab2a6437">小波变换算法<br>对图像进行分解,放大有用的部分</li></ul><p data-id="p9e609acb-3409607180080d191d68c" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><br></p><p data-id="peafa0b28-340945140007e51472f86" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;">此外,在这类算法的基础上出现了众多的基于图像增强原理的改进算法。</p><p data-id="peafa0b28-340960727713c496be01a" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><br></p><p data-id="peafa0b28-34094514000b47d2a1ae0" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><img src="https://s4.51cto.com/images/blog/202110/13110935_61664def3180022540.jpg" alt="" title="" style="visibility: visible; width: 654px; height: 491px;"></p><h3 style="line-height: 1.5;" id="he5f05f26-34094514000874c1049e2" data-id="he5f05f26-34094514000874c1049e2"><strong>(2) 基于图像复原的去雾算法</strong></h3><p data-id="peafa0b28-34094514000ab4478e541" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;">主要是基于大气散射物理学模型,通过对大量有雾图像和无雾图像进行观察总结,得到其中存在的一些映射关系,然后根据有雾图像的形成过程来进行逆运算,从而恢复清晰图像。其中最经典的要属何恺明大佬提出的:</p><p data-id="peafa0b28-340960773681e7cf931a3" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><br></p><ul data-id="ub57b5d59-34094514000d29f24c9ca"><li data-id="le74fd7c4-340945140004419bdaf12">暗通道先验去雾算法<br>通过对大量无雾图像进行特征分析,找到了无雾图像与大气散射模型中某些参数的先验关系。该算法复杂度低,去雾效果好,因此在其基础上出现了大量基于暗通道先验的改进算法。</li></ul><p data-id="peafa0b28-340960791890519378967" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><br></p><p data-id="peafa0b28-34094514000ed6c4740d4" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><img src="https://s4.51cto.com/images/blog/202110/13110935_61664def2f87956468.jpg" alt="" title="" style="visibility: visible; width: 593px; height: 592px;"></p><h3 style="line-height: 1.5;" id="he5f05f26-34094514000a4442b8bcf" data-id="he5f05f26-34094514000a4442b8bcf"><strong>(3) 基于CNN的去雾算法</strong></h3><p data-id="peafa0b28-3409451400019a42f73a7" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;">使用 CNN 建立一个端到端的模型,通过有雾图像恢复出无雾图像,目前使用神经网络进行去雾的算法主要有两种思路:</p><ul data-id="ub57b5d59-340945140008a5ecfced1"><li data-id="le74fd7c4-3409451400034a74fa529">使用 CNN 生成大气散射模型的某些参数,然后再根据大气散射模型来恢复无雾图像</li><li data-id="le74fd7c4-340945140008df803aefd">使用 CNN (例如 GAN)直接根据模糊图像生成无雾的清晰图像</li></ul><p data-id="pb2ed2a3f-34096084657dd67351ccf" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><br></p><p data-id="peafa0b28-340945140004eb3a1bca3" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;">CNN 因其强大的学习能力在多个领域得到应用,因此也出现了采用 CNN 进行去雾的算法。2016年CAI等首次提出了一种名为DehazeNet的去雾网络,用于估计有雾图像的透射率。DehazeNet 将有雾的模糊图像作为输入,输出其透射率,基于大气散射模型理论恢复出无雾的清晰图像。</p><p data-id="peafa0b28-340960855191ea8148613" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><br></p><p data-id="peafa0b28-340945140003cf8934588" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><img src="https://s4.51cto.com/images/blog/202110/13110935_61664def2e9a496042.jpg" alt="" title="" style="visibility: visible; width: 654px; height: 183px;"></p><p data-id="pc95c63ac-340960872200c6584d6a5" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><br></p><p data-id="peafa0b28-340945140006ecd8fc45b" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;">下图是分别对直方图均衡化、暗通道先验去雾、DehazeNet和AOD-Net去雾算法进行测试,实验结果如图所示。由图可知,基于图像增强的直方图均衡化算法的去雾图像对比度明显增强,由于不考虑降质原因,在增加对比度的同时也对噪声进行了放大,出现细节丢失与色彩偏差现象。基于物理模型的暗通道去雾算法、基于神经网络的 DehazeNet 和 AOD-Net 算法的去雾效果较直方图均衡化算法更佳。</p><p data-id="peafa0b28-34096088186d72cd0a6bc" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><br></p><p data-id="peafa0b28-34094514000f44f95197e" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><img src="https://s4.51cto.com/images/blog/202110/13110935_61664def2259461146.jpg" alt="" title="" style="visibility: visible; width: 654px; height: 298px;"></p><p data-id="pfad2eb1b-340960902697fde05aae6" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><br></p><p data-id="peafa0b28-340945140009b30de19e0" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;">其他去雾算法对比结果如下图所示,比如城市和道路有无图像去雾效果对比。</p><p data-id="peafa0b28-34096091230122a54e280" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><br></p><p data-id="peafa0b28-3409451400009a487cc9d" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><img src="https://s4.51cto.com/images/blog/202110/13110935_61664def214dc59655.jpg" alt="" title="" style="visibility: visible; width: 654px; height: 421px;"><img src="https://s4.51cto.com/images/blog/202110/13110935_61664def6119870271.jpg" alt="" title="" style="visibility: visible; width: 654px; height: 407px;"></p><p data-id="p62e98320-340960940445854ff3b27" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><br></p><p data-id="peafa0b28-340945140009e7a702a95" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;">最后,正如总结王道累老师总结的一样,目前针对有雾图像去雾的算法主要是从基于图像增强、图像复原和 CNN 3 个方向进行的。</p><p data-id="peafa0b28-3409609514855777225c9" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><br></p><ul data-id="ub57b5d59-34094514000743b811682"><li data-id="le74fd7c4-3409451400067f56602ee">基于图像增强的方法不考虑有雾图像的形成过程,而是直接通过突出图像的细节,提高对比度等方式,从而使有雾图像看上去更加清晰。</li><li data-id="le74fd7c4-34094514000ac6c0fe250">基于图像复原的方法则是追寻图像降质的物理过程,通过物理模型还原出清晰的图像。</li><li data-id="le74fd7c4-340945140009ef2b516f1">基于 CNN 的方法则是利用神经网络强大的学习能力,寻找有雾图像与图像复原物理模型中某些系数的映射关系或者使用 GAN,根据有雾图像还原出无雾的清晰图像。</li></ul><p data-id="p68fdfdd8-3409609656664bbce2cb2" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><br></p><p data-id="peafa0b28-3409451400143c7f74a7e" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;">上述 3 类去雾算法对于雾天图像都有着明显的去雾效果,尽管其在实际生活中已经得到了广泛的应用,但下述几点仍有可能是今后图像去雾领域的研究重点和难点:</p><p data-id="peafa0b28-34096098584d03aed9d99" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><br></p><ul data-id="ub57b5d59-3409451400158e9793160"><li data-id="le74fd7c4-34094514001778ec8967d"><strong>更加真实的雾天图像数据集</strong><br>采用神经网络进行去雾的算法在效果上好于图像增强和复原的方法,但是由于在自然界中很难拍摄到一组背景相同的有雾图像和无雾图像,因此目前训练神经网络所采用的数据集均是通过合成得到的,虽然能够在一定程度上拟合自然环境,但是仍然存在着一些差距。所以目前急需一种由在真实环境中获取到的具有相同背景的有雾图像和无雾图像构建的数据集,来提高神经网络去雾算法的鲁棒性和稳定性。</li><li data-id="le74fd7c4-34094514001385b63b9ae"><strong>更加简便的去雾算法</strong><br>目前各类算法能够有效去除单幅图像上的雾霾,但相对较好的算法都存在着时间复杂度高的问题,很难应用到视频去雾或者需求较多的复杂任务中去。</li><li data-id="le74fd7c4-340945140017382cd1861"><strong>鲁棒性更强的去雾算法</strong><br>上述算法都只对图像上存在的均匀的薄雾有较好的去雾效果,对于浓雾或者分布不均的团雾则效果较差,因此找到一种适用范围更广的去雾方法将会是一个极具挑战性的课题。</li></ul><h2 style="line-height: 1.5;" id="h301ae07a-34094514001f27961fac4" data-id="h301ae07a-34094514001f27961fac4"><strong>二.ACE去雾算法</strong></h2><h3 style="line-height: 1.5;" id="he5f05f26-34094514001263e2cccd7" data-id="he5f05f26-34094514001263e2cccd7"><strong>1.算法原理</strong></h3><p data-id="peafa0b28-34094514001c73e729a17" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;">该部分主要介绍参考作者书籍以及相关论文进行叙述,简单介绍ACE算法的原理知识。如果读者想详细了解其原理,推荐阅读英文原文,详见下面的参考文献,都是大佬。</p><p data-id="peafa0b28-34094514001b42f12a44b" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;">引用及参考中文论文:</p><ul data-id="ub57b5d59-340945140016c8b567455"><li data-id="le74fd7c4-3409451400159253f4826">尹胜楠, 等. 基于快速ACE算法的视觉里程计图像增强方法[J]. 电子测量与仪器学报, 2021.</li><li data-id="le74fd7c4-340945140016d186eea69">李景文, 等. 基于暗通道先验改进的自动色彩均衡算法[J]. 科学技术与工程, 2019.</li><li data-id="le74fd7c4-34094514001094c434168">杨秀璋, 等. 一种改进的复杂环境下条形码图像增强和定位算法[J]. 现代计算机, 2020.</li><li data-id="le74fd7c4-34094514001873eca63d2">​<a href="https://blog.csdn.net/wsp_1138886114/article/details/99701117" target="_blank">​OpenCV—python 自动色彩均衡(ACE)- SongpingWang​</a>​</li><li data-id="le74fd7c4-34094514001435b3f0b80">​<a href="https://blog.csdn.net/Eastmount/article/details/114706950" target="_blank">​OpenCV图像增强万字详解(直方图均衡化、局部直方图均衡化、自动色彩均衡化)- Eastmount​</a>​</li></ul><p data-id="pd25f326f-340961490629c7132db49" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><br></p><p data-id="peafa0b28-340945140013aa6c31963" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;">英文原文:</p><p data-id="peafa0b28-34096144147cfd9167793" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><span style="color: #333333;"><span style="font-size: 10pt;"><span style="font-family: Symbol;">·        
</span></span><span style="font-family: Helvetica;">https://www.ipol.im/pub/art/2012/g-ace/?utm_source=doi<br>;
Automatic Color Enhancement (ACE) and its Fast Implementation</span></span></p><p data-id="peafa0b28-340961441476577e9bcf7" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><span style="color: #333333;"><span style="font-size: 10pt;"><span style="font-family: Symbol;">·        
</span></span><span style="font-family: Helvetica;">https://www.sciencedirect.com/science/article/abs/pii/S0167865502003239<br>;
A new algorithm for unsupervised global and local color correction</span><span style="font-family: STSong, 华文宋体, SimSun, "Songti SC", NSimSun, serif;">(原作者</span><span style="font-family: Helvetica;">Rizzi</span><span style="font-family: STSong, 华文宋体, SimSun, "Songti SC", NSimSun, serif;">大佬)</span></span></p><p data-id="peafa0b28-340961518547612fdefb4" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><span style="color: #333333;"><span style="font-family: STSong, 华文宋体, SimSun, "Songti SC", NSimSun, serif;">​</span></span></p><p data-id="peafa0b28-3409614414797fa1be576" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><br></p><p data-id="peafa0b28-3409451400169208e23c3" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><img src="https://s4.51cto.com/images/blog/202110/13110935_61664def6a96b65230.jpg" alt="" title="" style="visibility: visible; width: 654px; height: 538px;"></p><p data-id="p5b0c7149-34096154181d21f786e21" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><br></p><p data-id="peafa0b28-3409451400101d25c7dcf" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;">图像对比度增强的算法在很多场合都有用处,特别是在医学图像中,这是因为在众多疾病的诊断中,医学图像的视觉检查时很有必要的。Retinex算法是代表性的图像增强算法,它根据人的视网膜和大脑皮层模拟对物体颜色的波长光线反射能力而形成,对复杂环境下的一维条码具有一定范围内的动态压缩,对图像边缘有着一定自适应的增强。</p><p data-id="peafa0b28-340961552137e310cd250" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><br></p><p data-id="peafa0b28-34094514001beb5d30f07" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><strong>自动色彩均衡(Automatic Color Enhancement,ACE)</strong> 算法是Rizzi大神在Retinex算法的理论上提出的,它通过计算图像目标像素点和周围像素点的明暗程度及其关系来对最终的像素值进行校正,实现图像的对比度调整,产生类似人体视网膜的色彩恒常性和亮度恒常性的均衡,具有很好的图像增强效果。</p><p data-id="peafa0b28-34096156696a5ecb1c60b" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><br></p><p data-id="peafa0b28-34094514001984792e50a" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;">ACE算法包括两个步骤:</p><ul data-id="ub57b5d59-34094514001c357f7ad60"><li data-id="le74fd7c4-34094514001a6f2967894">一是对图像进行色彩和空域调整,完成图像的色差校正,得到空域重构图像。<br>模仿视觉系统的侧抑制性和区域自适应性,进行色彩的空域调整。侧抑制性是一个生理学概念,指在某个神经元受到刺激而产生兴奋时,再刺激相近的神经元,后者所发生的兴奋对前者产生的抑制作用。</li><li data-id="le74fd7c4-340945140019d1352dd92">二是对校正后的图像进行动态扩展。<br>对图像的动态范围进行全局调整,并使图像满足灰度世界理论和白斑点假设。算法针对单通道,再延伸应用到RGB彩色空间的3通道图像,即对3个通道分别处理再进行整合完成。</li></ul><p data-id="p4de5ddd3-340961610772ff969ee75" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><strong><br></strong></p><p data-id="peafa0b28-340945140018d4d0103df" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><strong>(1) 区域自适应滤波</strong></p><p data-id="peafa0b28-340945140011263760858" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;">输入图像I(灰度图为例),该步是对单通道图像I中所有点p的区域自适应滤波,得到完成色差校正,空域重构后的中间结果图像,计算公式如下:</p><p data-id="peafa0b28-34096162300330c231496" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><br></p><p data-id="peafa0b28-340945140015f4be72795" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><img src="https://s4.51cto.com/images/blog/202110/13110935_61664def6dae774139.png" alt="" title="" style="visibility: visible; width: 481px; height: 100px;"></p><p data-id="p727f7566-34096163886ba37b0d5a3" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><br></p><p data-id="peafa0b28-34094514001969db38173" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;">式中:Ic§-Ic(j)为p、j两个像素点间灰度差值,表达拟生物学上的侧抑制性;d(p,j)表示距离度量函数,使用两点间的欧氏距离,作用上控制点j对p的影响权重,映射出滤波的区域适应性;Sa(x)是亮度表现函数(奇函数),本文算法选择经典Saturation函数。</p><p data-id="peafa0b28-340961658009a4878b1b8" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><br></p><p data-id="peafa0b28-3409451400195cf6b4ce4" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><img src="https://s4.51cto.com/images/blog/202110/13110935_61664def704fa94092.png" alt="" title="" style="visibility: visible; width: 646px; height: 461px;"></p><p data-id="pd0688d5b-34096167987c1253056d1" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><br></p><p data-id="peafa0b28-340945140013c0cfebeaa" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;">不同亮度函数和参数的选择控制了对比度增强的程度,经典的Saturation函数在饱和前取越大的斜率,结果的对比度增强越明显,如图2所示,极限情况是sign函数形式,而Sign函数由于无差别过度增强放大,导致噪声同样得到放大效果不佳,最终选择Saturation函数作为相对亮度表现函数。公式如下:</p><p data-id="peafa0b28-34096168923522bccc745" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><br></p><p data-id="peafa0b28-340945140013aceb229c2" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><img src="https://s4.51cto.com/images/blog/202110/13110935_61664def6fab792204.png" alt="" title="" style="visibility: visible; width: 425px; height: 124px;"></p><p data-id="pfd86bafc-34096170674db41748fe2" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><strong><br></strong></p><p data-id="peafa0b28-34094514001c55e04f7f2" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><strong>(2) 色调重整拉伸,对图像动态扩展</strong></p><p data-id="peafa0b28-34094514001e7c80224c3" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;">将式(1)中得到的中间量拉伸映射到 [0, 255] 中,占满动态范围 [0, 255](8位灰度图像),计算公式如下,式中:[minR,maxR]是中间量L(x)的全部定义域,该项使图像达到全局白平衡。</p><p data-id="peafa0b28-340961741962546ffb296" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><br></p><p data-id="peafa0b28-34094514001b22b994ecd" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><img src="https://s4.51cto.com/images/blog/202110/13110935_61664def919ef98142.png" alt="" title="" style="visibility: visible; width: 243px; height: 72px;"></p><p data-id="pa0e3e791-34096173543ebb1019189" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><br></p><p data-id="peafa0b28-340945140014056756b7e" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;">下图是条形码图像进行ACE图像增强后的效果图,通过图像增强后的图(b)对比度更强,改善了原图像的明暗程度,增强的同时保持了图像的真实性。</p><p data-id="peafa0b28-340961758042501d396ce" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><br></p><p data-id="peafa0b28-340945140010e5e8e689c" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><img src="https://s4.51cto.com/images/blog/202110/13110935_61664def9c1f989554.jpg" alt="" title="" style="visibility: visible; width: 654px; height: 319px;"></p><p data-id="p78396f21-340961779297534f20190" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><br></p><p data-id="peafa0b28-340945140010667f19356" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;">ACE算法英文介绍如下:</p><p data-id="peafa0b28-34096178764477ee05175" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><br></p><p data-id="peafa0b28-34094514001950fb8b9fc" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><img src="https://s4.51cto.com/images/blog/202110/13110935_61664defac48864495.jpg" alt="" title="" style="visibility: visible; width: 654px; height: 513px;"></p><p data-id="pa1bc7582-34096181007ed8aef6006" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><br></p><p data-id="peafa0b28-3409451400154a1c43b95" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;">实验对比效果如下图所示,大家在写该主题论文的时候,注意和传统方法对比。</p><p data-id="peafa0b28-3409618347466455ca49c" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><br></p><p data-id="peafa0b28-3409451400134a4ff36c4" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><img src="https://s4.51cto.com/images/blog/202110/13110935_61664defa9db553983.jpg" alt="" title="" style="visibility: visible; width: 654px; height: 314px;"><img src="https://s4.51cto.com/images/blog/202110/13110935_61664defabc0d48642.jpg" alt="" title="" style="visibility: visible; width: 654px; height: 439px;"></p><h3 style="line-height: 1.5;" id="he5f05f26-340945140029568f975b2" data-id="he5f05f26-340945140029568f975b2"><strong>2.代码实现</strong></h3><p data-id="peafa0b28-340945140029b1fd4a4a8" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;">由于OpenCV中暂时没有ACE算法包,下面的代码是借鉴“zmshy2128”老师的文章,修改实现的彩色直方图均衡化处理。后面有机会作者详细分析其代码实现过程。</p><ul data-id="ub57b5d59-34094514002de9f62a0c8"><li data-id="le74fd7c4-34094514002aefcec5104">自动色彩均衡(ACE)快速算法 - zmshy2128老师</li></ul><p data-id="peafa0b28-340961918727012e8b0e4" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><br></p><div data-syntax="text"><div class="data-codeblock-content" style="border: 1px solid rgb(232, 232, 232); max-width: 750px; color: rgb(38, 38, 38); margin: 0px; padding: 0px; background: rgb(249, 249, 249);"><div class="CodeMirror" style="color: rgb(89, 89, 89); margin: 0px; padding: 16px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);"><pre class="cm-s-default" style="color: rgb(89, 89, 89); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);"># -- coding: utf-8 --<br># By:Eastmount CSDN 2021-03-12<br># 惨zmshy2128老师文章并修改成Python3代码<br>import cv2<br>import numpy as np<br>import math<br>import matplotlib.pyplot as plt<br><br>#线性拉伸处理<br>#去掉最大最小0.5%的像素值 线性拉伸至[0,1]<br>def stretchImage(data, s=0.005, bins = 2000): <br> ht = np.histogram(data, bins);<br> d = np.cumsum(ht[0])/float(data.size)<br> lmin = 0; lmax=bins-1<br> while lmin<bins:<br> if d[lmin]>=s:<br> break<br> lmin+=1<br> while lmax>=0:<br> if d[lmax]<=1-s:<br> break<br> lmax-=1<br> return np.clip((data-ht[1][lmin])/(ht[1][lmax]-ht[1][lmin]), 0,1)<br><br>#根据半径计算权重参数矩阵<br>g_para = {}<br>def getPara(radius = 5): <br> global g_para<br> m = g_para.get(radius, None)<br> if m is not None:<br> return m<br> size = radius2+1<br> m = np.zeros((size, size))<br> for h in range(-radius, radius+1):<br> for w in range(-radius, radius+1):<br> if h==0 and w==0:<br> continue<br> m[radius+h, radius+w] = 1.0/math.sqrt(h2+w2)<br> m /= m.sum()<br> gpara[radius] = m<br> return m<br><br>#常规的ACE实现<br>def zmIce(I, ratio=4, radius=300): <br> para = getPara(radius)<br> height,width = I.shape<br> zh = []<br> zw = []<br> n = 0<br> while n < radius:<br> zh.append(0)<br> zw.append(0)<br> n += 1<br> for n in range(height):<br> zh.append(n)<br> for n in range(width):<br> zw.append(n)<br> n = 0<br> while n < radius:<br> zh.append(height-1)<br> zw.append(width-1)<br> n += 1<br> #print(zh)<br> #print(zw)<br> <br> Z = I[np.ix(zh, zw)]<br> res = np.zeros(I.shape)<br> for h in range(radius2+1):<br> for w in range(radius2+1):<br> if para[h][w] == 0:<br> continue<br> res += (para[h][w] np.clip((I-Z[h:h+height, w:w+width])ratio, -1, 1))<br> return res<br><br>#单通道ACE快速增强实现<br>def zmIceFast(I, ratio, radius):<br> print(I)<br> height, width = I.shape[:2]<br> if min(height, width) <=2:<br> return np.zeros(I.shape)+0.5<br> Rs = cv2.resize(I, (int((width+1)/2), int((height+1)/2)))<br> Rf = zmIceFast(Rs, ratio, radius) #递归调用<br> Rf = cv2.resize(Rf, (width, height))<br> Rs = cv2.resize(Rs, (width, height))<br> <br> return Rf+zmIce(I,ratio, radius)-zmIce(Rs,ratio,radius) <br><br>#rgb三通道分别增强 ratio是对比度增强因子 radius是卷积模板半径 <br>def zmIceColor(I, ratio=4, radius=3): <br> res = np.zeros(I.shape)<br> for k in range(3):<br> res[:,:,k] = stretchImage(zmIceFast(I[:,:,k], ratio, radius))<br> return res<br><br>#主函数<br>if name == 'main':<br> img = cv2.imread('car.png')<br> res = zmIceColor(img/255.0)255<br> cv2.imwrite('car-Ice.jpg', res)</pre></div></div></div><p data-id="p43deaf89-3409619899665b6110a67" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><br></p><p data-id="peafa0b28-34094514002d426fd267f" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;">运行结果如图所示,ACE算法能有效进行图像去雾处理,实现图像的细节增强。</p><p data-id="peafa0b28-34096200285f3aff3bd13" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><br></p><p data-id="peafa0b28-340945140021410fad332" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><img src="https://s4.51cto.com/images/blog/202110/13110935_61664defb2d9354862.jpg" alt="" title="" style="visibility: visible; width: 654px; height: 244px;"><img src="https://s4.51cto.com/images/blog/202110/13110935_61664defd1df033157.jpg" alt="" title="" style="visibility: visible; width: 654px; height: 235px;"></p><p data-id="pb3c23d4f-340962060120c80f39e71" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><br></p><p data-id="peafa0b28-34094514002f08b9e2096" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;">最后是目标检测去雾和女神去雾的效果,哈哈,继续加油!</p><p data-id="peafa0b28-34096206829433eca77ad" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><br></p><p data-id="peafa0b28-3409451400282eee7164b" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><img src="https://s4.51cto.com/images/blog/202110/13110935_61664defd57ed42030.jpg" alt="" title="" style="visibility: visible; width: 654px; height: 210px;"><img src="https://s4.51cto.com/images/blog/202110/13110935_61664defecaf390872.jpg" alt="" title="" style="visibility: visible; width: 654px; height: 421px;"></p><h2 style="line-height: 1.5;" id="h301ae07a-34094514002b209d5897e" data-id="h301ae07a-34094514002b209d5897e"><strong>三.暗通道先验去雾算法</strong></h2><p data-id="peafa0b28-3409451400207b51bf367" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;">该算法是计算机视觉领域何恺明大佬于2009年提出的图像去雾经典算法,并获取当年CVPR最佳论文。论文题目为《Single Image Haze Removal Using Dark Channel Prior》。下图是大佬的百科简介,是真的厉害,值得我们大家学习。</p><p data-id="peafa0b28-340962108002349f6553b" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><br></p><ul data-id="ub57b5d59-3409451400202973b2272"><li data-id="le74fd7c4-34094514002ecf25ffedf">2003年5月,何恺明拿到保送清华的资格,是当年执信中学唯一保送上清华大学的学生;高考结果出炉以后,何恺明获得满分900分的成绩,成为当年广东省9位满分状元之一。</li><li data-id="le74fd7c4-34094514002ae4e637d4a">2009年,何恺明成为首获计算机视觉领域三大国际会议之一CVPR“最佳论文奖”的中国学者。</li><li data-id="le74fd7c4-34094514002e5c496ada0">在2015年的ImageNet图像识别大赛中,何恺明和他的团队用“图像识别深度差残学习”系统,击败谷歌、英特尔、高通等业界团队,荣获第一。</li><li data-id="le74fd7c4-3409451400232c5d01925">何恺明作为第一作者获得了CVPR 2009,CVPR 2016和ICCV 2017(Marr Prize)的最佳论文奖,并获得了ICCV 2017最佳学生论文奖。</li><li data-id="le74fd7c4-34094514002f202e3c1b3">2018年,第31届计算机视觉和模式识别大会(Conference on Computer Vision and Pattern Recognition, CVPR)在美国盐湖城召开,何恺明获得本届大会的PAMI年轻学者奖。</li></ul><p data-id="peafa0b28-340962129043ccf0d9a56" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><br></p><p data-id="peafa0b28-34094514002ad4dba331a" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><img src="https://s4.51cto.com/images/blog/202110/13110935_61664defe9b2f9561.jpg" alt="" title="" style="visibility: visible; width: 654px; height: 353px;"></p><h3 style="line-height: 1.5;" id="he5f05f26-34094514002e99494fad4" data-id="he5f05f26-34094514002e99494fad4"><strong>1.算法原理</strong></h3><p data-id="peafa0b28-3409451400298b12b6ddc" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;">言归正传,如果是图像处理或研究图像去雾领域的作者,建议大家认真阅读这篇英文原文,能在2009年提出该算法真的很惊艳。</p><p data-id="peafa0b28-3409621497786c7a5be06" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><br></p><p data-id="peafa0b28-34094514002d942837470" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;">引用及参考中文论文:</p><ul data-id="ub57b5d59-3409451400269181fef82"><li data-id="le74fd7c4-34094514002dbf411f8b7">何涛, 等. 基于暗通道先验的单幅图像去雾新算法[J]. 计算机科学, 2021.</li><li data-id="le74fd7c4-34094514002732b09d8f0">王蓉, 等. 基于改进加权融合暗通道算法的图像去雾研究[J]. 浙江科技学院学报, 2021.</li><li data-id="le74fd7c4-340945140023c2bd3f2ab">图像去雾算法的原理、实现、效果(速度可实时)- 挚爱图像处理</li><li data-id="le74fd7c4-340945140026861e7c399">​<a href="https://link.zhihu.com/?target=https%3A//blog.csdn.net/s12244315/article/details/50292049/" target="_blank">​图像去雾之何凯明暗通道先验去雾算法原理及c++代码实现 - Do it !​</a>​</li></ul><p data-id="pfb707cd1-340962169928bedf89a21" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><br></p><p data-id="peafa0b28-340945140028c5d886b8e" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;">英文原文:</p><p data-id="peafa0b28-3409624123251f28b394b" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><span style="color: #333333;"><span style="font-size: 10pt;"><span style="font-family: Symbol;">·        
</span></span></span>​<a href="https://ieeexplore.ieee.org/document/5567108"><span style="color: #4EA1DB;">​<span style="font-family: Helvetica;"><span style="color: #4EA1DB;">https://ieeexplore.ieee.org/document/5567108</span></span>​</span></a>​<span style="color: #333333;"><span style="font-family: Helvetica;">
Single Image Haze Removal Using Dark Channel Prior</span></span></p><p data-id="peafa0b28-34096241232bbedbfe600" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><span style="color: #333333;"><span style="font-size: 10pt;"><span style="font-family: Symbol;">·        
</span></span></span>​<a href="https://ieeexplore.ieee.org/document/5206515"><span style="color: #4EA1DB;">​<span style="font-family: Helvetica;"><span style="color: #4EA1DB;">https://ieeexplore.ieee.org/document/5206515</span></span>​</span></a>​<span style="color: #333333;"><span style="font-family: Helvetica;">
Single image haze removal using dark channel prior</span></span></p><p data-id="peafa0b28-3409624123282b0e38650" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><br></p><p data-id="peafa0b28-340945140025426255d9b" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><img src="https://s4.51cto.com/images/blog/202110/13110936_61664df00666e69404.jpg" alt="" title="" style="visibility: visible; width: 654px; height: 295px;"></p><p data-id="p8cf3e33b-34096246724dae52189fa" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><strong><br></strong></p><p data-id="peafa0b28-34094514002817931e62f" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><strong>暗通道先验(Dark Channel Prior, DCP)去雾算法</strong> 依赖大气散射模型进行去雾处理,通过对大量有雾图像和无雾图像进行观察总结,得到其中存在的一些映射关系,然后根据有雾图像的形成过程来进行逆运算,从而恢复清晰图像。</p><p data-id="peafa0b28-34096247692fe50a2d7b1" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><br></p><p data-id="peafa0b28-340945140023be16d12eb" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><img src="https://s4.51cto.com/images/blog/202110/13110936_61664df00c25a29435.jpg" alt="" title="" style="visibility: visible; width: 654px; height: 388px;"></p><p data-id="p34e704c5-340962493437d2ae9a93e" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><br></p><p data-id="peafa0b28-34094514002ac0a74bdca" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;">算法实现过程及原理如下,参考何恺明老师和何涛老师的论文。</p><p data-id="peafa0b28-340962501879fd6f4b29e" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><br></p><p data-id="peafa0b28-34094514002beea6d57c8" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><strong>(1) 大气散射模型</strong></p><p data-id="peafa0b28-340945140028c2f97880b" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;">在计算机视觉和计算机图形学中,方程所描述的大气散射模型被广泛使用。参数解释如下:</p><ul data-id="ub57b5d59-34094514002a257e7b063"><li data-id="le74fd7c4-34094514002c8d3381029">x是图像的空间坐标</li><li data-id="le74fd7c4-34094514002fe072353b3">I(x)代表有雾图像(待去雾图像)</li><li data-id="le74fd7c4-34094514002d456baeef9">J(x)代表无雾图像(待恢复图像)</li><li data-id="le74fd7c4-340945140027a6635dd6d">A代表全球大气光值</li><li data-id="le74fd7c4-34094514002dd3794c955">t(x)代表透射率</li></ul><p data-id="p80e9736a-3409625188905b1c54877" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><br></p><p data-id="peafa0b28-340945140020a24020edb" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;">方程右边第一项为场景直接衰减项,第二项为环境光项。</p><p data-id="peafa0b28-340962528211467ff72f0" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><br></p><p data-id="peafa0b28-340945140023f739b4a9d" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><img src="https://s4.51cto.com/images/blog/202110/13110936_61664df030cc380788.png" alt="" title="" style="visibility: visible; width: 344px; height: 48px;"></p><p data-id="pac12b185-3409625432953b7994f53" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><strong><br></strong></p><p data-id="peafa0b28-340945140035ca46b7d9d" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><strong>(2) 暗通道定义</strong></p><p data-id="peafa0b28-34094514003a91eca4236" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;">在绝大多数非天空的局部区域中,某些像素总会至少有一个颜色通道的值很低。对于一幅图像J(x),其暗通道的数学定义表示如下:</p><p data-id="peafa0b28-34096255136fc3ad18da1" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><br></p><p data-id="peafa0b28-34094514003dd74436819" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><img src="https://s4.51cto.com/images/blog/202110/13110936_61664df01d42b87011.png" alt="" title="" style="visibility: visible; width: 372px; height: 74px;"></p><p data-id="p52633f1f-34096256073899abd9978" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><br></p><p data-id="peafa0b28-3409451400370c13d3be4" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;">其中,Ω(x)表示以x为中心的局部区域,上标c表示RGB三个通道。该公式的意义用代码表达也很简单,首先求出每个像素RGB分量中的最小值,存入一副和原始图像大小相同的灰度图中,然后再对这幅灰度图进行最小值滤波,滤波的半径由窗口大小决定。</p><p data-id="peafa0b28-34096257097ff3b01d556" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><br></p><p data-id="peafa0b28-3409451400316905d3b2c" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><strong>(3) 暗通道先验理论</strong></p><p data-id="peafa0b28-3409451400344937518a9" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;">暗通道先验理论指出:对于非天空区域的无雾图像J(x)的暗通道趋于0,即:</p><p data-id="peafa0b28-340962586369ad6e1cc12" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><br></p><p data-id="peafa0b28-3409451400312574824cf" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><img src="https://s4.51cto.com/images/blog/202110/13110936_61664df030ca984905.png" alt="" title="" style="visibility: visible; width: 170px; height: 51px;"></p><p data-id="p927f50bd-340962597999df3b97707" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><br></p><p data-id="peafa0b28-3409451400354de6336b5" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;">实际生活中造成暗原色中低通道值主要有三个因素:</p><ul data-id="ub57b5d59-340945140037600739137"><li data-id="le74fd7c4-3409451400305e488b9c9">a) 汽车、建筑物和城市中玻璃窗户的阴影,或者是树叶、树与岩石等自然景观的投影;</li><li data-id="le74fd7c4-340945140031c984440ff">b) 色彩鲜艳的物体或表面,在RGB的三个通道中有些通道的值很低(比如绿色的草地/树/植物,红色或黄色的花朵/叶子,或者蓝色的水面);</li><li data-id="le74fd7c4-34094514003c3b512dcc1">c) 颜色较暗的物体或者表面,例如灰暗色的树干和石头。</li></ul><p data-id="peafa0b28-340962616845f658af231" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><br></p><p data-id="peafa0b28-340945140030e9f274375" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><img src="https://s4.51cto.com/images/blog/202110/13110936_61664df03a31c54137.jpg" alt="" title="" style="visibility: visible; width: 654px; height: 410px;"></p><p data-id="p86ec7c0f-340962633482ec3e553fe" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><br></p><p data-id="peafa0b28-340945140034c79779b8f" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;">总之,自然景物中到处都是阴影或者彩色,这些景物的图像的暗原色总是很灰暗的,而有雾的图像较亮。因此,可以明显的看到暗通道先验理论的普遍性。</p><p data-id="peafa0b28-340962642894e7a7b5dc1" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><br></p><p data-id="peafa0b28-340945140035afa141027" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><img src="https://s4.51cto.com/images/blog/202110/13110936_61664df043e7342098.jpg" alt="" title="" style="visibility: visible; width: 654px; height: 384px;"><img src="https://s4.51cto.com/images/blog/202110/13110936_61664df053e7a98210.jpg" alt="" title="" style="visibility: visible; width: 654px; height: 326px;"></p><p data-id="p2bf8f49d-340962666842601d77388" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><strong><br></strong></p><p data-id="peafa0b28-340945140038df811ea4b" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><strong>(4) 公式变形</strong></p><p data-id="peafa0b28-340945140033a69164fdc" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;">根据大气散射模型,将第一个公式稍作处理,变形为下式:</p><p data-id="peafa0b28-3409626759930a1cde31f" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><br></p><p data-id="peafa0b28-34094514003cf802bb771" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><img src="https://s4.51cto.com/images/blog/202110/13110936_61664df06461b35590.png" alt="" title="" style="visibility: visible; width: 472px; height: 110px;"></p><p data-id="pd480e683-340962685784ff1a1cdd0" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><br></p><p data-id="peafa0b28-340945140038619e17a47" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;">假设每一个窗口的透射率t(x)为常数,记为t’(x),并且A值已给定,对式两边同时进行两次最小值运算,可得:</p><p data-id="peafa0b28-3409626930619170e89e4" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><br></p><p data-id="peafa0b28-3409451400393d6fff72a" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><img src="https://s4.51cto.com/images/blog/202110/13110936_61664df06c48677222.png" alt="" title="" style="visibility: visible; width: 654px; height: 153px;"></p><p data-id="pf39b5cd5-3409627202960a6550703" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><br></p><p data-id="peafa0b28-34094514003044e26dcb9" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;">其中,J(x)是要求的无雾图像,根据前述的暗通道先验理论可知:</p><p data-id="peafa0b28-34096272870b5efc158fc" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><br></p><p data-id="peafa0b28-340945140036f6dd46818" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><img src="https://s4.51cto.com/images/blog/202110/13110936_61664df07419425129.png" alt="" title="" style="visibility: visible; width: 515px; height: 96px;"></p><p data-id="p3481c2fc-34096273945e4f021752c" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><br></p><p data-id="peafa0b28-3409451400313dbe09c8e" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;">因此可推导出:</p><p data-id="peafa0b28-3409627457133503699f7" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><br></p><p data-id="peafa0b28-34094514003ca08841471" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><img src="https://s4.51cto.com/images/blog/202110/13110936_61664df07898268939.png" alt="" title="" style="visibility: visible; width: 377px; height: 122px;"></p><p data-id="p09821b71-340962762570f855618d6" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><strong><br></strong></p><p data-id="peafa0b28-34094514003c329ea884a" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><strong>(5) 透射率计算</strong></p><p data-id="peafa0b28-340945140032e1ab35f20" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;">将上式带入可得到透射率t’(x)的预估值,如下所示:</p><p data-id="peafa0b28-34096277097943af8a8ce" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><br></p><p data-id="peafa0b28-340945140038dcf557b8c" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><img src="https://s4.51cto.com/images/blog/202110/13110936_61664df08172228915.png" alt="" title="" style="visibility: visible; width: 471px; height: 117px;"></p><p data-id="pdfc8637a-34096278265ce4c7d436e" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><br></p><p data-id="peafa0b28-3409451400387e8eb7567" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;">现实生活中,即便晴空万里,空气中也会存在一些颗粒,在眺望远处的景物时,人们还是能感觉到雾的存在。另外,雾的存在让人们感受到景深,因此在去雾的同时有必要保留一定程度的雾。可以通过引入一个0到1之 间 的 因 子 w(一 般取0.95)对预估透射率进行修正,如式所示:</p><p data-id="peafa0b28-34096281780a77119bc43" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><br></p><p data-id="peafa0b28-34094514003ab8ca8ee5a" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><img src="https://s4.51cto.com/images/blog/202110/13110936_61664df09197854206.png" alt="" title="" style="visibility: visible; width: 514px; height: 124px;"></p><p data-id="p1d4bacc4-34096283183b0ef9068e6" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><br></p><p data-id="peafa0b28-34094514003043eafd7de" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;">以上的推导过程均假设大气光值A是已知的,在实际中,可以借助暗通道图从原始雾图中求取。具体步骤如下:</p><ul data-id="ub57b5d59-34094514003d7983465f9"><li data-id="le74fd7c4-34094514003eb2456d219">先求取暗通道图,在暗通道图中按照亮度的大小提取最亮的前0.1%的像素</li><li data-id="le74fd7c4-3409451400374f4868214">在原始雾图I(x)中找对应位置上具有最高亮度的点的值,作为大气光值A</li></ul><p data-id="p0e731635-340962848762d8a092227" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><br></p><p data-id="peafa0b28-34094514003a956d73a59" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;">此外,由于透射率t偏小时,会造成J偏大,恢复的无雾图像整体向白场过度,因此有必要对透射率设置一个下限值t0(一般取值为0.1),当t值小于t0 时,取t=t0。将以上求得的透射率和大气光值代入公式,最终整理得到图像的恢复公式如下:</p><p data-id="peafa0b28-340962863062ed77e63ac" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><br></p><p data-id="peafa0b28-3409451400335af74c317" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><img src="https://s4.51cto.com/images/blog/202110/13110936_61664df0a242218881.png" alt="" title="" style="visibility: visible; width: 445px; height: 95px;"></p><p data-id="p2cbd043f-340962873075316103b0e" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><br></p><p data-id="peafa0b28-340945140036f6612764b" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;">这就是暗通道先验去雾算法的原理过程,下面简单补充论文中的处理效果图。</p><p data-id="peafa0b28-340962882944067d49525" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><br></p><p data-id="peafa0b28-3409451400301455ea0b9" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><img src="https://s4.51cto.com/images/blog/202110/13110936_61664df0af56f18553.jpg" alt="" title="" style="visibility: visible; width: 654px; height: 363px;"></p><p data-id="p0e2dbbae-34096290237f905eaecd1" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><br></p><p data-id="peafa0b28-34094514003d9b6c9c949" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;">再次膜拜偶像,极力推荐大家阅读论文。</p><h3 style="line-height: 1.5;" id="he5f05f26-3409451400351e1cea17b" data-id="he5f05f26-3409451400351e1cea17b"><strong>2.算法实现</strong></h3><p data-id="peafa0b28-34094514003a9bab6e496" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;">实现代码引用木老师的,感觉比我写得好,参考如下:</p><ul data-id="ub57b5d59-340945140038380d3c28d"><li data-id="le74fd7c4-3409451400348270f110a">​<a href="https://blog.csdn.net/leviopku/article/details/83898619" target="_blank">​openCV+python实现图像去雾 - 木盏老师​</a>​</li></ul><p data-id="peafa0b28-34096307111010404aae7" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><br></p><div data-syntax="text"><div class="data-codeblock-content" style="border: 1px solid rgb(232, 232, 232); max-width: 750px; color: rgb(38, 38, 38); margin: 0px; padding: 0px; background: rgb(249, 249, 249);"><div class="CodeMirror" style="color: rgb(89, 89, 89); margin: 0px; padding: 16px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);"><pre class="cm-s-default" style="color: rgb(89, 89, 89); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);"># -- coding: utf-8 --<br>"""<br>Created on Sat Sep 11 00:16:07 2021<br>@author: xiuzhang<br><br>参考资料:<br>https://blog.csdn.net/leviopku/article/details/83898619<br>"""<br><br>import sys<br>import cv2<br>import math<br>import numpy as np<br> <br>def DarkChannel(im,sz):<br> b,g,r = cv2.split(im)<br> dc = cv2.min(cv2.min(r,g),b)<br> kernel = cv2.getStructuringElement(cv2.MORPH_RECT,(sz,sz))<br> dark = cv2.erode(dc,kernel)<br> return dark<br> <br>def AtmLight(im,dark):<br> [h,w] = im.shape[:2]<br> imsz = hw<br> numpx = int(max(math.floor(imsz/1000),1))<br> darkvec = dark.reshape(imsz,1)<br> imvec = im.reshape(imsz,3)<br> <br> indices = darkvec.argsort()<br> indices = indices[imsz-numpx::]<br> <br> atmsum = np.zeros([1,3])<br> for ind in range(1,numpx):<br> atmsum = atmsum + imvec[indices[ind]]<br> <br> A = atmsum / numpx;<br> return A<br> <br>def TransmissionEstimate(im,A,sz):<br> omega = 0.95<br> im3 = np.empty(im.shape,im.dtype)<br> <br> for ind in range(0,3):<br> im3[:,:,ind] = im[:,:,ind]/A[0,ind]<br><br> transmission = 1 - omegaDarkChannel(im3,sz)<br> return transmission<br> <br>def Guidedfilter(im,p,r,eps):<br> mean_I = cv2.boxFilter(im,cv2.CV_64F,(r,r))<br> mean_p = cv2.boxFilter(p, cv2.CV_64F,(r,r))<br> mean_Ip = cv2.boxFilter(imp,cv2.CV_64F,(r,r))<br> cov_Ip = mean_Ip - mean_Imean_p<br> <br> mean_II = cv2.boxFilter(imim,cv2.CV_64F,(r,r))<br> var_I = mean_II - mean_Imean_I<br> <br> a = cov_Ip/(var_I + eps)<br> b = mean_p - amean_I<br> <br> mean_a = cv2.boxFilter(a,cv2.CV_64F,(r,r))<br> mean_b = cv2.boxFilter(b,cv2.CV_64F,(r,r))<br> <br> q = mean_aim + mean_b<br> return q<br> <br>def TransmissionRefine(im,et):<br> gray = cv2.cvtColor(im,cv2.COLOR_BGR2GRAY)<br> gray = np.float64(gray)/255<br> r = 60<br> eps = 0.0001<br> t = Guidedfilter(gray,et,r,eps)<br> <br> return t<br> <br>def Recover(im,t,A,tx = 0.1):<br> res = np.empty(im.shape,im.dtype)<br> t = cv2.max(t,tx)<br> <br> for ind in range(0,3):<br> res[:,:,ind] = (im[:,:,ind]-A[0,ind])/t + A[0,ind]<br> <br> return res<br> <br>if name == 'main':<br> <br> fn = 'car-02.png'<br> src = cv2.imread(fn)<br> I = src.astype('float64')/255<br> <br> dark = DarkChannel(I,15)<br> A = AtmLight(I,dark)<br> te = TransmissionEstimate(I,A,15)<br> t = TransmissionRefine(src,te)<br> J = Recover(I,t,A,0.1)<br> <br> arr = np.hstack((I, J))<br> cv2.imshow("contrast", arr)<br> cv2.imwrite("car-02-dehaze.png", J255 )<br> cv2.imwrite("car-02-contrast.png", arr255)<br> cv2.waitKey();</pre></div></div></div><p data-id="p34042e45-340963105444c54090de4" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><br></p><p data-id="peafa0b28-34094514003f02ae1638c" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;">实现效果如下图所示:</p><p data-id="peafa0b28-34096311139e9f65e3282" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><br></p><p data-id="peafa0b28-3409451400338aabe7aff" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><img src="https://s4.51cto.com/images/blog/202110/13110936_61664df0b152a29951.jpg" alt="" title="" style="visibility: visible; width: 654px; height: 183px;"></p><p data-id="p3e62262e-340963125944cf3a9565e" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><br></p><p data-id="peafa0b28-34094514004b4887772d1" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;">如果想和后续目标汽车检测结合,同样可以先去雾再进行检测,如下图所示:</p><p data-id="peafa0b28-34096313389a266776468" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><br></p><p data-id="peafa0b28-34094514004d0806c1450" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><img src="https://s4.51cto.com/images/blog/202110/13110936_61664df0b61d546047.jpg" alt="" title="" style="visibility: visible; width: 654px; height: 240px;"></p><h2 style="line-height: 1.5;" id="h301ae07a-34094514004a464f4028f" data-id="h301ae07a-34094514004a464f4028f"><strong>四.图像噪声和雾生成</strong></h2><p data-id="peafa0b28-34094514004900a84d5e2" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;">图像处理总少不了噪声添加或生成,下面补充两个简单的椒盐噪声和雾气模拟生成的代码。这与本文的实验紧密相关,能为我们提供更多的GAN生成样本。后面人工智能系列文章,GAN我们看看能不能学习真实雾化场景的图像,值得期待,哈哈!</p><h3 style="line-height: 1.5;" id="he5f05f26-34094514004f344a9a78e" data-id="he5f05f26-34094514004f344a9a78e"><strong>1.加盐噪声</strong></h3><p data-id="peafa0b28-34094514004f6b64b935e" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;">原图是一张风景图像:</p><p data-id="peafa0b28-34096315526749c338783" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><br></p><p data-id="peafa0b28-34094514004c3e970cb27" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><img src="https://s4.51cto.com/images/blog/202110/13110936_61664df0c0e4281046.jpg" alt="" title="" style="visibility: visible; width: 600px; height: 398px;"></p><p data-id="pd31cd069-34096317134c10bd90742" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><br></p><p data-id="peafa0b28-34094514004487cff40c0" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;">代码如下:</p><p data-id="peafa0b28-3409631771336451ae6c1" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><br></p><div data-syntax="text"><div class="data-codeblock-content" style="border: 1px solid rgb(232, 232, 232); max-width: 750px; color: rgb(38, 38, 38); margin: 0px; padding: 0px; background: rgb(249, 249, 249);"><div class="CodeMirror" style="color: rgb(89, 89, 89); margin: 0px; padding: 16px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);"><pre class="cm-s-default" style="color: rgb(89, 89, 89); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);"># -- coding:utf-8 --<br>import cv2<br>import numpy as np<br><br>#读取图片<br>img = cv2.imread("fj.png", cv2.IMREAD_UNCHANGED)<br>rows, cols, chn = img.shape<br><br>#加噪声<br>for i in range(50000): <br> x = np.random.randint(0, rows) <br> y = np.random.randint(0, cols) <br> img[x,y,:] = 210<br><br>cv2.imshow("noise", img)<br> <br>#等待显示<br>cv2.waitKey(0)<br>cv2.destroyAllWindows()<br>cv2.imwrite('fj-res.png',img)</pre></div></div></div><p data-id="p16b4b53f-34096319528faeb5b0376" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><br></p><p data-id="peafa0b28-3409451400440d70192a8" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;">输出结果如下图所示:</p><p data-id="peafa0b28-34096320184ec511fd7f8" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><br></p><p data-id="peafa0b28-3409451400495c12ec4c7" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><img src="https://s4.51cto.com/images/blog/202110/13110936_61664df0d22549722.jpg" alt="" title="" style="visibility: visible; width: 600px; height: 398px;"></p><h3 style="line-height: 1.5;" id="he5f05f26-34094514004df1eb91efd" data-id="he5f05f26-34094514004df1eb91efd"><strong>2.雾的模拟生成</strong></h3><p data-id="peafa0b28-340945140049b3a8964b8" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;">代码如下:</p><p data-id="peafa0b28-3409632171763a9f86f40" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><br></p><div data-syntax="text"><div class="data-codeblock-content" style="border: 1px solid rgb(232, 232, 232); max-width: 750px; color: rgb(38, 38, 38); margin: 0px; padding: 0px; background: rgb(249, 249, 249);"><div class="CodeMirror" style="color: rgb(89, 89, 89); margin: 0px; padding: 16px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);"><pre class="cm-s-default" style="color: rgb(89, 89, 89); margin: 0px; padding: 0px; background: none 0% 0% / auto repeat scroll padding-box border-box rgba(0, 0, 0, 0);">import numpy as np<br>import cv2 as cv<br>import os<br>import random<br> <br>file = ['fj.png']<br>output = 'fj-wu.png'<br><br>for file_img in file:<br> #打开图像<br> img = cv.imread(file_img)<br> mask_img = cv.imread(file_img)<br> <br> #雾的颜色<br> mask_img[:, :] = (166, 178, 180) <br> <br> #里面参数可调,主要调整雾的浓度<br> image = cv.addWeighted(img,<br> round(random.uniform(0.03, 0.28), 2),<br> mask_img, 1, 0) <br><br> #保存的文件夹<br> cv.imwrite(output, image)</pre></div></div></div><p data-id="p47167e80-340963233120dc4677b7f" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><br></p><p data-id="peafa0b28-3409451400479f7b606d3" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;">输出结果如下图所示,效果还不错。</p><p data-id="peafa0b28-340963239525460fcdc0f" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><br></p><p data-id="peafa0b28-340945140044b82aadf10" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><img src="https://s4.51cto.com/images/blog/202110/13110936_61664df0e0c3d77438.jpg" alt="" title="" style="visibility: visible; width: 600px; height: 398px;"><img src="https://s4.51cto.com/images/blog/202110/13110936_61664df0ed87d53806.jpg" alt="" title="" style="visibility: visible; width: 618px; height: 474px;"></p><p data-id="pe7548c19-3409632803674d3ed21ce" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;"><br></p><p data-id="peafa0b28-34094514004bfba1067e5" style="letter-spacing: 0.05em; outline-style: none; overflow-wrap: break-word;">​<a href="https://bbs.huaweicloud.com/blogs?utm_source=51cto&utm_medium=bbs-ex&utm_campaign=other&utm_content=content" target="_blank">​<strong>点击关注,第一时间了解华为云新鲜技术~</strong>​</a>​</p></div>