Disclosure of Invention
The present disclosure proposes an image processing technical solution.
According to an aspect of the present disclosure, there is provided an image processing method including: extracting depth information of an image to be processed to obtain a first depth map of the image to be processed; and inputting the image to be processed and the first depth map into a neural network for image deblurring processing to obtain a first processed image, wherein the definition of the first processed image is higher than that of the image to be processed. By the method, the blurred image can be restored according to the scene depth information, and the definition of the processed image is improved.
In a possible implementation manner, the neural network includes a depth adjustment network and an image adjustment network, where inputting the image to be processed and the first depth map into the neural network to perform image deblurring processing, so as to obtain a first processed image, and the method includes: inputting the image to be processed and the first depth map into the depth adjustment network for depth deblurring processing to obtain a second depth map; and inputting the image to be processed and the second depth map into the image adjusting network for image deblurring processing to obtain a first processed image, wherein the definition of the second depth map is higher than that of the first depth map. In this way, the depth map can be deblurred through the neural network, and then the image to be processed is deblurred through the neural network according to the deblurred depth map, so that the deblurring effect is improved.
In a possible implementation manner, the depth adjustment network includes a first feature extraction sub-network, a first coding/decoding sub-network, and a first superposition sub-network, where the image to be processed and the first depth map are input into the depth adjustment network to perform depth deblurring processing, so as to obtain a second depth map, and the method includes: performing feature extraction on the first depth map and the image to be processed through the first feature extraction sub-network to obtain depth feature information of the first depth map; coding and decoding the depth feature information through the first coding and decoding sub-network to obtain a third depth map; and superposing the first depth map and the third depth map through the first superposition sub-network to obtain the second depth map. In this way, residual blurring effects in the scene depth of the blurred image can be eliminated, resulting in a more accurate scene depth map (second depth map) containing a large number of sharp boundaries
In one possible implementation manner, the first feature extraction sub-network includes a first convolution layer and a first spatial feature transformation layer, wherein feature extraction is performed on the first depth map and the image to be processed by the first feature extraction sub-network to obtain depth feature information of the first depth map, and the feature extraction sub-network includes: performing feature extraction on the first depth map through the first convolution layer to obtain a feature map of the first depth map; and taking the image to be processed as prior information, and performing spatial feature transformation on the feature map of the first depth map through the first spatial feature transformation layer to obtain the depth feature information. In this way, the scene depth map (first depth map) of the blurred image and the blurred image (to-be-processed image) are used as input, and the blurred image (to-be-processed image) is used as prior information to perform spatial feature transformation on the scene depth map of the blurred image, so that the residual blurring effect in the scene depth of the blurred image can be eliminated, and the processing effect of depth deblurring is improved.
In a possible implementation manner, the image adjusting network includes a second feature extraction sub-network, a second coding/decoding sub-network, and a second overlay sub-network, where the image to be processed and the second depth map are input into the image adjusting network to perform image deblurring processing, so as to obtain a first processed image, and the method includes: performing feature extraction on the image to be processed and the second depth map through the second feature extraction sub-network to obtain image feature information of the image to be processed; coding and decoding the image characteristic information through the second coding and decoding sub-network to obtain a second processed image; and performing superposition processing on the image to be processed and the second processed image through the second superposition sub-network to obtain the first processed image. In this way, the deblurred depth map can be input into an image adjustment network for image restoration as prior information, and the restoration effect of the image is improved by utilizing spatial information such as edges, depth and the like in the scene depth.
In one possible implementation manner, the second feature extraction sub-network includes a second convolution layer and a second spatial feature transformation layer, wherein the obtaining of the image feature information of the image to be processed by performing feature extraction on the image to be processed and the second depth map through the second feature extraction sub-network includes: performing feature extraction on the image to be processed through the second convolution layer to obtain a feature map of the image to be processed; and taking the second depth map as prior information, and performing spatial feature transformation on the feature map of the image to be processed through the second spatial feature transformation layer to obtain the image feature information. By the method, the blurred image (to-be-processed image) and the accurate scene depth map (second depth map) are used as input, the accurate scene depth map (second depth map) is used as prior information to perform spatial feature transformation on the blurred image, and feature extraction is performed through an encoder and a decoder, so that a deblurred sharp image (first processed image) can be obtained.
In one possible implementation, the method further includes: training the neural network according to a preset training set, wherein the training set comprises a sample image and a label image corresponding to the sample image, and the definition of the label image is higher than that of the sample image.
In one possible implementation, training the neural network according to a preset training set includes: inputting a fourth depth map of a sample image and the sample image into the depth adjustment network for processing, and outputting a fifth depth map; inputting the fifth depth map and the sample image into the image adjustment network for processing, and outputting a third processed image; determining an overall loss of the neural network from the third processed image, the label image corresponding to the sample image, and the fifth depth map; adjusting network parameters of the neural network according to the overall loss.
In one possible implementation, determining the total loss of the neural network according to the third processed image, the label image corresponding to the sample image, and the fifth depth map includes: determining a content loss according to the third processed image and the label image; determining a perception loss according to the third processed image, the label image and a pre-trained convolutional network; determining depth adjustment loss according to a sixth depth map of the label image and the fifth depth map; determining the overall loss from the content loss, the perceptual loss, and the depth adjustment loss.
In one possible implementation, determining a perceptual loss according to the third processed image, the label image, and a pre-trained convolutional network includes: inputting the third processed image and the label image into a pre-trained convolutional network for processing respectively, and outputting a feature map of the third processed image and a feature map of the label image; and determining the perception loss according to the feature map of the third processed image and the feature map of the label image.
According to another aspect of the present disclosure, there is provided an image processing method including: under the condition that the definition of an image to be processed acquired by image acquisition equipment is smaller than or equal to a preset threshold value, performing image processing on the image to be processed by the method to obtain a first processed image; outputting and/or displaying the first processed image.
According to another aspect of the present disclosure, there is provided an image processing apparatus including: the depth extraction module is used for extracting depth information of an image to be processed to obtain a first depth map of the image to be processed; and the deblurring module is used for inputting the image to be processed and the first depth map into a neural network for image deblurring processing to obtain a first processed image, wherein the definition of the first processed image is higher than that of the image to be processed.
In one possible implementation, the neural network includes a depth adjustment network and an image adjustment network, wherein the deblurring module includes: the depth deblurring submodule is used for inputting the image to be processed and the first depth map into the depth adjustment network for depth deblurring processing to obtain a second depth map; and the image deblurring submodule is used for inputting the image to be processed and the second depth map into the image adjusting network for image deblurring processing to obtain a first processed image, wherein the definition of the second depth map is higher than that of the first depth map.
In one possible implementation, the depth adjustment network includes a first feature extraction sub-network, a first coding sub-network, and a first superposition sub-network, wherein the depth deblurring sub-module is configured to: performing feature extraction on the first depth map and the image to be processed through the first feature extraction sub-network to obtain depth feature information of the first depth map; coding and decoding the depth feature information through the first coding and decoding sub-network to obtain a third depth map; and superposing the first depth map and the third depth map through the first superposition sub-network to obtain the second depth map.
In one possible implementation, the first feature extraction sub-network includes a first convolution layer and a first spatial feature transform layer, wherein the depth deblurring sub-module is configured to: performing feature extraction on the first depth map through the first convolution layer to obtain a feature map of the first depth map; and taking the image to be processed as prior information, and performing spatial feature transformation on the feature map of the first depth map through the first spatial feature transformation layer to obtain the depth feature information.
In one possible implementation, the image adjustment network includes a second feature extraction sub-network, a second coding sub-network, and a second overlay sub-network, wherein the image deblurring sub-module is configured to: performing feature extraction on the image to be processed and the second depth map through the second feature extraction sub-network to obtain image feature information of the image to be processed; coding and decoding the image characteristic information through the second coding and decoding sub-network to obtain a second processed image; and performing superposition processing on the image to be processed and the second processed image through the second superposition sub-network to obtain the first processed image.
In one possible implementation, the second feature extraction sub-network includes a second convolution layer and a second spatial feature transform layer, wherein the image deblurring sub-module is configured to: performing feature extraction on the image to be processed through the second convolution layer to obtain a feature map of the image to be processed; and taking the second depth map as prior information, and performing spatial feature transformation on the feature map of the image to be processed through the second spatial feature transformation layer to obtain the image feature information.
In one possible implementation, the apparatus further includes: the training module is used for training the neural network according to a preset training set, wherein the training set comprises a sample image and a label image corresponding to the sample image, and the definition of the label image is higher than that of the sample image.
In one possible implementation, the training module includes: the depth output sub-module is used for inputting the fourth depth map of the sample image and the sample image into the depth adjustment network for processing and outputting a fifth depth map; the image output sub-module is used for inputting the fifth depth map and the sample image into the image adjusting network for processing and outputting a third processed image; a loss determination submodule for determining an overall loss of the neural network from the third processed image, the label image corresponding to the sample image, and the fifth depth map; and the parameter adjusting submodule is used for adjusting the network parameters of the neural network according to the total loss.
In one possible implementation, the loss determination submodule is configured to: determining a content loss according to the third processed image and the label image; determining a perception loss according to the third processed image, the label image and a pre-trained convolutional network; determining depth adjustment loss according to a sixth depth map of the label image and the fifth depth map; determining the overall loss from the content loss, the perceptual loss, and the depth adjustment loss.
In one possible implementation, the loss determination submodule is configured to: inputting the third processed image and the label image into a pre-trained convolutional network for processing respectively, and outputting a feature map of the third processed image and a feature map of the label image; and determining the perception loss according to the feature map of the third processed image and the feature map of the label image.
According to another aspect of the present disclosure, there is provided an image processing apparatus including: the image processing module is used for processing the image to be processed through the device under the condition that the definition of the image to be processed, acquired by the image acquisition equipment, is less than or equal to a preset threshold value to obtain a first processed image; and the output module is used for outputting and/or displaying the first processed image.
According to another aspect of the present disclosure, there is provided an electronic device including: a processor; a memory for storing processor-executable instructions; wherein the processor is configured to execute the image processing method described above when executing the executable instructions.
According to another aspect of the present disclosure, there is provided a computer readable storage medium having stored thereon computer program instructions which, when executed by a processor, implement the above-described image processing method.
In the embodiment of the disclosure, the blurred depth map of the blurred image to be processed can be extracted, and the image deblurring processing is performed on the image to be processed through the neural network according to the blurred depth map to obtain a clear processed image, so that the blurred image is restored through the scene depth information, and the definition degree of the processed image is improved.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure. Other features and aspects of the present disclosure will become apparent from the following detailed description of exemplary embodiments, which proceeds with reference to the accompanying drawings.
Detailed Description
Various exemplary embodiments, features and aspects of the present disclosure will be described in detail below with reference to the accompanying drawings. In the drawings, like reference numbers can indicate functionally identical or similar elements. While the various aspects of the embodiments are presented in drawings, the drawings are not necessarily drawn to scale unless specifically indicated.
The word "exemplary" is used exclusively herein to mean "serving as an example, embodiment, or illustration. Any embodiment described herein as "exemplary" is not necessarily to be construed as preferred or advantageous over other embodiments.
The term "and/or" herein is merely an association describing an associated object, meaning that three relationships may exist, e.g., a and/or B, may mean: a exists alone, A and B exist simultaneously, and B exists alone. In addition, the term "at least one" herein means any one of a plurality or any combination of at least two of a plurality, for example, including at least one of A, B, C, and may mean including any one or more elements selected from the group consisting of A, B and C.
Furthermore, in the following detailed description, numerous specific details are set forth in order to provide a better understanding of the present disclosure. It will be understood by those skilled in the art that the present disclosure may be practiced without some of these specific details. In some instances, methods, means, elements and circuits that are well known to those skilled in the art have not been described in detail so as not to obscure the present disclosure.
Fig. 1 illustrates a flowchart of an image processing method according to an embodiment of the present disclosure, which includes, as illustrated in fig. 1:
in step S11, extracting depth information of an image to be processed to obtain a first depth map of the image to be processed;
in step S12, the image to be processed and the first depth map are input to a neural network for image deblurring processing, so as to obtain a first processed image, where a resolution of the first processed image is higher than a resolution of the image to be processed.
According to the embodiment of the disclosure, the fuzzy depth map of the fuzzy image to be processed can be extracted, and the image deblurring processing is performed on the image to be processed through the neural network according to the fuzzy depth map to obtain a clear processed image, so that the fuzzy image is restored through the scene depth information, and the definition degree of the processed image is improved.
In one possible implementation, the image processing method may be performed by an electronic device such as a terminal device or a server, the terminal device may be a User Equipment (UE), a mobile device, a User terminal, a cellular phone, a cordless phone, a Personal Digital Assistant (PDA), a handheld device, a computing device, a vehicle-mounted device, a wearable device, or the like, and the method may be implemented by a processor calling a computer readable instruction stored in a memory. Alternatively, the method may be performed by a server.
In one possible implementation, the image to be processed may be, for example, an image taken in a dynamic scene, which results in image blur (lower sharpness) due to camera shake, object movement, and scene depth change, among others. It should be understood that the image to be processed may be a blurred image acquired in any manner, and the shooting scene and the acquisition manner of the image to be processed are not limited by the present disclosure.
In one possible implementation manner, in step S11, depth information extraction may be performed on the image to be processed, so as to obtain a first depth map of the image to be processed. The scene depth estimation may be performed to extract depth information in a manner possible in the related art, which is not limited by the present disclosure.
In a possible implementation manner, after obtaining the first depth map, the to-be-processed image and the first depth map may be input to a neural network for image deblurring processing in step S12, so as to obtain a first processed image. The neural network implementing step S12 may be, for example, a deep neural network, and the present disclosure does not limit the specific network type of the neural network.
In a possible implementation manner, the neural network includes a depth adjustment network and an image adjustment network, the depth adjustment network is configured to perform depth deblurring processing on the first depth map, and the image adjustment network is configured to perform image deblurring processing on the image to be processed.
In this case, step S12 may include:
inputting the image to be processed and the first depth map into the depth adjustment network for depth deblurring processing to obtain a second depth map;
inputting the image to be processed and the second depth map into the image adjusting network for image deblurring processing to obtain a first processed image,
wherein the sharpness of the second depth map is higher than the sharpness of the first depth map.
For example, in the process of deblurring, the first depth map (blurred depth map) may be depth deblurred according to the image to be processed, i.e., the image to be processed and the first depth map are input into the depth adjustment network, and the second depth map (sharp depth map) is output. After the second depth map is obtained, the image to be processed can be deblurred according to the second depth map, that is, the image to be processed and the second depth map are input into the image adjusting network, and the first processed image is output, so that the whole process of deblurring processing is realized.
In one possible implementation, the depth adjustment network may include a first feature extraction sub-network, a first coding sub-network, and a first superposition sub-network. The step of inputting the image to be processed and the first depth map into the depth adjustment network for depth deblurring processing to obtain a second depth map may include:
performing feature extraction on the first depth map and the image to be processed through the first feature extraction sub-network to obtain depth feature information of the first depth map;
coding and decoding the depth feature information through the first coding and decoding sub-network to obtain a third depth map;
and superposing the first depth map and the third depth map through the first superposition sub-network to obtain the second depth map.
For example, feature extraction may be performed on the first depth map and the image to be processed by a first feature extraction sub-network (e.g., including one or more convolutional layers) of the depth adjustment network, resulting in depth feature information for the first depth map. For example, the first depth map and the image to be processed are connected in series (for example, fully connected) at the first convolution layer of the first feature extraction sub-network, and feature extraction is performed through the subsequent network layer. The present disclosure does not limit the specific structure of the first feature extraction subnetwork.
In a possible implementation manner, the first Feature extraction sub-network may further perform Feature extraction on the first depth map and the to-be-processed image by using a Spatial Feature Transform (SFT). In this case, the first feature extraction sub-network may include a first convolution layer and a first spatial feature transform layer,
the step of obtaining the depth feature information of the first depth map by performing feature extraction on the first depth map and the image to be processed through the first feature extraction sub-network may include:
performing feature extraction on the first depth map through the first convolution layer to obtain a feature map of the first depth map;
and taking the image to be processed as prior information, and performing spatial feature transformation on the feature map of the first depth map through the first spatial feature transformation layer to obtain the depth feature information.
That is, feature extraction may be performed on the first depth map through a first convolutional layer (including one or more convolutional layers), so as to obtain a feature map of the first depth map; and taking the image to be processed (blurred image) as prior information, and performing spatial feature transformation on the feature map of the first depth map through a first spatial feature transformation layer. The image to be processed can be input into a first sub-convolution layer (comprising a plurality of convolution layers) of a first spatial feature transformation layer to be processed, so as to obtain a Condition feature Map (Condition Map) of the image to be processed; inputting the condition characteristic diagram into a second sub-convolution layer and a third sub-convolution layer (both comprise a plurality of convolution layers) respectively for processing to obtain a first characteristic gamma and a second characteristic beta; multiplying the input feature (the feature map of the first depth map) by the first feature gamma to obtain a scaling feature; and adding the scaling characteristic to the second characteristic beta to obtain the converted depth characteristic information.
In this way, the scene depth map (first depth map) of the blurred image and the blurred image (to-be-processed image) are used as input, and the blurred image (to-be-processed image) is used as prior information to perform spatial feature transformation on the scene depth map of the blurred image, so that the residual blurring effect in the scene depth of the blurred image can be eliminated, and the processing effect of depth deblurring is improved.
In a possible implementation manner, after the depth feature information of the first depth map is obtained, the depth feature information may be encoded and decoded through a first sub-coding network. The first codec subnetwork may comprise, for example, a plurality of network layers, such as a convolutional layer (downsampling), a residual layer, an inverse convolutional layer (upsampling), a residual layer, and an active layer. After the processing of the first coding and decoding subnetwork, a third depth map can be obtained. The first depth map and the third depth map may then be superimposed by a first superimposing sub-network (e.g. comprising fully connected layers), resulting in a second depth map.
In this way, residual blurring effects in the scene depth of the blurred image can be eliminated, resulting in a more accurate scene depth map (second depth map) containing a large number of sharp boundaries.
In a possible implementation manner, after the second depth map is obtained, the image to be processed may be subjected to image deblurring processing according to the second depth map through the image adjustment network, so as to obtain the first processed image. The image adjusting network comprises a second feature extraction sub-network, a second coding and decoding sub-network and a second superposition sub-network.
In a possible implementation manner, the step of inputting the image to be processed and the second depth map into the image adjustment network for image deblurring processing to obtain a first processed image may include:
performing feature extraction on the image to be processed and the second depth map through the second feature extraction sub-network to obtain image feature information of the image to be processed;
coding and decoding the image characteristic information through the second coding and decoding sub-network to obtain a second processed image;
and performing superposition processing on the image to be processed and the second processed image through the second superposition sub-network to obtain the first processed image.
For example, the image feature information of the image to be processed may be obtained by performing feature extraction on the image to be processed and the second depth map through a second feature extraction sub-network (e.g., including one or more convolution layers) of the image adjustment network. For example, the image to be processed and the second depth map are connected in series (for example, fully connected) at the first convolution layer of the second feature extraction sub-network, and feature extraction is performed through the subsequent network layer. Wherein the network structure of the image adjustment network may be similar to the network structure of the depth adjustment network. The present disclosure does not limit the specific structure of the second feature extraction sub-network.
In a possible implementation manner, the second feature extraction sub-network may further perform feature extraction on the image to be processed and the second depth map by using a spatial feature transformation manner. In this case, the second feature extraction sub-network may include a second convolution layer and a second spatial feature transform layer,
the step of obtaining the image feature information of the image to be processed by performing feature extraction on the image to be processed and the second depth map through the second feature extraction sub-network may include:
performing feature extraction on the image to be processed through the second convolution layer to obtain a feature map of the image to be processed;
and taking the second depth map as prior information, and performing spatial feature transformation on the feature map of the image to be processed through the second spatial feature transformation layer to obtain the image feature information.
That is, feature extraction may be performed on the image to be processed by the second convolution layer (including one or more convolution layers), so as to obtain a feature map of the image to be processed. And taking the second depth map (clear depth map) as prior information, and performing spatial feature transformation on the feature map of the image to be processed through a second spatial feature transformation layer. First, the second depth map may be input into a fourth sub-convolutional layer (including a plurality of convolutional layers) of the second spatial feature transform layer for processing, so as to obtain a conditional feature map of the second depth map; inputting the condition feature map into a fifth sub-convolution layer and a sixth sub-convolution layer (both comprise a plurality of convolution layers) respectively for processing to obtain a third feature and a fourth feature; multiplying the input feature (the feature map of the image to be processed) with the third feature to obtain a scaling feature; and adding the scaling characteristic and the fourth characteristic to obtain the transformed image characteristic information.
In this way, the deblurred depth map can be input into an image adjustment network for image restoration as prior information, and the restoration effect of the image is improved by utilizing spatial information such as edges, depth and the like in the scene depth.
In a possible implementation manner, after the image feature information of the image to be processed is obtained, the image feature information may be encoded and decoded through the second coding and decoding sub-network. The codec sub-network may include, for example, a plurality of network layers, such as a convolutional layer (downsampling), a residual layer, an inverse convolutional layer (upsampling), a residual layer, and an active layer. After the encoding and decoding sub-network processing, a second processing image can be obtained. Then, the image to be processed and the second processed image can be superposed to obtain a first processed image. And the definition of the first processed image is higher than that of the image to be processed.
By the method, the blurred image (to-be-processed image) and the accurate scene depth map (second depth map) are used as input, the accurate scene depth map (second depth map) is used as prior information to perform spatial feature transformation on the blurred image, and feature extraction is performed through an encoder and a decoder, so that a deblurred sharp image (first processed image) can be obtained.
Fig. 2 shows a schematic diagram of a neural network of an image processing method according to an embodiment of the present disclosure. As shown in fig. 2, the neural network may include adepth adjustment network 21 and animage adjustment network 22. Thedepth adjustment network 21 comprises a first feature extraction subnetwork (comprising afirst convolution layer 211 and a first spatial feature transform layer 212, afirst codec subnetwork 213 and afirst overlay subnetwork 214; and theimage adjustment network 22 comprises a second feature extraction subnetwork (comprising asecond convolution layer 221 and a second spatial feature transform layer 222), asecond codec subnetwork 223 and asecond overlay subnetwork 224.
In the processing procedure, thefirst depth map 24 may be input into thefirst convolution layer 211 of the first feature extraction sub-network, and the feature map of the first depth map is output; inputting the feature map of the first depth map and theimage 23 to be processed into the first spatial feature transformation layer 212, and outputting the transformed depth feature information; inputting the depth feature information into thefirst codec subnetwork 213, a third depth map can be output; the second depth map 25 (the accurate scene depth map) can then be obtained by superimposing thefirst depth map 24 and the third depth map by means of thefirst superimposing sub-network 214.
After obtaining thesecond depth map 25, theimage 23 to be processed may be input into thesecond convolution layer 221 of the second feature extraction sub-network, and the feature map of theimage 23 to be processed is output; inputting the feature map of theimage 23 to be processed and thesecond depth map 25 into the second spatial feature transformation layer 222, and outputting the transformed image feature information; inputting the image characteristic information into the second coding anddecoding sub-network 223, and outputting a second processed image; the first processed image 26 (sharp image) is then obtained by superimposing the image to be processed 23 and the second processed image by means of thesecond superimposing sub-network 224.
By the method, the scene depth of the blurred image can be input into a neural network for image restoration as prior information after being finely adjusted, and the sharp image can be restored by utilizing spatial information such as edges and depth in the scene depth, so that the restoration effect of the image is improved.
The neural network may be trained prior to applying the neural network.
In one possible implementation manner, the image processing method according to the embodiment of the present disclosure may further include: training the neural network according to a preset training set,
the training set comprises a sample image and a label image corresponding to the sample image, and the definition of the label image is higher than that of the sample image. That is, the training set may include a plurality of blurred sample images and true sharp images (label images) respectively corresponding to the respective sample images, thereby constituting a plurality of sets of training sample pairs.
In one possible implementation, the step of training the neural network according to a preset training set may include:
inputting a fourth depth map of a sample image and the sample image into the depth adjustment network for processing, and outputting a fifth depth map;
inputting the fifth depth map and the sample image into the image adjustment network for processing, and outputting a third processed image;
determining an overall loss of the neural network from the third processed image, the label image corresponding to the sample image, and the fifth depth map;
adjusting network parameters of the neural network according to the overall loss.
For example, in the training process, any sample image can be selected and a fourth depth map of the sample image is obtained; inputting the fourth depth map and the sample image into a depth adjustment network for processing, and outputting a fifth depth map; inputting the sample image and the fifth depth map into an image adjustment network for processing, and outputting a third processed image; from the third processed image, the label image corresponding to the sample image, and the fifth depth map, an overall loss of the neural network may be determined.
In one possible implementation, the step of determining, from the third processed image, the label image corresponding to the sample image, and the fifth depth map, an overall loss of the neural network may include:
determining a content loss according to the third processed image and the label image;
determining a perception loss according to the third processed image, the label image and a pre-trained convolutional network;
determining depth adjustment loss according to a sixth depth map of the label image and the fifth depth map;
determining the overall loss from the content loss, the perceptual loss, and the depth adjustment loss.
The overall loss may include, for example, content loss, perceptual loss, and depth adjustment loss. Wherein the content is lost LcMay represent the difference between the deblurred sharp image and the true sharp image, and may employ, for example, an L2 loss function to determine the content loss LcAs shown in equation (1):
in formula (1), I may represent the third processed image (deblurred sharp image); i isgtA label image (true sharp image) can be represented. The present disclosure is not limited to the particular loss function employed for content loss.
In one possible implementation, the perceptual loss LpThe difference in characteristics between the deblurred sharp image and the true sharp image can be represented. Where a pre-trained convolutional network V (e.g., VGG-19 network) may be provided, the specific type of convolutional network is not limited by this disclosure.
In one possible implementation, the step of determining a perceptual loss according to the third processed image, the label image and a pre-trained convolutional network may include:
inputting the third processed image and the label image into a pre-trained convolutional network for processing respectively, and outputting a feature map of the third processed image and a feature map of the label image;
and determining the perception loss according to the feature map of the third processed image and the feature map of the label image.
That is, the third processed image I (deblurred sharp image) and the label image I can be combinedgtRespectively inputting the real clear image into a convolution network V for processing, and outputting a feature map V of a third processed imaget(I) And feature map V of label imaget(Igt). Wherein, VtRepresenting the output of the t-th layer of the convolutional network V, t being an integer greater than 1. When the convolutional network V is VGG-19, t may, for example, take the value 15. The present disclosure is not so limited.
Furthermore, the characteristic diagram V can be usedt(I) And Vt(Igt) Determining the perceptual loss as shown in equation (2):
in one possible implementation, the depth adjustment penalty LdMay represent the depth difference between the adjusted depth map and the depth map of the true sharp image. That is, the depth adjustment loss L may be determined by the fifth depth map and the sixth depth map of the tag imagedAs shown in equation (3):
in the formula (3), DrMay represent an adjusted depth map (fifth depth map), DgtA sixth depth map that may represent a label image.
In one possible implementation, after the content loss, perceptual loss, and depth adjustment loss are obtained, the overall loss L of the neural network can be determined according to equation (4):
L=λcLc+λdLd+λpLp (4)
in the formula (4), λc、λd、λpWeights representing content loss, perceptual loss and depth adjustment loss, respectively, e.g. each weight may take the value λc=1、λd=0.01、λp1. It should be understood that the value of each weight can be set by one skilled in the art according to practical situations, and the disclosure does not limit this.
In one possible implementation, after determining the overall loss L of the neural network, the network parameters of the neural network may be inversely adjusted according to the overall loss L. After multiple adjustments, when the total loss meets the preset training condition, the trained neural network can be obtained. The present disclosure does not limit the specific training mode of the neural network.
According to an embodiment of the present disclosure, there is also provided an image processing method, including:
under the condition that the definition of an image to be processed acquired by image acquisition equipment is smaller than or equal to a preset threshold value, performing image processing on the image to be processed by the method to obtain a first processed image;
outputting and/or displaying the first processed image.
For example, the image capturing device may be, for example, a camera of an electronic device (e.g., a smartphone), a camera of a monitoring device, or an in-vehicle camera in an autonomous driving scenario, etc. Images captured by an image capture device (e.g., a captured photograph or a video frame in a video stream) may be blurred due to camera shake, object movement, and scene depth changes, among others.
In one possible implementation, if the sharpness of the image to be processed is less than or equal to a preset sharpness threshold (preset threshold), it may be considered that the image to be processed needs to be deblurred. The image to be processed can be processed by the method, that is, the depth map of the image to be processed is extracted, and the image to be processed and the depth map thereof are input into the neural network for image deblurring, so that the first processed image is obtained. The preset threshold value can be set by a person skilled in the art according to actual conditions, and the specific value of the preset threshold value is not limited by the present disclosure.
In one possible implementation, after obtaining the first processed image, the blurred to-be-processed image may be replaced with a sharp first processed image, for example, displayed on a display screen of the electronic device. The first processed image may also be output, for example to a processing device for further processing, for example to implement an automated driving analysis or to perform an intelligent video analysis, etc.
According to the image processing method of the embodiment of the disclosure, the method can be applied to blurred image restoration in various scenes. For example, the method is applied to an image processing scene, and is used for deblurring a blurring effect caused by camera shake, object motion and depth change in an image, so that the imaging quality is improved; the method is applied to a computer vision recognition scene, and input images are preprocessed, so that the problems of low precision, low efficiency and the like caused by the influence of image blurring on subsequent vision tasks such as target detection, target tracking and the like are solved; the method is applied to automatic driving and intelligent video analysis scenes, and is used for recovering objects blurred due to movement in the images or videos, so that the definition of processed images is improved.
According to the image processing method disclosed by the embodiment of the disclosure, the scene depth of the blurred image can be finely adjusted, and the defects of blurring effect, edge information loss and the like caused by image blurring on scene depth estimation are eliminated; and the scene depth after fine adjustment is used as prior information to be input into a neural network for image restoration, and the edge, depth and other spatial information in the scene depth are utilized to help restore a clear image, so that the definition degree of the processed image is improved.
Compared with a fuzzy image restoration method based on traditional priori knowledge, the image processing method of the embodiment of the disclosure has better restoration effect and stronger robustness; compared with other deep learning blurred images restoration methods, the image processing method has the advantages that the restored image boundary is clearer and the details are richer.
It is understood that the above-mentioned method embodiments of the present disclosure can be combined with each other to form a combined embodiment without departing from the logic of the principle, which is limited by the space, and the detailed description of the present disclosure is omitted. It will be understood by those skilled in the art that the order of writing of the steps in the above methods of the embodiments does not imply a strict order of execution and that the particular order of execution of the steps should be determined by their function and possibly their inherent logic.
In addition, the present disclosure also provides an image processing apparatus, an electronic device, a computer-readable storage medium, and a program, which can be used to implement any one of the image processing methods provided by the present disclosure, and the descriptions and corresponding descriptions of the corresponding technical solutions and the corresponding descriptions in the methods section are omitted for brevity.
Fig. 3 illustrates a block diagram of an image processing apparatus according to an embodiment of the present disclosure, which includes, as illustrated in fig. 3: thedepth extraction module 31 is configured to perform depth information extraction on an image to be processed to obtain a first depth map of the image to be processed; and adeblurring module 32, configured to input the image to be processed and the first depth map into a neural network to perform image deblurring processing, so as to obtain a first processed image, where a definition of the first processed image is higher than a definition of the image to be processed.
In one possible implementation, the neural network includes a depth adjustment network and an image adjustment network, wherein the deblurring module includes: the depth deblurring submodule is used for inputting the image to be processed and the first depth map into the depth adjustment network for depth deblurring processing to obtain a second depth map; and the image deblurring submodule is used for inputting the image to be processed and the second depth map into the image adjusting network for image deblurring processing to obtain a first processed image, wherein the definition of the second depth map is higher than that of the first depth map.
In one possible implementation, the depth adjustment network includes a first feature extraction sub-network, a first coding sub-network, and a first superposition sub-network, wherein the depth deblurring sub-module is configured to: performing feature extraction on the first depth map and the image to be processed through the first feature extraction sub-network to obtain depth feature information of the first depth map; coding and decoding the depth feature information through the first coding and decoding sub-network to obtain a third depth map; and superposing the first depth map and the third depth map through the first superposition sub-network to obtain the second depth map.
In one possible implementation, the first feature extraction sub-network includes a first convolution layer and a first spatial feature transform layer, wherein the depth deblurring sub-module is configured to: performing feature extraction on the first depth map through the first convolution layer to obtain a feature map of the first depth map; and taking the image to be processed as prior information, and performing spatial feature transformation on the feature map of the first depth map through the first spatial feature transformation layer to obtain the depth feature information.
In one possible implementation, the image adjustment network includes a second feature extraction sub-network, a second coding sub-network, and a second overlay sub-network, wherein the image deblurring sub-module is configured to: performing feature extraction on the image to be processed and the second depth map through the second feature extraction sub-network to obtain image feature information of the image to be processed; coding and decoding the image characteristic information through the second coding and decoding sub-network to obtain a second processed image; and performing superposition processing on the image to be processed and the second processed image through the second superposition sub-network to obtain the first processed image.
In one possible implementation, the second feature extraction sub-network includes a second convolution layer and a second spatial feature transform layer, wherein the image deblurring sub-module is configured to: performing feature extraction on the image to be processed through the second convolution layer to obtain a feature map of the image to be processed; and taking the second depth map as prior information, and performing spatial feature transformation on the feature map of the image to be processed through the second spatial feature transformation layer to obtain the image feature information.
In one possible implementation, the apparatus further includes: the training module is used for training the neural network according to a preset training set, wherein the training set comprises a sample image and a label image corresponding to the sample image, and the definition of the label image is higher than that of the sample image.
In one possible implementation, the training module includes: the depth output sub-module is used for inputting the fourth depth map of the sample image and the sample image into the depth adjustment network for processing and outputting a fifth depth map; the image output sub-module is used for inputting the fifth depth map and the sample image into the image adjusting network for processing and outputting a third processed image; a loss determination submodule for determining an overall loss of the neural network from the third processed image, the label image corresponding to the sample image, and the fifth depth map; and the parameter adjusting submodule is used for adjusting the network parameters of the neural network according to the total loss.
In one possible implementation, the loss determination submodule is configured to: determining a content loss according to the third processed image and the label image; determining a perception loss according to the third processed image, the label image and a pre-trained convolutional network; determining depth adjustment loss according to a sixth depth map of the label image and the fifth depth map; determining the overall loss from the content loss, the perceptual loss, and the depth adjustment loss.
In one possible implementation, the loss determination submodule is configured to: inputting the third processed image and the label image into a pre-trained convolutional network for processing respectively, and outputting a feature map of the third processed image and a feature map of the label image; and determining the perception loss according to the feature map of the third processed image and the feature map of the label image.
According to an embodiment of the present disclosure, there is also provided an image processing apparatus including: the image processing module is used for processing the image to be processed through the device under the condition that the definition of the image to be processed, acquired by the image acquisition equipment, is less than or equal to a preset threshold value to obtain a first processed image; and the output module is used for outputting and/or displaying the first processed image.
In some embodiments, functions of or modules included in the apparatus provided in the embodiments of the present disclosure may be used to execute the method described in the above method embodiments, and specific implementation thereof may refer to the description of the above method embodiments, and for brevity, will not be described again here.
Embodiments of the present disclosure also provide a computer-readable storage medium having stored thereon computer program instructions, which when executed by a processor, implement the above-mentioned method. The computer readable storage medium may be a non-volatile computer readable storage medium.
An embodiment of the present disclosure further provides an electronic device, including: a processor; a memory for storing processor-executable instructions; wherein the processor is configured as the above method.
The electronic device may be provided as a terminal, server, or other form of device.
Fig. 4 illustrates a block diagram of anelectronic device 800 in accordance with an embodiment of the disclosure. For example, theelectronic device 800 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, or the like terminal.
Referring to fig. 4,electronic device 800 may include one or more of the following components: processingcomponent 802,memory 804,power component 806,multimedia component 808,audio component 810, input/output (I/O)interface 812,sensor component 814, andcommunication component 816.
Theprocessing component 802 generally controls overall operation of theelectronic device 800, such as operations associated with display, telephone calls, data communications, camera operations, and recording operations. Theprocessing components 802 may include one ormore processors 820 to execute instructions to perform all or a portion of the steps of the methods described above. Further, theprocessing component 802 can include one or more modules that facilitate interaction between theprocessing component 802 and other components. For example, theprocessing component 802 can include a multimedia module to facilitate interaction between themultimedia component 808 and theprocessing component 802.
Thememory 804 is configured to store various types of data to support operations at theelectronic device 800. Examples of such data include instructions for any application or method operating on theelectronic device 800, contact data, phonebook data, messages, pictures, videos, and so forth. Thememory 804 may be implemented by any type or combination of volatile or non-volatile memory devices such as Static Random Access Memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic or optical disks.
Thepower supply component 806 provides power to the various components of theelectronic device 800. Thepower components 806 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power for theelectronic device 800.
Themultimedia component 808 includes a screen that provides an output interface between theelectronic device 800 and a user. In some embodiments, the screen may include a Liquid Crystal Display (LCD) and a Touch Panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive an input signal from a user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundary of a touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, themultimedia component 808 includes a front facing camera and/or a rear facing camera. The front camera and/or the rear camera may receive external multimedia data when theelectronic device 800 is in an operation mode, such as a shooting mode or a video mode. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.
Theaudio component 810 is configured to output and/or input audio signals. For example, theaudio component 810 includes a Microphone (MIC) configured to receive external audio signals when theelectronic device 800 is in an operational mode, such as a call mode, a recording mode, and a voice recognition mode. The received audio signals may further be stored in thememory 804 or transmitted via thecommunication component 816. In some embodiments,audio component 810 also includes a speaker for outputting audio signals.
The I/O interface 812 provides an interface between theprocessing component 802 and peripheral interface modules, which may be keyboards, click wheels, buttons, etc. These buttons may include, but are not limited to: a home button, a volume button, a start button, and a lock button.
Thesensor assembly 814 includes one or more sensors for providing various aspects of state assessment for theelectronic device 800. For example, thesensor assembly 814 may detect an open/closed state of theelectronic device 800, the relative positioning of components, such as a display and keypad of theelectronic device 800, thesensor assembly 814 may also detect a change in the position of theelectronic device 800 or a component of theelectronic device 800, the presence or absence of user contact with theelectronic device 800, orientation or acceleration/deceleration of theelectronic device 800, and a change in the temperature of theelectronic device 800.Sensor assembly 814 may include a proximity sensor configured to detect the presence of a nearby object without any physical contact. Thesensor assembly 814 may also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, thesensor assembly 814 may also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
Thecommunication component 816 is configured to facilitate wired or wireless communication between theelectronic device 800 and other devices. Theelectronic device 800 may access a wireless network based on a communication standard, such as WiFi, 2G or 3G, or a combination thereof. In an exemplary embodiment, thecommunication component 816 receives a broadcast signal or broadcast related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, thecommunication component 816 further includes a Near Field Communication (NFC) module to facilitate short-range communications. For example, the NFC module may be implemented based on Radio Frequency Identification (RFID) technology, infrared data association (IrDA) technology, Ultra Wideband (UWB) technology, Bluetooth (BT) technology, and other technologies.
In an exemplary embodiment, theelectronic device 800 may be implemented by one or more Application Specific Integrated Circuits (ASICs), Digital Signal Processors (DSPs), Digital Signal Processing Devices (DSPDs), Programmable Logic Devices (PLDs), Field Programmable Gate Arrays (FPGAs), controllers, micro-controllers, microprocessors or other electronic components for performing the above-described methods.
In an exemplary embodiment, a non-transitory computer-readable storage medium, such as thememory 804, is also provided that includes computer program instructions executable by theprocessor 820 of theelectronic device 800 to perform the above-described methods.
Fig. 5 illustrates a block diagram of anelectronic device 1900 in accordance with an embodiment of the disclosure. For example, theelectronic device 1900 may be provided as a server. Referring to fig. 5,electronic device 1900 includes aprocessing component 1922 further including one or more processors and memory resources, represented bymemory 1932, for storing instructions, e.g., applications, executable byprocessing component 1922. The application programs stored inmemory 1932 may include one or more modules that each correspond to a set of instructions. Further, theprocessing component 1922 is configured to execute instructions to perform the above-described method.
Theelectronic device 1900 may also include apower component 1926 configured to perform power management of theelectronic device 1900, a wired orwireless network interface 1950 configured to connect theelectronic device 1900 to a network, and an input/output (I/O)interface 1958. Theelectronic device 1900 may operate based on an operating system stored inmemory 1932, such as Windows Server, Mac OS XTM, UnixTM, LinuxTM, FreeBSDTM, or the like.
In an exemplary embodiment, a non-transitory computer readable storage medium, such as thememory 1932, is also provided that includes computer program instructions executable by theprocessing component 1922 of theelectronic device 1900 to perform the above-described methods.
The present disclosure may be systems, methods, and/or computer program products. The computer program product may include a computer-readable storage medium having computer-readable program instructions embodied thereon for causing a processor to implement various aspects of the present disclosure.
The computer readable storage medium may be a tangible device that can hold and store the instructions for use by the instruction execution device. The computer readable storage medium may be, for example, but not limited to, an electronic memory device, a magnetic memory device, an optical memory device, an electromagnetic memory device, a semiconductor memory device, or any suitable combination of the foregoing. More specific examples (a non-exhaustive list) of the computer readable storage medium would include the following: a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a Static Random Access Memory (SRAM), a portable compact disc read-only memory (CD-ROM), a Digital Versatile Disc (DVD), a memory stick, a floppy disk, a mechanical coding device, such as punch cards or in-groove projection structures having instructions stored thereon, and any suitable combination of the foregoing. Computer-readable storage media as used herein is not to be construed as transitory signals per se, such as radio waves or other freely propagating electromagnetic waves, electromagnetic waves propagating through a waveguide or other transmission medium (e.g., optical pulses through a fiber optic cable), or electrical signals transmitted through electrical wires.
The computer-readable program instructions described herein may be downloaded from a computer-readable storage medium to a respective computing/processing device, or to an external computer or external storage device via a network, such as the internet, a local area network, a wide area network, and/or a wireless network. The network may include copper transmission cables, fiber optic transmission, wireless transmission, routers, firewalls, switches, gateway computers and/or edge servers. The network adapter card or network interface in each computing/processing device receives computer-readable program instructions from the network and forwards the computer-readable program instructions for storage in a computer-readable storage medium in the respective computing/processing device.
The computer program instructions for carrying out operations of the present disclosure may be assembler instructions, Instruction Set Architecture (ISA) instructions, machine-related instructions, microcode, firmware instructions, state setting data, or source or object code written in any combination of one or more programming languages, including an object oriented programming language such as Smalltalk, C + + or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The computer-readable program instructions may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider). In some embodiments, the electronic circuitry that can execute the computer-readable program instructions implements aspects of the present disclosure by utilizing the state information of the computer-readable program instructions to personalize the electronic circuitry, such as a programmable logic circuit, a Field Programmable Gate Array (FPGA), or a Programmable Logic Array (PLA).
Various aspects of the present disclosure are described herein with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the disclosure. It will be understood that each block of the flowchart illustrations and/or block diagrams, and combinations of blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer-readable program instructions.
These computer-readable program instructions may be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions/acts specified in the flowchart and/or block diagram block or blocks. These computer-readable program instructions may also be stored in a computer-readable storage medium that can direct a computer, programmable data processing apparatus, and/or other devices to function in a particular manner, such that the computer-readable medium storing the instructions comprises an article of manufacture including instructions which implement the function/act specified in the flowchart and/or block diagram block or blocks.
The computer readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other devices to cause a series of operational steps to be performed on the computer, other programmable apparatus or other devices to produce a computer implemented process such that the instructions which execute on the computer, other programmable apparatus or other devices implement the functions/acts specified in the flowchart and/or block diagram block or blocks.
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of instructions, which comprises one or more executable instructions for implementing the specified logical function(s). In some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
Having described embodiments of the present disclosure, the foregoing description is intended to be exemplary, not exhaustive, and not limited to the disclosed embodiments. Many modifications and variations will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the described embodiments. The terminology used herein is chosen in order to best explain the principles of the embodiments, the practical application, or improvements made to the technology in the marketplace, or to enable others of ordinary skill in the art to understand the embodiments disclosed herein.