Image processing method, image processing device and electronic equipment
By aligning and merging high-definition and low-definition images through the flow matrix, the problem of improving photo clarity and keeping details consistent is solved, achieving efficient high-definition processing of face images and ensuring the accuracy and consistency of identity features.
Patent Information
- Application Number
- CN202011331349.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-11-24
- Publication Date
- 2024-08-23
- Estimated Expiration
- 2040-11-24
AI Technical Summary
It is difficult with existing technology to improve the clarity of photos while keeping the original details of the photo subject unchanged. Especially in face image processing, the network's "imagination" causes details to change and affects identity characteristics.
By acquiring a high-definition second image and a low-definition first image, the flow matrix is used to position the pixels of the second image to align them with the first image, and perform image fusion to generate a higher-definition image. of the fourth image to ensure accuracy and consistency of detail.
Significantly improves the effect of high-definition image processing, ensuring that the improved photo clarity is consistent with the original details. Especially in facial image processing, facial details such as wrinkles, moles, dimples and other features are retained.
Smart Images

Figure CN112381749B
Abstract
Description
Technical Field
[0001] The present application belongs to the field of image processing technology, and specifically relates to an image processing method, an image processing device and an electronic device. Background Art
[0002] In related technologies, due to limitations of shooting equipment, network limitations, image compression or other reasons, the clarity of photos is low, which affects the appearance of photos. At present, based on image processing technology, the resolution of photos can be improved to a certain extent, but the supplement of photo details needs to rely on the "imagination" of the network.
[0003] For highly recognizable photos such as faces, the details "imagined" by the network are different from the original details of the subject in the photo, which will cause the details of the face's identity to be changed. How to improve the clarity of the photo while ensuring that the original details of the subject remain unchanged is a technical problem that needs to be solved urgently. Summary of the invention
[0004] The purpose of the embodiments of the present application is to provide an image processing method, device, electronic device and readable storage medium, which can solve the problem of how to improve the clarity of a photo while ensuring that the original details of the photo subject remain unchanged.
[0005] In order to solve the above technical problems, this application is implemented as follows:
[0006] In a first aspect, an embodiment of the present application provides an image processing method, the method comprising:
[0007] Acquire a first image and a second image of the same object, wherein the definition of the second image is higher than the definition of the first image;
[0008] Get the flow matrix;
[0009] By using the flow matrix, position shifting is performed on the pixel points of the second image to obtain a third image, wherein the third image is an image aligned with the first image;
[0010] The third image and the first image are fused to generate a fourth image, wherein the fourth image has a higher definition than the first image.
[0011] In a second aspect, an embodiment of the present application provides an image processing device, including:
[0012] An acquisition module, used for acquiring a first image and a second image of the same object, wherein the definition of the second image is higher than the definition of the first image;
[0013] a processing module, configured to obtain a flow matrix, and perform position shifting on the pixels of the second image through the flow matrix to obtain a third image, wherein the third image is an image aligned with the first image; and
[0014] The third image and the first image are fused to generate a fourth image, wherein the fourth image has a higher definition than the first image.
[0015] In a third aspect, an embodiment of the present application provides an electronic device, which includes a processor, a memory, and a program or instruction stored in the memory and executable on the processor, and when the program or instruction is executed by the processor, the steps of the image processing method provided in the first aspect are implemented.
[0016] In a fourth aspect, an embodiment of the present application provides a readable storage medium, on which a program or instruction is stored, and when the program or instruction is executed by a processor, the steps of the image processing method provided in the first aspect are implemented.
[0017] In a fifth aspect, an embodiment of the present application provides a chip, the chip including a processor and a communication interface, the communication interface and the processor are coupled, and the processor is used to run programs or instructions to implement the steps of the image processing method provided in the first aspect.
[0018] In an embodiment of the present application, when a first image of a certain clarity is processed for high definition, the pixels of a second image whose subject is the same object and whose clarity is higher than that of the first image are offset through a fluid matrix, and the second image is processed into a third image aligned with the first image through pixel offset.
[0019] Specifically, assuming that both the first image and the second image are human face images, after pixel shifting of the second image, a human face image is obtained whose face portion is aligned with the face portion of the first image, i.e., the third image mentioned above. Here, "alignment" means that the contours of the face overlap, or the positions of key facial features such as eyes, nose, and mouth overlap.
[0020] After obtaining a third image that is aligned with the first image and retains more details due to its higher definition, the first image and the third image are fused. This improves the clarity of the first image, while superimposing the facial details on the third image, such as wrinkles, moles, dimples, etc., on the first image, so that the details added on the first image are the facial details of the same person, effectively ensuring that the details of the photo after the clarity is improved are consistent with the original details of the subject of the photo, thereby effectively solving the technical problem of how to ensure that the original details of the subject of the photo remain unchanged while improving the clarity of the photo, and can significantly improve the processing effect of high-definition image processing. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] Figure 1 One of the flowcharts of the image processing method according to an embodiment of the present application is shown;
[0022] Figure 2 A second flowchart of the image processing method according to an embodiment of the present application is shown;
[0023] Figure 3 A third flowchart of the image processing method according to an embodiment of the present application is shown;
[0024] Figure 4 A fourth flowchart of the image processing method according to an embodiment of the present application is shown;
[0025] Figure 5 A schematic diagram showing the flow direction of a single channel point in the flow matrix;
[0026] Figure 6 A fifth flowchart of the image processing method according to an embodiment of the present application is shown;
[0027] Figure 7 A sixth flowchart of the image processing method according to an embodiment of the present application is shown;
[0028] Figure 8 FIG7 shows a flowchart of an image processing method according to an embodiment of the present application;
[0029] Fig. 9 FIG8 shows an eighth flowchart of an image processing method according to an embodiment of the present application;
[0030] Fig.10 FIG9 shows a flowchart of an image processing method according to an embodiment of the present application;
[0031] Fig.11 A structural block diagram of an image processing device according to an embodiment of the present application is shown;
[0032] Fig.12 A schematic diagram of the hardware structure of an electronic device according to an embodiment of the application is shown. DETAILED DESCRIPTION
[0033] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0034] The terms "first", "second", etc. in the specification and claims of the present application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable under appropriate circumstances, so that the embodiments of the present application can be implemented in an order other than those illustrated or described here. In addition, the "and / or" in the specification and claims represents at least one of the connected objects, and the character " / " generally represents that the objects associated with each other are in an "or" relationship.
[0035] The image processing method, image processing device and electronic device provided in the embodiments of the present application are described in detail below with reference to the accompanying drawings through specific embodiments and their application scenarios.
[0036] In some embodiments of the present application, an image processing method is provided. Figure 1 One of the flowcharts of the image processing method according to the embodiment of the present application is shown. Specifically, the image processing method may include the following steps:
[0037] Step 102, acquiring a first image and a second image of the same object;
[0038] In step 102, the definition of the second image is higher than the definition of the first image.
[0039] Step 104, obtaining a flow matrix;
[0040] Step 106, performing position shifting on the pixel points of the second image by using the flow matrix to obtain a third image;
[0041] In step 106, the third image is an image aligned with the first image.
[0042] Step 108: Fusing the third image with the first image to generate a fourth image.
[0043] In step 108 , the fourth image has a higher definition than the first image.
[0044] In the embodiment of the present application, when a low-definition first image is processed into a high-definition image, a second image of the same object is obtained, and the second image has a higher definition than the first image, so more detail information is retained in the second image compared to the first image. At the same time, the subject in the second image is the same object as that in the first image. For example, when the first image and the second image are facial images, the "face" in the second image and the first image belongs to the same person, but can be facial images at different times, different postures, and different expressions.
[0045] The same object can also be the same object, such as an apple, the same table, etc.
[0046] In the process of processing the first image, the pixels of the second image are offset by the flow matrix, so that the second image is processed into a third image aligned with the first image. Specifically, assuming that both the first image and the second image are facial images, after the pixels of the second image are offset, a facial image is obtained in which the facial part is aligned with the facial part of the first image, i.e., the third image mentioned above. Here, "alignment" refers to the overlap of the contours of the face, or the overlap of the positions of key facial features such as the eyes, nose, and mouth.
[0047] It can be understood that when the subject of the photo is an object other than a human face, the processed image and the original photo can be "aligned" by making the outer contours of the object overlap.
[0048] After obtaining a third image that is aligned with the first image and retains more details due to its higher definition, the first image and the third image are fused. This improves the clarity of the first image, while superimposing the facial details on the third image, such as wrinkles, moles, dimples, etc., on the first image, so that the details added on the first image are the facial details of the same person, effectively ensuring that the details of the photo after the clarity is improved are consistent with the original details of the subject of the photo, thereby effectively solving the technical problem of how to ensure that the original details of the subject of the photo remain unchanged while improving the clarity of the photo, and can significantly improve the processing effect of high-definition image processing.
[0049] In some embodiments of the present application, Figure 2 The second flowchart of the image processing method according to the embodiment of the present application is shown. Specifically, the pixel points of the second image are shifted by the flow matrix to obtain the third image. Specifically, the following steps may be included:
[0050] Step 202, determining a first key point coordinate set and a second key point coordinate set;
[0051] In step 202, the first key point coordinate set includes coordinates of at least one first key point in the first image, and the second key point coordinate set includes coordinates of at least one second key point in the second image.
[0052] Step 204, performing coordinate transformation on the second key point coordinate set through the flow matrix to obtain a third key point coordinate set after position shifting;
[0053] In step 204, the third key point coordinate set includes the coordinates of at least one key point that coincides with the first key point coordinate set.
[0054] Step 206, determining a first offset of the third key point coordinate set relative to the second key point coordinate set;
[0055] Step 208, determining second offsets corresponding to the remaining pixel point coordinate sets in the second image by bilinear interpolation according to the first offset;
[0056] Step 210: Perform position shift on the remaining pixel point coordinate sets in the second image according to the second offset to obtain a third image.
[0057] In the embodiment of the present application, in the process of converting the high-definition second image into the low-definition first image, the first key point and the second key point in the first image and the second image are respectively determined.
[0058] Among them, for facial images, "key points" can be the positions of key facial features such as eyes, nose, mouth, etc., or other key points. For example, through facial key point detection, the corresponding key point positions can be detected in two facial images.
[0059] In an embodiment of the present application, the open source Dlib library (a tool library developed based on C++, including machine learning algorithms, image processing, network and other tool libraries) can be used to perform key point detection on the faces in the first image and the second image to obtain facial landmark data of the same person, thereby realizing key point detection.
[0060] After obtaining the coordinate set of the first key point and the coordinate set of the second key point, the first coordinate set is used as the target to transform the second coordinate through a preset flow matrix, and then the second key point is "offset" to the position of the first key point to obtain the third key point coordinate set, and the third key point is formed to be able to approximately coincide with all the first key points, thereby achieving alignment of the first image key point with the second image key point.
[0061] Among them, the first image is converted into two-channel data, and the two-channel data of all pixels in the first image can be obtained, and then a secondary coordinate system corresponding to the first image is established, that is, the two-channel data is converted into coordinate data of each pixel, and the coordinate data of the key points therein are marked and used as the first key point coordinate set.
[0062] Similarly, the second image is converted into two-channel data to obtain two-channel data of all pixels in the second image, and a coordinate system is established in the same way to obtain a second key point coordinate set corresponding to the second key point.
[0063] In the coordinate system of the second image, taking the first key point coordinate set as a target, coordinate transformation is performed on the second key point coordinate set, so that the second key point can be transferred to a third key point aligned with the first key point.
[0064] For other pixels that are not key points, the bilinear interpolation method can be used to interpolate the offset of the point based on the offset of the surrounding key points, and then other pixels in the same coordinate system are offset to obtain the offset pixel position.
[0065] Specifically, after completing the position offset from the second key point to the third key point, determine the offset between each third key point coordinate and the corresponding second key point coordinate in the third key point coordinate set, and record it as the first offset of the key point coordinate. The first offset can be determined by the difference between the second key point coordinate and the third key point coordinate, and the first offset is a vector indicating the offset distance and offset direction of the second key point offset to the third key point.
[0066] After obtaining the first offset corresponding to each key point, for other pixel points near the key point, the pixel points can be moved by bilinear interpolation method, so as to achieve position offset of all pixel points in the second image and obtain a third image aligned with the first image.
[0067] The embodiment of the present application can accurately align the high-definition face with the blurred face through the flow matrix, so as to accurately restore the detail information in the high-definition face image to the blurred face image, and can ensure that the restored details are consistent with the identity details of the original blurred face, and ensure that the high-definition processed photo is consistent with the original details of the original photo subject, thereby effectively solving the technical problem of how to improve the clarity of the photo while ensuring that the original details of the photo subject remain unchanged, and can significantly improve the processing effect of high-definition image processing.
[0068] In some embodiments of the present application, Figure 3 The third flowchart of the image processing method according to the embodiment of the present application is shown. Specifically, when acquiring the first image and the second image of the same object, the following steps may be specifically included:
[0069] Step 302, acquiring a first original image and a second original image;
[0070] In step 302, the first original image and the second original image are "full images" including facial images, which may include the face, body parts, background, and objects interacting with the person.
[0071] Step 304: extract a first image of the object in the first original image, and extract a second image of the object in the second original image.
[0072] In step 304, "cutting out" the first image of the object and "cutting out" the second image of the object refer to separating the face part of the "object" from the original image, that is, removing the background part of the original image and retaining only the face part.
[0073] Since human vision is much more sensitive to facial details than to details of other objects, such as backgrounds and scenery, when the original image is processed for high definition, a face detection algorithm can be used to perform face detection in the blurred image, thereby "cutting out" a facial image, i.e., the first image, from the original blurred image.
[0074] Similarly, a high-definition face image of the same person is cut out from another high-definition photo of the same person, i.e., the second image
[0075] Among them, face detection can use open source tool libraries such as opencv.
[0076] By only fusing the details of the face image, the amount of calculation can be effectively reduced, thereby improving the efficiency of image processing, so that the image processing method can be run and implemented on lower-performance devices, such as smart watches, smart glasses and other wearable devices, thereby improving the versatility of high-definition image processing.
[0077] In some embodiments of the present application, Figure 4 The fourth flowchart of the image processing method according to the embodiment of the present application is shown. Specifically, obtaining a preset flow matrix may include the following steps:
[0078] Step 402, obtaining a preset target encoding-decoding model;
[0079] In step 402, the target encoding-decoding model includes an encoding neural network and a decoding neural network, wherein the decoding neural network includes a transposed convolutional network and a normal convolutional network;
[0080] Step 404, merging the first image and the second image according to the natural three primary color channels to obtain a merged image;
[0081] Step 406, convolving the merged image through the encoding neural network, and normalizing the convolved merged image to obtain encoding data output by the encoding neural network;
[0082] Step 408, performing transposed convolution on the encoded data through the decoding neural network, normalizing the encoded data after the transposed convolution, and performing ordinary convolution on the normalized encoded data to obtain a flow matrix output by the decoding neural network.
[0083] In the embodiment of the present application, a flow matrix when converting between a blurred image and a high-definition image is determined by an encoder-decoder network structure (such as a warpNet network structure).
[0084] The encoder neural network can use convolution with a kernel size of 3 and a stride of 2. The decoder neural network can include two convolution methods: transposed convolution network and ordinary convolution network. The convolution kernel of the transposed convolution is 3 and the stride is 2. After the transposed convolution, ordinary convolution is used to increase the network depth, thereby enhancing the network computing power.
[0085] Specifically, the blurred face image and the high-definition face image, that is, the first image and the second image, are merged according to the three primary color channels (RGB channels) to obtain a 6-channel merged image, wherein the 6 channels are the R channel, the G channel and the B channel of the first image, and the R channel, the G channel and the B channel of the second image.
[0086] The merged image is input to the encoding neural network, which convolves the merged image and normalizes the convolved image, wherein the normalization can be performed by the InstanceNorm (Instance Normalization) method. In this process, the ReLU (Rectified Linear Unit) function is used as the activation function to increase the nonlinearity of the encoding neural network. In the encoding neural network, the above-mentioned convolution-normalization-increase nonlinearity structure is repeated many times, specifically 4 times.
[0087] After the convolution process of the encoding neural network, the feature map of the merged image is reduced during the convolution process, which can effectively reduce the amount of calculation and increase the receptive field. The output of the encoding neural network is the encoded data of the multi-channel feature map. After four convolutions with a step size of 2, the encoding length of the encoded data can be reduced to one sixteenth of the original image.
[0088] The encoded data output by the above encoding neural network is input into the decoding neural network. The decoding neural network first performs transposed convolution on the encoded data, and then normalizes it by the InstanceNorm method after the transposed convolution, and uses the ReLU function as the activation function, and then performs another ordinary convolution. Finally, the encoder network outputs a 2-channel (x, y channel) matrix of the same image size, that is, the above flow matrix. In the flow matrix, the position corresponding to each point is the offset of a pixel in the x direction and the y direction respectively.
[0089] Figure 5 A schematic diagram of the flow direction of a single channel point in the flow matrix is shown. Through the flow matrix, the mutual conversion between blurred images and high-definition images can be realized, and the alignment of high-definition faces to blurred faces can be accurately achieved, so that the detail information in the high-definition face image can be accurately restored to the blurred face image.
[0090] In some embodiments of the present application, Figure 6 The fifth flowchart of the image processing method according to the embodiment of the present application is shown. Specifically, when the pixel points of the second image are shifted by the flow matrix, the following steps may be specifically included:
[0091] Step 602, obtaining a preset encoding-decoding model;
[0092] Step 604, determining a first objective loss function based on the first key point and the second key point;
[0093] Step 606: Train the preset encoding-decoding model using the first target loss function to obtain a target encoding-decoding model.
[0094] In the embodiment of the present application, the preset encoding-decoding model is trained to obtain the target encoding-decoding model. Specifically, the loss function of the preset encoding-decoding model can be set using the key points detected in the first image and the second image.
[0095] Specifically, the loss function is as follows:
[0096]
[0097] Among them, Loss Landmark is the loss value of the above loss function, The first key point is The second key point.
[0098] By training the neural network through the above loss function to obtain the target encoding-decoding model, the accuracy of the flow matrix can be effectively improved, thereby improving the accuracy of high-definition image processing.
[0099] In some embodiments of the present application, Figure 7 The sixth flowchart of the image processing method according to the embodiment of the present application is shown. Specifically, when the third image and the first image are image-fused, the following steps are specifically included:
[0100] Step 702, obtaining a target neural network model;
[0101] Step 704: The third image and the first image are fused through the target neural network model to obtain a fourth image output by the target neural network model.
[0102] In an embodiment of the present application, a target neural network trained by machine learning is used to perform image fusion on a high-definition face image aligned with a blurred face image and on a blurred face image, that is, to perform image fusion on the third image and the first image, and to automatically add detail information on the high-definition face image to the processed first image, ultimately generating a fourth image with improved clarity and retaining facial identity details.
[0103] And because the third image and the first image to be processed are facial images of the same person, when the clarity of the first image is improved, the supplemented details are the facial details of the same person, which effectively ensures that the details of the photo after the clarity is improved are consistent with the original details of the subject of the photo. This effectively solves the technical problem of how to improve the clarity of the photo while ensuring that the original details of the subject of the photo remain unchanged, and can significantly improve the processing effect of high-definition image processing.
[0104] In some embodiments of the present application, Figure 8 FIG. 7 shows a flowchart of an image processing method according to an embodiment of the present application. Specifically, before performing image fusion on the third image and the first image, the image processing method may further include the following steps:
[0105] Step 802, obtaining a preset neural network model, a discriminator network model, an image training set, and a comparison image set;
[0106] Step 804, input the image training set into the neural network model to obtain an intermediate image;
[0107] Step 806, inputting the intermediate image and the corresponding contrast image in the contrast image set into the discriminator network model, and performing adversarial training on the preset neural network model;
[0108] Step 808, training the preset neural network model that has completed adversarial training through a preset second target loss function to obtain a target neural network model.
[0109] In an embodiment of the present application, a preset neural network model is subjected to machine learning training to obtain a target neural network retention model that can accurately fuse the aligned high-definition face image and the blurred face image.
[0110] Specifically, the preset neural network model can use the U-Net network as the generator network, and reference the discriminator network model to form a generative adversarial network. The discriminator network model can use a resblock network structure.
[0111] During training, an image training set consisting of a large number of blurred face images and a comparison image set consisting of high-definition face images corresponding one-to-one to the blurred face images are obtained.
[0112] First, the image training set is input into the generator network of the preset neural network model to obtain the intermediate image, and then the intermediate image and the contrast image corresponding to the input blurred face image in the contrast image set are input into the discriminator network model, so that the generative adversarial network is alternately trained until the generator network and the discriminator network become stronger at the same time and reach a balanced state.
[0113] Among them, for the intermediate image and the corresponding blurred image, a perceptual consistency loss function can be used to ensure that the semantic information remains unchanged. The loss function can be performed by inputting the intermediate image and the corresponding blurred image into a pre-trained vgg network (a deep convolutional neural network developed by researchers from the Computer Vision Group of the University of Oxford and Google Deep Mind) respectively, and extracting the feature map after the last convolution ReLU activation function, and performing L1 loss on the two feature maps of the blurred image and the intermediate image, that is, the above-mentioned second loss function. Specifically, the second loss function includes:
[0114] L percept =||θ(I p )-θ(I r )||1;(1)
[0115]
[0116] Among them, function (1) is the perceptual loss function of the image, which is used to ensure the consistency of the image content, θ is the pre-trained VGG network mentioned above, and I p is the above blurred image, I r For the above intermediate image, for the feature map, the above perceptual loss function can ensure that the overall content remains unchanged while ignoring the details.
[0117] Function (2) is the GAN (Generative Adversarial Network) loss function, which is used to ensure the authenticity and clarity of the image. G max D It means that when the discriminator network maximizes function (2), the generator network minimizes the function (2). represents a random selection of a blurred image in the image training set, D is the discriminator network, D(I p ) represents the score of the randomly selected blurred image output by the discriminator network.
[0118] During the training process, the 6-channel image data obtained by splicing the original blurred face image and the high-definition face image that is aligned with the blurred face image after position conversion by the flow matrix is input into the generator network. The detail features extracted from the high-definition face image can be fused to the blurred face image, making the blurred face image clear, and ensuring that the detailed features of the cleared face are the same as the original face features, thereby ensuring that the identity features of the face image remain unchanged.
[0119] Among them, the intermediate image (high-definition face image) and the blurred image (original face image) generated during training are brought into function (1) and function (1) is minimized, which can ensure that the information of the intermediate image and the original image are consistent. The above intermediate image and the above blurred image are brought into function (2) to ensure the clarity of the face in the intermediate image, and finally improve the image processing effect of high-definition face image processing.
[0120] In some embodiments of the present application, Fig. 9 FIG8 is a flowchart of an image processing method according to an embodiment of the present application. Specifically, after obtaining the fourth image, the image processing method may further include the following steps:
[0121] Step 902, fusing the fourth image with the first original image by using a Poisson fusion algorithm;
[0122] Step 904, obtaining the processed target image.
[0123] In an embodiment of the present application, after obtaining the high-definition fourth image, that is, a facial image with improved clarity and supplemented detail features, the fourth image is fused with the first original image, and the high-definition facial image is "put back" into the initial photo, thereby completing the high-definition processing of the facial image in the initial photo.
[0124] Among them, by using the Poisson fusion algorithm (ie, seamlessClone algorithm) to fuse the fourth image and the first original image, the fused boundary can be made more natural and smoother, and the effect of image processing can be effectively guaranteed.
[0125] In some real-time methods, the first original image data, that is, the background image other than the portrait part in the initial photo, can be aligned with the background image part for high-definition processing through an image processing algorithm based on deep learning and generative adversarial networks, so that the final target image is more natural.
[0126] In some embodiments of the present application, Fig.10 FIG9 shows a flowchart of an image processing method according to an embodiment of the present application. Specifically, the completion process of the image processing method includes:
[0127] Step 1002, performing face detection on the photo to be processed and the high-definition photo to obtain a fuzzy face image and a high-definition face image;
[0128] Step 1004, performing key point detection on the face image to obtain key point coordinates;
[0129] Step 1006, performing pixel shifting on the high-definition image according to the key point coordinates to obtain a detailed face image that is aligned with the blurred face image after the shifting;
[0130] Step 1008, fusing the blurred face image and the detailed face image through a generative adversarial network to obtain a high-definition face image;
[0131] Step 1010, stitching the high-definition face image with the photo to be processed to obtain an output image.
[0132] The embodiment of the present application uses a point flow method to align images, thereby extracting details in high-definition images and contours of blurred images, and uses a generative adversarial network to fuse the image details to the blurred contours, thereby clarifying the blurred image. At the same time, it can ensure that the facial details are the same as the real face, ensuring that the facial features of the photographed person remain unchanged.
[0133] In some embodiments of the present application, it should be noted that the image processing method provided in the embodiments of the present application may be executed by an image processing device, or by a control module in the image processing device for executing the loaded image processing method. In the embodiments of the present application, the image processing method provided in the embodiments of the present application is described by taking the image processing device executing the loaded image processing method as an example.
[0134] Fig.11 The structure block diagram of the image processing device according to the embodiment of the present application is shown. Specifically, the image processing device 1100 includes:
[0135] An acquisition module 1102 is used to acquire a first image and a second image of the same object, wherein the definition of the second image is higher than the definition of the first image;
[0136] The processing module 1104 is used to obtain a flow matrix, and perform position shifting on the pixels of the second image by using the flow matrix to obtain a third image, wherein the third image is an image aligned with the first image; and
[0137] The third image and the first image are fused to generate a fourth image, wherein the fourth image has a higher definition than the first image.
[0138] In the embodiment of the present application, when a low-definition first image is processed into a high-definition image, a second image of the same object is obtained, and the second image has a higher definition than the first image, so more detail information is retained in the second image compared to the first image. At the same time, the subject in the second image is the same object as that in the first image. For example, when the first image and the second image are facial images, the "face" in the second image and the first image belongs to the same person, but can be facial images at different times, different postures, and different expressions.
[0139] The same object can also be the same object, such as an apple, the same table, etc.
[0140] In the process of processing the first image, the pixels of the second image are offset by the flow matrix, so that the second image is processed into a third image aligned with the first image. Specifically, assuming that both the first image and the second image are facial images, after the pixels of the second image are offset, a facial image is obtained in which the facial part is aligned with the facial part of the first image, i.e., the third image mentioned above. Here, "alignment" refers to the overlap of the contours of the face, or the overlap of the positions of key facial features such as the eyes, nose, and mouth.
[0141] It can be understood that when the subject of the photo is an object other than a human face, the processed image and the original photo can be "aligned" by making the outer contours of the object overlap.
[0142] After obtaining a third image that is aligned with the first image and retains more details due to its higher definition, the first image and the third image are fused. This improves the clarity of the first image, while superimposing the facial details on the third image, such as wrinkles, moles, dimples, etc., on the first image, so that the details added on the first image are the facial details of the same person, effectively ensuring that the details of the photo after the clarity is improved are consistent with the original details of the subject of the photo, thereby effectively solving the technical problem of how to ensure that the original details of the subject of the photo remain unchanged while improving the clarity of the photo, and can significantly improve the processing effect of high-definition image processing.
[0143] The image processing device in the embodiment of the present application can be a device, or a component, integrated circuit, or chip in a terminal. The device can be a mobile electronic device or a non-mobile electronic device. Exemplarily, the mobile electronic device can be a mobile phone, a tablet computer, a laptop computer, a PDA, an in-vehicle electronic device, a wearable device, an ultra-mobile personal computer (UMPC), a netbook, or a personal digital assistant (PDA), etc. The non-mobile electronic device can be a server, a network attached storage (NAS), a personal computer (PC), a television (TV), a teller machine or a self-service machine, etc., which is not specifically limited in the embodiment of the present application.
[0144] The image processing device in the embodiment of the present application may be a device having an operating system. The operating system may be an Android operating system, an iOS operating system, or other possible operating systems, which are not specifically limited in the embodiment of the present application.
[0145] The image processing device provided in the embodiment of the present application can achieve Figures 1 to 10 To avoid repetition, the various processes implemented by the image processing device in the method embodiment will not be described here.
[0146] Optionally, an embodiment of the present application also provides an electronic device 1900, including a processor 1910, a memory 1909, and a program or instruction stored in the memory 1909 and executable on the processor 1910. When the program or instruction is executed by the processor 1910, each process of the above-mentioned image processing method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
[0147] It should be noted that the electronic devices in the embodiments of the present application include the above-mentioned mobile electronic devices and non-mobile electronic devices.
[0148] Fig.12 A schematic diagram of the hardware structure of an electronic device according to an embodiment of the application is shown.
[0149] The electronic device 1900 includes but is not limited to components such as a radio frequency unit 1901, a network module 1902, an audio output unit 1903, an input unit 1904, a sensor 1905, a display unit 1906, a user input unit 1907, an interface unit 1908, a memory 1909, and a processor 1910.
[0150] Those skilled in the art will appreciate that the electronic device 1900 may also include a power source (such as a battery) for supplying power to each component, and the power source may be logically connected to the processor 1910 through a power management system, thereby implementing functions such as managing charging, discharging, and power consumption management through the power management system. Fig.12 The electronic device structure shown in the figure does not constitute a limitation on the electronic device. The electronic device may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently, which will not be described in detail here.
[0151] Processor 1910 is used to perform face detection on the first original image data and the second original image data, so as to obtain the first image and the second image of the same object, and detect the key points of the first image and the second image, and process the high-definition second image into a third image aligned with the first image through a flow matrix according to the coordinates of the key points, and at the same time, fuse the third image and the first image through a generative adversarial network to obtain a high-definition fourth image, and fuse the fourth image with the first original image data, so as to finally realize high-definition processing of the face in the original blurred photo.
[0152] It should be understood that in the embodiment of the present application, the radio frequency unit 1901 can be used to send and receive information or send and receive signals during a call, specifically, receive downlink data from a base station or send uplink data to a base station. The radio frequency unit 1901 includes but is not limited to an antenna, at least one amplifier, a transceiver, a coupler, a low noise amplifier, a duplexer, etc.
[0153] The network module 1902 provides users with wireless broadband Internet access, such as helping users to send and receive emails, browse web pages, and access streaming media.
[0154] The audio output unit 1903 can convert the audio data received by the RF unit 1901 or the network module 1902 or stored in the memory 1909 into an audio signal and output it as sound. Moreover, the audio output unit 1903 can also provide audio output related to a specific function performed by the electronic device 1900 (for example, a call signal reception sound, a message reception sound, etc.). The audio output unit 1903 includes a speaker, a buzzer, a receiver, etc.
[0155] The input unit 1904 is used to receive audio or video signals. The input unit 1904 may include a graphics processing unit (GPU) 5082 and a microphone 5084. The graphics processor 5082 processes the image data of a static picture or video obtained by an image capture device (such as a camera) in a video capture mode or an image capture mode. The processed image frame can be displayed on the display unit 1906, or stored in the memory 1909 (or other storage medium), or sent via the radio frequency unit 1901 or the network module 1902. The microphone 5084 can receive sound and can process the sound into audio data. The processed audio data can be converted into a format that can be sent to a mobile communication base station via the radio frequency unit 1901 in the case of a telephone call mode.
[0156] The electronic device 1900 also includes at least one sensor 1905, such as a fingerprint sensor, a pressure sensor, an iris sensor, a molecular sensor, a gyroscope, a barometer, a hygrometer, a thermometer, an infrared sensor, a light sensor, a motion sensor, and other sensors.
[0157] The display unit 1906 is used to display information input by the user or information provided to the user. The display unit 1906 may include a display panel 5122, which may be configured in the form of a liquid crystal display, an organic light emitting diode, or the like.
[0158] The user input unit 1907 can be used to receive input digital or character information, and to generate key signal input related to user settings and function control of the electronic device. Specifically, the user input unit 1907 includes a touch panel 5142 and other input devices 5144. The touch panel 5142 is also called a touch screen, which can collect the user's touch operations on or near it. The touch panel 5142 may include two parts: a touch detection device and a touch controller. Among them, the touch detection device detects the user's touch orientation, detects the signal brought by the touch operation, and transmits the signal to the touch controller; the touch controller receives the touch information from the touch detection device, and converts it into contact coordinates, and then sends it to the processor 1910, receives the command sent by the processor 1910 and executes it. Other input devices 5144 may include but are not limited to physical keyboards, function keys (such as volume control keys, switch keys, etc.), trackballs, mice, and joysticks, which will not be repeated here.
[0159] Furthermore, the touch panel 5142 may be covered on the display panel 5122. When the touch panel 5142 detects a touch operation on or near it, it is transmitted to the processor 1910 to determine the type of the touch event, and then the processor 1910 provides a corresponding visual output on the display panel 5122 according to the type of the touch event. The touch panel 5142 and the display panel 5122 may be two independent components or integrated into one component.
[0160] The interface unit 1908 is an interface for connecting an external device to the electronic device 1900. For example, the external device may include a wired or wireless headset port, an external power supply (or battery charger) port, a wired or wireless data port, a memory card port, a port for connecting a device with an identification module, an audio input / output (I / 0) port, a video I / 0 port, a headphone port, etc. The interface unit 1908 may be used to receive input (e.g., data information, power, etc.) from an external device and transmit the received input to one or more elements within the electronic device 1900 or may be used to transmit data between the electronic device 1900 and an external device.
[0161] The memory 1909 can be used to store software programs and various data. The memory 1909 can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area can store data created according to the use of the mobile terminal (such as audio data, a phone book, etc.), etc. In addition, the memory 1909 can include a high-speed random access memory, and can also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.
[0162] The processor 1910 performs various functions of the electronic device 1900 and processes data by running or executing software programs and / or modules stored in the memory 1909 and calling data stored in the memory 1909, thereby monitoring the electronic device 1900 as a whole. The processor 1910 may include one or more processing units; preferably, the processor 1910 may integrate an application processor and a modem processor, wherein the application processor mainly processes an operating system, a user interface, and application programs, and the modem processor mainly processes wireless communications.
[0163] The electronic device 1900 may also include a power supply 1911 for supplying power to various components. Preferably, the power supply 1911 may be logically connected to the processor 1910 via a power management system, thereby implementing functions such as charging, discharging, and power consumption management through the power management system.
[0164] When the embodiment of the present application performs high-definition processing on a first image of a certain clarity, the pixel points of a second image with the same shooting subject and higher clarity than the first image are offset through a fluid matrix, and the second image is processed into a third image aligned with the first image through pixel offset.
[0165] Specifically, assuming that both the first image and the second image are human face images, after pixel shifting of the second image, a human face image is obtained whose face portion is aligned with the face portion of the first image, i.e., the third image mentioned above. Here, "alignment" means that the contours of the face overlap, or the positions of key facial features such as eyes, nose, and mouth overlap.
[0166] After obtaining a third image that is aligned with the first image and retains more details due to its higher definition, the first image and the third image are fused. This improves the clarity of the first image, while superimposing the facial details on the third image, such as wrinkles, moles, dimples, etc., on the first image, so that the details added on the first image are the facial details of the same person, effectively ensuring that the details of the photo after the clarity is improved are consistent with the original details of the subject of the photo, thereby effectively solving the technical problem of how to ensure that the original details of the subject of the photo remain unchanged while improving the clarity of the photo, and can significantly improve the processing effect of high-definition image processing.
[0167] An embodiment of the present application also provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, the various processes of the above-mentioned image processing method embodiment are implemented and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
[0168] The processor is the processor in the electronic device in the above embodiment. The readable storage medium includes a computer readable storage medium, such as a computer read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0169] An embodiment of the present application further provides a chip, which includes a processor and a communication interface, wherein the communication interface and the processor are coupled, and the processor is used to run programs or instructions to implement the various processes of the above-mentioned image processing method embodiment, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0170] It should be understood that the chip mentioned in the embodiments of the present application can also be called a system-level chip, a system chip, a chip system or a system-on-chip chip, etc.
[0171] It should be noted that, in this article, the terms "comprise", "include" or any other variant thereof are intended to cover non-exclusive inclusion, so that the process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise one..." do not exclude the presence of other identical elements in the process, method, article or device including the element. In addition, it should be pointed out that the scope of the methods and devices in the embodiments of the present application is not limited to performing functions in the order shown or discussed, and may also include performing functions in a substantially simultaneous manner or in reverse order according to the functions involved, for example, the described method may be performed in an order different from that described, and various steps may also be added, omitted, or combined. In addition, the features described with reference to certain examples may be combined in other examples.
[0172] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, a disk, or an optical disk), and includes a number of instructions for a terminal (which can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods of each embodiment of the present application.
[0173] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present application, ordinary technicians in this field can also make many forms without departing from the purpose of the present application and the scope of protection of the claims, all of which are within the protection of the present application.
Claims
1. An image processing method, It is characterized in that include: Acquire a first image and a second image of the same object, wherein the subject in the second image and the first image is the same object, and the definition of the second image is higher than that of the first image; Get the flow matrix; Determine a first key point coordinate set and a second key point coordinate set, the first key point coordinate set including coordinates of at least one first key point in the first image, and the second key point coordinate set including coordinates of at least one second key point in the second image; Performing coordinate transformation on the second key point coordinate set through the flow matrix to obtain a third key point coordinate set after position shift, wherein the third key point coordinate set includes coordinates of at least one key point that coincides with the first key point coordinate set; Determine a first offset of the third key point coordinate set relative to the second key point coordinate set; Determine, according to the first offset, second offsets corresponding to the remaining pixel point coordinate sets in the second image by bilinear interpolation; According to the second offset, positionally offset the remaining pixel point coordinate sets in the second image to obtain a third image; wherein the third image is an image aligned with the first image; The third image and the first image are fused to generate a fourth image, wherein the fourth image has a higher definition than the first image.
2. The image processing method according to claim 1, It is characterized in that The step of acquiring a first image and a second image of the same object comprises: Acquire a first original image and a second original image; In the first original image, the first image of the object is cut out, and in the second original image, the second image of the object is cut out.
3. The image processing method according to claim 1, It is characterized in that The obtaining of the flow matrix comprises: Obtaining a preset target encoding-decoding model, wherein the target encoding-decoding model includes an encoding neural network and a decoding neural network, wherein the decoding neural network includes a transposed convolutional network and a normal convolutional network; Merging the first image and the second image according to the natural three primary color channels to obtain a merged image; Convolving the combined image through the encoding neural network, and normalizing the combined image after the convolution to obtain encoding data output by the encoding neural network; The decoding neural network is used to perform transposed convolution on the encoded data, normalize the encoded data after the transposed convolution, and perform ordinary convolution on the encoded data after the normalization to obtain the flow matrix output by the decoding neural network.
4. The image processing method according to claim 3, It is characterized in that The image processing method further comprises: Get the preset encoding-decoding model; Determining a first objective loss function based on the first key point and the second key point; The preset encoding-decoding model is trained using the first target loss function to obtain the preset target encoding-decoding model.
5. The image processing method according to any one of claims 1 to 4, It is characterized in that The step of fusing the third image with the first image to generate a fourth image includes: Obtain the target neural network model; The third image and the first image are fused through the target neural network model to obtain the fourth image output by the target neural network model.
6. The image processing method according to claim 5, It is characterized in that Before fusing the third image with the first image, the image processing method further includes: Obtain the preset neural network model, discriminator network model, image training set and comparison image set; Inputting the image training set into the neural network model to obtain an intermediate image; Inputting the intermediate image and the corresponding contrast image in the contrast image set into the discriminator network model, and performing adversarial training on the preset neural network model; The preset neural network model that has completed the adversarial training is trained through a preset second target loss function to obtain the target neural network model.
7. The image processing method according to claim 2, It is characterized in that After obtaining the fourth image, the image processing method further includes: The fourth image is fused with the first original image through a Poisson fusion algorithm to obtain a processed target image.
8. An image processing device, It is characterized in that include: An acquisition module, configured to acquire a first image and a second image of the same object, wherein the subject in the second image and the first image is the same object, and the definition of the second image is higher than that of the first image; a processing module, configured to obtain a flow matrix, and determine a first key point coordinate set and a second key point coordinate set, wherein the first key point coordinate set includes coordinates of at least one first key point in the first image, and the second key point coordinate set includes coordinates of at least one second key point in the second image; Performing coordinate transformation on the second key point coordinate set through the flow matrix to obtain a third key point coordinate set after position shift, wherein the third key point coordinate set includes coordinates of at least one key point that coincides with the first key point coordinate set; Determine a first offset of the third key point coordinate set relative to the second key point coordinate set; Determine, according to the first offset, second offsets corresponding to the remaining pixel point coordinate sets in the second image by bilinear interpolation; According to the second offset, positionally offset the remaining pixel point coordinate sets in the second image to obtain a third image; wherein the third image is an image aligned with the first image; and The third image and the first image are fused to generate a fourth image, wherein the fourth image has a higher definition than the first image.
9. An electronic device, It is characterized in that The method comprises a processor, a memory, and a program or instruction stored in the memory and executable on the processor, wherein the program or instruction, when executed by the processor, implements the steps of the image processing method as claimed in any one of claims 1 to 7.
