WO2021238420A1 - Image defogging method, terminal, and computer storage medium - Google Patents

Image defogging method, terminal, and computer storage medium Download PDF

Info

Publication number
WO2021238420A1
WO2021238420A1 PCT/CN2021/085694 CN2021085694W WO2021238420A1 WO 2021238420 A1 WO2021238420 A1 WO 2021238420A1 CN 2021085694 W CN2021085694 W CN 2021085694W WO 2021238420 A1 WO2021238420 A1 WO 2021238420A1
Authority
WO
WIPO (PCT)
Prior art keywords
image
defogging
processed
model
sub
Prior art date
Application number
PCT/CN2021/085694
Other languages
French (fr)
Chinese (zh)
Inventor
崔永明
Original Assignee
Oppo广东移动通信有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Oppo广东移动通信有限公司 filed Critical Oppo广东移动通信有限公司
Publication of WO2021238420A1 publication Critical patent/WO2021238420A1/en

Links

Images

Classifications

    • G06T5/73
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • G06N3/045Combinations of networks
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T3/00Geometric image transformation in the plane of the image
    • G06T3/40Scaling the whole image or part thereof
    • G06T3/4038Scaling the whole image or part thereof for image mosaicing, i.e. plane images composed of plane sub-images
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/10Image acquisition modality
    • G06T2207/10016Video; Image sequence
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/20Special algorithmic details
    • G06T2207/20081Training; Learning
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/20Special algorithmic details
    • G06T2207/20084Artificial neural networks [ANN]

Abstract

An image defogging method, a terminal, and a computer storage medium. The image defogging method comprises: after determining that an image to be processed is a foggy image, determining a size parameter of the image to be processed (101); determining, according to the size parameter, a preprocessing policy corresponding to the image to be processed, wherein the preprocessing policy is used for limiting the image size (102); if the preprocessing policy is dividing the image to be processed, dividing the image to be processed to obtain sub-images corresponding to the image to be processed (103); performing defogging processing on the sub-images according to an image defogging model to obtain defogged sub-images corresponding to the sub-images (104); and performing stitching processing on the defogged sub-images according to an image stitching model to obtain a defogged image corresponding to the image to be processed (105).

Description

图像去雾方法、终端及计算机存储介质Image defogging method, terminal and computer storage medium
相关申请的交叉引用Cross-references to related applications
本申请要求在2020年05月29日提交中国专利局、申请号为202010472428.1、申请名称为“图像去雾方法、终端及计算机存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims the priority of a Chinese patent application filed with the Chinese Patent Office on May 29, 2020, the application number is 202010472428.1, and the application title is "Image Dehazing Method, Terminal and Computer Storage Medium", the entire content of which is incorporated by reference In this application.
技术领域Technical field
本申请实施例涉及终端技术领域,尤其涉及一种图像去雾方法、终端及计算机存储介质。The embodiments of the present application relate to the field of terminal technology, and in particular, to an image defogging method, terminal, and computer storage medium.
背景技术Background technique
随着计算机视觉的发展及其在交通、安全监控领域的应用,图像去雾已成为计算机视觉的重要研究领域。目前,图像去雾的方法主要有非物理模型去雾方法和物理模型去雾方法这两大类。其中,非物理模型的去雾方法本质上是增强图像的对比度与颜色;物理模型去雾方法是利用大气物理散射规律来建立图像还原模型。With the development of computer vision and its application in the fields of traffic and safety monitoring, image defogging has become an important research field of computer vision. Currently, image defogging methods mainly include two categories: non-physical model defogging methods and physical model defogging methods. Among them, the non-physical model defogging method is essentially to enhance the contrast and color of the image; the physical model defogging method is to use the atmospheric physical scattering law to establish an image restoration model.
然而,非物理模型去雾方法仅能改善视觉效果,并不能提高雾化图像的质量,甚至可能丢失图像的某些信息;物理模型去雾方法处理时间长,处理效率较低。可见,现有的图像去雾方法仍不够成熟,无法兼顾去雾处理的效果和效率。However, the non-physical model defogging method can only improve the visual effect, and cannot improve the quality of the fogged image, and may even lose some information of the image; the physical model defogging method has a long processing time and low processing efficiency. It can be seen that the existing image defogging methods are still not mature enough to take into account the effect and efficiency of defogging processing.
发明内容Summary of the invention
本申请实施例提供一种图像去雾方法、终端及计算机存储介质,能够在提高处理精度的同时,大大提升处理速度,从而实现高质量、高效率的图像去雾处理。The embodiments of the present application provide an image defogging method, terminal, and computer storage medium, which can greatly increase the processing speed while improving processing accuracy, thereby realizing high-quality and high-efficiency image defogging processing.
本申请实施例的技术方案是这样实现的:The technical solutions of the embodiments of the present application are implemented as follows:
第一方面,本申请实施例提供了一种图像去雾方法,所述方法包括:In the first aspect, an embodiment of the present application provides an image defogging method, and the method includes:
在判定待处理图像为雾化图像之后,确定待处理图像的尺寸参数;After determining that the image to be processed is a fogged image, determine the size parameter of the image to be processed;
根据所述尺寸参数确定待处理图像对应的预处理策略;其中,所述预处理策略用于对图像尺寸进行限制;Determine a preprocessing strategy corresponding to the image to be processed according to the size parameter; wherein, the preprocessing strategy is used to limit the size of the image;
若所述预处理策略为划分所述待处理图像,则划分所述待处理图像,获得所述待处理图像对应的子图像;If the preprocessing strategy is to divide the image to be processed, divide the image to be processed to obtain a sub-image corresponding to the image to be processed;
根据图像去雾模型对所述子图像进行去雾处理,获得所述子图像对应的去雾后子图像;Performing defogging processing on the sub-image according to the image defogging model to obtain a defogging sub-image corresponding to the sub-image;
根据图像拼接模型对所述去雾后子图像进行拼接处理,获得所述待处理图像对应的去雾后图像。Performing a splicing process on the defogging sub-images according to the image splicing model to obtain a defogging image corresponding to the image to be processed.
第二方面,本申请实施例提供了一种终端,所述终端包括:确定部分,划分部分,去雾部分,划分部分,In the second aspect, an embodiment of the present application provides a terminal. The terminal includes: a determining part, a dividing part, a dehazing part, and a dividing part,
所述确定部分,配置为在判定待处理图像为雾化图像之后,确定待处理图像的尺寸参数;以及根据所述尺寸参数确定待处理图像对应的预处理策略;其中,所述预处理策略用于对图像尺寸进行限制;The determining part is configured to determine the size parameter of the image to be processed after determining that the image to be processed is a fogged image; and determine the preprocessing strategy corresponding to the image to be processed according to the size parameter; wherein the preprocessing strategy is used To limit the size of the image;
所述划分部分,配置为若所述预处理策略为划分所述待处理图像,则划分所述待处理图像,获得所述待处理图像对应的子图像;The dividing part is configured to divide the image to be processed if the preprocessing strategy is to divide the image to be processed to obtain a sub-image corresponding to the image to be processed;
所述去雾部分,配置为根据图像去雾模型对所述子图像进行去雾处理,获得所述子图像对应的去雾后子图像;The defogging part is configured to perform defogging processing on the sub-image according to the image defogging model to obtain a defogging sub-image corresponding to the sub-image;
所述划分部分,配置为根据图像拼接模型对所述去雾后子图像进行拼接处理,获得所述 待处理图像对应的去雾后图像。The dividing part is configured to perform stitching processing on the defogging sub-images according to an image stitching model to obtain a defogging image corresponding to the image to be processed.
第三方面,本申请实施例提供了一种终端,所述终端包括处理器、存储有所述处理器可执行指令的存储器,当所述指令被所述处理器执行时,实现如上所述的图像去雾方法。In a third aspect, an embodiment of the present application provides a terminal. The terminal includes a processor and a memory storing executable instructions of the processor. When the instructions are executed by the processor, the above-mentioned Image defogging method.
第四方面,本申请实施例提供了一种计算机可读存储介质,其上存储有程序,应用于终端中,所述程序被处理器执行时,实现如上所述的图像去雾方法。In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium with a program stored thereon and applied to a terminal. When the program is executed by a processor, the image defogging method as described above is implemented.
本申请实施例提供一种图像去雾方法、终端及计算机存储介质,终端在判定待处理图像为雾化图像之后,确定待处理图像的尺寸参数;根据尺寸参数确定待处理图像对应的预处理策略;其中,预处理策略用于对图像尺寸进行限制;若预处理策略为划分待处理图像,则划分待处理图像,获得待处理图像对应的子图像;根据图像去雾模型对子图像进行去雾处理,获得子图像对应的去雾后子图像;根据图像拼接模型对去雾后子图像进行拼接处理,获得待处理图像对应的去雾后图像。由此可见,在本申请的实施例中,终端可以利用深度学习获得的图像去雾模型对待处理图像进行去雾处理,同时,对于尺寸较大的待处理图像,终端还可以在利用图像去雾模型对待处理图像划分后的子图像进行去雾处理之后,使用深度学习获得的图像拼接模型进行拼接处理,以在保证处理精度的同时提高处理速度。进一步地,图像去雾模型和图像拼接模型是终端对CNN进行了极小网络设计而获得的,因此上述图像去雾方法可以在终端中实时运行。也就是说,在本申请中,基于深度学习获得的图像去雾模型和图像拼接模型进行图像去雾处理,能够在提高处理精度的同时,大大提升处理速度,从而实现高质量、高效率的图像去雾处理。The embodiments of the application provide an image defogging method, terminal, and computer storage medium. After determining that the image to be processed is a fogged image, the terminal determines the size parameter of the image to be processed; and determines the preprocessing strategy corresponding to the image to be processed according to the size parameter. ; Among them, the preprocessing strategy is used to limit the image size; if the preprocessing strategy is to divide the image to be processed, the image to be processed is divided to obtain the sub-image corresponding to the image to be processed; the sub-image is defogged according to the image defogging model Process to obtain the defogging sub-image corresponding to the sub-image; perform stitching processing on the defogging sub-image according to the image stitching model to obtain the defogging image corresponding to the image to be processed. It can be seen that, in the embodiment of the present application, the terminal can use the image defogging model obtained by deep learning to defog the image to be processed. At the same time, for the large-sized image to be processed, the terminal can also use the image defogging. After the model performs defogging processing on the sub-images after dividing the image to be processed, the image stitching model obtained by deep learning is used for stitching processing to increase the processing speed while ensuring the processing accuracy. Further, the image defogging model and the image stitching model are obtained by the terminal's minimal network design on the CNN, so the above-mentioned image defogging method can be run in the terminal in real time. That is to say, in this application, the image defogging process based on the image defogging model and the image stitching model obtained by deep learning can greatly increase the processing speed while improving the processing accuracy, thereby achieving high-quality and high-efficiency images. Defogging treatment.
附图说明Description of the drawings
图1为目前的图像去雾处理方法的示意图;Figure 1 is a schematic diagram of a current image defogging processing method;
图2为图像去雾方法的实现流程示意图一;Figure 2 is the first schematic diagram of the implementation process of the image defogging method;
图3为图像去雾方法的实现流程示意图二;Figure 3 is a second schematic diagram of the implementation process of the image defogging method;
图4为图像去雾方法的实现流程示意图三;Figure 4 is the third schematic diagram of the implementation process of the image defogging method;
图5为图像去雾方法的实现流程示意图四;Figure 5 is a fourth schematic diagram of the implementation process of the image defogging method;
图6为常规卷积处理的示意图;Fig. 6 is a schematic diagram of conventional convolution processing;
图7为Depthwise卷积处理的示意图;Figure 7 is a schematic diagram of Depthwise convolution processing;
图8为Pointwise卷积处理的示意图;Fig. 8 is a schematic diagram of Pointwise convolution processing;
图9为图像去雾方法的实现流程示意图五;Figure 9 is a schematic diagram five of the implementation process of the image defogging method;
图10为图像去雾方法的实现流程示意图六;FIG. 10 is a sixth schematic diagram of the implementation process of the image defogging method;
图11为终端的组成结构示意图一;Figure 11 is a first schematic diagram of the terminal structure;
图12为终端的组成结构示意图二。Figure 12 is a second schematic diagram of the terminal structure.
具体实施方式Detailed ways
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述。可以理解的是,此处所描述的具体实施例仅仅用于解释相关申请,而非对该申请的限定。另外还需要说明的是,为了便于描述,附图中仅示出了与有关申请相关的部分。The technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. It is understandable that the specific embodiments described here are only used to explain the related application, but not to limit the application. In addition, it should be noted that, for ease of description, only the parts related to the relevant application are shown in the drawings.
由于受到大气中漂浮水滴对光的折射、反射、自身吸收和自身成像等影响,使得在雾天时所捕获图像的对比度较低,并引起色彩失真,甚至会导致机器视觉系统无法正常工作。在雾霾天气导致能见度较低的恶劣气象条件下,采集到的图片受大气中悬浮颗粒物(如雾、霾等)的影响,导致图片质量不佳,难以辨别图片中的物体特征,甚至影响例如室外监控、目标识别和交通导航中图片的质量。因此,有雾图像特征清晰化有着极为重要的意义。Due to the influence of light refraction, reflection, self-absorption and self-imaging by floating water droplets in the atmosphere, the contrast of the image captured in foggy weather is low, and color distortion is caused, and the machine vision system may even fail to work normally. Under severe weather conditions where visibility is low due to haze weather, the collected pictures are affected by suspended particulates in the atmosphere (such as fog, haze, etc.), resulting in poor picture quality, making it difficult to distinguish the features of the objects in the picture, and even affecting, for example, The quality of pictures in outdoor surveillance, target recognition and traffic navigation. Therefore, the sharpening of foggy image features is extremely important.
随着计算机视觉的发展及其在交通、安全监控领域的应用,图像去雾已成为计算机视觉的重要研究领域。目前主要是利用传统图像处理方法或者物理模型去雾方法将雾化图像输入,输出得到清晰图像。其中,传统图像处理方法本质上是增强图像的对比度与颜色,仅能 改善视觉效果,并不能提高雾化图像的质量,甚至可能丢失图像的某些信息;物理模型去雾方法是利用大气物理散射规律来建立图像还原模型,但处理时间长,处理效率较低。With the development of computer vision and its application in the fields of traffic and safety monitoring, image defogging has become an important research field of computer vision. At present, traditional image processing methods or physical model defogging methods are mainly used to input fogged images and output clear images. Among them, the traditional image processing method is essentially to enhance the contrast and color of the image, which can only improve the visual effect, but cannot improve the quality of the fogged image, and may even lose some information of the image; the physical model defogging method is to use atmospheric physical scattering The image restoration model is established according to the law, but the processing time is long and the processing efficiency is low.
具体地,一方面,图像增强类算法直接从图像处理角度出发,通过增强含雾图像的对比度,突出图片的特征或有效信息,一定程度上改善图片的视觉效果。但是该类方法忽略了图像降质的真正原因,所以对于场景复杂的图片无法提高图片的质量,甚至可能丢失图像的某些信息。另一方面,模型去雾类算法通过建立大气散射模型,研究图像退化的物理原理,得出大气中悬浮颗粒物对光的散射作用以及对图片的影响,复原出更真实的图片,且在复杂场景中去雾效果较好,图像信息较完整。该算法对非天空区域的图片有着良好的去雾效果,而对于有天空的这类的亮区域结果并不理想,且该算法计算量太大,效率较低。Specifically, on the one hand, image enhancement algorithms directly start from the perspective of image processing, by enhancing the contrast of the foggy image, highlighting the characteristics or effective information of the image, and improving the visual effect of the image to a certain extent. However, this type of method ignores the real cause of image degradation, so for pictures with complex scenes, the quality of the picture cannot be improved, and some information of the image may even be lost. On the other hand, the model defogging algorithm establishes an atmospheric scattering model, studies the physical principles of image degradation, and obtains the scattering effect of suspended particles in the atmosphere on the light and the influence on the picture, and restores more realistic pictures, and in complex scenes The medium dehazing effect is better, and the image information is more complete. This algorithm has a good dehazing effect for pictures in non-sky areas, but the results are not ideal for bright areas with sky, and the algorithm is too computationally expensive and low in efficiency.
图1为目前的图像去雾处理方法的示意图,如图1所示,现有的技术方案主要是将雾化图像输入至去雾算法模型中,输出得到去雾后的清晰图像。其中,机器学习的模型是基于传统算法生成的。可见,现有技术是利用传统算法对整幅雾化图像进行处理,主要有以下缺点:Fig. 1 is a schematic diagram of a current image defogging processing method. As shown in Fig. 1, the existing technical solution is mainly to input a fogged image into a defogging algorithm model, and output a clear image after defogging. Among them, the machine learning model is generated based on traditional algorithms. It can be seen that the prior art uses traditional algorithms to process the entire fogged image, which has the following disadvantages:
1、传统手工设计算法泛化性比较差,在环境变化比较大的情况下,效果不好。1. The generalization of traditional manual design algorithms is relatively poor, and the effect is not good when the environment changes greatly.
2、对整幅图像直接进行去雾处理时,如果输入图像非常大,比如3000×4000时,处理速度非常慢。2. When the whole image is directly defogged, if the input image is very large, such as 3000×4000, the processing speed is very slow.
也就是说,现有技术中,由于缺少相关利用深度学习算法进行图像去雾的算法,复杂场景下的去雾效果并不理想;且现有的去雾处理方法存在处理效率低的问题。That is to say, in the prior art, due to the lack of related algorithms for image defogging using deep learning algorithms, the defogging effect in complex scenes is not ideal; and the existing defogging processing methods have a problem of low processing efficiency.
在人工智能(Artificial Intelligence,AI)领域日益发展的今天,深度学习对图像去雾的效果越来越好,因此,本申请提出的图像去雾方法,利用AI进行图像去雾模型的搭建,同时,还可以通过构建的图像拼接模型辅助大尺寸图像的去雾处理,从而可以同时对去雾处理的效果和效率进行提升。进一步对,在本申请中,图像去雾模型和图像拼接模型均是在卷积神经网络(Convolutional Neural Networks,CNN)网络结构的基础上简化设计获得的,可以以较低的乘积累加运算(Multiply-Accumulates,MACs)在移动终端中运行,从而实现了端到端的实时图像去雾。Today, with the increasing development of artificial intelligence (AI), deep learning is getting better and better for image defogging. Therefore, the image defogging method proposed in this application uses AI to build an image defogging model, and at the same time , You can also assist the defogging processing of large-size images through the constructed image stitching model, so that the effect and efficiency of the defogging processing can be improved at the same time. Furthermore, in this application, both the image defogging model and the image stitching model are obtained by simplifying the design on the basis of the convolutional neural network (Convolutional Neural Networks, CNN) network structure. -Accumulates, MACs) run in the mobile terminal to achieve end-to-end real-time image defogging.
具体地,为了解决上述缺陷,本申请提出的图像去雾算法,终端可以利用深度学习获得的图像去雾模型对待处理图像进行去雾处理,同时,对于尺寸较大的待处理图像,终端还可以在利用图像去雾模型对待处理图像划分后的子图像进行去雾处理之后,使用深度学习获得的图像拼接模型进行拼接处理,以在保证处理精度的同时提高处理速度。进一步地,图像去雾模型和图像拼接模型是终端对CNN进行了极小网络设计而获得的,因此上述图像去雾方法可以在终端中实时运行。也就是说,在本申请中,基于深度学习获得的图像去雾模型和图像拼接模型进行图像去雾处理,能够在提高处理精度的同时,大大提升处理速度,从而实现高质量、高效率的图像去雾处理。Specifically, in order to solve the above shortcomings, in the image defogging algorithm proposed in this application, the terminal can use the image defogging model obtained by deep learning to defog the image to be processed. At the same time, for the larger image to be processed, the terminal can also After the image defogging model is used to perform defogging processing on the sub-images after the image to be processed is divided, the image stitching model obtained by deep learning is used for stitching processing, so as to increase processing speed while ensuring processing accuracy. Further, the image defogging model and the image stitching model are obtained by the terminal's minimal network design on the CNN, so the above-mentioned image defogging method can be run in the terminal in real time. That is to say, in this application, the image defogging process based on the image defogging model and the image stitching model obtained by deep learning can greatly increase the processing speed while improving the processing accuracy, thereby achieving high-quality and high-efficiency images. Defogging treatment.
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述。The technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application.
本申请一实施例提供了一种图像去雾方法,图2为图像去雾方法的实现流程示意图一,如图2所示,在本申请的实施例中,终端进行图像去雾处理的方法可以包括以下步骤:An embodiment of the present application provides an image defogging method. FIG. 2 is a schematic diagram of the implementation process of the image defogging method. As shown in FIG. It includes the following steps:
步骤101、在判定待处理图像为雾化图像之后,确定待处理图像的尺寸参数。Step 101: After determining that the image to be processed is a fogged image, determine the size parameter of the image to be processed.
在本申请的实施例中,终端在确定待处理图像为雾化图像之后,可以先对待处理图像的尺寸参数进行确定。In the embodiment of the present application, after determining that the image to be processed is a fogged image, the terminal may first determine the size parameter of the image to be processed.
需要说明的是,在本申请的实施例中,上述终端可以为任何具备通信和存储功能的终端,例如:平板电脑、手机、电子阅读器、遥控器、个人计算机(Personal Computer,PC)、笔记本电脑、车载设备、网络电视、可穿戴设备、个人数字助理(Personal Digital Assistant,PDA)、便捷式媒体播放器(Portable Media Player,PMP)、导航装置等终端。It should be noted that, in the embodiments of the present application, the above-mentioned terminal may be any terminal with communication and storage functions, such as: tablet computer, mobile phone, e-reader, remote control, personal computer (PC), notebook Terminals such as computers, in-vehicle equipment, Internet TV, wearable devices, personal digital assistants (PDA), portable media players (PMP), navigation devices, etc.
进一步地,在本申请的实施例中,待处理图像可以为终端预先存储的图像,例如,待处理图像可以为手机相册中的图像;待处理图像也可以为终端实时采集的图像,例如,待处理图像可以为手机拍摄获得的预览图像;待处理图像还可以为终端实时录制的视频中的一帧图 像,例如,待处理图像可以为监控设备录制的监控视频中的一帧图像。Further, in the embodiments of the present application, the image to be processed may be an image stored in advance by the terminal. For example, the image to be processed may be an image in a mobile phone album; the image to be processed may also be an image collected by the terminal in real time, for example, The processed image may be a preview image captured by a mobile phone; the to-be-processed image may also be a frame of an image in a video recorded in real time by the terminal. For example, the to-be-processed image may be a frame of a surveillance video recorded by a surveillance device.
也就是说,在本申请的实施例中,待处理图像可以为终端预先存储的,也可以为终端实时采集的,还可以为终端接收其它设备发送的,本申请不做具体限定。That is to say, in the embodiment of the present application, the image to be processed may be pre-stored by the terminal, may also be collected by the terminal in real time, or may be sent by the terminal receiving other devices, which is not specifically limited in this application.
步骤102、根据尺寸参数确定待处理图像对应的预处理策略;其中,预处理策略用于对图像尺寸进行限制。Step 102: Determine a preprocessing strategy corresponding to the image to be processed according to the size parameter; wherein, the preprocessing strategy is used to limit the size of the image.
在本申请的实施例中,终端在确定待处理图像的尺寸参数之后,可以进一步根据尺寸参数确定待处理图像对应的预处理策略。In the embodiment of the present application, after determining the size parameter of the image to be processed, the terminal may further determine the preprocessing strategy corresponding to the image to be processed according to the size parameter.
需要说明的是,在本申请的实施例中,预处理策略可以用于对图像尺寸进行限制。也就是说,对于不同的尺寸参数的图像,终端所确定的预处理策略是不相同。It should be noted that, in the embodiment of the present application, the preprocessing strategy can be used to limit the image size. In other words, for images with different size parameters, the preprocessing strategies determined by the terminal are different.
示例性的,在本申请的实施例中,对于尺寸较大的图像,终端确定的与其对应的预处理策略可以为先对该图像进行图像划分的预处理,然后再进行去雾处理;对于尺寸较小的图像,终端确定的与其对应的预处理策略可以为直接进行去雾处理。Exemplarily, in the embodiment of the present application, for an image with a larger size, the corresponding preprocessing strategy determined by the terminal may be to perform image division preprocessing on the image first, and then perform defogging processing; For smaller images, the corresponding pre-processing strategy determined by the terminal can be directly defogging.
由此可见,在本申请的实施例中,对于不同尺寸参数的待处理图像,终端确定的预处理策略是不同的。具体地,根据尺寸参数的大小,预处理策略可以包括不划分处理和划分处理。It can be seen that, in the embodiment of the present application, the preprocessing strategy determined by the terminal is different for images to be processed with different size parameters. Specifically, according to the size of the size parameter, the preprocessing strategy may include non-division processing and division processing.
可以理解的是,在本申请的实施例中,待处理图像的尺寸参数可以包括图像的长度与宽度,其中,图像的长度和宽度可以是以像素为单位的,也可以是以厘米为单位。It is understandable that, in the embodiment of the present application, the size parameter of the image to be processed may include the length and width of the image, where the length and width of the image may be in units of pixels or centimeters.
进一步地,在本申请的实施例中,终端可以预先设置一个用于确定待处理图像的预处理策略的尺寸参数,即预设尺寸阈值。Further, in the embodiment of the present application, the terminal may preset a size parameter used to determine the preprocessing strategy of the image to be processed, that is, the preset size threshold.
示例性的,在本申请的实施例中,终端在根据尺寸参数确定待处理图像对应的预处理策略时,可以将待处理图像的尺寸参数与预设尺寸阈值进行比较,从而可以根据比较结果进一步确定待处理图像的预处理策略。Exemplarily, in the embodiment of the present application, when the terminal determines the preprocessing strategy corresponding to the image to be processed according to the size parameter, it may compare the size parameter of the image to be processed with a preset size threshold, so that it can further be based on the comparison result. Determine the preprocessing strategy of the image to be processed.
进一步地,在本申请的实施例中,终端在将待处理图像的尺寸参数与预设尺寸阈值进行比较之后,如果比较结果为尺寸参数大于或者等于预设尺寸阈值,那么终端便可以确定预处理策略为划分待处理图像;如果比较结果为尺寸参数小于预设尺寸阈值,那么终端便可以确定预处理策略为不划分待处理图像。Further, in the embodiment of the present application, after the terminal compares the size parameter of the image to be processed with the preset size threshold, if the comparison result is that the size parameter is greater than or equal to the preset size threshold, the terminal can determine the preprocessing The strategy is to divide the image to be processed; if the comparison result is that the size parameter is less than the preset size threshold, the terminal can determine that the preprocessing strategy is not to divide the image to be processed.
需要说明的是,在本申请的实施例中,终端可以对待处理图像的高度进行限制,也可以对待处理图像的宽度进行限制,还可以对待处理图像的高度和宽度进行限制;相应地,预设尺寸阈值可以为高度尺寸上限值,也可以为宽度尺寸上限值,还可以为高度和宽度的尺寸上限值。It should be noted that, in the embodiments of the present application, the terminal can limit the height of the image to be processed, or limit the width of the image to be processed, or limit the height and width of the image to be processed; accordingly, the preset The size threshold may be the upper limit of the height size, the upper limit of the width size, or the upper limit of the height and the width.
示例性的,在本申请中,终端可以将预设尺寸阈值确定为2048×1536,从而可以按照2048×1536的尺寸阈值对待处理图像的高度和宽度进行限制。Exemplarily, in this application, the terminal may determine the preset size threshold as 2048×1536, so that the height and width of the image to be processed may be restricted according to the size threshold of 2048×1536.
步骤103、若预处理策略为划分待处理图像,则划分待处理图像,获得待处理图像对应的子图像。Step 103: If the preprocessing strategy is to divide the image to be processed, divide the image to be processed to obtain a sub-image corresponding to the image to be processed.
在本申请的实施例中,终端在根据尺寸参数确定待处理图像对应的预处理策略之后,如果预处理策略为划分待处理图像,那么终端可以对待处理图像进行划分,获得待处理图像对应的子图像。In the embodiment of the present application, after the terminal determines the preprocessing strategy corresponding to the image to be processed according to the size parameter, if the preprocessing strategy is to divide the image to be processed, the terminal can divide the image to be processed to obtain the subprocess corresponding to the image to be processed. image.
进一步地,在本申请的实施例中,为了提高去雾处理的效率,对于尺寸较大的待处理图像,终端可以先将待处理图像划分为大小相等的多个子图像,然后在对划分后的子图像进行去雾处理,便可以加速去雾处理。Further, in the embodiment of the present application, in order to improve the efficiency of defogging processing, for a larger-sized image to be processed, the terminal may first divide the image to be processed into multiple sub-images of equal size, and then divide the divided image into multiple sub-images. Sub-images are processed for defogging to speed up the defogging processing.
需要说明的是,在本申请的实施例中,终端在划分待处理图像时,可以根据待处理图像的尺寸参数确定划分获得的子图像的个数,即对于不同的尺寸参数,划分待处理图像后获得的子图像的个数也可能不同。例如,将尺寸参数为a1的待处理图像划分为6个子图像,将尺寸参数为a2的待处理图像划分为9个子图像,其中,a1小于a2。It should be noted that, in the embodiment of the present application, when the terminal divides the image to be processed, it can determine the number of sub-images obtained by the division according to the size parameter of the image to be processed, that is, for different size parameters, divide the image to be processed The number of sub-images obtained later may also be different. For example, the image to be processed with the size parameter a1 is divided into 6 sub-images, and the image to be processed with the size parameter a2 is divided into 9 sub-images, where a1 is smaller than a2.
进一步地,在本申请的实施例中,终端在划分待处理图像时,还可以预先设置划分个数,即对于不同的尺寸参数,划分待处理图像后获得的子图像的个数是相同的。例如,将尺寸参数为a1的待处理图像划分为9个子图像,将尺寸参数为a2的待处理图像划分为9个子图像, 其中,a1小于a2。Further, in the embodiment of the present application, when the terminal divides the image to be processed, the number of divisions may be preset, that is, for different size parameters, the number of sub-images obtained after dividing the image to be processed is the same. For example, the image to be processed with the size parameter a1 is divided into 9 sub-images, and the image to be processed with the size parameter a2 is divided into 9 sub-images, where a1 is smaller than a2.
可以理解的是,在本申请的实施例中,如果预处理策略为划分待处理图像,那么终端可以将待处理图像划分为n个尺寸相同的子图像,其中,n为大于1的整数。It is understandable that, in the embodiment of the present application, if the preprocessing strategy is to divide the image to be processed, the terminal may divide the image to be processed into n sub-images of the same size, where n is an integer greater than 1.
步骤104、根据图像去雾模型对子图像进行去雾处理,获得子图像对应的去雾后子图像。Step 104: Perform defogging processing on the sub-image according to the image defogging model to obtain a defogging sub-image corresponding to the sub-image.
在本申请的实施例中,如果待处理图像对应的预处理策略为划分待处理图像,那么终端在划分待处理图像,获得待处理图像对应的子图像之后,便可以根据图像去雾模型对子图像进行去雾处理,从而便可以获得子图像对应的去雾后子图像。In the embodiment of the present application, if the preprocessing strategy corresponding to the image to be processed is to divide the image to be processed, the terminal can divide the image to be processed and obtain the sub-images corresponding to the image to be processed, and then pair the image according to the image defogging model. The image is processed for defogging, so that the defogging sub-image corresponding to the sub-image can be obtained.
可以理解的是,在本申请的实施例中,由于终端将待处理图像划分为n个尺寸相同的子图像,对应的,终端在对分别对每一个子图像进行去雾处理之后,可以获得n个子图像对应的n个去雾后子图像,其中,一个子图像对应一个去雾后子图像。It is understandable that, in the embodiment of the present application, since the terminal divides the image to be processed into n sub-images of the same size, correspondingly, the terminal can obtain n sub-images after defogging each sub-image. The n sub-images correspond to n sub-images after defogging, where one sub-image corresponds to one sub-image after defogging.
需要说明的是,在本申请的实施例中,为了提高图像去雾的处理效果,终端可以利用深度学习的图像去雾模型来分别对多个子图像进行去雾处理。其中,图像去雾模型可以为终端基于AI所构建的图像去雾算法。It should be noted that, in the embodiment of the present application, in order to improve the processing effect of image defogging, the terminal may use a deep learning image defogging model to perform defogging processing on multiple sub-images respectively. Among them, the image defogging model can be an image defogging algorithm built by the terminal based on AI.
进一步地,在本申请的实施例中,图像去雾模型可以是终端基于卷积神经网络CNN进行训练获得的。具体地,在本申请中,终端可以利用CNN中的MobileNet-V2来确定图像去雾模型。Further, in the embodiment of the present application, the image defogging model may be obtained by the terminal training based on the convolutional neural network CNN. Specifically, in this application, the terminal can use MobileNet-V2 in CNN to determine the image defogging model.
深度CNN网络如ResNet和DenseNet,已经极大地提高了图像分类的准确度。但是除了准确度外,计算复杂度也是CNN网络要考虑的重要指标,过复杂的网络可能速度很慢。为了满足终端所需要的既准确又高效的小模型,一些轻量级的CNN网络如MobileNet被提出,它们在速度和准确度之间做了很好地平衡。Deep CNN networks such as ResNet and DenseNet have greatly improved the accuracy of image classification. However, in addition to accuracy, computational complexity is also an important indicator to be considered for CNN networks. Overly complex networks may be very slow. In order to meet the accurate and efficient small models required by the terminal, some lightweight CNN networks such as MobileNet have been proposed, which have a good balance between speed and accuracy.
示例性的,在本申请的实施例中,终端在第一轻量化卷积神经网络的基础上,可以将部分卷积层修改为Depthwise卷积+Pointwise卷积,从而可以在保证处理效果的同时提高图像处理效率。其中,第一轻量化卷积神经网络可以为CNN中的MobileNet-V2网络。Exemplarily, in the embodiment of the present application, on the basis of the first lightweight convolutional neural network, the terminal can modify part of the convolutional layer to Depthwise convolution + Pointwise convolution, so that the processing effect can be guaranteed at the same time Improve image processing efficiency. Among them, the first lightweight convolutional neural network can be the MobileNet-V2 network in CNN.
MobileNet-V2是对MobileNet-V1的改进,同样是一个轻量化卷积神经网络,是适用于移动端的深度学习网络,其中,由于MobileNet-V2采用深度可分离的卷积(Depthwise Separable Convolution)代替传统卷积方式,将原始卷积分为Depthwise卷积+Pointwise卷积两部分,因此具有参数少、模型小、准确率相比一些传统卷积损失少等有点。MobileNet-V2 is an improvement of MobileNet-V1. It is also a lightweight convolutional neural network. It is a deep learning network suitable for mobile terminals. Among them, because MobileNet-V2 uses depthwise separable convolution instead of traditional Convolution method, the original convolution is divided into two parts of Depthwise convolution + Pointwise convolution, so it has the advantages of fewer parameters, smaller models, and less accuracy than some traditional convolutions.
Depthwise,即不同的channel使用不同的卷积核卷积提取特征;Pointwise,即对某一点,某一像素的卷积。Depthwise, that is, different channels use different convolution kernels to convolution to extract features; Pointwise, that is, the convolution of a certain point and a certain pixel.
Depthwise卷积与Pointwise卷积,合起来被称作Depthwise Separable Convolution,该结构和常规卷积操作类似,可用来提取特征,但相比于常规卷积操作,其参数量和运算成本较低,所以这种结构更适用于轻量级网络中,如MobileNet。Depthwise convolution and Pointwise convolution are collectively called Depthwise Separable Convolution. This structure is similar to conventional convolution operations and can be used to extract features, but compared to conventional convolution operations, its parameter amount and computational cost are lower, so This structure is more suitable for lightweight networks, such as MobileNet.
可以理解的是,在本申请的实施例中,终端在根据图像去雾模型对子图像进行去雾处理时,为了提高处理效率,终端可以基于图像去雾模型,同时对每一个子图像进行去雾处理。It is understandable that, in the embodiment of the present application, when the terminal performs defogging processing on sub-images according to the image defogging model, in order to improve processing efficiency, the terminal can dehaze each sub-image based on the image defogging model. Fog treatment.
可以理解的是,在本申请的实施例中,终端在根据图像去雾模型对子图像进行去雾处理之后,便可以获得每一个子图像对应的一个去雾后子图像。It is understandable that, in the embodiment of the present application, after the terminal performs defogging processing on the sub-images according to the image defogging model, it can obtain a defogging sub-image corresponding to each sub-image.
需要说明的是,在本申请的实施例中,终端在构建图像去雾模型时,可以先对第一图像样本集进行划分,获得第一训练数据和第一测试数据;其中,第一图像样本集包括雾化图像和雾化图像对应的清晰图像;然后基于第一轻量化卷积神经网络构建第一网络模型,并根据第一训练数据对第一网络模型进行训练处理,获得初始去雾模型;最后根据第一测试数据对初始去雾模型进行测试处理,便可以获得图像去雾模型。It should be noted that, in the embodiment of the present application, when the terminal constructs the image defogging model, it may first divide the first image sample set to obtain the first training data and the first test data; wherein, the first image sample The set includes the fogged image and the clear image corresponding to the fogged image; then the first network model is constructed based on the first lightweight convolutional neural network, and the first network model is trained according to the first training data to obtain the initial defogging model ; Finally, the initial defogging model is tested according to the first test data, and then the image defogging model can be obtained.
步骤105、根据图像拼接模型对去雾后子图像进行拼接处理,获得待处理图像对应的去雾后图像。Step 105: Perform splicing processing on the defogging sub-images according to the image splicing model to obtain a defogging image corresponding to the image to be processed.
在本申请的实施例中,终端在根据图像去雾模型对子图像进行去雾处理,获得子图像对应的去雾后子图像之后,终端可以根据图像拼接模型对全部去雾后子图像进行拼接处理,从而可以获得待处理图像对应的清晰图像,即去雾后图像。In the embodiment of the present application, after the terminal performs defogging processing on the sub-images according to the image defogging model to obtain the defogging sub-images corresponding to the sub-images, the terminal may stitch all the defogging sub-images according to the image stitching model Through processing, a clear image corresponding to the image to be processed can be obtained, that is, the image after defogging.
可以理解的是,在本申请的实施例中,终端在对分别对待处理图像的多个子图像进行去雾处理之后,可以获得多个子图像对应的多个去雾后子图像,进而,终端需要通过将多个去雾后子图像进行拼接,最终获得一帧与待处理图像对应的去雾后图像。It is understandable that, in the embodiment of the present application, after the terminal performs defogging processing on multiple sub-images of the image to be processed, it can obtain multiple defogging sub-images corresponding to the multiple sub-images, and further, the terminal needs to pass The multiple defogging sub-images are stitched together, and finally a frame of defogging image corresponding to the image to be processed is obtained.
需要说明的是,在本申请的实施例中,为了提高图像拼接的处理效果,终端可以利用深度学习的图像拼接模型来将多个去雾后子图像拼接成对应的去雾后图像。其中,图像拼接模型可以为终端基于人工智能AI所构建的图像拼接算法。It should be noted that, in the embodiment of the present application, in order to improve the processing effect of image splicing, the terminal may use a deep learning image splicing model to splice multiple defogging sub-images into corresponding defogging images. Among them, the image stitching model may be an image stitching algorithm constructed by the terminal based on artificial intelligence AI.
进一步地,在本申请的实施例中,图像拼接模型可以是终端基于CNN进行训练获得的。具体地,在本申请中,终端可以利CNN中的ShuffleNet-V2来确定图像拼接模型。Further, in the embodiment of the present application, the image stitching model may be obtained by the terminal training based on CNN. Specifically, in this application, the terminal can use ShuffleNet-V2 in CNN to determine the image stitching model.
除MobileNet以外,轻量化卷积神经网络CNN还包括ShuffleNet,ShuffleNet在速度和准确度之间也能达到很好地平衡。In addition to MobileNet, the lightweight convolutional neural network CNN also includes ShuffleNet, which can also achieve a good balance between speed and accuracy.
示例性的,在本申请的实施例中,终端在第二轻量化卷积神经网络的基础上,可以去掉部分卷积层,通过将部分卷积层修改为Depthwise卷积+Pointwise卷积的方式进行网络加速,从而可以基于这种对CNN进行了极小网络设计,实现在保证拼接效果的同时提高图像处理效率。其中,第二轻量化卷积神经网络可以为CNN中的ShuffleNet-V2网络。Exemplarily, in the embodiment of the present application, on the basis of the second lightweight convolutional neural network, the terminal can remove part of the convolutional layer, and modify the part of the convolutional layer to Depthwise convolution + Pointwise convolution. The network is accelerated, so that a very small network design for CNN can be carried out based on this, and the efficiency of image processing can be improved while ensuring the splicing effect. Among them, the second lightweight convolutional neural network may be the ShuffleNet-V2 network in CNN.
ShuffleNet-V2是ShuffleNet-V1的升级版本,在同等复杂度下,ShuffleNet-V2比ShuffleNet-V1和MobileNet-V2更准确。ShuffleNet-V2 is an upgraded version of ShuffleNet-V1. Under the same complexity, ShuffleNet-V2 is more accurate than ShuffleNet-V1 and MobileNet-V2.
为了改善ShuffleNet-V1的缺陷,ShuffleNet-V2版本引入了一种新的运算:Channel Split,将module的输入channels分为两部分,一部分直接向下传递,另外一部分则进行真正的向后计算。到了module的末尾,直接将两分支上的output channels数目级连起来,从而规避了ShuffleNet-V1中Element-wise sum的操作。然后我们再对最终输出的output feature maps进行Random Shuffle操作,从而使得各channels之间的信息相互交通。In order to improve the defects of ShuffleNet-V1, the ShuffleNet-V2 version introduces a new operation: Channel Split, which divides the input channels of the module into two parts, one part is passed down directly, and the other part is for real backward calculation. At the end of the module, the number of output channels on the two branches is directly connected, thereby avoiding the element-wise sum operation in ShuffleNet-V1. Then we perform Random Shuffle operation on the final output feature maps, so that the information between the channels can communicate with each other.
具体来说,在开始时先将输入特征图在通道维度分成两个分支:通道数分别为c’和c-c’,实际实现时c’=c/2。左边分支做同等映射,右边的分支包含3个连续的卷积,并且输入和输出通道相同,这符合G1原则(相同的通道宽度可最小化内存访问成本)。而且两个1x1卷积不再是组卷积,这符合G2原则(过度的组卷积会增访问成本),另外两个分支相当于已经分成两组。两个分支的输出不再是Add元素,而是concat在一起,紧接着是对两个分支concat结果进行channle shuffle,以保证两个分支信息交流。其实concat和channel shuffle可以和下一个模块单元的channel split合成一个元素级运算,这符合原则G4。Specifically, at the beginning, the input feature map is divided into two branches in the channel dimension: the number of channels is c'and c-c' respectively, and in actual implementation, c'=c/2. The left branch does the same mapping, the right branch contains 3 consecutive convolutions, and the input and output channels are the same, which conforms to the G1 principle (the same channel width can minimize the memory access cost). Moreover, two 1x1 convolutions are no longer group convolutions, which conforms to the G2 principle (excessive group convolutions will increase access costs), and the other two branches are equivalent to being divided into two groups. The output of the two branches is no longer an Add element, but concat together, followed by a channle shuffle of the concat results of the two branches to ensure the exchange of information between the two branches. In fact, concat and channel shuffle can be combined with the channel split of the next module unit to form an element-level operation, which is in line with principle G4.
需要说明的是,在本申请的实施例中,终端在构建图像拼接模型时,可以先对第二图像样本集进行划分,获得第二训练数据和第二测试数据;其中,第二图像样本集包括原始图像和原始图像对应的多个分解图像;然后基于第二轻量化卷积神经网络构建第二网络模型,并根据第二训练数据对第二网络模型进行训练处理,获得初始拼接模型;最后根据第二测试数据对初始拼接模型进行测试处理,便可以获得图像拼接模型。It should be noted that, in the embodiment of the present application, when the terminal constructs the image stitching model, it may first divide the second image sample set to obtain the second training data and the second test data; wherein, the second image sample set Including the original image and multiple decomposed images corresponding to the original image; then constructing a second network model based on the second lightweight convolutional neural network, and training the second network model according to the second training data to obtain the initial stitching model; and finally The initial stitching model is tested according to the second test data, and then the image stitching model can be obtained.
由此可见,在本申请中,如果预处理策略为划分待处理图像,那么终端可以先划分待处理图像,获得待处理图像对应的子图像;然后根据图像去雾模型对子图像进行去雾处理,从而获得子图像对应的去雾后子图像;最后便可以基于图像拼接模型对去雾后子图像进行拼接处理,进而获得去雾后图像。It can be seen that, in this application, if the preprocessing strategy is to divide the image to be processed, the terminal can first divide the image to be processed to obtain the sub-image corresponding to the image to be processed; then perform the defogging process on the sub-image according to the image defogging model , So as to obtain the defogging sub-images corresponding to the sub-images; finally, the defogging sub-images can be stitched based on the image stitching model to obtain the defogging images.
图3为图像去雾方法的实现流程示意图二,如图3所示,在本申请的实施例中,终端在根据尺寸参数确定待处理图像对应的预处理策略之后,即步骤102之后,那么终端进行图像去雾处理的方法还可以包括以下步骤:Figure 3 is a schematic diagram of the second implementation process of the image defogging method. As shown in Figure 3, in the embodiment of the present application, after the terminal determines the preprocessing strategy corresponding to the image to be processed according to the size parameter, that is, after step 102, the terminal The method for image defogging processing may further include the following steps:
步骤106、若预处理策略为不划分待处理图像,则直接根据图像去雾模型对待处理图像进行去雾处理,获得去雾后图像。Step 106: If the preprocessing strategy is not to divide the image to be processed, then directly perform defogging processing on the image to be processed according to the image defogging model to obtain a defogging image.
在本申请的实施例中,终端在根据尺寸参数确定待处理图像对应的预处理策略之后,便可以基于预处理测策略,根据图像去雾模型对待处理图像进行去雾处理,从而获得待处理图像对应的清晰图像,即去雾后图像。其中,如果预处理策略为不划分待处理图像,那么终端可以利用图像去雾模型对待处理图像进行去雾处理。In the embodiment of the present application, after the terminal determines the preprocessing strategy corresponding to the image to be processed according to the size parameter, it can perform defogging processing on the image to be processed according to the image defogging model based on the preprocessing measurement strategy, so as to obtain the image to be processed The corresponding clear image is the image after defogging. Among them, if the preprocessing strategy is not to divide the image to be processed, the terminal can use the image defogging model to perform defogging processing on the image to be processed.
示例性的,在本申请的实施例中,如果预处理策略为不划分待处理图像,那么终端便不需要对待处理图像进行划分处理,因此,终端可以直接根据图像去雾模型对待处理图像进行去雾处理,从而获得待处理图像对应的去雾后图像。Exemplarily, in the embodiment of the present application, if the preprocessing strategy is not to divide the image to be processed, the terminal does not need to divide the image to be processed. Therefore, the terminal can directly remove the image to be processed according to the image defogging model. Fog processing to obtain the defogged image corresponding to the image to be processed.
由此可见,本申请提出的图像去雾方法,对于不同尺寸参数的待处理图像,终端可以选择不同的预处理策略来对待处理图像进行去雾处理,从而可以提升去雾处理的处理效率。It can be seen that, for the image defogging method proposed in this application, for images to be processed with different size parameters, the terminal can select different preprocessing strategies to perform defogging processing on the image to be processed, thereby improving the processing efficiency of the defogging processing.
图4为图像去雾方法的实现流程示意图三,如图4所示,在本申请的实施例中,终端在确定待处理图像的尺寸参数之前,即步骤101之前,终端进行图像去雾处理的方法还可以包括以下步骤:Figure 4 is a schematic diagram of the third implementation process of the image defogging method. As shown in Figure 4, in the embodiment of the present application, before the terminal determines the size parameters of the image to be processed, that is, before step 101, the terminal performs image defogging processing The method can also include the following steps:
步骤107、对待处理图像进行分析处理,获得分析结果。Step 107: Perform analysis processing on the image to be processed to obtain the analysis result.
在本申请的实施例中,终端在获取待处理图像之后,可以先对待处理图像进行分析处理,获得分析结果。In the embodiment of the present application, after acquiring the image to be processed, the terminal may first analyze and process the image to be processed to obtain the analysis result.
可以理解的是,在本申请的实施例中,终端在对待处理图像进行分析处理时,可以检测待处理图像中的特征信息,然后基于特征信息获得待处理图像的分析结果。其中,分析结果可以用于对待处理图像是否有雾或待处理图像的雾化程度进行表征。It is understandable that, in the embodiment of the present application, when the terminal analyzes and processes the image to be processed, it can detect feature information in the image to be processed, and then obtain the analysis result of the image to be processed based on the feature information. Among them, the analysis result can be used to characterize whether the image to be processed is foggy or the degree of fogging of the image to be processed.
示例性的,在本申请的实施例中,终端可以利用预先学习的识别模型对待处理图像进行分析处理,即终端将待处理图像输入值识别模型中,输出待处理图像的分析结果。Exemplarily, in the embodiment of the present application, the terminal may use a pre-learned recognition model to analyze and process the image to be processed, that is, the terminal inputs the value of the image to be processed into the recognition model, and outputs the analysis result of the image to be processed.
步骤108、根据分析结果判断待处理图像是否为雾化图像。Step 108: Determine whether the image to be processed is a fogged image according to the analysis result.
在本申请的实施例中,终端在对待处理图像进行分析处理,获得分析结果以后,便可以根据分析结果判断待处理图像是否为雾化图像,即判断是否需要对待处理图像进行去雾处理。In the embodiment of the present application, after the terminal analyzes and processes the image to be processed and obtains the analysis result, it can determine whether the image to be processed is a fogged image based on the analysis result, that is, whether it is necessary to perform defogging processing on the image to be processed.
进一步地,在本申请的实施例中,由于待处理图像的分析结果可以表征待处理图像是否有雾,也可以表征待处理图像的雾化程度,因此,终端根在据分析结果判断待处理图像是否为雾化图像是,既可以直接将有雾的待处理图像确定为雾化图像,而将没雾的待处理图像确定为非雾化图像;也可以将雾化程度较高的图像确定为雾化图像,而将雾化程度较低的图像确定为非雾化图像。Further, in the embodiment of the present application, since the analysis result of the image to be processed can characterize whether the image to be processed is foggy, or the degree of fogging of the image to be processed, the terminal judges the image to be processed based on the analysis result. Whether it is a fogged image, you can directly determine a foggy image to be processed as a fogged image, and determine a non-fogged image to be processed as a non-fogged image; you can also determine an image with a higher degree of fog as a fogged image A fogged image, and an image with a low degree of fogging is determined as a non-fogged image.
进一步地,在本申请的另一示例中,终端在确定待处理图像的尺寸参数之前,即步骤101之前,终端可以先对待处理图像进行提取处理,获得待处理图像的每个像素RGB分量的最小分量值,将其存入到一个和待处理图像相同大小的灰度图中,然后将灰度图划分为多个像素为15×15的窗口,并对每个窗口进行最小值滤波,用窗口的最小像素值替代该窗口的所有像素后,得到的暗通道图。接着,终端可以将暗通道图的所有像素值与待处理图像分别作差,将所有差值累加得到差值总和,然后将差值总和与差值阈值进行比较,如果差值总和小于差值阈值,那么终端可以任认为不需要对待处理图像进行去雾处理;如果差值总和大于或者等于差值阈值,那么终端可以任认为需要对待处理图像进行去雾处理,则将待处理图像判定为雾化图像。Further, in another example of the present application, before the terminal determines the size parameter of the image to be processed, that is, before step 101, the terminal may first extract the image to be processed to obtain the smallest RGB component of each pixel of the image to be processed. The component value is stored in a grayscale image of the same size as the image to be processed, and then the grayscale image is divided into multiple 15×15 windows, and each window is filtered with the minimum value. After replacing all the pixels of the window with the minimum pixel value of, the dark channel image is obtained. Then, the terminal can separately make differences between all the pixel values of the dark channel image and the image to be processed, accumulate all the differences to obtain the sum of the differences, and then compare the sum of the differences with the difference threshold, if the sum of the differences is less than the difference threshold , The terminal can arbitrarily consider that the image to be processed does not need to be defogged; if the sum of the differences is greater than or equal to the difference threshold, the terminal can arbitrarily consider that the image to be processed needs to be defogged, and then judge the image to be processed as fogging image.
由此可见,在本申请的实施例中,基于上述步骤101至步骤108所提出的图像去雾方法,利用AI进行图像去雾模型的搭建,同时,还可以通过构建的图像拼接模型辅助大尺寸图像的去雾处理,从而可以同时对去雾处理的效果和效率进行提升。It can be seen that, in the embodiment of this application, based on the image defogging method proposed in steps 101 to 108 above, AI is used to build an image defogging model, and at the same time, the built image stitching model can also be used to assist large-size images. The image defogging process can improve the effect and efficiency of the defogging process at the same time.
进一步地,本申请提出的图像去雾方法包括通过AI图像去雾算法精确地对图像进行去雾处理,大大提高去雾处理的效果;还包括通过AI图像拼接算法对图像进行拼接处理,对多角度,多场景下的图像都有较好的拼接效果。经过实验对比,本申请提出的利用深度学习的图像去雾方法,比传统算法精度要高2倍以上,同时,由于可以将大尺寸图像划分为多个子图像进行并行处理,然后将处理结果拼接起来,因此对大尺寸图像的处理速度可以提升5倍以上。Further, the image defogging method proposed in the present application includes accurately defogging the image through the AI image defogging algorithm, which greatly improves the effect of the defogging processing; it also includes the image stitching processing through the AI image stitching algorithm, and Angles, images in multiple scenes have better stitching effects. After experimental comparison, the image defogging method using deep learning proposed in this application is more than 2 times more accurate than the traditional algorithm. At the same time, because the large-size image can be divided into multiple sub-images for parallel processing, and then the processing results are stitched together , So the processing speed of large-size images can be increased by more than 5 times.
可以理解的是,本申请提出的图像去雾方法可以在视频监控、图像美化等领域有广泛应用。比如在监控领域,当出现雾气比较大的情况下,摄像头很难拍清楚目标对象,经过对图像去雾之后,能清晰的看到目标任务。在图像美化方面,在使用手机进行自拍时,如果是天 气不好,或者拍的比较模糊时,利用图像去雾算法可以自动对图像进行去雾处理,使图像比较清晰。It is understandable that the image defogging method proposed in this application can be widely used in video surveillance, image beautification and other fields. For example, in the field of surveillance, when the fog is relatively large, the camera can hardly take a clear picture of the target object. After defogging the image, the target task can be clearly seen. In terms of image beautification, when using a mobile phone to take a selfie, if the weather is bad or the shot is blurry, the image defogging algorithm can automatically defog the image to make the image clearer.
本申请提出了一种图像去雾方法,终端在判定待处理图像为雾化图像之后,确定待处理图像的尺寸参数;根据尺寸参数确定待处理图像对应的预处理策略;其中,预处理策略用于对图像尺寸进行限制;若预处理策略为划分待处理图像,则划分待处理图像,获得待处理图像对应的子图像;根据图像去雾模型对子图像进行去雾处理,获得子图像对应的去雾后子图像;根据图像拼接模型对去雾后子图像进行拼接处理,获得待处理图像对应的去雾后图像。由此可见,在本申请的实施例中,终端可以利用深度学习获得的图像去雾模型对待处理图像进行去雾处理,同时,对于尺寸较大的待处理图像,终端还可以在利用图像去雾模型对待处理图像划分后的子图像进行去雾处理之后,使用深度学习获得的图像拼接模型进行拼接处理,以在保证处理精度的同时提高处理速度。进一步地,图像去雾模型和图像拼接模型是终端对CNN进行了极小网络设计而获得的,因此上述图像去雾方法可以在终端中实时运行。也就是说,在本申请中,基于深度学习获得的图像去雾模型和图像拼接模型进行图像去雾处理,能够在提高处理精度的同时,大大提升处理速度,从而实现高质量、高效率的图像去雾处理。This application proposes an image defogging method. After the terminal determines that the image to be processed is a fogged image, the size parameter of the image to be processed is determined; the preprocessing strategy corresponding to the image to be processed is determined according to the size parameter; wherein the preprocessing strategy is used In order to limit the image size; if the preprocessing strategy is to divide the image to be processed, the image to be processed is divided to obtain the sub-image corresponding to the image to be processed; the sub-image is defogged according to the image defogging model to obtain the corresponding sub-image Sub-image after defogging; the sub-image after defogging is stitched according to the image stitching model to obtain the defogging image corresponding to the image to be processed. It can be seen that, in the embodiment of the present application, the terminal can use the image defogging model obtained by deep learning to defog the image to be processed. At the same time, for the large-sized image to be processed, the terminal can also use the image defogging. After the model performs defogging processing on the sub-images after dividing the image to be processed, the image stitching model obtained by deep learning is used for stitching processing to increase the processing speed while ensuring the processing accuracy. Further, the image defogging model and the image stitching model are obtained by the terminal's minimal network design on the CNN, so the above-mentioned image defogging method can be run in the terminal in real time. That is to say, in this application, the image defogging process based on the image defogging model and the image stitching model obtained by deep learning can greatly increase the processing speed while improving the processing accuracy, thereby achieving high-quality and high-efficiency images. Defogging treatment.
基于上述实施例,在本申请的再一实施例中,图5为图像去雾方法的实现流程示意图四,如图5所示,在本申请的实施例中,终端在根据图像去雾模型对子图像进行去雾处理,获得子图像对应的去雾后子图像之前,即步骤104之前,终端进行图像去雾处理的方法还可以包括以下步骤:Based on the foregoing embodiment, in another embodiment of the present application, FIG. 5 is a schematic diagram of the fourth implementation process of the image defogging method, as shown in FIG. The sub-image is subjected to defogging processing, and before the defogging sub-image corresponding to the sub-image is obtained, that is, before step 104, the method for the terminal to perform image defogging processing may further include the following steps:
步骤109、对第一图像样本集进行划分,获得第一训练数据和第一测试数据;其中,第一图像样本集包括雾化图像和雾化图像对应的清晰图像。Step 109: Divide the first image sample set to obtain first training data and first test data; wherein, the first image sample set includes a fogged image and a clear image corresponding to the fogged image.
步骤1010、基于第一轻量化卷积神经网络构建第一网络模型,并根据第一训练数据对第一网络模型进行训练处理,获得初始去雾模型。Step 1010: Construct a first network model based on the first lightweight convolutional neural network, and perform training processing on the first network model according to the first training data to obtain an initial defogging model.
步骤1011、根据第一测试数据对初始去雾模型进行测试处理,获得图像去雾模型。Step 1011: Perform a test process on the initial defogging model according to the first test data to obtain an image defogging model.
在本申请的实施例中,终端在利用图像去雾模型对待处理图像进行去雾处理之前,可以先构建该图像去雾模型。In the embodiment of the present application, the terminal may first construct the image defogging model before performing the defogging processing on the image to be processed using the image defogging model.
进一步地,在本申请的实施例中,终端可以基于第一轻量化卷积神经网络构建第一网络模型,通过修改处理来提升速度。具体地,在第一轻量化卷积神经网络MobileNet-V2网络的基础上,可以将部分卷积层修改为Depthwise卷积+Pointwise卷积,通过这种的方式所设计的图像去雾模型,可以在不降低精度的情况下来提升速度,且能够在终端中实时运行。Further, in the embodiment of the present application, the terminal may construct the first network model based on the first lightweight convolutional neural network, and improve the speed by modifying the processing. Specifically, on the basis of the first lightweight convolutional neural network MobileNet-V2 network, part of the convolutional layer can be modified to Depthwise convolution + Pointwise convolution. The image defogging model designed in this way can be Increase the speed without reducing the accuracy, and can run in the terminal in real time.
Depthwise Separable Convolution是将一个完整的卷积运算分解为两步进行,即分解为Depthwise卷积与Pointwise卷积。Depthwise Separable Convolution is to decompose a complete convolution operation into two steps, namely decomposition into Depthwise convolution and Pointwise convolution.
图6为常规卷积处理的示意图,如图6所示,对于一张5×5像素、三通道彩色输入图片(shape为5×5×3)。经过3×3卷积核的卷积层(假设输出通道数为4,则卷积核shape为3×3×3×4),最终输出4个Feature Map,如果有same padding则尺寸与输入层相同(5×5),如果没有则为尺寸变为3×3。Fig. 6 is a schematic diagram of conventional convolution processing, as shown in Fig. 6, for a 5×5 pixel, three-channel color input picture (shape is 5×5×3). After the convolutional layer of the 3×3 convolution kernel (assuming the number of output channels is 4, the shape of the convolution kernel is 3×3×3×4), and finally output 4 Feature Maps, if there is same padding, the size and input layer Same (5×5), if not, the size becomes 3×3.
具体地,不同于常规卷积操作,Depthwise卷积的一个卷积核负责一个通道,一个通道只被一个卷积核卷积,而常规卷积每个卷积核是同时操作输入图片的每个通道。图7为Depthwise卷积处理的示意图,如图7所示,对于一张5×5像素、三通道彩色输入图片(shape为5×5×3),Depthwise卷积首先经过第一次卷积运算,不同于常规卷积,Depthwise完全是在二维平面内进行。卷积核的数量与上一层的通道数相同(通道和卷积核一一对应)。所以一个三通道的图像经过运算后生成了3个Feature map(如果有same padding则尺寸与输入层相同为5×5)。Specifically, different from conventional convolution operations, one convolution kernel of Depthwise convolution is responsible for one channel, and one channel is convolved by only one convolution kernel, while each convolution kernel of regular convolution operates each input image at the same time. aisle. Figure 7 is a schematic diagram of Depthwise convolution processing. As shown in Figure 7, for a 5×5 pixel, three-channel color input picture (shape is 5×5×3), Depthwise convolution first undergoes the first convolution operation Unlike conventional convolution, Depthwise is completely performed in a two-dimensional plane. The number of convolution kernels is the same as the number of channels in the previous layer (the channel and the convolution kernel correspond one-to-one). Therefore, a three-channel image generates 3 Feature maps (if there is same padding, the size is the same as the input layer and is 5×5).
Depthwise卷积完成后的Feature map数量与输入层的通道数相同,无法扩展Feature map。而且这种运算对输入层的每个通道独立进行卷积运算,没有有效的利用不同通道在相同空间位置上的feature信息。因此需要Pointwise卷积来将这些Feature map进行组合生成新的 Feature map。After the depthwise convolution is completed, the number of feature maps is the same as the number of channels in the input layer, and the feature map cannot be expanded. Moreover, this operation independently performs convolution operations on each channel of the input layer, and does not effectively use the feature information of different channels at the same spatial position. Therefore, Pointwise convolution is needed to combine these feature maps to generate a new feature map.
图8为Pointwise卷积处理的示意图,如图8所示,Pointwise卷积的运算与常规卷积运算非常相似,它的卷积核的尺寸为1×1×M,M为上一层的通道数。所以这里的卷积运算会将上一步的Feature map在深度方向上进行加权组合,生成新的Feature map。其中,有几个卷积核就有几个输出Feature map。例如,4个卷积核对应输出4个Feature map。Figure 8 is a schematic diagram of Pointwise convolution processing. As shown in Figure 8, the operation of Pointwise convolution is very similar to conventional convolution operations. The size of its convolution kernel is 1×1×M, and M is the channel of the previous layer. number. Therefore, the convolution operation here will perform a weighted combination of the feature map of the previous step in the depth direction to generate a new feature map. Among them, there are several output feature maps for several convolution kernels. For example, 4 convolution kernels correspond to output 4 feature maps.
MobileNet-V1与MobileNet-V2相比:Compared with MobileNet-V1 and MobileNet-V2:
MobileNet-V1:Depthwise+Pointwise,然后线性整流函数(Rectified Linear Unit,ReLU)激活;MobileNet-V2:先进行1×1的Pointwise通道扩张,Depthwise+Pointwise通道压缩,然后Linear激活。其中,Depthwise是对单个通道做卷积,前面通道数增大对它的计算量影响不会太大。MobileNet-V1: Depthwise+Pointwise, and then the linear rectification function (Rectified Linear Unit, ReLU) is activated; MobileNet-V2: 1×1 Pointwise channel expansion, Depthwise+Pointwise channel compression, and Linear activation. Among them, Depthwise is to perform convolution on a single channel, and the increase in the number of previous channels will not have much impact on its calculation.
MobileNet-V2与ResNet相比:Compared with ResNet, MobileNet-V2:
ResNet的残差网络(Residual block):原始ResNet的连线里是两个卷积,ResNet瓶颈结构连线里是1×1通道压缩+卷积+1×1通道扩张;MobileNet-V2的倒残块(Inverted Residual block):1×1通道扩张+卷积+1×1通道缩小。Residual block of ResNet: There are two convolutions in the original ResNet connection. The bottleneck structure connection of ResNet is 1×1 channel compression + convolution + 1×1 channel expansion; MobileNet-V2's residual Inverted Residual block: 1×1 channel expansion + convolution + 1×1 channel reduction.
具体地,MobileNet-V2的网络结构如表1所示:Specifically, the network structure of MobileNet-V2 is shown in Table 1:
表1Table 1
InputInput OperatorOperator tt cc nn ss
224 2×3 224 2 ×3 conv2dconv2d -- 3232 11 22
112 2×32 112 2 ×32 bottleneckbottleneck 11 1616 11 11
112 2×16 112 2 ×16 bottleneckbottleneck 66 24twenty four 22 22
56 2×24 56 2 ×24 bottleneckbottleneck 66 3232 33 22
28 2×32 28 2 ×32 bottleneckbottleneck 66 6464 44 22
14 2×64 14 2 ×64 bottleneckbottleneck 66 9696 33 11
14 2×96 14 2 ×96 bottleneckbottleneck 66 160160 33 22
7 2×160 7 2 ×160 bottleneckbottleneck 66 320320 11 11
7 2×320 7 2 ×320 conv2d 1×1conv2d 1×1 -- 12801280 11 11
7 2×1280 7 2 ×1280 avgpool 7×7avgpool 7×7 -- -- 11 --
1×1×12801×1×1280 conv2d 1×1conv2d 1×1 -- kk --  To
其中,t是输入通道的倍增系数,即表示“扩张”倍数,c是输出通道数,n是该模块重复次数,s表示步长stride。Among them, t is the multiplication factor of the input channel, which means "expansion" multiple, c is the number of output channels, n is the number of repetitions of the module, and s is the stride.
进一步地,在本申请的实施例中,终端可以先利用卷积神经网络CNN中的MobileNet-V2网络构建第一网络模型,然后通过对第一网络模型的训练和测试获得图像去雾模型。Further, in the embodiment of the present application, the terminal may first use the MobileNet-V2 network in the convolutional neural network CNN to construct the first network model, and then obtain the image defogging model through training and testing of the first network model.
可以理解的是,在本申请的实施例中,终端可以先获取第一图像样本集,其中,第一图像样本集包括雾化图像和雾化图像对应的清晰图像。也就是说,在第一图像样本集中,存储有一一对应的雾化图像和清晰图像。It is understandable that, in the embodiment of the present application, the terminal may first obtain the first image sample set, where the first image sample set includes a fogged image and a clear image corresponding to the fogged image. That is to say, in the first image sample set, there is a one-to-one correspondence between the fogged image and the clear image.
示例性的,在本申请的实施例中,第一图像样本集包括100个不同场景对应的雾化图像和清晰图像,即第一图像样本集中存储有200帧图像。Exemplarily, in the embodiment of the present application, the first image sample set includes 100 fogged images and clear images corresponding to different scenes, that is, the first image sample set stores 200 frames of images.
需要说明的是,在本申请的实施例中,第一图像样本集可以为终端采集获得的,也可以为终端接收其他图像采集装置发送的,本申请不作具体限定。It should be noted that, in the embodiment of the present application, the first image sample set may be collected by the terminal, or may be sent by the terminal receiving other image collection devices, which is not specifically limited in this application.
进一步地,在本申请的实施例中,终端在获取第一图像样本集之后,可以对第一图像样本集进行划分,获得第一训练数据和第一测试数据。其中,第一训练数据用于对第一网络模型进行训练,第一测试数据用于对初始去雾模型进行测试。Further, in the embodiment of the present application, after acquiring the first image sample set, the terminal may divide the first image sample set to obtain the first training data and the first test data. Among them, the first training data is used to train the first network model, and the first test data is used to test the initial defogging model.
可以理解的是,在本申请的实施例中,第一训练数据和第一测试数据中均包括有一一对应的雾化图像和清晰图像,然而,第一训练数据和第一测试数据中的图像是不相同,即第一图像样本集中的任意一组雾化图像和清晰图像,只能被划分为第一训练数据或者第一测试数据,不可以同时作为第一训练数据中的训练图像和第一测试数据中的测试图像。It can be understood that, in the embodiment of the present application, the first training data and the first test data both include a one-to-one correspondence between fog images and clear images. However, the first training data and the first test data The images are not the same, that is, any group of fogged images and clear images in the first image sample set can only be divided into the first training data or the first test data, and cannot be used as the training image and the first training data at the same time. The test image in the first test data.
进一步地,在本申请的实施例中,终端在基于第一轻量化卷积神经网络构建第一网络模型,且划分第一图像样本集获得第一训练数据和第一测试数据之后,终端便可以先使用第一 训练数据对第一网络模型进行训练处理,获得初始去雾模型;然后利用第一测试数据对初始去雾模型进行测试处理,以获得最终的图像去雾模型。Further, in the embodiment of the present application, after the terminal constructs the first network model based on the first lightweight convolutional neural network, and divides the first image sample set to obtain the first training data and the first test data, the terminal can First use the first training data to train the first network model to obtain the initial defogging model; then use the first test data to test the initial defogging model to obtain the final image defogging model.
需要说明的是,在本申请的实施例中,终端在使用第一训练数据对第一网络模型进行训练处理时,可以标注第一训练数据,经过反复迭代第一训练数据最终得到了识别精度较高的初始去雾模型。It should be noted that, in the embodiment of the present application, when the terminal uses the first training data to train the first network model, it can label the first training data, and after repeated iterations of the first training data, the recognition accuracy is finally obtained. High initial dehazing model.
具体地,在本申请的实施例中,终端在利用第一训练数据训练获得初始去雾模型,并利用第一测试数据集获得图像去雾模型的过程中,可以采用多种损失函数进行联合处理,示例性的,在本申请中,终端可以采用Softmax loss和focal loss进行联合训练,Specifically, in the embodiment of the present application, in the process of using the first training data to train the terminal to obtain the initial defogging model, and using the first test data set to obtain the image defogging model, multiple loss functions may be used for joint processing Exemplarily, in this application, the terminal may use Softmax loss and focal loss for joint training,
Softmax loss是最常用的损失函数之一,在图像分类和分割任务中都被广泛使用。Softmax loss是由softmax和交叉熵(cross-entropy loss)loss组合而成,所以全称是Softmax with cross-entropy loss,在caffe,tensorflow等开源框架的实现中,直接将两者放在一个层中,而不是分开不同层,可以让数值计算更加稳定,因为正指数概率可能会有非常大的值。Softmax loss is one of the most commonly used loss functions and is widely used in image classification and segmentation tasks. Softmax loss is a combination of softmax and cross-entropy loss, so the full name is Softmax with cross-entropy loss. In the implementation of open source frameworks such as caffe and tensorflow, the two are directly placed in one layer. Instead of separating different layers, you can make numerical calculations more stable, because the positive exponential probability may have a very large value.
Focal loss主要是为了解决one-stage目标检测中正负样本比例严重失衡的问题。该损失函数降低了大量简单负样本在训练中所占的权重,也可理解为一种困难样本挖掘。Focal loss is mainly to solve the problem of a serious imbalance in the ratio of positive and negative samples in one-stage target detection. This loss function reduces the weight of a large number of simple negative samples in training, and can also be understood as a kind of difficult sample mining.
需要说明的是,在本申请的实施例中,终端在根据第一测试数据对初始去雾模型进行测试处理,获得图像去雾模型时,可以先根据第一测试数据对初始去雾模型进行测试处理,生成第一测试结果;然后按照第一测试结果修正初始去雾模型,获得图像去雾模型。It should be noted that, in the embodiment of the present application, the terminal tests the initial defogging model according to the first test data to obtain the image defogging model, and may first test the initial defogging model according to the first test data. Process to generate a first test result; then modify the initial defogging model according to the first test result to obtain an image defogging model.
也就是说,在本申请中,终端在采用第一训练数据训练获得的初始去雾模型之后,可以基于第一测试数据对初始去雾模型的去雾处理效果进行测试。具体地,终端可以将第一测试数据中的雾化图像输入至初始去雾模型中,输出去雾图像,然后将该去雾图像与对应的清晰图像进行图像信息的比较,便可以获得第一测试结果。That is to say, in this application, after the terminal uses the initial defogging model trained by the first training data, it can test the defogging processing effect of the initial defogging model based on the first test data. Specifically, the terminal can input the fogged image in the first test data into the initial defogging model, output the defogging image, and then compare the defogging image with the corresponding clear image to obtain the first image information. Test Results.
可以理解的是,在本申请的实施例中,终端在获得第一测试结果之后,可以基于第一测试结果对训练获得的初始去雾模型进行修正,从而可以提升去雾处理的效果,获得优化后的模型,即图像去雾模型。It is understandable that, in the embodiment of the present application, after obtaining the first test result, the terminal can modify the initial defogging model obtained by training based on the first test result, thereby improving the effect of defogging processing and obtaining optimization The latter model is the image dehazing model.
由此可见,在本申请的实施例中,在CNN网络结构设计过程中,终端通过裁剪网络和优化网络,可使得图像去雾模型以非常低的MACs来实现在终端中快速运行,能够完全满足终端的实时检测要求。在设计算法的过程中,还可以针对多种图像场景进一步进行优化,从而提升去雾算法的效果。It can be seen that in the embodiment of this application, in the CNN network structure design process, the terminal can cut the network and optimize the network to make the image defogging model run quickly in the terminal with very low MACs, which can fully satisfy Real-time detection requirements of the terminal. In the process of designing the algorithm, it can be further optimized for a variety of image scenes to improve the effect of the defogging algorithm.
本申请提出了一种图像去雾方法,终端可以利用深度学习获得的图像去雾模型对待处理图像进行去雾处理,同时,对于尺寸较大的待处理图像,终端还可以在利用图像去雾模型对待处理图像划分后的子图像进行去雾处理之后,使用深度学习获得的图像拼接模型进行拼接处理,以在保证处理精度的同时提高处理速度。进一步地,图像去雾模型和图像拼接模型是终端对CNN进行了极小网络设计而获得的,因此上述图像去雾方法可以在终端中实时运行。也就是说,在本申请中,基于深度学习获得的图像去雾模型和图像拼接模型进行图像去雾处理,能够在提高处理精度的同时,大大提升处理速度,从而实现高质量、高效率的图像去雾处理。This application proposes an image defogging method. The terminal can use the image defogging model obtained by deep learning to perform defogging processing on the image to be processed. At the same time, for larger-sized images to be processed, the terminal can also use the image defogging model After defogging the sub-images after dividing the image to be processed, the image stitching model obtained by deep learning is used for stitching processing, so as to improve the processing speed while ensuring the processing accuracy. Further, the image defogging model and the image stitching model are obtained by the terminal's minimal network design on the CNN, so the above-mentioned image defogging method can be run in the terminal in real time. That is to say, in this application, the image defogging process based on the image defogging model and the image stitching model obtained by deep learning can greatly increase the processing speed while improving the processing accuracy, thereby achieving high-quality and high-efficiency images. Defogging treatment.
基于上述实施例,在本申请的另一实施例中,图9为图像去雾方法的实现流程示意图五,如图9所示,在本申请的实施例中,终端在根据图像拼接模型对去雾后子图像进行拼接处理,获得待处理图像对应的去雾后图像之前,即步骤105之前,终端进行图像去雾处理的方法还可以包括以下步骤:Based on the foregoing embodiment, in another embodiment of the present application, FIG. 9 is a schematic diagram of the implementation process of the image defogging method 5. As shown in FIG. The post-fogging sub-images are stitched together, and before the defogging image corresponding to the image to be processed is obtained, that is, before step 105, the method for the terminal to perform image defogging processing may further include the following steps:
步骤1012、对第二图像样本集进行划分,获得第二训练数据和第二测试数据;其中,第二图像样本集包括原始图像和原始图像对应的多个分解图像。Step 1012: Divide the second image sample set to obtain second training data and second test data; where the second image sample set includes the original image and multiple decomposed images corresponding to the original image.
步骤1013、基于第二轻量化卷积神经网络构建第二网络模型,并根据第二训练数据对第二网络模型进行训练处理,获得初始拼接模型。Step 1013: Construct a second network model based on the second lightweight convolutional neural network, and perform training processing on the second network model according to the second training data to obtain an initial splicing model.
步骤1014、根据第二测试数据对初始拼接模型进行测试处理,获得图像拼接模型。Step 1014: Perform test processing on the initial stitching model according to the second test data to obtain an image stitching model.
在本申请的实施例中,终端在利用图像拼接模型对待处理图像对应的多个去雾后子图像 进行拼接处理之前,可以先构建该图像拼接模型。In the embodiment of the present application, the terminal may first construct the image stitching model before using the image stitching model to stitch the multiple defogging sub-images corresponding to the image to be processed.
进一步地,在本申请的实施例中,终端可以基于第二轻量化卷积神经网络构建第二网络模型,通过修改处理来提升速度。具体地,在第二轻量化卷积神经网络ShuffleNet-V2网络的基础上,可以将部分卷积层去掉,并将部分卷积层修改为Depthwise卷积+Pointwise卷积,通过这种的方式所设计的图像拼接模型,可以获得更好的图像拼接效果,且能够在终端中实时运行。Further, in the embodiment of the present application, the terminal may construct a second network model based on the second lightweight convolutional neural network, and improve the speed by modifying the processing. Specifically, on the basis of the second lightweight convolutional neural network ShuffleNet-V2 network, part of the convolutional layer can be removed, and part of the convolutional layer can be modified to Depthwise convolution + Pointwise convolution. The designed image splicing model can obtain better image splicing effects and can run in real time in the terminal.
由于ShuffleNet-V1大量使用了1x1组卷积,违背了G2原则(过度的组卷积会增访问成本),另外,ShuffleNet-V1采用了类似ResNet中的瓶颈层(bottleneck layer),输入和输出通道数不同,违背了G1原则(相同的通道宽度可最小化内存访问成本);同时使用过多的组,也违背了G3原则(网络碎片化会降低并行度);短路连接中存在大量的元素级Add运算,违背了G4原则(元素级运算不可忽视)。Since ShuffleNet-V1 uses a large number of 1x1 group convolutions, it violates the G2 principle (excessive group convolution will increase access costs). In addition, ShuffleNet-V1 uses a bottleneck layer similar to ResNet, input and output channels The number is different, which violates the G1 principle (the same channel width can minimize the memory access cost); using too many groups at the same time also violates the G3 principle (network fragmentation will reduce the degree of parallelism); there are a large number of element levels in short-circuit connections The Add operation violates the G4 principle (element-level operations cannot be ignored).
ShuffleNet-V2通过channel split的引进,改善了ShuffleNet-V1的缺陷。ShuffleNet-V2对于下采样模块,不再有channel split,而是每个分支都是直接copy一份输入,每个分支都有stride=2的下采样,最后concat在一起后,特征图空间大小减半,但是通道数翻倍。ShuffleNet-V2 improves the defects of ShuffleNet-V1 through the introduction of channel split. ShuffleNet-V2 no longer has a channel split for the downsampling module. Instead, each branch directly copies a copy of the input. Each branch has a downsampling of stride=2. After concat together, the feature map space is reduced. Half, but the number of channels doubled.
ShuffleNet-V2整体的网络结构和ShuffleNet-V1很相似。一个额外的1x1卷积层用在GlobalPool层之前是为了混合通道特征,在每个块中的通道数按比例缩放得到不同FLOPS的网络,即设定每个block的channel数,如0.5x,1x,从而可以调整模型的复杂度。The overall network structure of ShuffleNet-V2 is very similar to ShuffleNet-V1. An additional 1x1 convolutional layer is used before the GlobalPool layer to mix channel characteristics. The number of channels in each block is scaled to obtain a network with different FLOPS, that is, the number of channels for each block is set, such as 0.5x, 1x , Which can adjust the complexity of the model.
具体地,ShuffleNet-V2的网络结构如表2所示:Specifically, the network structure of ShuffleNet-V2 is shown in Table 2:
表2Table 2
Figure PCTCN2021085694-appb-000001
Figure PCTCN2021085694-appb-000001
进一步地,在本申请的实施例中,终端可以先利用卷积神经网络CNN中的ShuffleNet-V2网络构建第二网络模型,然后通过对第二网络模型的训练和测试获得图像拼接模型。Further, in the embodiment of the present application, the terminal may first use the ShuffleNet-V2 network in the convolutional neural network CNN to construct the second network model, and then obtain the image stitching model through training and testing of the second network model.
可以理解的是,在本申请的实施例中,终端可以先获取第二图像样本集,其中,第二图像样本集包括分解前的原始图像,以及该原始图像被划分后所对应的多个分解图像。也就是说,在第二图像样本集中,存储有对应的分解前的大尺寸图像和分解后的小尺寸图像。It is understandable that, in the embodiment of the present application, the terminal may first obtain the second image sample set, where the second image sample set includes the original image before decomposition, and multiple decompositions corresponding to the original image after the original image is divided. image. That is, in the second image sample set, the corresponding large-size image before decomposition and the small-size image after decomposition are stored.
示例性的,在本申请的实施例中,第二图像样本集包括100个不同场景对应的原始图像和分解图像,其中,一帧原始图像可以对应m帧分解图像,m为大于1的整数。Exemplarily, in the embodiment of the present application, the second image sample set includes original images and decomposed images corresponding to 100 different scenes, where one frame of original image may correspond to m frames of decomposed images, and m is an integer greater than 1.
可以理解的是,在本申请的实施例中,第二图像样本集中的不同原始图像所对应的分解图像的数量可能不同,例如,原始图像A对应有6个分解图像a1-a6,即对原始图像A进行划分处理后获得的分解图像a1-a6;原始图像B对应有9个分解图像b1-b9,即对原始图像B进行划分处理后获得的分解图像b1-b9。It is understandable that, in the embodiment of the present application, the number of decomposed images corresponding to different original images in the second image sample set may be different. For example, the original image A corresponds to 6 decomposed images a1-a6, which means that Image A is divided into decomposed images a1-a6; the original image B corresponds to 9 decomposed images b1-b9, that is, the decomposed images b1-b9 obtained after the original image B is divided.
需要说明的是,在本申请的实施例中,第二图像样本集可以为终端采集并划分获得的,也可以为终端接收其他图像采集装置发送的,本申请不作具体限定。It should be noted that, in the embodiment of the present application, the second image sample set may be collected and divided by the terminal, or may be sent by the terminal receiving other image collection devices, which is not specifically limited in this application.
进一步地,在本申请的实施例中,终端在获取第二图像样本集之后,可以对第二图像样 本集进行划分,获得第二训练数据和第二测试数据。其中,第二训练数据用于对第二网络模型进行训练,第二测试数据用于对初始拼接模型进行测试。Further, in the embodiment of the present application, after obtaining the second image sample set, the terminal may divide the second image sample set to obtain the second training data and the second test data. Among them, the second training data is used to train the second network model, and the second test data is used to test the initial splicing model.
可以理解的是,在本申请的实施例中,第二训练数据和第二测试数据中均包括有对应的原始图像和分解图像,然而,第二训练数据和第二测试数据中的图像是不相同,即第二图像样本集中的任意一组原始图像和对应的分解图像,只能被划分为第二训练数据或者第二测试数据,不可以同时作为第二训练数据中的训练图像和第二测试数据中的测试图像。It can be understood that, in the embodiment of the present application, the second training data and the second test data both include corresponding original images and decomposed images. However, the images in the second training data and the second test data are different. The same, that is, any set of original images and corresponding decomposed images in the second image sample set can only be divided into the second training data or the second test data, and cannot be used as the training image and the second test data in the second training data at the same time. The test image in the test data.
进一步地,在本申请的实施例中,终端在基于第二轻量化卷积神经网络构建第二网络模型,且划分第二图像样本集获得第二训练数据和第二测试数据之后,终端便可以先使用第二训练数据对第二网络模型进行训练处理,获得初始拼接模型;然后利用第二测试数据对初始拼接模型进行测试处理,以获得最终的图像拼接模型。Further, in the embodiment of the present application, after the terminal constructs the second network model based on the second lightweight convolutional neural network, and divides the second image sample set to obtain the second training data and the second test data, the terminal can First use the second training data to train the second network model to obtain the initial stitching model; then use the second test data to test the initial stitching model to obtain the final image stitching model.
需要说明的是,在本申请的实施例中,终端在使用第二训练数据对第二网络模型进行训练处理时,可以标注第二训练数据,经过反复迭代第二训练数据最终得到了识别精度较高的初始拼接模型。It should be noted that, in the embodiment of the present application, when the terminal uses the second training data to train the second network model, it can mark the second training data, and after repeated iterations of the second training data, the recognition accuracy is finally obtained. High initial stitching model.
具体地,在本申请的实施例中,终端在利用第二训练数据训练获得初始拼接模型,并利用第二测试数据集获得图像拼接模型的过程中,可以采用多种损失函数进行联合处理,示例性的,在本申请中,终端可以采用Softmax loss和focal loss进行联合训练,Specifically, in the embodiment of the present application, in the process of using the second training data to train the terminal to obtain the initial splicing model and using the second test data set to obtain the image splicing model, multiple loss functions may be used for joint processing. Example In this application, the terminal can use Softmax loss and focal loss for joint training,
需要说明的是,在本申请的实施例中,终端在根据第二测试数据对初始拼接模型进行测试处理,获得图像拼接模型时,可以先根据第二测试数据对初始拼接模型进行测试处理,生成第二测试结果;然后按照第二测试结果修正初始拼接模型,获得图像拼接模型。It should be noted that, in the embodiment of the present application, when the terminal performs test processing on the initial splicing model according to the second test data, and obtains the image splicing model, it may first perform the test processing on the initial splicing model according to the second test data to generate The second test result; then the initial stitching model is corrected according to the second test result to obtain an image stitching model.
也就是说,在本申请中,终端在采用第二训练数据训练获得的初始拼接模型之后,可以基于第二测试数据对初始拼接模型的拼接处理效果进行测试。具体地,终端可以将第二测试数据中的分解图像输入至初始拼接模型中,输出拼接后图像,然后将该拼接后图像与对应的原始图像进行图像信息的比较,便可以获得第二测试结果。That is, in this application, after the terminal uses the initial splicing model obtained by training with the second training data, it may test the splicing processing effect of the initial splicing model based on the second test data. Specifically, the terminal may input the decomposed image in the second test data into the initial stitching model, output the stitched image, and then compare the stitched image with the corresponding original image to obtain the second test result. .
可以理解的是,在本申请的实施例中,终端在获得第二测试结果之后,可以基于第二测试结果对训练获得的初始拼接模型进行修正,从而可以提升拼接处理的效果,获得优化后的模型,即图像拼接模型。It is understandable that, in the embodiment of the present application, after obtaining the second test result, the terminal can modify the initial stitching model obtained by training based on the second test result, thereby improving the effect of stitching processing and obtaining optimized Model, that is, image stitching model.
由此可见,在本申请的实施例中,在CNN网络结构设计过程中,终端通过裁剪网络和优化网络,可使得图像拼接模型以非常低的MACs来实现在终端中快速运行,能够完全满足终端的实时检测要求。在设计算法的过程中,还可以针对多种图像场景进一步进行优化,从而提升拼接算法的效果。It can be seen that in the embodiment of this application, in the CNN network structure design process, the terminal can cut the network and optimize the network, so that the image stitching model can run quickly in the terminal with very low MACs, which can fully satisfy the terminal Real-time detection requirements. In the process of designing the algorithm, it can be further optimized for a variety of image scenes, so as to improve the effect of the stitching algorithm.
本申请提出了一种图像去雾方法,终端可以利用深度学习获得的图像去雾模型对待处理图像进行去雾处理,同时,对于尺寸较大的待处理图像,终端还可以在利用图像去雾模型对待处理图像划分后的子图像进行去雾处理之后,使用深度学习获得的图像拼接模型进行拼接处理,以在保证处理精度的同时提高处理速度。进一步地,图像去雾模型和图像拼接模型是终端对CNN进行了极小网络设计而获得的,因此上述图像去雾方法可以在终端中实时运行。也就是说,在本申请中,基于深度学习获得的图像去雾模型和图像拼接模型进行图像去雾处理,能够在提高处理精度的同时,大大提升处理速度,从而实现高质量、高效率的图像去雾处理。This application proposes an image defogging method. The terminal can use the image defogging model obtained by deep learning to perform defogging processing on the image to be processed. At the same time, for larger-sized images to be processed, the terminal can also use the image defogging model After defogging the sub-images after dividing the image to be processed, the image stitching model obtained by deep learning is used for stitching processing, so as to improve the processing speed while ensuring the processing accuracy. Further, the image defogging model and the image stitching model are obtained by the terminal's minimal network design on the CNN, so the above-mentioned image defogging method can be run in the terminal in real time. That is to say, in this application, the image defogging process based on the image defogging model and the image stitching model obtained by deep learning can greatly increase the processing speed while improving the processing accuracy, thereby achieving high-quality and high-efficiency images. Defogging treatment.
基于上述实施例,在本申请的又一实施例中,图10为图像去雾处理的处理流程图六,如图10所示,终端对待处理图像进行去雾处理的方法可以包括以下步骤:Based on the foregoing embodiment, in another embodiment of the present application, FIG. 10 is a sixth flowchart of image defogging processing. As shown in FIG. 10, the method for the terminal to perform defogging processing on the image to be processed may include the following steps:
步骤201、判断待处理图像是否为雾化图像,如果是,执行步骤202,否则执行步骤207。Step 201: Determine whether the image to be processed is a fogged image, if yes, execute step 202, otherwise, execute step 207.
在本申请的实施例中,终端在获取待处理图像之后,可以先判断待处理图像是否为雾化图像。具体地,终端可以对待处理图像进行分析处理,获得分析结果,然后根据分析结果来判断待处理图像是否为雾化图像。In the embodiment of the present application, after acquiring the image to be processed, the terminal may first determine whether the image to be processed is a fogged image. Specifically, the terminal may analyze and process the image to be processed to obtain the analysis result, and then determine whether the image to be processed is a fogged image according to the analysis result.
步骤202、确定待处理图像的尺寸参数。Step 202: Determine the size parameter of the image to be processed.
在本申请的实施例中,如果判定待处理图像为雾化图像,那么终端便需要对待处理图像 执行去雾处理流程,首先,终端需要先确定待处理图像的图像大小,即确定待处理图像的尺寸参数。In the embodiment of this application, if it is determined that the image to be processed is a fogged image, the terminal needs to perform a defogging process for the image to be processed. First, the terminal needs to determine the image size of the image to be processed, that is, determine the size of the image to be processed. Size parameters.
步骤203、待处理图像的尺寸参数是否大于或者等于预设尺寸阈值,是则执行步骤204,否则执行步骤208。Step 203: Whether the size parameter of the image to be processed is greater than or equal to the preset size threshold, if yes, step 204 is executed, otherwise, step 208 is executed.
在本申请的实施例中,终端可以根据尺寸参数确定待处理图像对应的预处理策略,具体地,终端可以将待处理图像的尺寸参数与预设尺寸阈值进行比较,从而根据比较结果进一步确定对应的预处理策略。其中,预处理策略可以用于对图像尺寸进行限制。也就是说,对于不同的尺寸参数的图像,终端所确定的预处理策略是不相同。In the embodiment of the present application, the terminal may determine the preprocessing strategy corresponding to the image to be processed according to the size parameter. Specifically, the terminal may compare the size parameter of the image to be processed with a preset size threshold, so as to further determine the corresponding Pretreatment strategy. Among them, the preprocessing strategy can be used to limit the image size. In other words, for images with different size parameters, the preprocessing strategies determined by the terminal are different.
示例性的,在本申请的实施例中,对于尺寸较大的图像,终端确定的与其对应的预处理策略可以为先对该图像进行图像划分的预处理,然后再进行去雾处理;对于尺寸较小的图像,终端确定的与其对应的预处理策略可以为直接进行去雾处理。Exemplarily, in the embodiment of the present application, for an image with a larger size, the corresponding preprocessing strategy determined by the terminal may be to perform image division preprocessing on the image first, and then perform defogging processing; For smaller images, the corresponding pre-processing strategy determined by the terminal can be directly defogging.
步骤204、划分待处理图像,获得待处理图像对应的子图像。Step 204: Divide the image to be processed, and obtain sub-images corresponding to the image to be processed.
在本申请的实施例中,如果待处理图像的尺寸参数大于或者等于预设尺寸阈值,即预处理策略为划分待处理图像,那么终端可以对待处理图像进行划分,获得待处理图像对应的子图像。In the embodiment of the present application, if the size parameter of the image to be processed is greater than or equal to the preset size threshold, that is, the preprocessing strategy is to divide the image to be processed, the terminal can divide the image to be processed to obtain the sub-image corresponding to the image to be processed .
为了提高去雾处理的效率,对于尺寸较大的待处理图像,终端可以先将待处理图像划分为大小相等的多个子图像,然后在对划分后的子图像进行去雾处理,便可以加速去雾处理。In order to improve the efficiency of defogging processing, the terminal can first divide the to-be-processed image into multiple sub-images of equal size, and then perform defogging processing on the divided sub-images to speed up the processing. Fog treatment.
步骤205、基于图像去雾模型获得子图像对应的去雾后子图像。Step 205: Obtain a defogging sub-image corresponding to the sub-image based on the image defogging model.
在本申请的实施例中,终端根据图像去雾模型对子图像进行去雾处理,获得子图像对应的去雾后子图像。其中,为了提高图像去雾的处理效果,终端可以利用深度学习的图像去雾模型来分别对多个子图像进行去雾处理。In the embodiment of the present application, the terminal performs defogging processing on the sub-image according to the image defogging model, and obtains the defogging sub-image corresponding to the sub-image. Among them, in order to improve the processing effect of image defogging, the terminal may use a deep learning image defogging model to perform defogging processing on multiple sub-images respectively.
示例性的,在本申请的实施例中,终端在MobileNet-V2网络的基础上,可以将部分卷积层修改为Depthwise卷积+Pointwise卷积,从而可以在保证处理效果的同时提高图像处理效率。Exemplarily, in the embodiment of the present application, based on the MobileNet-V2 network, the terminal may modify part of the convolutional layer to Depthwise convolution + Pointwise convolution, which can improve the image processing efficiency while ensuring the processing effect .
步骤206、利用图像拼接模型拼接去雾后子图像,获得去雾后图像。Step 206: Use the image stitching model to stitch the defogging sub-images to obtain the defogging image.
在本申请的实施例中,终端可以根据图像拼接模型对全部去雾后子图像进行拼接处理,从而可以获得待处理图像对应的清晰图像,即去雾后图像。其中,为了提高图像拼接的处理效果,终端可以利用深度学习的图像拼接模型来将多个去雾后子图像拼接成对应的去雾后图像。In the embodiment of the present application, the terminal may perform splicing processing on all the sub-images after defogging according to the image splicing model, so as to obtain a clear image corresponding to the image to be processed, that is, the defogging image. Among them, in order to improve the processing effect of image splicing, the terminal may use a deep learning image splicing model to splice multiple defogging sub-images into corresponding defogging images.
示例性的,在本申请的实施例中,终端在ShuffleNet-V2网络的基础上,可以去掉部分卷积层,通过将部分卷积层修改为Depthwise卷积+Pointwise卷积的方式进行网络加速,从而可以基于这种对CNN进行了极小网络设计,实现在保证拼接效果的同时提高图像处理效率。Exemplarily, in the embodiment of the present application, based on the ShuffleNet-V2 network, the terminal can remove part of the convolutional layer, and perform network acceleration by modifying part of the convolutional layer to Depthwise convolution + Pointwise convolution. Therefore, a minimal network design for CNN can be carried out based on this, and the efficiency of image processing can be improved while ensuring the splicing effect.
步骤207、跳过去雾处理流程。Step 207: Jump over the fog processing flow.
在本申请的实施例中,如果判定待处理图像不为雾化图像,那么终端便不需要对待处理图像执行去雾处理流程。In the embodiment of the present application, if it is determined that the image to be processed is not a fogged image, then the terminal does not need to perform a defogging process on the image to be processed.
步骤208、基于图像去雾模型获得待处理图像对应的去雾后图像。Step 208: Obtain a defogging image corresponding to the image to be processed based on the image defogging model.
在本申请的实施例中,如果待处理图像的尺寸参数小于预设尺寸阈值,即预处理策略为不划分待处理图像,那么终端可以直接根据图像去雾模型对待处理图像进行去雾处理,获得待处理图像对应的去雾后图像。In the embodiment of the present application, if the size parameter of the image to be processed is less than the preset size threshold, that is, the preprocessing strategy is not to divide the image to be processed, the terminal can directly perform defogging processing on the image to be processed according to the image defogging model to obtain The dehazing image corresponding to the image to be processed.
进一步地,在本申请的实施例中,终端在执行步骤205或步骤208之前,终端对待处理图像进行去雾处理的方法还可以包括以下步骤:Further, in the embodiment of the present application, before the terminal performs step 205 or step 208, the method for the terminal to defog the image to be processed may further include the following steps:
步骤209、基于第一图像样本集进行深度学习,获得图像去雾模型。Step 209: Perform deep learning based on the first image sample set to obtain an image defogging model.
在本申请的实施例中,第一图像样本集包括雾化图像和雾化图像对应的清晰图像。终端将第一图像样本集划分为第一训练数据和第一测试数据,利用第一训练数据进行模型训练,获得初始去雾模型,再利用第一测试数据对初始去雾模型进行测试,获得图像去雾模型。In the embodiment of the present application, the first image sample set includes a fogged image and a clear image corresponding to the fogged image. The terminal divides the first image sample set into the first training data and the first test data, uses the first training data for model training to obtain the initial defogging model, and then uses the first test data to test the initial defogging model to obtain the image Dehazing model.
进一步地,在本申请的实施例中,终端在执行步骤206之前,终端对待处理图像进行去雾处理的方法还可以包括以下步骤:Further, in the embodiment of the present application, before the terminal performs step 206, the method for the terminal to defog the image to be processed may further include the following steps:
步骤2010、基于第二图像样本集进行深度学习,获得图像拼接模型。Step 2010: Perform deep learning based on the second image sample set to obtain an image mosaic model.
在本申请的实施例中,第二图像样本集包括原始图像和原始图像对应的多个分解图像。终端将第二图像样本集划分为第二训练数据和第二测试数据,利用第二训练数据进行模型训练,获得初始拼接模型,再利用第二测试数据对初始拼接模型进行测试,获得图像拼接模型。In the embodiment of the present application, the second image sample set includes the original image and multiple decomposed images corresponding to the original image. The terminal divides the second image sample set into second training data and second test data, uses the second training data for model training to obtain the initial splicing model, and then uses the second test data to test the initial splicing model to obtain the image splicing model .
可以理解的是,本申请提出的图像去雾方法不仅仅可用于手机相册中的图像美化,还可以用于视频监控领域,改进人脸识别等场景下。比如在视频监控中,当雾比较大时,监控设备拍摄得到的图像质量非常差,很难在视频中清晰的看到目标人物,经过图像去雾后,可以较好的还原目标人物的面貌。It is understandable that the image defogging method proposed in this application can not only be used for image beautification in mobile phone albums, but also can be used in the field of video surveillance to improve face recognition and other scenarios. For example, in video surveillance, when the fog is relatively large, the quality of the image captured by the surveillance equipment is very poor, and it is difficult to clearly see the target person in the video. After the image is defogged, the face of the target person can be better restored.
进一步地,本申请提出的图像去雾方法也可以在人脸识别中作为辅助手段,提高人脸识别效果,当人脸识别摄像头处于逆光或者其他天气不好的情况时,使用去雾算法可以显著的提高识别效果。Further, the image defogging method proposed in this application can also be used as an auxiliary means in face recognition to improve the effect of face recognition. When the face recognition camera is in backlight or other bad weather conditions, the use of the defogging algorithm can be significant To improve the recognition effect.
本申请提出了一种图像去雾方法,终端可以利用深度学习获得的图像去雾模型对待处理图像进行去雾处理,同时,对于尺寸较大的待处理图像,终端还可以在利用图像去雾模型对待处理图像划分后的子图像进行去雾处理之后,使用深度学习获得的图像拼接模型进行拼接处理,以在保证处理精度的同时提高处理速度。进一步地,图像去雾模型和图像拼接模型是终端对CNN进行了极小网络设计而获得的,因此上述图像去雾方法可以在终端中实时运行。也就是说,在本申请中,基于深度学习获得的图像去雾模型和图像拼接模型进行图像去雾处理,能够在提高处理精度的同时,大大提升处理速度,从而实现高质量、高效率的图像去雾处理。This application proposes an image defogging method. The terminal can use the image defogging model obtained by deep learning to perform defogging processing on the image to be processed. At the same time, for larger-sized images to be processed, the terminal can also use the image defogging model After defogging the sub-images after dividing the image to be processed, the image stitching model obtained by deep learning is used for stitching processing, so as to improve the processing speed while ensuring the processing accuracy. Further, the image defogging model and the image stitching model are obtained by the terminal's minimal network design on the CNN, so the above-mentioned image defogging method can be run in the terminal in real time. That is to say, in this application, the image defogging process based on the image defogging model and the image stitching model obtained by deep learning can greatly increase the processing speed while improving the processing accuracy, thereby achieving high-quality and high-efficiency images. Defogging treatment.
基于上述实施例,在本申请的另一实施例中,图11为终端的组成结构示意图一,如图11所示,本申请实施例提出的终端10可以包括确定部分11,划分部分12,去雾部分13,拼接部分14,分析部分15,判断部分16,获取部分17。Based on the foregoing embodiment, in another embodiment of the present application, FIG. 11 is a schematic diagram 1 of the terminal structure. As shown in FIG. 11, the terminal 10 proposed in this embodiment of the present application may include a determining part 11, a dividing part 12, The fog part 13, the splicing part 14, the analysis part 15, the judgment part 16, and the acquisition part 17.
所述确定部分11,配置为在判定待处理图像为雾化图像之后,确定待处理图像的尺寸参数;以及根据所述尺寸参数确定待处理图像对应的预处理策略;其中,所述预处理策略用于对图像尺寸进行限制;The determining part 11 is configured to determine a size parameter of the image to be processed after determining that the image to be processed is a fogged image; and determine a preprocessing strategy corresponding to the image to be processed according to the size parameter; wherein, the preprocessing strategy Used to limit the image size;
所述划分部分12,配置为若所述预处理策略为划分所述待处理图像,则划分所述待处理图像,获得所述待处理图像对应的子图像;The dividing part 12 is configured to divide the image to be processed if the preprocessing strategy is to divide the image to be processed to obtain a sub-image corresponding to the image to be processed;
所述去雾部分13,配置为根据图像去雾模型对所述子图像进行去雾处理,获得所述子图像对应的去雾后子图像;The defogging part 13 is configured to perform defogging processing on the sub-image according to an image defogging model to obtain a defogging sub-image corresponding to the sub-image;
所述拼接部分14,配置为根据图像拼接模型对所述去雾后子图像进行拼接处理,获得所述待处理图像对应的去雾后图像。The splicing part 14 is configured to perform splicing processing on the defogging sub-images according to an image splicing model to obtain a defogging image corresponding to the image to be processed.
进一步地,在本申请的实施例中,所述分析部分15,配置为所述确定待处理图像的尺寸参数之前,对所述待处理图像进行分析处理,获得分析结果;Further, in the embodiment of the present application, the analysis part 15 is configured to perform analysis processing on the image to be processed before determining the size parameter of the image to be processed to obtain an analysis result;
所述判断部分16,配置为根据所述分析结果判断所述待处理图像是否为雾化图像。The judging part 16 is configured to judge whether the image to be processed is a fogged image according to the analysis result.
进一步地,在本申请的实施例中,所述确定部分11,具体配置为若所述尺寸参数大于或者等于预设尺寸阈值,则确定所述预处理策略为划分所述待处理图像;若所述尺寸参数小于所述预设尺寸阈值,则确定所述预处理策略为不划分所述待处理图像。Further, in the embodiment of the present application, the determining part 11 is specifically configured to determine that the preprocessing strategy is to divide the image to be processed if the size parameter is greater than or equal to a preset size threshold; If the size parameter is less than the preset size threshold, it is determined that the preprocessing strategy is not to divide the image to be processed.
进一步地,在本申请的实施例中,所述获取部分17,配置为所述根据图像去雾模型对所述子图像进行去雾处理,获得所述子图像对应的去雾后子图像之前,对第一图像样本集进行划分,获得第一训练数据和第一测试数据;其中,所述第一图像样本集包括雾化图像和所述雾化图像对应的清晰图像;以及基于第一轻量化卷积神经网络构建第一网络模型,并根据所述第一训练数据对所述第一网络模型进行训练处理,获得初始去雾模型;以及根据所述第一测试数据对所述初始去雾模型进行测试处理,获得所述图像去雾模型。Further, in the embodiment of the present application, the acquiring part 17 is configured to perform defogging processing on the sub-image according to the image defogging model, and before obtaining the defogging sub-image corresponding to the sub-image, The first image sample set is divided to obtain first training data and first test data; wherein, the first image sample set includes a fogged image and a clear image corresponding to the fogged image; and based on the first lightweight The convolutional neural network constructs a first network model, and performs training processing on the first network model according to the first training data to obtain an initial defogging model; and performing the initial defogging model on the basis of the first test data Perform test processing to obtain the image defogging model.
进一步地,在本申请的实施例中,所述获取部分17,具体配置为根据所述第一测试数据 对所述初始去雾模型进行测试处理,生成第一测试结果;以及按照所述第一测试结果修正所述图像去雾模型,获得所述图像去雾模型。Further, in the embodiment of the present application, the acquiring part 17 is specifically configured to perform a test process on the initial dehazing model according to the first test data to generate a first test result; and according to the first test data The test result corrects the image defogging model to obtain the image defogging model.
进一步地,在本申请的实施例中,所述获取部分17,还配置为根据图像拼接模型对所述去雾后子图像进行拼接处理,获得所述待处理图像对应的去雾后图像之前,对第二图像样本集进行划分,获得第二训练数据和第二测试数据;其中,所述第二图像样本集包括原始图像和所述原始图像对应的多个分解图像;以及基于第二轻量化卷积神经网络构建第二网络模型,并根据所述第二训练数据对所述第二网络模型进行训练处理,获得初始拼接模型;以及根据所述第二测试数据对所述初始拼接模型进行测试处理,获得所述图像拼接模型。Further, in the embodiment of the present application, the acquiring part 17 is further configured to perform stitching processing on the defogging sub-images according to the image stitching model, and before obtaining the defogging image corresponding to the image to be processed, Divide the second image sample set to obtain second training data and second test data; wherein, the second image sample set includes an original image and a plurality of decomposed images corresponding to the original image; and based on the second lightweight The convolutional neural network constructs a second network model, and performs training processing on the second network model according to the second training data to obtain an initial stitching model; and testing the initial stitching model according to the second test data Processing to obtain the image stitching model.
进一步地,在本申请的实施例中,所述获取部分17,具体配置为根据所述第二测试数据对所述初始拼接模型进行测试处理,生成第二测试结果;以及按照所述第二测试结果修正所述初始拼接模型,获得所述图像拼接模型。Further, in the embodiment of the present application, the acquiring part 17 is specifically configured to perform test processing on the initial splicing model according to the second test data to generate a second test result; and according to the second test As a result, the initial stitching model is corrected, and the image stitching model is obtained.
进一步地,在本申请的实施例中,所述去雾部分13,还配置为所述根据所述尺寸参数确定待处理图像对应的预处理策略之后,若所述预处理策略为不划分所述待处理图像,则直接根据所述图像去雾模型对所述待处理图像进行去雾处理,获得所述去雾后图像。Further, in the embodiment of the present application, the dehazing part 13 is further configured to determine the preprocessing strategy corresponding to the image to be processed according to the size parameter, if the preprocessing strategy is not to divide the For the image to be processed, the image to be processed is defogged directly according to the image defogging model to obtain the defogging image.
图12为终端的组成结构示意图二,如图12所示,本申请实施例提出的终端10还可以包括处理器18、存储有处理器18可执行指令的存储器19,进一步地,终端10还可以包括通信接口110,和用于连接处理器18、存储器19以及通信接口110的总线111。Fig. 12 is a second schematic diagram of the composition structure of the terminal. As shown in Fig. 12, the terminal 10 proposed in the embodiment of the present application may further include a processor 18 and a memory 19 storing executable instructions of the processor 18. Further, the terminal 10 may also It includes a communication interface 110 and a bus 111 for connecting the processor 18, the memory 19, and the communication interface 110.
在本申请的实施例中,上述处理器18可以为特定用途集成电路(Application Specific Integrated Circuit,ASIC)、数字信号处理器(Digital Signal Processor,DSP)、数字信号处理装置(Digital Signal Processing Device,DSPD)、可编程逻辑装置(ProgRAMmable Logic Device,PLD)、现场可编程门阵列(Field ProgRAMmable Gate Array,FPGA)、中央处理器(Central Processing Unit,CPU)、控制器、微控制器、微处理器中的至少一种。可以理解地,对于不同的设备,用于实现上述处理器功能的电子器件还可以为其它,本申请实施例不作具体限定。终端10还可以包括存储器19,该存储器19可以与处理器18连接,其中,存储器19用于存储可执行程序代码,该程序代码包括计算机操作指令,存储器19可能包含高速RAM存储器,也可能还包括非易失性存储器,例如,至少两个磁盘存储器。In the embodiment of the present application, the aforementioned processor 18 may be an application specific integrated circuit (ASIC), a digital signal processor (Digital Signal Processor, DSP), a digital signal processing device (Digital Signal Processing Device, DSPD). ), Programmable Logic Device (ProgRAMmable Logic Device, PLD), Field Programmable Gate Array (Field ProgRAMmable Gate Array, FPGA), Central Processing Unit (CPU), Controller, Microcontroller, Microprocessor At least one of. It is understandable that, for different devices, the electronic devices used to implement the above-mentioned processor functions may also be other, which is not specifically limited in the embodiment of the present application. The terminal 10 may also include a memory 19, which may be connected to the processor 18. The memory 19 is used to store executable program code, the program code includes computer operation instructions, the memory 19 may include a high-speed RAM memory, or may also include Non-volatile memory, for example, at least two disk memories.
在本申请的实施例中,总线111用于连接通信接口110、处理器18以及存储器19以及这些器件之间的相互通信。In the embodiment of the present application, the bus 111 is used to connect the communication interface 110, the processor 18 and the memory 19, and to communicate with each other among these devices.
在本申请的实施例中,存储器19,用于存储指令和数据。In the embodiment of the present application, the memory 19 is used to store instructions and data.
进一步地,在本申请的实施例中,上述处理器18,用于在判定待处理图像为雾化图像之后,确定待处理图像的尺寸参数;根据所述尺寸参数确定待处理图像对应的预处理策略;其中,所述预处理策略用于对图像尺寸进行限制;若所述预处理策略为划分所述待处理图像,则划分所述待处理图像,获得所述待处理图像对应的子图像;根据图像去雾模型对所述子图像进行去雾处理,获得所述子图像对应的去雾后子图像;根据图像拼接模型对所述去雾后子图像进行拼接处理,获得所述待处理图像对应的去雾后图像。Further, in the embodiment of the present application, the above-mentioned processor 18 is configured to determine the size parameter of the image to be processed after determining that the image to be processed is a fogged image; determine the preprocessing corresponding to the image to be processed according to the size parameter Strategy; wherein, the preprocessing strategy is used to limit the image size; if the preprocessing strategy is to divide the image to be processed, divide the image to be processed to obtain the sub-image corresponding to the image to be processed; Perform defogging processing on the sub-images according to the image defogging model to obtain the defogging sub-images corresponding to the sub-images; performing stitching processing on the defogging sub-images according to the image stitching model to obtain the to-be-processed image The corresponding image after defogging.
在实际应用中,上述存储器19可以是易失性存储器(volatile memor),例如随机存取存储器(Random-Access Memory,RAM);或者非易失性存储器(non-volatile memory),例如只读第一存储y器(Read-Only Memory,ROM),快闪存储器(flash memory),硬盘(Hard Disk Drive,HDD)或固态硬盘(Solid-State Drive,SSD);或者上述种类的存储器的组合,并向处理器18提供指令和数据。In practical applications, the above-mentioned memory 19 may be a volatile memory (volatile memory), such as a random-access memory (Random-Access Memory, RAM); or a non-volatile memory (non-volatile memory), such as a read-only memory. A storage device (Read-Only Memory, ROM), flash memory (flash memory), hard disk (Hard Disk Drive, HDD) or solid-state drive (Solid-State Drive, SSD); or a combination of the above types of memory, and Instructions and data are provided to the processor 18.
另外,在本实施例中的各功能模块可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能模块的形式实现。In addition, the functional modules in this embodiment may be integrated into one processing unit, or each unit may exist alone physically, or two or more units may be integrated into one unit. The above-mentioned integrated unit can be realized in the form of hardware or software function module.
集成的单元如果以软件功能模块的形式实现并非作为独立的产品进行销售或使用时,可以存储在一个计算机可读取存储介质中,基于这样的理解,本实施例的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出 来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)或processor(处理器)执行本实施例方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(Read Only Memory,ROM)、随机存取存储器(Random Access Memory,RAM)、磁碟或者光盘等各种可以存储程序代码的介质。If the integrated unit is implemented in the form of a software function module and is not sold or used as an independent product, it can be stored in a computer readable storage medium. Based on this understanding, the technical solution of this embodiment is essentially or correct The part that the prior art contributes or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes a number of instructions to enable a computer device (which can be a personal computer). A computer, a server, or a network device, etc.) or a processor (processor) execute all or part of the steps of the method in this embodiment. The aforementioned storage media include: U disk, mobile hard disk, read only memory (Read Only Memory, ROM), random access memory (Random Access Memory, RAM), magnetic disk or optical disk and other media that can store program codes.
本申请实施例提出的一种终端,该终端可以利用深度学习获得的图像去雾模型对待处理图像进行去雾处理,同时,对于尺寸较大的待处理图像,终端还可以在利用图像去雾模型对待处理图像划分后的子图像进行去雾处理之后,使用深度学习获得的图像拼接模型进行拼接处理,以在保证处理精度的同时提高处理速度。进一步地,图像去雾模型和图像拼接模型是终端对CNN进行了极小网络设计而获得的,因此上述图像去雾方法可以在终端中实时运行。也就是说,在本申请中,基于深度学习获得的图像去雾模型和图像拼接模型进行图像去雾处理,能够在提高处理精度的同时,大大提升处理速度,从而实现高质量、高效率的图像去雾处理。An embodiment of the present application proposes a terminal that can use the image defogging model obtained by deep learning to perform defogging processing on the image to be processed. At the same time, for larger-sized images to be processed, the terminal can also use the image defogging model After defogging the sub-images after dividing the image to be processed, the image stitching model obtained by deep learning is used for stitching processing, so as to improve the processing speed while ensuring the processing accuracy. Further, the image defogging model and the image stitching model are obtained by the terminal's minimal network design on the CNN, so the above-mentioned image defogging method can be run in the terminal in real time. That is to say, in this application, the image defogging process based on the image defogging model and the image stitching model obtained by deep learning can greatly increase the processing speed while improving the processing accuracy, thereby achieving high-quality and high-efficiency images. Defogging treatment.
本申请实施例提供一种计算机可读存储介质,其上存储有程序,该程序被处理器执行时实现如上所述的图像去雾方法。The embodiment of the present application provides a computer-readable storage medium on which a program is stored, and when the program is executed by a processor, the image defogging method as described above is realized.
具体来讲,本实施例中的一种图像去雾方法对应的程序指令可以被存储在光盘,硬盘,U盘等存储介质上,当存储介质中的与一种图像去雾方法对应的程序指令被一电子设备读取或被执行时,包括如下步骤:Specifically, the program instructions corresponding to an image defogging method in this embodiment can be stored on storage media such as optical disks, hard disks, USB flash drives, etc., when the program instructions corresponding to an image defogging method in the storage medium When being read or executed by an electronic device, it includes the following steps:
在判定待处理图像为雾化图像之后,确定待处理图像的尺寸参数;After determining that the image to be processed is a fogged image, determine the size parameter of the image to be processed;
根据所述尺寸参数确定待处理图像对应的预处理策略;其中,所述预处理策略用于对图像尺寸进行限制;Determine a preprocessing strategy corresponding to the image to be processed according to the size parameter; wherein, the preprocessing strategy is used to limit the size of the image;
若所述预处理策略为划分所述待处理图像,则划分所述待处理图像,获得所述待处理图像对应的子图像;If the preprocessing strategy is to divide the image to be processed, divide the image to be processed to obtain a sub-image corresponding to the image to be processed;
根据图像去雾模型对所述子图像进行去雾处理,获得所述子图像对应的去雾后子图像;Performing defogging processing on the sub-image according to the image defogging model to obtain a defogging sub-image corresponding to the sub-image;
根据图像拼接模型对所述去雾后子图像进行拼接处理,获得所述待处理图像对应的去雾后图像。Performing a splicing process on the defogging sub-images according to the image splicing model to obtain a defogging image corresponding to the image to be processed.
本领域内的技术人员应明白,本申请的实施例可提供为方法、终端、或计算机程序产品。因此,本申请可采用硬件实施例、软件实施例、或结合软件和硬件方面的实施例的形式。而且,本申请可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器和光学存储器等)上实施的计算机程序产品的形式。Those skilled in the art should understand that the embodiments of the present application can be provided as a method, a terminal, or a computer program product. Therefore, this application may adopt the form of hardware embodiments, software embodiments, or embodiments combining software and hardware. Moreover, this application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, optical storage, etc.) containing computer-usable program codes.
本申请是参照根据本申请实施例的方法、设备(系统)、和计算机程序产品的实现流程示意图和/或方框图来描述的。应理解可由计算机程序指令实现流程示意图和/或方框图中的每一流程和/或方框、以及实现流程示意图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在实现流程示意图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。This application is described with reference to the schematic diagrams and/or block diagrams of the implementation process of the methods, equipment (systems), and computer program products according to the embodiments of the application. It should be understood that each process and/or block in the schematic flow diagram and/or block diagram can be realized by computer program instructions, and a combination of processes and/or blocks in the schematic flow diagram and/or block diagram can be realized. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing equipment to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing equipment are used to generate A device for realizing the functions specified in one process or multiple processes in the schematic flow chart and/or one block or multiple blocks in the block diagram.
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在实现流程示意图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing equipment to work in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture including the instruction device. The device realizes the functions specified in one process or multiple processes in the realization process schematic diagram and/or one block or multiple blocks in the block diagram.
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在实现流程示意图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。These computer program instructions can also be loaded on a computer or other programmable data processing equipment, so that a series of operation steps are executed on the computer or other programmable equipment to produce computer-implemented processing, so as to execute on the computer or other programmable equipment. The instructions provide steps for implementing functions specified in one or more processes in the schematic diagram and/or one block or more in the block diagram.
以上所述,仅为本申请的较佳实施例而已,并非用于限定本申请的保护范围。The above are only preferred embodiments of the present application, and are not used to limit the protection scope of the present application.
工业实用性Industrial applicability
本申请实施例提供一种图像去雾方法、终端及计算机存储介质,终端在判定待处理图像为雾化图像之后,确定待处理图像的尺寸参数;根据尺寸参数确定待处理图像对应的预处理策略;其中,预处理策略用于对图像尺寸进行限制;若预处理策略为划分待处理图像,则划分待处理图像,获得待处理图像对应的子图像;根据图像去雾模型对子图像进行去雾处理,获得子图像对应的去雾后子图像;根据图像拼接模型对去雾后子图像进行拼接处理,获得待处理图像对应的去雾后图像。由此可见,在本申请的实施例中,终端可以利用深度学习获得的图像去雾模型对待处理图像进行去雾处理,同时,对于尺寸较大的待处理图像,终端还可以在利用图像去雾模型对待处理图像划分后的子图像进行去雾处理之后,使用深度学习获得的图像拼接模型进行拼接处理,以在保证处理精度的同时提高处理速度。进一步地,图像去雾模型和图像拼接模型是终端对CNN进行了极小网络设计而获得的,因此上述图像去雾方法可以在终端中实时运行。也就是说,在本申请中,基于深度学习获得的图像去雾模型和图像拼接模型进行图像去雾处理,能够在提高处理精度的同时,大大提升处理速度,从而实现高质量、高效率的图像去雾处理。The embodiments of the application provide an image defogging method, terminal, and computer storage medium. After determining that the image to be processed is a fogged image, the terminal determines the size parameter of the image to be processed; and determines the preprocessing strategy corresponding to the image to be processed according to the size parameter. ; Among them, the preprocessing strategy is used to limit the image size; if the preprocessing strategy is to divide the image to be processed, the image to be processed is divided to obtain the sub-image corresponding to the image to be processed; the sub-image is defogged according to the image defogging model Process to obtain the defogging sub-image corresponding to the sub-image; perform stitching processing on the defogging sub-image according to the image stitching model to obtain the defogging image corresponding to the image to be processed. It can be seen that, in the embodiment of the present application, the terminal can use the image defogging model obtained by deep learning to defog the image to be processed. At the same time, for the large-sized image to be processed, the terminal can also use the image defogging. After the model performs defogging processing on the sub-images after dividing the image to be processed, the image stitching model obtained by deep learning is used for stitching processing to increase the processing speed while ensuring the processing accuracy. Further, the image defogging model and the image stitching model are obtained by the terminal's minimal network design on the CNN, so the above-mentioned image defogging method can be run in the terminal in real time. That is to say, in this application, the image defogging process based on the image defogging model and the image stitching model obtained by deep learning can greatly increase the processing speed while improving the processing accuracy, thereby achieving high-quality and high-efficiency images. Defogging treatment.

Claims (20)

  1. 一种图像去雾方法,所述方法包括:An image defogging method, the method comprising:
    在判定待处理图像为雾化图像之后,确定待处理图像的尺寸参数;After determining that the image to be processed is a fogged image, determine the size parameter of the image to be processed;
    根据所述尺寸参数确定待处理图像对应的预处理策略;其中,所述预处理策略用于对图像尺寸进行限制;Determine a preprocessing strategy corresponding to the image to be processed according to the size parameter; wherein, the preprocessing strategy is used to limit the size of the image;
    若所述预处理策略为划分所述待处理图像,则划分所述待处理图像,获得所述待处理图像对应的子图像;If the preprocessing strategy is to divide the image to be processed, divide the image to be processed to obtain a sub-image corresponding to the image to be processed;
    根据图像去雾模型对所述子图像进行去雾处理,获得所述子图像对应的去雾后子图像;Performing defogging processing on the sub-image according to the image defogging model to obtain a defogging sub-image corresponding to the sub-image;
    根据图像拼接模型对所述去雾后子图像进行拼接处理,获得所述待处理图像对应的去雾后图像。Performing a splicing process on the defogging sub-images according to the image splicing model to obtain a defogging image corresponding to the image to be processed.
  2. 根据权利要求1所述的方法,其中,所述确定待处理图像的尺寸参数之前,所述方法还包括:The method according to claim 1, wherein before the determining the size parameter of the image to be processed, the method further comprises:
    对所述待处理图像进行分析处理,获得分析结果;Perform analysis processing on the to-be-processed image to obtain an analysis result;
    根据所述分析结果判断所述待处理图像是否为雾化图像。According to the analysis result, it is determined whether the image to be processed is a fogged image.
  3. 根据权利要求1所述的方法,其中,所述根据所述尺寸参数确定待处理图像对应的预处理策略,包括:The method according to claim 1, wherein the determining a preprocessing strategy corresponding to the image to be processed according to the size parameter comprises:
    若所述尺寸参数大于或者等于预设尺寸阈值,则确定所述预处理策略为划分所述待处理图像;If the size parameter is greater than or equal to a preset size threshold, determining that the preprocessing strategy is to divide the image to be processed;
    若所述尺寸参数小于所述预设尺寸阈值,则确定所述预处理策略为不划分所述待处理图像。If the size parameter is less than the preset size threshold, it is determined that the preprocessing strategy is not to divide the image to be processed.
  4. 根据权利要求1所述的方法,其中,所述根据图像去雾模型对所述子图像进行去雾处理,获得所述子图像对应的去雾后子图像之前,所述方法还包括:The method according to claim 1, wherein, before performing defogging processing on the sub-image according to the image defogging model, and obtaining the defogging sub-image corresponding to the sub-image, the method further comprises:
    对第一图像样本集进行划分,获得第一训练数据和第一测试数据;其中,所述第一图像样本集包括雾化图像和所述雾化图像对应的清晰图像;Dividing the first image sample set to obtain first training data and first test data; wherein the first image sample set includes a fogged image and a clear image corresponding to the fogged image;
    基于第一轻量化卷积神经网络构建第一网络模型,并根据所述第一训练数据对所述第一网络模型进行训练处理,获得初始去雾模型;Constructing a first network model based on the first lightweight convolutional neural network, and training the first network model according to the first training data to obtain an initial defogging model;
    根据所述第一测试数据对所述初始去雾模型进行测试处理,获得所述图像去雾模型。Perform test processing on the initial defogging model according to the first test data to obtain the image defogging model.
  5. 根据权利要求4所述的方法,其中,所述根据所述第一测试数据对所述初始去雾模型进行测试处理,获得所述图像去雾模型,包括:The method according to claim 4, wherein the performing test processing on the initial defogging model according to the first test data to obtain the image defogging model comprises:
    根据所述第一测试数据对所述初始去雾模型进行测试处理,生成第一测试结果;Performing test processing on the initial defogging model according to the first test data to generate a first test result;
    按照所述第一测试结果修正所述图像去雾模型,获得所述图像去雾模型。The image defogging model is corrected according to the first test result to obtain the image defogging model.
  6. 根据权利要求5所述的方法,其中,所述根据所述第一测试数据对所述初始去雾模型进行测试处理,生成第一测试结果,包括:The method according to claim 5, wherein said performing a test process on said initial defogging model according to said first test data to generate a first test result comprises:
    将所述第一测试数据中的雾化图像输入至所述初始去雾模型中,输出去雾图像;Inputting the fogging image in the first test data into the initial defogging model, and outputting the defogging image;
    将所述去雾图像与所述清晰图像进行图像信息比较,获得所述第一测试结果。The image information of the defogging image and the clear image are compared to obtain the first test result.
  7. 根据权利要求1所述的方法,其中,所述根据图像拼接模型对所述去雾后子图像进行拼接处理,获得所述待处理图像对应的去雾后图像之前,所述方法还包括:The method according to claim 1, wherein the method further comprises: before performing the stitching process on the defogging sub-images according to the image stitching model, and obtaining the defogging image corresponding to the image to be processed, the method further comprises:
    对第二图像样本集进行划分,获得第二训练数据和第二测试数据;其中,所述第二图像样本集包括原始图像和所述原始图像对应的多个分解图像;Dividing the second image sample set to obtain second training data and second test data; wherein the second image sample set includes an original image and a plurality of decomposed images corresponding to the original image;
    基于第二轻量化卷积神经网络构建第二网络模型,并根据所述第二训练数据对所述第二网络模型进行训练处理,获得初始拼接模型;Constructing a second network model based on the second lightweight convolutional neural network, and training the second network model according to the second training data to obtain an initial splicing model;
    根据所述第二测试数据对所述初始拼接模型进行测试处理,获得所述图像拼接模型。Performing test processing on the initial stitching model according to the second test data to obtain the image stitching model.
  8. 根据权利要求7所述的方法,其中,所述根据所述第二测试数据对所述初始拼接模型进行测试处理,获得所述图像拼接模型,包括:8. The method according to claim 7, wherein said performing test processing on said initial stitching model according to said second test data to obtain said image stitching model comprises:
    根据所述第二测试数据对所述初始拼接模型进行测试处理,生成第二测试结果;Performing test processing on the initial splicing model according to the second test data to generate a second test result;
    按照所述第二测试结果修正所述初始拼接模型,获得所述图像拼接模型。Correcting the initial stitching model according to the second test result to obtain the image stitching model.
  9. 根据权利要求8所述的方法,其中,所述根据所述第二测试数据对所述初始拼接模型进行测试处理,生成第二测试结果,包括:8. The method according to claim 8, wherein said performing test processing on said initial splicing model according to said second test data to generate a second test result comprises:
    将所述第二测试数据中的分解图像输入至所述初始拼接模型中,输出拼接后图像;Inputting the decomposed image in the second test data into the initial stitching model, and outputting the stitched image;
    将所述拼接后图像与所述原始图像进行图像信息比较,获得所述第二测试结果。The image information of the spliced image is compared with the original image to obtain the second test result.
  10. 根据权利要求3所述的方法,其中,所述根据所述尺寸参数确定待处理图像对应的预处理策略之后,所述方法还包括:The method according to claim 3, wherein, after the preprocessing strategy corresponding to the image to be processed is determined according to the size parameter, the method further comprises:
    若所述预处理策略为不划分所述待处理图像,则直接根据所述图像去雾模型对所述待处理图像进行去雾处理,获得所述去雾后图像。If the preprocessing strategy is not to divide the image to be processed, the image to be processed is defogged directly according to the image defogging model to obtain the defogging image.
  11. 根据权利要求3所述的方法,其中,The method of claim 3, wherein:
    所述预设尺寸阈值为高度尺寸上限值,或宽度尺寸上限值,或高度和宽度的尺寸上限值。The preset size threshold is the upper limit of the height size, or the upper limit of the width size, or the upper limit of the size of the height and the width.
  12. 根据权利要求1所述的方法,其中,所述划分所述待处理图像,获得所述待处理图像对应的子图像,包括:The method according to claim 1, wherein the dividing the image to be processed to obtain a sub-image corresponding to the image to be processed comprises:
    确定所述待处理图像对应的划分个数;Determine the number of divisions corresponding to the image to be processed;
    按照所述划分个数进行划分处理,获得所述子图像。Perform division processing according to the number of divisions to obtain the sub-images.
  13. 根据权利要求1所述的方法,其中,所述划分所述待处理图像,获得所述待处理图像对应的子图像,包括:The method according to claim 1, wherein the dividing the image to be processed to obtain a sub-image corresponding to the image to be processed comprises:
    确定预设划分个数;Determine the number of preset divisions;
    按照所述预设划分个数进行划分处理,获得所述子图像。Perform division processing according to the preset number of divisions to obtain the sub-image.
  14. 根据权利要求2所述的方法,其中,所述根据所述分析结果判断所述待处理图像是否为雾化图像之后,所述方法还包括:The method according to claim 2, wherein, after determining whether the image to be processed is a fogged image according to the analysis result, the method further comprises:
    若判定所述待处理图像不为雾化图像,则跳过去雾处理流程。If it is determined that the image to be processed is not a fogged image, skip to the fog processing flow.
  15. 根据权利要求1所述的方法,其中,所述图像去雾模型为基于AI构建的图像去雾算法。The method according to claim 1, wherein the image defogging model is an image defogging algorithm based on AI.
  16. 根据权利要求1所述的方法,其中,所述图像拼接模型为基于AI构建的图像拼接算法。The method according to claim 1, wherein the image stitching model is an image stitching algorithm based on AI.
  17. 根据权利要求1至16任一项所述的方法,其中,The method according to any one of claims 1 to 16, wherein:
    所述待处理图像为预先存储的图像;或者,The image to be processed is a pre-stored image; or,
    所述待处理图像为实时采集获得的图像;或者,The image to be processed is an image acquired in real time; or,
    所述待处理图像为其它设备发送的图像。The image to be processed is an image sent by another device.
  18. 一种终端,所述终端包括:确定部分,划分部分,去雾部分,拼接部分,A terminal, the terminal includes: a determination part, a division part, a defogging part, a splicing part,
    所述确定部分,配置为在判定待处理图像为雾化图像之后,确定待处理图像的尺寸参数;以及根据所述尺寸参数确定待处理图像对应的预处理策略;其中,所述预处理策略用于对图像尺寸进行限制;The determining part is configured to determine the size parameter of the image to be processed after determining that the image to be processed is a fogged image; and determine the preprocessing strategy corresponding to the image to be processed according to the size parameter; wherein the preprocessing strategy is used To limit the size of the image;
    所述划分部分,配置为若所述预处理策略为划分所述待处理图像,则划分所述待处理图像,获得所述待处理图像对应的子图像;The dividing part is configured to divide the image to be processed if the preprocessing strategy is to divide the image to be processed to obtain a sub-image corresponding to the image to be processed;
    所述去雾部分,配置为根据图像去雾模型对所述子图像进行去雾处理,获得所述子图像对应的去雾后子图像;The defogging part is configured to perform defogging processing on the sub-image according to the image defogging model to obtain a defogging sub-image corresponding to the sub-image;
    所述拼接部分,配置为根据图像拼接模型对所述去雾后子图像进行拼接处理,获得所述待处理图像对应的去雾后图像。The splicing part is configured to perform splicing processing on the defogging sub-images according to an image splicing model to obtain a defogging image corresponding to the image to be processed.
  19. 一种终端,所述终端包括处理器、存储有所述处理器可执行指令的存储器,当所述指令被所述处理器执行时,实现如权利要求1-8任一项所述的方法。A terminal comprising a processor and a memory storing executable instructions of the processor, and when the instructions are executed by the processor, the method according to any one of claims 1-8 is implemented.
  20. 一种计算机可读存储介质,其上存储有程序,应用于终端中,所述程序被处理器执行时,实现如权利要求1-8任一项所述的方法。A computer-readable storage medium with a program stored thereon and applied to a terminal. When the program is executed by a processor, the method according to any one of claims 1-8 is implemented.
PCT/CN2021/085694 2020-05-29 2021-04-06 Image defogging method, terminal, and computer storage medium WO2021238420A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202010472428.1A CN111626960A (en) 2020-05-29 2020-05-29 Image defogging method, terminal and computer storage medium
CN202010472428.1 2020-05-29

Publications (1)

Publication Number Publication Date
WO2021238420A1 true WO2021238420A1 (en) 2021-12-02

Family

ID=72260094

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/085694 WO2021238420A1 (en) 2020-05-29 2021-04-06 Image defogging method, terminal, and computer storage medium

Country Status (2)

Country Link
CN (1) CN111626960A (en)
WO (1) WO2021238420A1 (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114529464A (en) * 2022-01-14 2022-05-24 电子科技大学 Underwater image recovery method based on deep learning
CN115511735A (en) * 2022-09-20 2022-12-23 北京拙河科技有限公司 Snow field gray level picture optimization method and device
CN116935289A (en) * 2023-09-13 2023-10-24 长江信达软件技术(武汉)有限责任公司 Open channel embankment detection method based on video monitoring

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111626960A (en) * 2020-05-29 2020-09-04 Oppo广东移动通信有限公司 Image defogging method, terminal and computer storage medium
CN112183366A (en) * 2020-09-29 2021-01-05 重庆大学 High-voltage power line bird nest detection method, system and machine readable medium
CN115937144B (en) * 2022-12-08 2023-08-25 郑州大学 Image processing method and system in thoracoscopy

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20160196637A1 (en) * 2015-01-06 2016-07-07 The Regents Of The University Of California Raw sensor image and video de-hazing and atmospheric light analysis methods and systems
CN109934781A (en) * 2019-02-27 2019-06-25 合刃科技(深圳)有限公司 Image processing method, device, terminal device and computer readable storage medium
CN110322419A (en) * 2019-07-11 2019-10-11 广东工业大学 A kind of remote sensing images defogging method and system
CN110930320A (en) * 2019-11-06 2020-03-27 南京邮电大学 Image defogging method based on lightweight convolutional neural network
CN111626960A (en) * 2020-05-29 2020-09-04 Oppo广东移动通信有限公司 Image defogging method, terminal and computer storage medium

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110619618B (en) * 2018-06-04 2023-04-07 杭州海康威视数字技术股份有限公司 Surface defect detection method and device and electronic equipment
CN108898562B (en) * 2018-06-22 2022-04-12 大连海事大学 Mobile equipment image defogging method based on deep learning
CN109919887B (en) * 2019-02-25 2021-06-18 中国人民解放军陆军工程大学 Unsupervised image fusion method based on deep learning
CN110544216A (en) * 2019-08-29 2019-12-06 北京理工大学 Video defogging system based on deep learning
CN111047513B (en) * 2019-11-27 2024-01-23 中国人民解放军国防科技大学 Robust image alignment method and device for cylindrical panorama stitching

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20160196637A1 (en) * 2015-01-06 2016-07-07 The Regents Of The University Of California Raw sensor image and video de-hazing and atmospheric light analysis methods and systems
CN109934781A (en) * 2019-02-27 2019-06-25 合刃科技(深圳)有限公司 Image processing method, device, terminal device and computer readable storage medium
CN110322419A (en) * 2019-07-11 2019-10-11 广东工业大学 A kind of remote sensing images defogging method and system
CN110930320A (en) * 2019-11-06 2020-03-27 南京邮电大学 Image defogging method based on lightweight convolutional neural network
CN111626960A (en) * 2020-05-29 2020-09-04 Oppo广东移动通信有限公司 Image defogging method, terminal and computer storage medium

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114529464A (en) * 2022-01-14 2022-05-24 电子科技大学 Underwater image recovery method based on deep learning
CN115511735A (en) * 2022-09-20 2022-12-23 北京拙河科技有限公司 Snow field gray level picture optimization method and device
CN116935289A (en) * 2023-09-13 2023-10-24 长江信达软件技术(武汉)有限责任公司 Open channel embankment detection method based on video monitoring
CN116935289B (en) * 2023-09-13 2023-12-19 长江信达软件技术(武汉)有限责任公司 Open channel embankment detection method based on video monitoring

Also Published As

Publication number Publication date
CN111626960A (en) 2020-09-04

Similar Documents

Publication Publication Date Title
WO2021238420A1 (en) Image defogging method, terminal, and computer storage medium
CN109859190B (en) Target area detection method based on deep learning
CN110008806B (en) Information processing device, learning processing method, learning device, and object recognition device
CN112132156A (en) Multi-depth feature fusion image saliency target detection method and system
CN109753878B (en) Imaging identification method and system under severe weather
CN111046821B (en) Video behavior recognition method and system and electronic equipment
CN109472193A (en) Method for detecting human face and device
CN109977834B (en) Method and device for segmenting human hand and interactive object from depth image
Alajarmeh et al. Real-time framework for image dehazing based on linear transmission and constant-time airlight estimation
CN111461211B (en) Feature extraction method for lightweight target detection and corresponding detection method
CN114565539B (en) Image defogging method based on online knowledge distillation
CN114663309A (en) Image defogging method and system based on multi-scale information selection attention mechanism
CN116757986A (en) Infrared and visible light image fusion method and device
CN114241344B (en) Plant leaf disease and pest severity assessment method based on deep learning
US11783454B2 (en) Saliency map generation method and image processing system using the same
CN111582057B (en) Face verification method based on local receptive field
CN110738624B (en) Area-adaptive image defogging system and method
CN116757988A (en) Infrared and visible light image fusion method based on semantic enrichment and segmentation tasks
CN115937121A (en) Non-reference image quality evaluation method and system based on multi-dimensional feature fusion
CN115240163A (en) Traffic sign detection method and system based on one-stage detection network
CN113256528B (en) Low-illumination video enhancement method based on multi-scale cascade depth residual error network
CN112651926A (en) Method and device for detecting cracks based on recursive attention mechanism
CN112487911A (en) Real-time pedestrian detection method and device based on improved yolov3 in intelligent monitoring environment
Chen et al. GADO-Net: an improved AOD-Net single image dehazing algorithm
CN113052210B (en) Rapid low-light target detection method based on convolutional neural network

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 21813152

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 21813152

Country of ref document: EP

Kind code of ref document: A1