Image processing method, electronic device and computer readable storage medium

By generating an optical flow ring for static images, the static images are converted into videos, which solves the problem of static images not being able to display motion and achieves a higher user experience and smooth dynamic display effect.

CN117853377BActive Publication Date: 2024-09-20HONOR DEVICE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410177507.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-02-08
Publication Date
2024-09-20
Estimated Expiration
2044-02-08

AI Technical Summary

Technical Problem

Static pictures cannot show the dynamic state of the photographed object, resulting in a reduced user appreciation experience.

Method used

By obtaining the optical flow map of the static image, an optical flow ring is generated, and then the static image is converted into a target video, and the static image is dynamically displayed to improve the user experience.

Benefits of technology

It effectively improves the user's appreciation experience of static pictures, makes the dynamic display process smooth, enhances the dynamic display effect, and improves video quality through image quality filtering and video repair.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117853377B
    Figure CN117853377B
Patent Text Reader

Abstract

The present application relates to the field of image processing, and in particular to an image processing method, an electronic device, and a computer-readable storage medium. The method comprises: obtaining a first image to be processed; predicting a first optical flow map corresponding to the first image, wherein the optical flow map is used to represent the displacement of corresponding pixels between two frames of images; generating an optical flow ring according to the first optical flow map, wherein the optical flow ring comprises a group of optical flow maps connected end to end; and generating a target video corresponding to the first image according to the optical flow ring. Through the above method, static images can be displayed dynamically, thereby effectively improving the user's appreciation experience of static images.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of image processing, and in particular to an image processing method, an electronic device, and a computer-readable storage medium. Background Art

[0002] At present, many electronic devices have a camera function. The electronic devices store the captured pictures or videos in the album application, and users can browse the pictures or videos in the album application. For videos, the captured objects can be dynamically displayed, which is conducive to improving the user's appreciation experience, but it occupies a large storage space. For some static pictures, although the storage space they occupy is relatively small, they cannot display the dynamic state of the captured objects, which greatly reduces the user's appreciation experience. Summary of the invention

[0003] The present application provides an image processing method, an electronic device, and a computer-readable storage medium, which can dynamically display static images, thereby effectively improving the user's appreciation experience of static images.

[0004] In order to achieve the above objectives, this application adopts the following technical solutions:

[0005] In a first aspect, an image processing method is provided, the method comprising:

[0006] Acquire a first image to be processed;

[0007] Predicting a first optical flow map corresponding to the first image, wherein the optical flow map is used to represent the displacement of corresponding pixels between two previous and next frames of images;

[0008] generating an optical flow ring according to the first optical flow map, wherein the optical flow ring includes a group of optical flow maps connected end to end;

[0009] A target video corresponding to the first image is generated according to the optical flow ring.

[0010] In the embodiment of the present application, the first image is a static image.

[0011] In the embodiment of the present application, an optical flow map is predicted based on the image, an optical flow ring is generated based on the optical flow map, and then a target video is generated based on the optical flow ring; in the above manner, a static image can be dynamically displayed, thereby effectively improving the user's appreciation experience of static images. Among them, the optical flow ring includes the first connected optical flow map, which is equivalent to representing the cyclic action of the moving object, making the dynamic display process smoother and further improving the dynamic display effect.

[0012] In an implementation of the first aspect, obtaining a first image to be processed includes:

[0013] The first image is determined from the images in the preset gallery according to image quality of the images in the preset gallery.

[0014] In an embodiment of the present application, by selecting a first image from a preset gallery based on image quality, some images of poor quality can be filtered out, thereby reducing the occurrence of poor dynamic display effects due to image quality reasons, which is beneficial to ensuring the display effect of the target video subsequently generated based on the first image.

[0015] In an implementation of the first aspect, determining the first image from the images in the preset gallery according to image quality of the images in the preset gallery includes:

[0016] Detecting whether the image quality of the image in the preset gallery meets a first preset condition according to image parameters, wherein the image parameters include at least two of the following: image source, the number of words contained in the image, the blur degree of the image, and the quality score corresponding to the image;

[0017] An image in the preset image library whose image quality meets a first preset condition is determined as the first image.

[0018] The image source is used to indicate the way the image is obtained, such as screenshot, download from a webpage, or shooting by an electronic device. In some implementations, the images in the preset gallery record information about the image source, and the information used to record the image source of the images in the preset gallery can be obtained to determine the image source of the image.

[0019] The number of words contained in the image can be obtained by performing image recognition processing on the image. In some implementations, optical character recognition (OCR) processing can be performed on the images in the preset gallery to identify the words in the image, and then the number of recognized words is counted. It should be noted that in the embodiments of the present application, the method of OCR processing is not specifically limited.

[0020] The blur degree of an image is an important factor in image degradation. During the image acquisition, transmission and processing, there are possible factors that may cause image blur. For example, when shooting an image, incorrect focusing will produce out-of-focus blur; the relative movement of the scene and the camera may cause motion blur; and high frame loss during image compression will also cause image blur. In some implementations, the second-order guide map of the image in the preset gallery can be calculated to obtain the edge information of the image; then the variance of the second-order guide map is calculated; and the blur degree of the image is determined according to the variance of the calculated second-order guide map. In other implementations, the Laplace template can be used to calculate the sum of the Laplace gradient values ​​of all pixels in the image, and the blur degree of the image is determined based on the Laplace gradient value. It should be noted that the embodiment of the present application does not specifically limit the method for calculating the blur degree of the image. In addition, out-of-focus blur, motion blur or edge blur can be calculated according to the needs of actual applications.

[0021] It is understandable that the blur degree of an image and the clarity of an image are two related indicators, that is, the higher the blur degree, the lower the clarity of the image. Therefore, in the embodiment of the present application, the image parameter may also include the clarity of the image.

[0022] The quality score corresponding to the image is used to evaluate the quality of the image (such as the degree of image distortion, etc.). In some implementations, a scoring model for image quality can be trained; the images in the preset gallery are input into the trained scoring model, and the quality score of the image is output. It should be noted that the scoring model can be a neural network or an algorithm model that can realize the image scoring function. The embodiment of the present application does not specifically limit the structure of the scoring model.

[0023] In the embodiment of the present application, each image parameter has a corresponding preset condition. Exemplarily, for the image source, if the image source of image P in the preset gallery is taken by an electronic device, it is determined that image P meets the preset condition corresponding to the image source. For the number of words contained in the image, if the number of words contained in image P in the preset gallery is less than a first threshold, it is determined that image P meets the preset condition corresponding to the image parameter of the number of words contained in the image. For the blurriness of the image, if the blurriness of image P is less than a second threshold, it is determined that image P meets the preset condition corresponding to the image parameter of blurriness. If the quality score of image P is greater than a third threshold, it is determined that image P meets the preset condition corresponding to the image parameter of quality score.

[0024] In an implementation of the first aspect, the third image is any image in the preset gallery;

[0025] The step of detecting whether the image quality of the third image meets the first preset condition according to the image parameters comprises:

[0026] If the image source of the third image indicates that the third image is taken by an electronic device, the number of characters contained in the third image is less than a first threshold, the blurriness of the third image is less than a second threshold, and the quality score corresponding to the third image is greater than a third threshold, then it is determined that the image quality of the third image meets the first preset condition.

[0027] In an embodiment of the present application, evaluating images in a preset gallery based on a variety of image parameters can more accurately reflect the quality of the images in the preset gallery, reduce image quality evaluation errors caused by inaccurate calculation of a certain image parameter, and help ensure the display effect of the target video subsequently generated based on the first image.

[0028] In an implementation of the first aspect, predicting a first optical flow map corresponding to the first image includes:

[0029] A first optical flow map corresponding to the first image is predicted according to a preset optical flow generator.

[0030] In some implementations, the optical flow generator can be a generator in a trained GAN network.

[0031] In some training methods, paired images can be used to train the GAN network. The paired images include a sample image (such as an RGB image) and its corresponding real optical flow map. Exemplarily, the GAN network may include a generator and a discriminator. The generator is used to generate an optical flow map, and the discriminator is used to identify the authenticity of the optical flow map generated by the generator. The training goal of the GAN network is to make the generator generate an optical flow map as close to the real one as possible, and the discriminator recognize the predicted optical flow map as much as possible. Specifically, the sample image is input into the generator, and the predicted optical flow map is output; the discriminator calculates the loss value based on the predicted optical flow map and the real optical flow map corresponding to the sample image; if the loss value is greater than the preset threshold, the parameters of the generator and the discriminator are adjusted according to the loss value, and the training continues; if the loss value is less than the preset threshold, the training ends, and the current generator is used as the trained optical flow generator.

[0032] In other training methods, unpaired images can be used to train the GAN network. The unpaired images come from different sample data sets, one sample data set includes images, and the other sample data set includes optical flow maps. Exemplarily, the GAN network may include two generators and two discriminators. The generator G1 is used to generate an optical flow map y' from the image x in the sample data set Nx, and the generator G2 is used to generate an image x' from the optical flow map y in the sample data set Ny. The discriminator D1 is used to identify whether the input image is a real image (an image in the sample data set Nx) or a generated image, and the discriminator D2 is used to identify whether the input image is a real optical flow map (an image in the sample data set Ny) or a generated optical flow map. Specifically, the image x in the sample data set Nx is input into the generator G1, and the predicted optical flow map y' is output; the predicted optical flow map y' and the optical flow map y in the sample data set Nx are input into the discriminator D1, and the loss value loss1 is output; the optical flow map y in the sample data set Ny is input into the generator G2, and the predicted image x' is output; the predicted image x' and the image x in the sample data set Nx are input into the discriminator D2, and the loss value loss2 is output; the predicted optical flow map y' is input into the generator G2, and the predicted image x'' is output; the loss value loss3 is calculated according to the predicted image x'' and the image x; the total loss value is calculated according to the loss value loss1, the loss value loss2 and the loss value loss3; if the total loss value is greater than the preset threshold, the network parameters of the GAN network (including the parameters of the generator G1, the generator G2, the discriminator D1 and the discriminator D2) are adjusted according to the total loss value, and the training is continued until the total loss value is less than the preset threshold; if the total loss value is less than the preset threshold, the generator G1 in the current GAN network is determined as the optical flow generator.

[0033] In the embodiment of the present application, using a preset optical flow generator to predict the optical flow map can not only improve the prediction accuracy, but also improve the prediction efficiency.

[0034] In an implementation of the first aspect, predicting a first optical flow map corresponding to the first image according to a preset optical flow generator includes:

[0035] estimating depth information corresponding to the first image;

[0036] The depth information and the first image are input into the optical flow generator, and the first optical flow map is output.

[0037] The above method is equivalent to using the depth information of the image to assist in predicting the optical flow map, which can better reflect the distance relationship of objects in the image and make the edges of moving objects in the predicted optical flow map clearer, which is conducive to improving the display effect of the subsequently generated target video.

[0038] In some other implementations, predicting the first optical flow map corresponding to the first image according to a preset optical flow generator may include: performing semantic segmentation processing on the first image to segment a target object from the first image; inputting a local image of the target object and the first image into the optical flow generator, and outputting the first optical flow map corresponding to the first image, wherein the target object is a moving object.

[0039] Through the above method, it is equivalent to segmenting the moving object, and assisting in predicting the optical flow map based on the moving object, so that the edges of the moving objects in the predicted optical flow map are clearer, which is conducive to improving the display effect of the subsequently generated target video.

[0040] In an implementation of the first aspect, generating an optical flow ring according to the first optical flow map includes:

[0041] Obtaining a first optical flow value corresponding to the first optical flow map;

[0042] Performing interpolation processing according to the first optical flow value to obtain at least one second optical flow value which is smaller than the first optical flow value;

[0043] Generate a second optical flow map corresponding to each of the second optical flow values;

[0044] The optical flow ring is generated according to the first optical flow map and the second optical flow map.

[0045] In the embodiment of the present application, the optical flow generator may generate a first optical flow value corresponding to the first optical flow map, and may also calculate the first optical flow value according to the displacement of each pixel in the first optical flow map.

[0046] Among them, the interpolation processing method can be: according to the number of second optical flow values, the first optical flow value is evenly interpolated. Exemplarily, if a second optical flow value needs to be inserted, the second optical flow value O2 is O1 / 2, where O1 is the first optical flow value. If two second optical flow values ​​need to be inserted, the two second optical flow values ​​O2 are O1 / 3 and 2O1 / 3 respectively. By means of equal interpolation, the displacement of the moving object is made more uniform, so that the movement of the moving object in the generated target video is smoother.

[0047] Of course, the first optical flow values ​​may also be unequally interpolated according to the number of the second optical flow values, which is not specifically limited in the embodiment of the present application.

[0048] In another implementation, a plurality of first optical flow maps may be generated by an optical flow generator; interpolation may be performed based on the first optical flow value of each first optical flow map to obtain at least one second optical flow map generated based on each first optical flow map; an optical flow ring may be generated based on the plurality of first optical flow maps and at least one second optical flow map generated based on each first optical flow map. Each first optical flow map corresponds to a possible motion posture (motion direction and motion displacement) of a moving object.

[0049] Through the above implementation method, multiple first optical flow maps are added to the optical flow ring, which is equivalent to adding multiple possible motion postures of the moving object; interpolation is performed according to the multiple first optical flow maps to obtain a second optical flow map between two adjacent first optical flow maps, which is equivalent to adding multiple positions between the two motion postures of the moving object, making the displacement of the moving object more uniform, thereby making the movement of the moving object in the generated target video smoother.

[0050] In an implementation manner of the first aspect, generating a target video corresponding to the first image according to the optical flow ring includes:

[0051] Generate a fourth image corresponding to each optical flow map in the optical flow ring;

[0052] The target video is generated according to the combination of the first image and the fourth image.

[0053] In the embodiment of the present application, affine transformation processing (warp) may be performed on each optical flow map in the optical flow ring to obtain a fourth image corresponding to each optical flow map.

[0054] In an embodiment of the present application, since the optical flow ring can represent the cyclic motion of the moving object, the target video generated by combining the fourth image generated according to each optical flow map in the optical flow ring and the first image can dynamically display the cyclic motion of the moving object in the first image, thereby achieving a better dynamic display effect.

[0055] In the embodiment of the present application, the target video is generated by arranging the first image and the fourth image corresponding to the optical flow map in the order of the optical flow map in the optical flow ring to obtain the target video. In the target video, the first image is the first frame and the last frame of the target video.

[0056] In an implementation of the first aspect, the method further includes:

[0057] Perform video restoration processing on the target video to obtain the processed target video.

[0058] In some implementations, the fourth image can be input into the trained modification model, and the processed fourth image can be output. The repair model can be a neural network, such as a GAN network. Exemplarily, the repair model can implement video repair based on the filling method of video erasure. Specifically, during the training process, part of the image in the sample video can be randomly masked, and the masked sample video can be input into the repair model to output the repaired video; the loss value is calculated based on the sample video and the repaired video; if the loss value is greater than a preset threshold, the model parameters of the repair model are adjusted according to the loss value, and the training is continued until the loss value is less than the preset threshold; if the loss value is less than the preset threshold, the current repair model is determined as the trained repair model.

[0059] In another implementation, the fourth image can be input into the trained diffusion model to output the processed fourth image. Exemplarily, during the training process, the resolution of the sample video is enlarged, and then the diffusion model is used to fill in the enlarged video to obtain a filled video; the loss value is calculated based on the filled video and the sample video; if the loss value is greater than a preset threshold, the model parameters of the diffusion model are adjusted according to the loss value, and the training is continued until the loss value is less than the preset threshold; if the loss value is less than the preset threshold, the current diffusion model is determined as the trained diffusion model.

[0060] It should be noted that in the embodiments of the present application, there is no specific limitation on the method of video repair.

[0061] By repairing the target video, the "holes" in the image that appear after the optical flow map warp are repaired, making the repaired video richer and more natural, which is conducive to improving the viewing effect of the target video.

[0062] In an implementation of the first aspect, the method further includes:

[0063] If the video quality of the target video meets the second preset condition, displaying the target video;

[0064] If the video quality of the target video does not meet the second preset condition, the first image is displayed.

[0065] In the embodiment of the present application, whether to display the first image in a dynamic manner is determined according to the video quality of the target video. When the video quality of the target video generated according to the first image is low, the first image is still displayed in a static manner, which can effectively reduce the impact of low-quality video on the viewing effect and help improve user experience.

[0066] In an implementation of the first aspect, the method further includes:

[0067] Whether the target video satisfies the second preset condition is detected according to video parameters, wherein the video parameters include at least two of the following: continuity of adjacent frames, a quality score of the video, and a quality score of each image frame.

[0068] One way to calculate the continuity of adjacent frames is to calculate the average value of the optical flows between adjacent frames, and determine the continuity of adjacent frames based on the average value.

[0069] The quality score of a video is used to evaluate the quality of the video. In some implementations, a video quality scoring model can be trained; the target video is input into the trained scoring model, and the quality score of the target video is output. It should be noted that the scoring model can be a neural network or an algorithm model that can implement the video scoring function. The embodiment of the present application does not specifically limit the structure of the scoring model.

[0070] In the embodiment of the present application, each video parameter has its corresponding preset condition. Exemplarily, for the continuity of adjacent frames, if the continuity of adjacent frames is less than the fourth threshold, it is determined that the target video satisfies the preset condition corresponding to the continuity of adjacent frames. For the quality score of the video, if the quality score of the target video is greater than the fifth threshold, it is determined that the target video satisfies the preset condition corresponding to the video parameter of the quality score of the video. For the quality score of each image frame, if the quality score of each image frame in the target video is greater than the sixth threshold, it is determined that the target video satisfies the preset condition corresponding to the image parameter of the quality score of each image frame.

[0071] In an implementation of the first aspect, the detecting, according to the video parameter, whether the target video satisfies the second preset condition includes:

[0072] If the continuity of adjacent frames of the target video is less than a fourth threshold, the quality score of the target video is greater than a fifth threshold, and the quality score of each image frame in the target video is greater than a sixth threshold, it is determined that the target video meets the second preset condition.

[0073] In the embodiment of the present application, evaluating the video quality of the target video based on multiple video parameters can more accurately reflect the quality of the generated target video, reduce the video quality evaluation error caused by inaccurate calculation of a certain video parameter, and help ensure the dynamic display effect of the image.

[0074] In a second aspect, an electronic device is provided, the electronic device comprising: one or more processors, and a memory;

[0075] The memory is coupled to the one or more processors, and the memory is used to store computer program code, wherein the computer program code includes computer instructions, and the one or more processors call the computer instructions to enable the electronic device to perform the method as described in any one of the first aspects.

[0076] According to a third aspect, a chip system is provided, which is applied to an electronic device, and the chip system includes one or more processors, and the one or more processors are used to call computer instructions so that the electronic device executes a method as described in any one of the first aspects.

[0077] According to a fourth aspect, a computer-readable storage medium is provided, wherein the computer-readable storage medium includes instructions, and when the instructions are executed on an electronic device, the electronic device executes the method as described in any one of the first aspects. BRIEF DESCRIPTION OF THE DRAWINGS

[0078] Figure 1 It is a structural schematic diagram of an electronic device provided in an embodiment of the present application;

[0079] Figure 2 is a flowchart of an image processing method provided in an embodiment of the present application;

[0080] Figure 3 is a schematic diagram of the GAN network training process provided in an embodiment of the present application;

[0081] Figure 4 is a schematic diagram of the GAN network training process provided in an embodiment of the present application;

[0082] Figure 5 is a schematic diagram of an optical flow map generation process provided by an embodiment of the present application;

[0083] Figure 6 is a schematic diagram of an optical flow ring provided in an embodiment of the present application;

[0084] Figure 7 is a schematic diagram of an optical flow ring provided in an embodiment of the present application;

[0085] Figure 8 is a schematic diagram of an optical flow ring provided in an embodiment of the present application;

[0086] Fig. 9 is a schematic diagram of an image processing flow provided in an embodiment of the present application;

[0087] Fig.10 is a schematic diagram of the interface of the photo album application provided in the embodiment of the present application;

[0088] Fig.11 is a schematic diagram of a scene for dynamic display of images provided in an embodiment of the present application;

[0089] Fig.12 This is a schematic diagram of a scene for dynamic display of images provided in another embodiment of the present application. DETAILED DESCRIPTION

[0090] In the following description, specific details such as specific system structures and technologies are provided for illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application can also be implemented in other embodiments without these specific details.

[0091] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, wholes, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or combinations thereof.

[0092] It should also be understood that in the embodiments of the present application, "one or more" refers to one, two or more than two; "and / or" describes the association relationship of associated objects, indicating that three relationships may exist; for example, A and / or B may represent: A exists alone, A and B exist at the same time, and B exists alone, where A and B may be singular or plural. The character " / " generally indicates that the associated objects before and after are in an "or" relationship.

[0093] In addition, in the description of the present application specification and the appended claims, the terms "first", "second", "third", "fourth", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance.

[0094] References to "one embodiment" or "some embodiments" etc. described in the specification of this application mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Therefore, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.

[0095] At present, many electronic devices have a camera function. The electronic devices store the captured pictures or videos in the album application, and users can browse the pictures or videos in the album application. For videos, the captured objects can be dynamically displayed, which is conducive to improving the user's appreciation experience, but it occupies a large storage space. For some static pictures, although the storage space they occupy is relatively small, they cannot display the dynamic state of the captured objects, which greatly reduces the user's appreciation experience.

[0096] Based on this, the embodiment of the present application provides an image processing method. In the embodiment of the present application, a static image can be displayed dynamically, thereby effectively improving the user's appreciation experience of the static image.

[0097] The image processing method provided in the embodiment of the present application can be applied to an electronic device with a display function. The electronic device includes a terminal device, which can also be called a terminal, a user equipment (UE), a mobile station (MS), a mobile terminal (MT), etc. The terminal device can be a mobile phone, a smart TV, a wearable device, a tablet computer (Pad), a smart screen, a computer with a wireless transceiver function, a virtual reality (VR) terminal device, an augmented reality (AR) terminal device, a wireless terminal in industrial control, a wireless terminal in self-driving, a wireless terminal in remote medical surgery, a wireless terminal in smart grid, a wireless terminal in transportation safety, a wireless terminal in smart city, a wireless terminal in smart home, etc. The embodiment of the present application does not limit the specific technology and specific device form adopted by the electronic device.

[0098] See also Figure 1, is a structural diagram of an electronic device provided in an embodiment of the present application. The electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, a sensor module 180, a button 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc. The sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a touch sensor 180K, an ambient light sensor 180L, and the like.

[0099] It is to be understood that the structure illustrated in the embodiment of the present application does not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may include more or fewer components than shown in the figure, or combine some components, or split some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.

[0100] The processor 110 may include one or more processing units, for example, the processor 110 may include an application processor (application processor, AP), a modem processor, a graphics processor (graphics processing unit, GPU), an image signal processor (image signal processor, ISP), a controller, a memory, a video codec, a digital signal processor (digital signal processor, DSP), a baseband processor, and / or a neural network processor (neural-network processing unit, NPU), etc. Among them, different processing units may be independent devices or integrated into one or more processors. For example, the processor 110 is used to execute the image processing method in the embodiment of the present application.

[0101] The controller may be the nerve center and command center of the electronic device 100. The controller may generate an operation control signal according to the instruction operation code and the timing signal to complete the control of fetching and executing instructions.

[0102] The processor 110 may also be provided with a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. The memory may store instructions or data that the processor 110 has just used or cyclically used. If the processor 110 needs to use the instruction or data again, it may be directly called from the memory. This avoids repeated access, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.

[0103] The external memory 120 generally refers to an external memory. In the embodiment of the present application, the external memory refers to a memory other than the memory of the electronic device and the cache of the processor, and the memory is generally a non-volatile memory.

[0104] The internal memory 121, which may also be referred to as "memory", may be used to store computer executable program codes, which include instructions. The internal memory 121 may include a program storage area and a data storage area. The program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), and the like.

[0105] The display screen 194 is used to display images, videos, etc. The display screen 194 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode or an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), Miniled, MicroLed, Micro-OLED, a quantum dot light-emitting diode (QLED), etc. In some embodiments, the electronic device 100 may include 1 or N display screens 194, where N is a positive integer greater than 1. In some embodiments, the electronic device 100 displays a user interface through the display screen 194.

[0106] The electronic device 100 implements the display function through a GPU, a display screen 194, and an application processor. The GPU is a microprocessor for image processing, which connects the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 110 may include one or more GPUs that execute program instructions to generate or change display information.

[0107] The electronic device 100 can realize the shooting function through ISP, camera 193, video codec, GPU, display screen 194 and application processor.

[0108] The camera 193 is used to capture still images or videos. The object generates an optical image through the lens and projects it onto the photosensitive element. The photosensitive element can be a charge coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The photosensitive element converts the light signal into an electrical signal, and then passes the electrical signal to the ISP to be converted into a digital image signal. The ISP outputs the digital image signal to the DSP for processing. The DSP converts the digital image signal into an image signal in a standard RGB, YUV or other format. In some embodiments, the electronic device 100 may include 1 or N cameras 193, where N is a positive integer greater than 1. Exemplarily, the camera 193 is used to capture an image of a user looking at the display screen 194.

[0109] The electronic device 100 also includes various sensors that can convert various physical signals into electrical signals. Exemplarily, the pressure sensor 180A is used to sense the pressure signal and can convert the pressure signal into an electrical signal. The gyroscope sensor 180B can be used to determine the motion posture of the electronic device 100. The air pressure sensor 180C is used to measure the air pressure. The magnetic sensor 180D includes a Hall sensor. The acceleration sensor 180E can detect the magnitude of the acceleration of the electronic device 100 in various directions (generally three axes). The distance sensor 180F is used to measure the distance. The electronic device 100 can measure the distance by infrared or laser. The proximity light sensor 180G may include, for example, a light emitting diode (LED) and a light detector, such as a photodiode. The ambient light sensor 180L is used to sense the brightness of the ambient light. The electronic device 100 can adaptively adjust the brightness of the display screen 194 according to the perceived ambient light brightness. The fingerprint sensor 180H is used to collect fingerprints. The electronic device 100 can use the collected fingerprint characteristics to realize fingerprint unlocking, access application locks, fingerprint photography, fingerprint answering calls, etc. The temperature sensor 180J is used to detect the temperature. In some embodiments, the electronic device 100 uses the temperature detected by the temperature sensor 180J to execute a temperature processing strategy. The bone conduction sensor 180M can obtain a vibration signal.

[0110] The touch sensor 180K is also called a "touch panel". The touch sensor 180K can be set on the display screen 194, and the touch sensor 180K and the display screen 194 form a touch screen, also called a "touch screen". The touch sensor 180K is used to detect touch operations acting on or near it. The touch sensor can pass the detected touch operation to the application processor to determine the type of touch event. Visual output related to the touch operation can be provided through the display screen 194. In other embodiments, the touch sensor 180K can also be set on the surface of the electronic device 100, which is different from the position of the display screen 194.

[0111] Exemplarily, in an embodiment of the present application, the touch sensor 180K can detect a user's click operation on an application icon, and transmit the detected click operation to the application processor, determine that the click operation is used to start or run the application, and then execute the running operation of the application.

[0112] The wireless communication function of the electronic device 100 can be implemented through the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modem processor and the baseband processor.

[0113] The electronic device 100 can implement audio functions such as music playing and recording through the audio module 170, the speaker 170A, the receiver 170B, the microphone 170C, the headphone jack 170D, and the application processor.

[0114] The above is a specific description of the embodiment of the present application using the electronic device 100 as an example. It should be understood that the structure illustrated in the embodiment of the present application does not constitute a specific limitation on the electronic device 100. The electronic device 100 may have more or fewer components than those shown in the figure, may combine two or more components, or may have different component configurations. The various components shown in the figure may be implemented in hardware, software, or a combination of hardware and software including one or more signal processing and / or application specific integrated circuits.

[0115] The following describes the image processing method provided by the embodiments of the present application.

[0116] See also Figure 2 , is a flowchart of the image processing method provided in the embodiment of the present application. As an example and not a limitation, Figure 2 As shown, the image processing method may include the following steps:

[0117] S201, obtaining a first image to be processed.

[0118] In the embodiment of the present application, the first image is a static image.

[0119] In some application scenarios, the electronic device may be a mobile phone. Accordingly, a static image may be obtained from an album application (or gallery application) of the mobile phone as the first image to be processed.

[0120] In some embodiments, step S201 may include: selecting a first image from a preset gallery. Specifically, the image format of the material in the preset gallery may be determined; and the first image may be selected according to the image format. Exemplarily, if the image format of material A in the preset gallery is bmp, png, or jpg, etc., it indicates that material A is a static image; if the image format of material A is mp4, avi, or 3gp, etc., it indicates that material A is a video.

[0121] In the embodiment of the present application, the preset gallery is used to store and / or display images. For example, for a mobile phone, the preset gallery may be a photo album application (or gallery application) in the mobile phone. For another example, the preset gallery may be a third-party database for storing images. The mobile phone acquires images from the preset gallery by communicating with the preset gallery, and displays the acquired images on the display screen of the mobile phone.

[0122] In some embodiments, step S201 may include: determining the first image from the images in the preset gallery according to image quality of the images in the preset gallery.

[0123] In an embodiment of the present application, by selecting a first image from a preset gallery based on image quality, some images of poor quality can be filtered out, thereby reducing the occurrence of poor dynamic display effects due to image quality reasons, which is beneficial to ensuring the display effect of the target video subsequently generated based on the first image.

[0124] In some embodiments, the step of screening the first image according to image quality may include:

[0125] According to the image parameters, it is detected whether the image quality of the images in the preset gallery meets the first preset condition; and the images in the preset gallery whose image quality meets the first preset condition are determined as the first images.

[0126] In the embodiment of the present application, the image parameters include at least one of the following: the source of the image, the amount of text contained in the image, the blurriness of the image, and the quality score corresponding to the image.

[0127] The image source is used to indicate the way the image is obtained, such as screenshot, download from a webpage, or shooting by an electronic device. In some implementations, the images in the preset gallery record information about the image source, and the information used to record the image source of the images in the preset gallery can be obtained to determine the image source of the image.

[0128] The number of words contained in the image can be obtained by performing image recognition processing on the image. In some implementations, optical character recognition (OCR) processing can be performed on the images in the preset gallery to identify the words in the image, and then the number of recognized words is counted. It should be noted that in the embodiments of the present application, the method of OCR processing is not specifically limited.

[0129] The blur degree of an image is an important factor in image degradation. During the image acquisition, transmission and processing, there are possible factors that may cause image blur. For example, when shooting an image, incorrect focusing will produce out-of-focus blur; the relative movement of the scene and the camera may cause motion blur; and high frame loss during image compression will also cause image blur. In some implementations, the second-order guide map of the image in the preset gallery can be calculated to obtain the edge information of the image; then the variance of the second-order guide map is calculated; and the blur degree of the image is determined according to the variance of the calculated second-order guide map. In other implementations, the Laplace template can be used to calculate the sum of the Laplace gradient values ​​of all pixels in the image, and the blur degree of the image is determined based on the Laplace gradient value. It should be noted that the embodiment of the present application does not specifically limit the method for calculating the blur degree of the image. In addition, out-of-focus blur, motion blur or edge blur can be calculated according to the needs of actual applications.

[0130] It is understandable that the blur degree of an image and the clarity of an image are two related indicators, that is, the higher the blur degree, the lower the clarity of the image. Therefore, in the embodiment of the present application, the image parameter may also include the clarity of the image.

[0131] The quality score corresponding to the image is used to evaluate the quality of the image (such as the degree of image distortion, etc.). In some implementations, a scoring model for image quality can be trained; the images in the preset gallery are input into the trained scoring model, and the quality score of the image is output. It should be noted that the scoring model can be a neural network or an algorithm model that can realize the image scoring function. The embodiment of the present application does not specifically limit the structure of the scoring model.

[0132] In the embodiment of the present application, each image parameter has a corresponding preset condition. Exemplarily, for the image source, if the image source of image P in the preset gallery is taken by an electronic device, it is determined that image P meets the preset condition corresponding to the image source. For the number of words contained in the image, if the number of words contained in image P in the preset gallery is less than a first threshold, it is determined that image P meets the preset condition corresponding to the image parameter of the number of words contained in the image. For the blurriness of the image, if the blurriness of image P is less than a second threshold, it is determined that image P meets the preset condition corresponding to the image parameter of blurriness. If the quality score of image P is greater than a third threshold, it is determined that image P meets the preset condition corresponding to the image parameter of quality score.

[0133] As an implementation, if only one image parameter is used, detecting whether the image quality of the images in the preset gallery meets the first preset condition according to the image parameter may include: determining whether the third image meets the preset condition corresponding to the adopted image parameter; if the third image meets the preset condition corresponding to the adopted image parameter, determining that the third image meets the first preset condition. The third image is any image in the preset gallery.

[0134] As another implementation, if multiple image parameters are used, then detecting whether the image quality of the images in the preset gallery meets the first preset condition based on the image parameters may include: respectively determining whether the third image meets the preset condition corresponding to each image parameter; if the third image meets the preset condition corresponding to each image parameter, then determining that the third image meets the first preset condition. Exemplarily, if the image parameters used include the image source, the number of words contained in the image, the blurriness of the image, and the quality score corresponding to the image, then detecting whether the image quality of the images in the preset gallery meets the first preset condition based on the image parameters may include: if the image source of the third image indicates that the third image is an image taken by an electronic device, the number of words contained in the third image is less than a first threshold, the blurriness of the third image is less than a second threshold, and the quality score corresponding to the third image is greater than a third threshold, then determining that the image quality of the third image meets the first preset condition.

[0135] In an embodiment of the present application, evaluating images in a preset gallery based on a variety of image parameters can more accurately reflect the quality of the images in the preset gallery, reduce image quality evaluation errors caused by inaccurate calculation of a certain image parameter, and help ensure the display effect of the target video subsequently generated based on the first image.

[0136] S202: Predict a first optical flow map corresponding to the first image.

[0137] In the embodiment of the present application, the optical flow map is used to represent the displacement of corresponding pixels between two previous and next frames of images.

[0138] In some embodiments, step S202 may include: predicting a first optical flow map corresponding to the first image according to a preset optical flow generator.

[0139] In the embodiment of the present application, the optical flow generator may be a neural network. In some implementations, the optical flow generator may be a generator in a trained GAN network.

[0140] In some training methods, paired images can be used to train the GAN network, where the paired images include a sample image (such as an RGB image) and its corresponding real optical flow map.

[0141] For example, see Figure 3 , is a schematic diagram of the GAN network training process provided in the embodiment of the present application. As an example and not a limitation, Figure 3 As shown, the GAN network can include a generator and a discriminator. The generator is used to generate an optical flow map, and the discriminator is used to identify the authenticity of the optical flow map generated by the generator. The training goal of the GAN network is to make the generator generate an optical flow map as close to the real one as possible, and the discriminator recognizes the predicted optical flow map as much as possible.

[0142] Specifically, the sample image is input into the generator and the predicted optical flow map is output; the discriminator calculates the loss value based on the predicted optical flow map and the real optical flow map corresponding to the sample image; if the loss value is greater than the preset threshold, the parameters of the generator and the discriminator are adjusted according to the loss value, and training continues; if the loss value is less than the preset threshold, the training ends and the current generator is used as the trained optical flow generator.

[0143] In other training methods, unpaired images can be used to train the GAN network, where the unpaired images come from different sample data sets, one sample data set includes images, and the other sample data set includes optical flow maps.

[0144] For example, see Figure 4 , is a schematic diagram of the GAN network training process provided in the embodiment of the present application. As an example and not a limitation, Figure 4 As shown, the GAN network can include two generators and two discriminators. Among them, the generator G1 is used to generate an optical flow map y' from the image x in the sample data set Nx, and the generator G2 is used to generate an image x' from the optical flow map y in the sample data set Ny. The discriminator D1 is used to identify whether the input image is a real image (the image in the sample data set Nx) or a generated image, and the discriminator D2 is used to identify whether the input image is a real optical flow map (the image in the sample data set Ny) or a generated optical flow map.

[0145] Specifically, the image x in the sample data set Nx is input into the generator G1, and the predicted optical flow map y' is output; the predicted optical flow map y' and the optical flow map y in the sample data set Nx are input into the discriminator D1, and the loss value loss1 is output; the optical flow map y in the sample data set Ny is input into the generator G2, and the predicted image x' is output; the predicted image x' and the image x in the sample data set Nx are input into the discriminator D2, and the loss value loss2 is output; the predicted optical flow map y' is input into the generator G2, and the predicted image x'' is output; the loss value loss3 is calculated according to the predicted image x'' and the image x; the total loss value is calculated according to the loss value loss1, the loss value loss2 and the loss value loss3; if the total loss value is greater than the preset threshold, the network parameters of the GAN network (including the parameters of the generator G1, the generator G2, the discriminator D1 and the discriminator D2) are adjusted according to the total loss value, and the training is continued until the total loss value is less than the preset threshold; if the total loss value is less than the preset threshold, the generator G1 in the current GAN network is determined as the optical flow generator.

[0146] Of course, the predicted image x' may also be input into the generator G1, and the predicted optical flow map y'' may be output; and the loss value loss3 may be calculated based on the predicted optical flow map y'' and the optical flow map y.

[0147] It should be noted that the optical flow generator may also be an algorithm model that can generate an optical flow map based on an image, and the embodiments of the present application do not specifically limit the optical flow generator.

[0148] In some implementations, the step of predicting the first optical flow map corresponding to the first image according to a preset optical flow generator may include: inputting the first image into the optical flow generator, and outputting the first optical flow map corresponding to the first image.

[0149] In some other implementations, predicting the first optical flow map corresponding to the first image according to a preset optical flow generator may include: estimating depth information corresponding to the first image; inputting the depth information and the first image into the optical flow generator, and outputting the first optical flow map corresponding to the first image.

[0150] For example, see Figure 5 , is a schematic diagram of the optical flow map generation process provided in the embodiment of the present application. As an example and not a limitation, Figure 5 As shown, the output end of the depth estimator is connected to the input end of the optical flow generator. The first image is input into the depth estimator, and the depth information corresponding to the first image is output; the depth information corresponding to the first image and the first image are input into the optical flow generator, and the first optical flow map corresponding to the first image is output.

[0151] The depth estimator can be a trained neural network. During the training process, a sample image and its corresponding actual depth information are obtained; the sample image is input into the depth estimator to obtain estimated depth information (the distance between the pixel in the image and the camera); a loss value is calculated based on the actual depth information and estimated depth information corresponding to the sample image; if the calculated loss value is greater than a preset threshold, the parameters of the depth estimator are adjusted based on the calculated loss value, and training is continued until the loss value is less than or equal to the preset threshold; if the calculated loss value is less than or equal to the preset threshold, the current depth estimator is determined as the trained depth estimator.

[0152] It should be noted that the depth estimator may also be an algorithm model that can estimate the depth value of an image. The embodiment of the present application does not specifically limit the depth estimator.

[0153] The above method is equivalent to using the depth information of the image to assist in predicting the optical flow map, which can better reflect the distance relationship of objects in the image and make the edges of moving objects in the predicted optical flow map clearer, which is conducive to improving the display effect of the subsequently generated target video.

[0154] In some other implementations, predicting the first optical flow map corresponding to the first image according to a preset optical flow generator may include: performing semantic segmentation processing on the first image to segment a target object from the first image; inputting a local image of the target object and the first image into the optical flow generator, and outputting the first optical flow map corresponding to the first image, wherein the target object is a moving object.

[0155] Through the above method, it is equivalent to segmenting the moving object, and assisting in predicting the optical flow map based on the moving object, so that the edges of the moving objects in the predicted optical flow map are clearer, which is conducive to improving the display effect of the subsequently generated target video.

[0156] In some application scenarios, it is not possible to accurately identify the depth information of an image, or it is not possible to accurately segment a moving object from an image. In order to improve the prediction effect of the optical flow map, it is understandable that in some implementations, the depth information of the image and the segmented moving objects can be comprehensively considered. Specifically, the first image is input into a depth estimator, and the depth information of the first image is output; semantic segmentation is performed on the first image, and the target object is segmented from the first image; the depth information of the first image, the local image of the target object, and the first image are input into an optical flow generator, and a first optical flow map corresponding to the first image is output.

[0157] It should be noted that, in addition to the depth information of the first image and the local image of the moving object in the first image, other information may be added to assist the optical flow generator in predicting the optical flow map, and the embodiments of the present application do not specifically limit this.

[0158] S203: Generate an optical flow ring according to the first optical flow map.

[0159] In the embodiment of the present application, the optical flow ring includes a group of optical flow graphs connected end to end. In other words, the optical flow ring can represent the displacement of pixels between two adjacent frames of images of the moving object during the cyclic action.

[0160] In one implementation, step S203 may include: generating an optical flow ring according to the optical flow map when the optical flow value is 0 and the first optical flow map. In the starting frame where the moving object starts to move, the corresponding optical flow value is 0.

[0161] For example, see Figure 6 , is a schematic diagram of the optical flow ring provided in the embodiment of the present application. Figure 6 The optical flow ring corresponding to the first image 60 is shown. The first frame 61 in the optical flow ring is an optical flow graph when the optical flow value is 0, the second frame 62 in the optical flow ring is the first optical flow graph, and the third frame 64 in the optical flow ring is an optical flow graph when the optical flow value is 0. Figure 6 The optical flow ring shown is equivalent to the moving object in the image moving from the starting position to the position corresponding to the first optical flow map, and then moving from the position corresponding to the first optical flow map back to the starting position. It can be seen that Figure 6 The optical flow ring shown represents the cyclical motion process of the moving object.

[0162] In another implementation, step S203 may include: obtaining a first optical flow value corresponding to a first optical flow map; performing interpolation processing based on the first optical flow value to obtain at least one second optical flow value that is smaller than the first optical flow value; generating a second optical flow map corresponding to each second optical flow value; and generating an optical flow ring based on the first optical flow map and the second optical flow map.

[0163] In the embodiment of the present application, the optical flow generator may generate a first optical flow value corresponding to the first optical flow map, and may also calculate the first optical flow value according to the displacement of each pixel in the first optical flow map.

[0164] Among them, the interpolation processing method can be: according to the number of second optical flow values, the first optical flow value is evenly interpolated. Exemplarily, if a second optical flow value needs to be inserted, the second optical flow value O2 is O1 / 2, where O1 is the first optical flow value. If two second optical flow values ​​need to be inserted, the two second optical flow values ​​O2 are O1 / 3 and 2O1 / 3 respectively. By means of equal interpolation, the displacement of the moving object is made more uniform, so that the movement of the moving object in the generated target video is smoother.

[0165] Of course, the first optical flow values ​​may also be unequally interpolated according to the number of the second optical flow values, which is not specifically limited in the embodiment of the present application.

[0166] For example, see Figure 7, is a schematic diagram of the optical flow ring provided in the embodiment of the present application. Figure 7 As shown, the first frame 71 in the optical flow ring is the optical flow graph when the optical flow value is 0, the second frame 72 in the optical flow ring is the second optical flow graph, the third frame 73 in the optical flow ring is the first optical flow graph, the fourth frame 74 in the optical flow ring is the second optical flow graph, and the fifth frame 75 in the optical flow ring is the optical flow graph when the optical flow value is 0. Figure 7 The optical flow ring shown is equivalent to the moving object in the image moving from the starting position to the position corresponding to the second optical flow map, then moving from the position corresponding to the second optical flow map to the position corresponding to the first optical flow map, then moving from the position corresponding to the first optical flow map back to the position corresponding to the second optical flow map, and finally moving from the position corresponding to the second optical flow map back to the starting position. It can be seen that Figure 7 The optical flow ring shown represents the cyclical motion process of the moving object.

[0167] and Figure 6 compared to, Figure 7 The second optical flow map is added to the optical flow ring shown, which is equivalent to adding multiple positions between the starting position and the position corresponding to the first optical flow map, so that the displacement of the moving object is more uniform, thereby making the movement of the moving object in the generated target video smoother.

[0168] In another implementation, a plurality of first optical flow maps may be generated by an optical flow generator; interpolation may be performed based on the first optical flow value of each first optical flow map to obtain at least one second optical flow map generated based on each first optical flow map; an optical flow ring may be generated based on the plurality of first optical flow maps and at least one second optical flow map generated based on each first optical flow map. Each first optical flow map corresponds to a possible motion posture (motion direction and motion displacement) of a moving object.

[0169] For example, see Figure 8 , is a schematic diagram of the optical flow ring provided in the embodiment of the present application. Figure 8 As shown, the first frame 81 in the optical flow ring is an optical flow map when the optical flow value is 0, the third frame 83 and the fifth frame 85 in the optical flow ring are two different first optical flow maps generated by the optical flow generator, the second frame 82 and the eighth frame 88 in the optical flow ring are second optical flow maps obtained by interpolation processing based on the first optical flow map of the third frame 83, and the fourth frame 84 and the sixth frame 86 in the optical flow ring are second optical flow maps obtained by interpolation processing based on the first optical flow map of the fifth frame 85 and the first optical flow map of the third frame 83. For example, the second optical flow value of the second optical flow map of the fourth frame 84 is the average of the first optical flow value corresponding to the first optical flow map of the fifth frame 85 and the first optical flow value corresponding to the first optical flow map of the third frame 83. Figure 8 The optical flow ring shown is equivalent to the moving object in the image moving back and forth between the starting position and the position corresponding to the first optical flow graph of the fifth frame 85.

[0170] and Figure 7 compared to, Figure 8 A plurality of first optical flow maps are added to the optical flow ring shown, which is equivalent to adding a plurality of possible motion postures of the moving object; interpolation is performed based on the plurality of first optical flow maps to obtain a second optical flow map between two adjacent first optical flow maps, which is equivalent to adding a plurality of positions between the two motion postures of the moving object, making the displacement of the moving object more uniform, thereby making the motion of the moving object in the generated target video smoother.

[0171] S204: Generate a target video corresponding to the first image according to the optical flow ring.

[0172] In some embodiments, step S204 may include: generating a fourth image corresponding to each optical flow graph in the optical flow ring; and generating the target video according to a combination of the first image and the fourth image.

[0173] In the embodiment of the present application, affine transformation processing (warp) may be performed on each optical flow map in the optical flow ring to obtain a fourth image corresponding to each optical flow map.

[0174] For example, Figure 6 Taking the optical flow ring shown in FIG. 1 as an example, the method of warping the first optical flow map 62 is as follows: calculate the displacement of the corresponding pixels between the first optical flow map 62 and the optical flow map of the first frame 61 in the optical flow ring; update the coordinates of the corresponding pixels in the first image according to the calculated pixel displacement, and obtain the fourth image corresponding to the first optical flow map 62. For example, if the displacement of the pixel in the first row and first column in the first image is calculated to be shifted right by 1 pixel coordinate, then the pixel point in the first row and first column in the first image is shifted right by 1 pixel coordinate, that is, the pixel point in the first row and second column in the fourth image is the pixel point in the first row and first column in the first image.

[0175] In the embodiment of the present application, the target video is generated by arranging the first image and the fourth image corresponding to the optical flow map in the order of the optical flow map in the optical flow ring to obtain the target video. In the target video, the first image is the first frame and the last frame of the target video.

[0176] From the above warping method, it can be seen that there may be "holes" in the fourth image obtained after the warping process. For example, in the above example, since the pixel point in the first row and first column of the first image is shifted right by 1 pixel coordinate, the pixel position in the first row and first column of the fourth image is empty, resulting in a "hole". This makes the visual effect of the generated fourth image poor.

[0177] In order to solve the above problem, in some embodiments, the target video is repaired to obtain the processed target video.

[0178] In some implementations, the fourth image can be input into the trained modification model, and the processed fourth image can be output. The repair model can be a neural network, such as a GAN network. Exemplarily, the repair model can implement video repair based on the filling method of video erasure. Specifically, during the training process, part of the image in the sample video can be randomly masked, and the masked sample video can be input into the repair model to output the repaired video; the loss value is calculated based on the sample video and the repaired video; if the loss value is greater than a preset threshold, the model parameters of the repair model are adjusted according to the loss value, and the training is continued until the loss value is less than the preset threshold; if the loss value is less than the preset threshold, the current repair model is determined as the trained repair model.

[0179] In another implementation, the fourth image can be input into the trained diffusion model to output the processed fourth image. Exemplarily, during the training process, the resolution of the sample video is enlarged, and then the diffusion model is used to fill in the enlarged video to obtain a filled video; the loss value is calculated based on the filled video and the sample video; if the loss value is greater than a preset threshold, the model parameters of the diffusion model are adjusted according to the loss value, and the training is continued until the loss value is less than the preset threshold; if the loss value is less than the preset threshold, the current diffusion model is determined as the trained diffusion model.

[0180] It should be noted that in the embodiments of the present application, there is no specific limitation on the method of video repair.

[0181] By repairing the target video, the "holes" in the image that appear after the optical flow map warp are repaired, making the repaired video richer and more natural, which is conducive to improving the viewing effect of the target video.

[0182] In some embodiments, the method further comprises:

[0183] If the video quality of the target video meets the second preset condition, displaying the target video;

[0184] If the video quality of the target video does not meet the second preset condition, the first image is displayed.

[0185] In some implementations, if the video quality of the target video meets the second preset condition, the electronic device stores the target video, and when the first image needs to be displayed, plays the target video corresponding to the first image to achieve dynamic display of the first image. If the video quality of the target video does not meet the second preset condition, the generated target video is deleted, and the first image is still displayed in a static manner.

[0186] In the embodiment of the present application, whether to display the first image in a dynamic manner is determined according to the video quality of the target video. When the video quality of the target video generated according to the first image is low, the first image is still displayed in a static manner, which can effectively reduce the impact of low-quality video on the viewing effect and help improve user experience.

[0187] In some implementations, whether the target video satisfies the second preset condition is detected based on video parameters, wherein the video parameters include at least one of the following: continuity of adjacent frames, a quality score of the video, and a quality score of each image frame.

[0188] One way to calculate the continuity of adjacent frames is to calculate the average value of the optical flows between adjacent frames, and determine the continuity of adjacent frames based on the average value.

[0189] The quality score of a video is used to evaluate the quality of the video. In some implementations, a video quality scoring model can be trained; the target video is input into the trained scoring model, and the quality score of the target video is output. It should be noted that the scoring model can be a neural network or an algorithm model that can implement the video scoring function. The embodiment of the present application does not specifically limit the structure of the scoring model.

[0190] The quality score of each image frame is used to evaluate the quality of the image frame, and the method of obtaining the quality score corresponding to the image in the process of obtaining the first image in the above-mentioned embodiment can be adopted.

[0191] In the embodiment of the present application, each video parameter has its corresponding preset condition. Exemplarily, for the continuity of adjacent frames, if the continuity of adjacent frames is less than the fourth threshold, it is determined that the target video satisfies the preset condition corresponding to the continuity of adjacent frames. For the quality score of the video, if the quality score of the target video is greater than the fifth threshold, it is determined that the target video satisfies the preset condition corresponding to the video parameter of the quality score of the video. For the quality score of each image frame, if the quality score of each image frame in the target video is greater than the sixth threshold, it is determined that the target video satisfies the preset condition corresponding to the image parameter of the quality score of each image frame.

[0192] As an implementation method, if only one video parameter is used, detecting whether the video quality of the target video meets the second preset condition based on the video parameter may include: determining whether the target video meets the preset condition corresponding to the adopted video parameter; if the target video meets the preset condition corresponding to the adopted video parameter, determining that the video quality of the target video meets the second preset condition.

[0193] As another implementation, if multiple video parameters are used, detecting whether the video quality of the target video meets the second preset condition based on the video parameters may include: determining whether the target video meets the preset conditions corresponding to each video parameter; if the target video meets the preset conditions corresponding to each video parameter, determining that the video quality of the target video meets the second preset condition. Exemplarily, if the video parameters used include the continuity of adjacent frames, the quality score of the video, and the quality score of each image frame. Accordingly, if the continuity of adjacent frames of the target video is less than a fourth threshold, the quality score of the target video is greater than a fifth threshold, and the quality score of each image frame in the target video is greater than a sixth threshold, then the target video is determined to meet the second preset condition.

[0194] In the embodiment of the present application, evaluating the video quality of the target video based on multiple video parameters can more accurately reflect the quality of the generated target video, reduce the video quality evaluation error caused by inaccurate calculation of a certain video parameter, and help ensure the dynamic display effect of the image.

[0195] For example, see Fig. 9 , is a schematic diagram of the image processing flow provided in the embodiment of the present application. As an example and not a limitation, Fig. 9 As shown, the image processing flow may include the following steps:

[0196] S901: Determine a first image from images in a preset gallery.

[0197] Step S901 is the same as step S201, and for details, please refer to the description in the embodiment of step S201.

[0198] S902: Generate a target video corresponding to the first image.

[0199] S903: Perform restoration processing on the target video.

[0200] S904: Detect whether the video quality of the target video meets a second preset condition.

[0201] S905: If the video quality meets the second preset condition, display the target video.

[0202] S906: If the video quality does not meet the second preset condition, display the first image.

[0203] The implementation of steps S902-S906 can refer to the description of the embodiment of steps S202-S204, which will not be repeated here.

[0204] In the embodiment of the present application, an optical flow map is predicted based on the image, and an optical flow ring is generated based on the optical flow map to represent the cyclic action of the moving object. Through the above method, the static image can be dynamically displayed, thereby effectively improving the user's appreciation experience of the static image; in addition, since the optical flow ring represents the cyclic action of the moving object, the dynamic display process is smoother, further improving the dynamic display effect. In the embodiment of the present application, by screening the images in the preset gallery, the images with lower quality can be filtered out, which is conducive to improving the display effect of the target video generated subsequently. After the target video is generated, the target video is repaired, and the image "holes" that appear after the warp of the optical flow map are repaired, so that the picture of the repaired video is richer and more natural, which is conducive to improving the viewing effect of the target video. In addition, after the target video is generated, the video quality of the target video is evaluated. When the video quality of the target video is low, the first image is still displayed in a static manner, which can effectively reduce the impact of low-quality video on the viewing effect, which is conducive to improving the user experience.

[0205] In some application scenarios, the target video can be displayed in a special form. Take the album application in the mobile phone as an example, see Fig.10 , is a schematic diagram of the interface of the photo album application provided in the embodiment of the present application. Fig.10 In the browsing interface of the album application shown in (a), the display area of ​​image 1001 is larger than the display areas of other images that cannot be dynamically displayed, wherein image 1001 is the first image, that is, the image that can be dynamically displayed. Fig.10 In the browsing interface of the photo album application shown in (b), image 1002 has a border, while other images that cannot be dynamically displayed do not have a border, wherein image 1002 is the first image.

[0206] It should be noted that, in actual applications, the first image may also be displayed in other forms so that the user can distinguish between images in the album that can be dynamically displayed and images that cannot be dynamically displayed.

[0207] As an example of dynamic display, see Fig.11 , is a schematic diagram of a scene of dynamic image display provided by an embodiment of the present application. Fig.11 In the browsing interface of the photo album application shown in (a), an image 1101 is displayed. Image 1101 is an image that can be dynamically displayed (first image). When a user operates image 1101 (such as clicking or long pressing), in response to the user operation, the mobile phone displays Fig.11 The interface shown in (b)-(d) in FIG. Fig.11 As shown in (b), (c) and (d) in FIG. 1 , the mobile phone plays a target video 1102 (ie, the dynamic display image 1101 ) corresponding to the image 1101 .

[0208] As another example of dynamic display, see Fig.12 , is a schematic diagram of a scene of dynamic image display provided by another embodiment of the present application. Fig.12 In the browsing interface of the photo album application shown in (a), image 1201 is an image that can be dynamically displayed. When the user slides the browsing interface, in response to the user operation, the mobile phone monitors the position of image 1201; if image 1201 moves to a preset position (such as the middle area of ​​the screen), Fig.12 As shown in (b)-(d) in FIG. 1 , the target video 1202 corresponding to the image 1201 is played.

[0209] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.

[0210] The embodiment of the present application further provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments can be implemented.

[0211] The embodiments of the present application also provide a computer program product. When the computer program product is executed on an electronic device, the electronic device can implement the steps in the above-mentioned various method embodiments.

[0212] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, which can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may at least include: any entity or device that can carry the computer program code to the first device, a recording medium, a computer memory, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), an electric carrier signal, a telecommunication signal, and a software distribution medium. For example, a USB flash drive, a mobile hard disk, a magnetic disk or an optical disk. In some jurisdictions, according to legislation and patent practice, computer-readable media cannot be electric carrier signals and telecommunication signals.

[0213] The embodiment of the present application also provides a chip system, the chip system includes a processor, the processor is coupled to a memory, and the processor executes a computer program stored in the memory to implement the steps of any method embodiment of the present application. The chip system can be a single chip or a chip module composed of multiple chips.

[0214] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0215] Those of ordinary skill in the art will appreciate that the units and method steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application. Finally, it should be noted that the above is only a specific implementation method of the present application, but the scope of protection of the present application is not limited thereto, and any changes or substitutions within the technical scope disclosed in this application should be included in the scope of protection of this application. Therefore, the scope of protection of the present application shall be based on the scope of protection of the claims.

Claims

1. An image processing method, characterized in that: include: Acquire a first image to be processed; Predicting a first optical flow map corresponding to the first image, wherein the optical flow map is used to represent the displacement of corresponding pixels between two previous and next frames of images; generating an optical flow ring according to the first optical flow map, wherein the optical flow ring includes a group of optical flow maps connected end to end; Generate a target video corresponding to the first image according to the optical flow ring; Generating an optical flow ring according to the first optical flow graph includes: Obtaining a first optical flow value corresponding to the first optical flow map; Performing interpolation processing according to the first optical flow value to obtain at least one second optical flow value which is smaller than the first optical flow value; Generate a second optical flow map corresponding to each of the second optical flow values; The optical flow ring is generated according to the first optical flow map and the second optical flow map.

2. The method according to claim 1, characterized in that The step of acquiring a first image to be processed comprises: The first image is determined from the images in the preset gallery according to image quality of the images in the preset gallery.

3. The method according to claim 2, characterized in that The determining the first image from the images in the preset gallery according to the image quality of the images in the preset gallery comprises: Detecting whether the image quality of the image in the preset gallery meets a first preset condition according to image parameters, wherein the image parameters include at least two of the following: image source, the number of words contained in the image, the blur degree of the image, and the quality score corresponding to the image; An image in the preset image library whose image quality meets a first preset condition is determined as the first image.

4. The method according to claim 3, characterized in that The third image is any image in the preset gallery; The step of detecting whether the image quality of the third image meets the first preset condition according to the image parameters comprises: If the image source of the third image indicates that the third image is taken by an electronic device, the number of characters contained in the third image is less than a first threshold, the blurriness of the third image is less than a second threshold, and the quality score corresponding to the third image is greater than a third threshold, then it is determined that the image quality of the third image meets the first preset condition.

5. The method according to claim 1, characterized in that The predicting a first optical flow map corresponding to the first image includes: A first optical flow map corresponding to the first image is predicted according to a preset optical flow generator.

6. The method according to claim 5, characterized in that The predicting a first optical flow map corresponding to the first image according to a preset optical flow generator includes: estimating depth information corresponding to the first image; The depth information and the first image are input into the optical flow generator, and the first optical flow map is output.

7. The method according to claim 1, characterized in that The step of generating a target video corresponding to the first image according to the optical flow ring includes: Generate a fourth image corresponding to each optical flow map in the optical flow ring; The target video is generated according to the combination of the first image and the fourth image.

8. The method according to claim 1, characterized in that: The method further comprises: Perform video restoration processing on the target video to obtain the processed target video.

9. The method according to claim 1, characterized in that: The method further comprises: If the video quality of the target video meets the second preset condition, displaying the target video; If the video quality of the target video does not meet the second preset condition, the first image is displayed.

10. The method according to claim 9, characterized in that The method further comprises: Whether the target video satisfies the second preset condition is detected according to video parameters, wherein the video parameters include at least two of the following: continuity of adjacent frames, a quality score of the video, and a quality score of each image frame.

11. The method according to claim 10, characterized in that The detecting, according to the video parameter, whether the target video satisfies the second preset condition comprises: If the continuity of adjacent frames of the target video is less than a fourth threshold, the quality score of the target video is greater than a fifth threshold, and the quality score of each image frame in the target video is greater than a sixth threshold, it is determined that the target video meets the second preset condition.

12. An electronic device, characterized in that: The electronic device includes: one or more processors, and a memory; The memory is coupled to the one or more processors, and the memory is used to store computer program codes, wherein the computer program codes include computer instructions, and the one or more processors call the computer instructions to enable the electronic device to perform the method as claimed in any one of claims 1 to 11.

13. A chip system, characterized in that: The chip system is applied to an electronic device, and the chip system includes one or more processors, and the one or more processors are used to call computer instructions so that the electronic device executes the method as described in any one of claims 1 to 11.

14. A computer-readable storage medium, characterized in that: The computer-readable storage medium comprises instructions, and when the instructions are executed on an electronic device, the electronic device executes the method as claimed in any one of claims 1 to 11.