Image restoration method and device, computer equipment and storage medium
By using attention windows in image sequences to fuse image frames and their splicing features, the problem of high computational complexity in the existing technology is solved, efficient image restoration is achieved, and image clarity is significantly improved.
Patent Information
- Application Number
- CN202411082657.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-08
- Publication Date
- 2024-10-18
AI Technical Summary
Existing motion blur removal algorithms consume large amounts of resources due to high computational complexity when processing image sequences, making it difficult to restore clarity efficiently.
By acquiring multiple image frames in the image sequence, the attention window is used to fuse the image frames and their splicing features to generate higher-definition image frames, avoid using complex algorithms, and achieve efficient image restoration.
While maintaining high efficiency, the clarity of image restoration is significantly improved, the consumption of computing resources is reduced, and a more efficient image restoration effect is achieved.
Smart Images

Figure CN118799228A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image restoration technology, and in particular to an image restoration method, apparatus, computer equipment and storage medium. Background Art
[0002] During the image sequence acquisition process, the rapid movement of the target object or the shaking of the acquisition equipment can easily lead to the loss of details and lack of sharpness in the acquired image, thus affecting the viewing experience. This image blurring phenomenon caused by movement is called motion blur.
[0003] Currently, de-motion blur algorithms aim to repair the details lost during the shooting process to improve image clarity. Existing de-motion blur algorithms generally model temporal information by designing a complex alignment module, such as dynamic convolution (Deformable Convolution), grouped spatial shift module (Grouped Spatial Shift), optical flow-guided sparse transformer module (Flow-Guided Sparse Transformer), optical flow-guided deformable attention module (Guideddeformable attention), etc. However, the algorithms to implement these modules are usually highly complex and require more computing resources. Summary of the invention
[0004] Based on this, it is necessary to provide an image restoration method, apparatus, computer device, computer-readable storage medium and computer program product that can obtain a second image frame with higher clarity than the first image frame in response to the above technical problems.
[0005] In a first aspect, the present application provides an image restoration method. The method comprises:
[0006] Acquire a first image sequence; the first image sequence includes a plurality of first image frames arranged in time sequence;
[0007] Obtaining a plurality of first stitched image features based on each of the first image frames; the first image frames and the first stitched image features correspond one to one;
[0008] Based on the attention window, each of the first spliced image features is fused with each of the first image frames to obtain a fused image feature of each of the first image frames;
[0009] Based on the fused image features of each of the first image frames, a plurality of the second image frames are obtained; the clarity of the second image frames is higher than that of the first image frames.
[0010] In a second aspect, the present application also provides an image restoration device. The device comprises:
[0011] An acquisition module, configured to acquire a first image sequence; the first image sequence comprises a plurality of first image frames arranged in time sequence;
[0012] A stitching module, configured to obtain a plurality of first stitched image features based on each of the first image frames; the first image frames and the first stitched image features correspond one to one;
[0013] a fusion module, configured to fuse each of the first spliced image features with each of the first image frames based on an attention window to obtain a fused image feature of each of the first image frames;
[0014] A restoration module is used to obtain multiple second image frames based on the fused image features of each of the first image frames; the clarity of the second image frames is higher than that of the first image frames.
[0015] In a third aspect, the present application further provides a computer device, which includes a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, it implements some or all of the steps described in any method of the first aspect of the present application.
[0016] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements some or all of the steps described in any method of the first aspect of the present application.
[0017] In a fifth aspect, the present application further provides a computer program product, which includes a computer program, and when the computer program is executed by a processor, it implements part or all of the steps described in any method of the first aspect of the embodiment of the present application.
[0018] The above-mentioned image restoration method, apparatus, computer equipment, storage medium and computer program product obtain a first image sequence; the first image sequence includes multiple first image frames arranged in time sequence; multiple first spliced image features are obtained based on each first image frame; there is a one-to-one correspondence between the first image frame and the first spliced image feature; based on the attention window, each first spliced image feature is fused with each first image frame to obtain a fused image feature of each first image frame; based on the fused image feature of each first image frame, multiple second image frames are obtained; the clarity of the second image frame is higher than that of the first image frame. The image restoration method provided in the present application realizes the clarity restoration of each first image frame on the basis of the fused image features of each first image frame obtained based on the attention window, thereby obtaining multiple second image frames with higher clarity. In the image restoration process, the attention window is used to avoid the use of complex algorithms that require more computing resources, thereby achieving efficient image restoration. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] FIG1 is a diagram showing an application environment of an image restoration method according to an embodiment;
[0020] FIG2 is a schematic diagram of a flow chart of an image restoration method in one embodiment;
[0021] FIG3 is a schematic flow chart of an image restoration method in another embodiment;
[0022] FIG4 is a block diagram of an image restoration device in one embodiment;
[0023] FIG5 is a diagram showing the internal structure of a computer device in one embodiment;
[0024] FIG. 6 is a diagram showing the internal structure of a computer device in another embodiment. DETAILED DESCRIPTION
[0025] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0026] It should be noted that in the following description, the terms "first, second and third" involved are merely used to distinguish similar objects and do not represent a specific ordering of the objects. It can be understood that "first, second and third" can be interchanged in a specific order or sequence where permitted, so that the embodiments of the present application described here can be implemented in an order other than that illustrated or described here.
[0027] The image restoration method provided in the embodiment of the present application can be applied in the application environment shown in FIG1 . In which, the terminal 102 communicates with the server 104 through a network. The data storage system can store data that the server 104 needs to process. The data storage system can be integrated on the server 104, or placed on the cloud or other network servers.
[0028] The terminal 102 may be a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart speaker, a smart watch, an IoT device, and a portable wearable device. The IoT device may be a smart speaker, a smart TV, a smart air conditioner, and a smart vehicle-mounted device, etc. The portable wearable device may be a smart watch, a smart bracelet, a head-mounted device, etc.
[0029] The server 104 may be an independent physical server or a service node in a blockchain system. A peer-to-peer (P2P) network is formed between the service nodes in the blockchain system. The P2P protocol is an application layer protocol running on the Transmission Control Protocol (TCP).
[0030] In addition, server 104 can also be a server cluster composed of multiple physical servers, and can be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDN), as well as big data and artificial intelligence platforms.
[0031] The terminal 102 and the server 104 may be connected via Bluetooth, USB (Universal Serial Bus) or a network or other communication connection method, and this application does not impose any limitation thereto.
[0032] In one embodiment, as shown in FIG2 , an image restoration method is provided. The method may be executed by the server or the terminal in FIG1 , or by the server and the terminal in collaboration. The method is described by taking the method executed by the terminal in FIG1 as an example, and includes the following steps:
[0033] Step 202, acquiring a first image sequence; the first image sequence includes a plurality of first image frames arranged in time sequence.
[0034] The multiple first image frames arranged in time sequence refer to the multiple first image frames being arranged in the first image sequence according to the occurrence time of the image frames, that is, the first image sequence is time-continuous. It is easy to understand that the first image sequence is an image sequence with image restoration requirements.
[0035] Optionally, the source file of the first image sequence may be a video file, and the first image sequence is obtained by converting the video file into a plurality of first image frames arranged in time sequence.
[0036] Optionally, when image restoration is required, the user uploads the first image sequence to the terminal so that the terminal obtains the first image sequence; or the user uploads a video file to the terminal so that the terminal obtains the video file and converts the video file to obtain the first image sequence.
[0037] Step 204 , obtaining a plurality of first stitched image features based on each first image frame; the first image frames correspond to the first stitched image features one by one.
[0038] Optionally, the first spliced image feature may include the embedded features of the first image frame and the embedded features of the image frames at the time nodes before and after the first image frame. Exemplarily, it may include the embedded features of the first image frame, the embedded features of the first image frame at the previous time node, and the embedded features of the first image frame at the next time node. Another option is that the first spliced image feature may include the embedded features of the first image frame, the embedded features of the first image frames at the first preset number of time nodes before, and the embedded features of the first image frames at the first preset number of time nodes after. The first preset number may be 2, 4 or other numbers. It is easy to understand that an image frame is captured at a time node. Therefore, the first image frame at the previous time node can be understood as the first image frame before the first image frame. The same is true for the first image frames at other time nodes, which will not be repeated here.
[0039] Step 206 , based on the attention window, fuse each first stitched image feature with each first image frame to obtain a fused image feature of each first image frame.
[0040] The attention window enables the key fusion area to be focused on a specific area window of each first image frame during the fusion of each first stitched image feature with each first image frame. That is, the attention window is used to determine the image parameters of the specific area window of each first image frame that needs to be paid attention to.
[0041] Optionally, the size of the attention window can be 3*3, 8*8, or 11*11. The larger the attention window, the more effectively the image can be restored. However, the larger the attention window, the greater the time complexity, which in turn causes the terminal to consume more computing resources.
[0042] Specifically, the first spliced image features are fused with the first image frames so as to allow the first image frames to learn the temporal features of a long sequence to obtain fused image features of the first image frames.
[0043] In an exemplary embodiment, the above-mentioned first stitched image features are fused with each first image frame based on the attention window to obtain the fused image features of each first image frame, including: based on the attention window and the gated recurrent unit, each first stitched image feature is fused with each first image frame to obtain the fused image features of each first image frame.
[0044] Among them, the gated recurrent unit includes a reset gate and an update gate; the reset gate is used to determine the correlation between the implicit state and each first image frame, and to promptly discard the historical image frame information that is irrelevant to the predicted second image frame, so as to avoid the accumulation of irrelevant historical image frame information and thus cause the collapse of the predicted image frame features; the update gate is used to control the updating strength of the implicit state, so as to more accurately capture the dependency between the first image frames with larger time node distances in the time series.
[0045] In an exemplary embodiment, the above-mentioned first stitched image features are fused with each first image frame based on the attention window to obtain the fused image features of each first image frame, including: determining the image restoration level for the first image sequence; determining the target size of the attention window based on the image restoration level of the first image sequence; based on the attention window of the target size, fusing each first stitched image feature with each first image frame to obtain the fused image features of each first image frame.
[0046] The image restoration level is used to characterize the degree of restoration of multiple first image frames in the first image sequence. The image restoration level is positively correlated with the degree of restoration. Therefore, the image restoration level is positively correlated with the target size of the attention window. That is, the higher the image restoration level, the higher the degree of image restoration is required for the first image frame, so a larger attention window is selected.
[0047] Optionally, the image restoration level may be input to the terminal simultaneously when the user uploads the first image sequence or the video file corresponding to the first image sequence to the terminal; or the terminal may judge the user level of the user, and after determining the user level, determine the image restoration level based on the user level.
[0048] Step 208: obtaining a plurality of second image frames based on the fused image features of the first image frames; the second image frames have a higher definition than the first image frames.
[0049] It is easy to understand that the second image frame is obtained by image restoration of the first image frame, and therefore, the second image frame has higher definition than the first image frame.
[0050] Specifically, the second image frames correspond to the first image frames at different time nodes, that is, each time node corresponds to a first image frame and a second image frame, and the first image frame and the second image frame at the same time node have the same image content but different definition.
[0051] Optionally, after obtaining multiple second image frames, the multiple second image frames can be merged into a third image sequence; or when the source file of the first image sequence is a video file, the multiple second image frames can be merged into a third image sequence, and the third image sequence can be further converted into the file format of a video file.
[0052] In an exemplary embodiment, the method further includes: at each time node, respectively determining a first image frame and a second image frame having a time correspondence; determining a clarity difference between the first image frame and the second image frame having a time correspondence; when the clarity difference is less than a first preset difference, enlarging the attention window to obtain an updated attention window; based on the attention window, each first spliced image feature is fused with each first image frame to obtain a fused image feature of each first image frame, including: based on the updated attention window, each first spliced image feature is re-fused with each first image frame to obtain an updated fused image feature of each first image frame; the updated attention window is larger than the attention window; based on the fused image feature of each first image frame, multiple second image frames are obtained, including: based on the updated fused image feature of each first image frame, multiple updated second image frames are obtained; at each time node, the clarity difference between the updated second image frame and the first image frame is greater than or equal to the first preset difference.
[0053] In an exemplary embodiment, when the clarity difference is less than a first preset difference, the attention window is enlarged to obtain an updated attention window, including: when the clarity difference is less than the first preset difference, determining the ratio between the clarity difference and the first preset difference; determining a window enlargement coefficient based on the size of the ratio; and enlarging the attention window based on the window enlargement coefficient to obtain an updated attention window.
[0054] Among them, there is a correlation between the ratio and the window enlargement coefficient. That is to say, when the difference in clarity is smaller, the effect of enlarging the attention window is more obvious, so that the image restoration effect can be better when the image is restored again.
[0055] In the above-mentioned image restoration method, a first image sequence is obtained; the first image sequence includes a plurality of first image frames arranged in time sequence; a plurality of first spliced image features are obtained based on each first image frame; there is a one-to-one correspondence between the first image frame and the first spliced image features; based on the attention window, each first spliced image feature is fused with each first image frame to obtain a fused image feature of each first image frame; based on the fused image feature of each first image frame, a plurality of second image frames are obtained; the clarity of the second image frame is higher than that of the first image frame. The image restoration method provided in the present application realizes the clarity restoration of each first image frame on the basis of the fused image features of each first image frame obtained based on the attention window, thereby obtaining a plurality of second image frames with higher clarity. In the image restoration process, the attention window is used to avoid the use of complex algorithms that consume a lot of computing resources, thereby realizing efficient image restoration.
[0056] In an exemplary embodiment, the above-mentioned obtaining a plurality of first stitched image features based on each first image frame includes:
[0057] Extracting features from each first image frame to obtain embedded features of each first image frame;
[0058] The embedded features of each first image frame are optically aligned with the embedded features of the first image frame of its corresponding adjacent time node, and then stitched together to obtain multiple first stitched image features; there is a one-to-one correspondence between the first image frame and the first stitched image features.
[0059] The embedded features of the first image frame are low-dimensional, high-information-density numerical vectors of the first image frame, and may include information such as color, texture, and shape of the first image frame.
[0060] The first image frame at the adjacent time node corresponding to the first image frame refers to the first image frame at the previous time node and the first image frame at the next time node of the first image frame.
[0061] The embedded features of each first image frame are optically aligned with the embedded features of the first image frame at its corresponding adjacent time node to ensure that the embedded features of the first image frames from different time nodes can correctly correspond to each other in space, thereby providing an accurate information basis for subsequent image feature fusion and image restoration.
[0062] In an exemplary embodiment, the above-mentioned feature extraction of each first image frame to obtain embedded features of each first image frame includes: extracting features of each first image frame based on a second preset number of residual modules that do not contain normalization layers to obtain embedded features of each first image frame of a third preset number of channels.
[0063] In an exemplary embodiment, the above-mentioned multiple second image frames are obtained based on the fused image features of each first image frame, including: based on a second preset number of residual modules that do not contain a normalization layer, channel conversion of the fused image features of each first image frame of a third preset number of channels is performed; and multiple second image frames including an R channel, a G channel and a B channel are obtained; the second image frame is a three-channel image frame.
[0064] The value range of the second preset number may be [3, 15]. The value of the third preset number may be selected from {32, 48, 64, 96, 128, 160, 192}.
[0065] In this embodiment, feature extraction is performed on each first image frame to obtain embedded features of each first image frame; the embedded features of each first image frame are optically aligned with the embedded features of the first image frame at its corresponding adjacent time node, and after the optical flow alignment, splicing is performed to obtain a plurality of first spliced image features, thereby ensuring that the embedded features of each first image frame can establish a correct correspondence in space, and further, by ensuring the accuracy of the image information, the second image frame subsequently obtained through image restoration has more accuracy and higher clarity.
[0066] In an exemplary embodiment, the above-mentioned fusion of each first spliced image feature with each first image frame based on the attention window to obtain the fused image feature of each first image frame includes:
[0067] Based on the attention window and each first stitched image feature, a plurality of second stitched image features are obtained;
[0068] Each second spliced image feature and the fused image feature of the first image frame at the previous time node corresponding thereto are fused to obtain the fused image feature of each first image frame.
[0069] Optionally, based on the attention window and each first stitched image feature, each first stitched image feature can be finely aligned to obtain a plurality of second stitched image features; each first stitched image feature can also be weighted to increase or decrease the weight of some first stitched image features to obtain a plurality of second stitched image features; or after finely aligning each first stitched image feature, each first stitched image after the fine feature alignment can be weighted to obtain a plurality of second stitched image features.
[0070] The second stitched image feature obtained based on the embodiment of the present application not only considers the spatial correspondence, but also considers the correlation between image features, so that the second stitched image feature has richer and more accurate image information than the first stitched image feature.
[0071] Fusion of each second stitched image feature and the fused image feature of the first image frame at the corresponding previous time node can enable the fused image features of each first image frame to capture more comprehensive image information, which is helpful for subsequently obtaining a second image frame with higher definition.
[0072] In this embodiment, based on the attention window and each first stitched image feature, a plurality of second stitched image features are obtained, thereby making the second stitched image features have richer and more accurate image information, and then each second stitched image feature and the fused image feature of the first image frame at the previous time node corresponding thereto are fused to obtain the fused image feature of each first image frame, thereby further making the fused image feature of each first image frame able to capture more comprehensive image information, and further, based on the fused image feature of each first image frame, the second image frame obtained after subsequent image restoration can have more accurate and higher definition.
[0073] In an exemplary embodiment, the first spliced image feature, the fused image features of each first image frame, and the second image frame are obtained based on the target model; the method further includes:
[0074] Acquire a training model and a second image sequence; the second image sequence includes a plurality of first training image frames arranged in time sequence;
[0075] Performing blur processing on a plurality of first training image frames to obtain a plurality of second training image frames; the clarity of the first training image frames is higher than that of the second training image frames;
[0076] Inputting the plurality of second training image frames into the training model to obtain a plurality of third training image frames;
[0077] determining a total loss function between the plurality of first training image frames and the plurality of third training image frames;
[0078] The training model is iteratively optimized based on the total loss function until the total loss function reaches the preset loss condition, and then the target model is obtained.
[0079] The first training image frame may be a historical image frame used to train the training model; and it is easy to understand that the second image sequence is an image sequence used to train the training model.
[0080] Optionally, an image blurring processing method such as Gaussian blurring, motion blurring, zoom blurring, etc. may be used to perform blurring processing on the plurality of first training image frames to obtain a plurality of second training image frames.
[0081] The total loss function is used to characterize the size of the image content gap between the third training image frame and the first training image frame.
[0082] Optionally, the preset loss function may be a total loss function that is less than or equal to a preset loss value. Furthermore, the size of the preset loss function should satisfy the condition that the difference in clarity between the third training image frame and the first training image frame is less than or equal to a second preset difference, that is, the size of the preset loss function should make the third training image frame obtained by the training model after the iteration is completed close to the first training image frame in terms of image content, in other words, the third training image frame obtained has a better image restoration effect.
[0083] In this embodiment, during the training process of the training model, the total loss function between multiple first training image frames and multiple third training image frames is determined, and the training model is iteratively optimized based on the total loss function until the total loss function reaches a preset loss condition, then the target model is determined. Thus, the target model obtained based on the embodiment of the present application can obtain accurate first spliced image features and fused image features of each first image frame, so that the first image frame can be restored to obtain a second image frame with higher clarity.
[0084] In an exemplary embodiment, the step of inputting the plurality of second training image frames into the training model to obtain the plurality of third training image frames includes:
[0085] Inputting a plurality of second training image frames into the training model, so that the training model obtains a plurality of first training spliced image features based on each of the second training image frames; and the second training image frames correspond one to one to the first training spliced image features;
[0086] Based on the attention window, each first training spliced image feature is fused with each second training image frame to obtain a fused image feature of each second training image frame;
[0087] Based on the fused image features of each second training image frame, a plurality of third training image frames are obtained.
[0088] In this embodiment, during the training process of the training model, first, multiple second training image frames are input into the training model so that the training model obtains multiple first training spliced image features based on each second training image frame, and then, based on the attention window, each first training spliced image feature is fused with each second training image frame to obtain the fused image features of each second training image frame, and finally, based on the fused image features of each second training image frame, multiple third training image frames are obtained. Thus, the training model can perform image restoration on the second training image frame based on comprehensive and accurate image information to obtain a third training image frame with higher definition, and at the same time, in the image restoration process, the attention window is used to avoid the use of complex algorithms that consume more computing resources, and image restoration is completed efficiently.
[0089] In existing de-motion blur algorithms, when synthesizing training image frames for training, the pixel values of high-frame-rate video frames are usually averaged to obtain the training image frames. However, there is a large gap between the blur effect of the training image frames synthesized by this traditional method and the blurred image frames captured in the real world, which in turn leads to poor generalization of the trained image restoration model.
[0090] Based on this, in an exemplary embodiment, the fuzzy processing is performed on the plurality of first training image frames to obtain the plurality of second training image frames, including:
[0091] Based on the interpolation algorithm, multiple interpolation processing is performed on the multiple first training image frames to obtain multiple third training image frames;
[0092] Convert each third training image frame from the red, green and blue domain to a linear domain to obtain a plurality of third training image frames in the linear domain; the maximum pixel value of the third training image frame in the linear domain is a first value;
[0093] The maximum pixel value of the third training image frame of each linear domain is increased to obtain a plurality of fourth training image frames; the maximum pixel value of the fourth training image frame is a second value, and the second value is greater than the first value;
[0094] Averaging pixel values of a plurality of fourth training image frames, and converting the fourth training image frames after the pixel value averaging from a linear domain to a red, green, and blue domain to obtain a plurality of fourth training image frames in the red, green, and blue domains;
[0095] The plurality of fourth training image frames in the red, green and blue domains are sharpened and blurred to obtain a plurality of second training image frames.
[0096] The frame rate of the third training image frame is greater than that of the first training image frame.
[0097] Optionally, when performing multiple frame interpolation processing, the interpolation multiple may be 4 times, 8 times, 16 times, 32 times or other multiples.
[0098] Optionally, the first value may be 255, and thus the second value is a value greater than 255.
[0099] It is easy to understand that the red, green and blue domain is the RGB domain.
[0100] Specifically, the maximum pixel value of the third training image frame of each linear domain is increased by randomly increasing the maximum pixel value of the third training image frame of each linear domain, that is, determining the pixel points with a pixel value of 255 in the third training image frame of the linear domain, and then randomly increasing the pixel values of these pixel points to pixel values greater than 255. Thus, the obtained multiple fourth training image frames can retain the original highlight information.
[0101] Specifically, averaging the pixel values of the plurality of fourth training image frames is averaging the pixel values of each third preset number of consecutive fourth training image frames in the plurality of fourth training image frames to simulate the long-time exposure effect of the fourth training image frames.
[0102] Optionally, converting the fourth training image frame after averaging pixel values from a linear domain to a red, green, and blue domain may be converting the fourth training image frame after averaging pixel values from a linear domain to a red, green, and blue domain based on a camera CRF curve.
[0103] In an exemplary embodiment, the above-mentioned increasing the maximum pixel value of the third training image frame of each linear domain to obtain multiple fourth training image frames includes: determining the overexposed area value of the third training image frame based on the pixel value of the third training image frame of each linear domain; increasing the maximum pixel value of the third training image frame of each linear domain based on the hyperparameter, the overexposed area values of the multiple third training image frames, and the multiple third training frames to obtain multiple fourth training image frames.
[0104] Exemplarily, the image abscissa of the third training image frame is represented as , the image ordinate of the third training image frame is expressed as , the number of channels (third preset number) of the third training image frame is expressed as , the overexposed area value of the third training image frame is expressed as , and the hyperparameters are expressed as , the pixel value of the third training image frame is expressed as , the pixel value of the fourth training image frame is expressed as , the over-exposure region value of the pixel point with a pixel value of 255 is determined to be 1, and the over-exposure region value of the pixel point with a pixel value other than 255 is determined to be 0, and the over-exposure region value of the third training image frame is obtained. Specifically, the over-exposure region value of the third training image frame is The calculation formula can be expressed as: , the fourth training image frame The pixel value can be expressed as a hyperparameter and the overexposed area value of the third training image frame The product of the pixel value of the third training image frame The sum of the values between the fourth training image frame The pixel value can be expressed as It can be seen that this embodiment realizes increasing the maximum pixel value of the third training image frame in each linear domain, and further realizes highlight recovery of the third training image frame in the linear domain to obtain a fourth training image frame with highlight information.
[0105] Optionally, the sharpening processing is performed on the fourth training image frames in the multiple red, green and blue domains, and the sharpening processing can be adaptively performed based on the clarity of the fourth training image frames in the multiple red, green and blue domains. The clarity is negatively correlated with the sharpening degree of the adaptive sharpening processing. That is, the lower the clarity of the fourth training image frame (that is, the blurrier it is), the higher the sharpening degree is, and the higher the clarity of the fourth training image frame, the lower the sharpening degree is. Thus, a more realistic sharpening effect can be simulated.
[0106] Optionally, blurring is performed on the fourth training image frames in the multiple red, green and blue domains, and Gaussian blurring, jpeg compression or other blurring methods may be performed on the fourth training image frames in the multiple red, green and blue domains, thereby simulating an image quality degradation effect consistent with the real world.
[0107] In the present embodiment, in the process of obtaining multiple second training image frames, that is, obtaining training image frames for optimizing iterative training of the training model, multiple interpolation processing is performed, the maximum pixel value is increased to achieve highlight recovery, pixel value averaging is performed to simulate a long exposure effect, sharpening processing is performed to simulate a real sharpening effect, and blurring processing is performed to simulate a real blur effect. Thus, based on the present embodiment, a real blurred image frame can be synthesized as the second training image frame for optimizing iterative training of the training model. Furthermore, based on the second training image frame with a real blur effect, a better model training effect can be achieved to obtain a target model with a more accurate and better image restoration effect.
[0108] In an exemplary embodiment, determining the total loss function between the plurality of first training image frames and the plurality of third training image frames comprises:
[0109] respectively determining a pixel loss, an optical flow loss, and a frequency domain loss between the plurality of first training image frames and the plurality of third training image frames;
[0110] Based on the pixel loss, the optical flow loss, and the frequency domain loss, a total loss function between the plurality of first training image frames and the plurality of third training image frames is determined.
[0111] The pixel loss is a loss function used to measure the pixel-level difference between the first training image frame and the third training image frame. The pixel loss evaluates the image restoration performance of the training model by calculating the brightness difference at each pixel between the first training image frame and the third training image frame.
[0112] Optical flow loss is a loss function used to measure the difference between the optical flow of the first training image frame and the optical flow of the third training image frame. The optical flow of an image frame describes the pattern of object motion in an image sequence.
[0113] Optical flow loss includes alignment loss and smoothness loss. Alignment loss is determined in a self-supervised manner. The purpose of determining alignment loss is to ensure that the optical flow of the third training image frame output by the training model can accurately reflect the movement of the object between consecutive video frames, so that the optical flow of the third training image frame is visually consistent with the optical flow of the first training image frame. The purpose of determining smoothness loss is to make the optical flow of the third training image frame output by the training model as smooth as possible.
[0114] The frequency domain loss is a loss function used to measure the difference between the first training image frame and the third training image frame in the frequency domain after Fourier transformation. The frequency domain loss helps to restore the high-frequency details of the image.
[0115] For example, the pixel loss adopts L2 loss, and the pixel loss is expressed as , the pixel value of the first training image frame is expressed as , the pixel value of the third training image frame is expressed as , then the pixel loss is the pixel value of the first training image frame and the pixel values of the third training image frame The difference norm between them, the specific pixel loss The calculation formula is: .
[0116] Exemplarily, the optical flow loss is expressed as , the alignment loss is expressed as , the first training image frame of the tth frame is represented as ,Will arrive The optical flow is expressed as ,in, Indicates that According to the predicted optical flow If the transformation operation is performed, the alignment loss The calculation formula is: ; The smoothing loss is expressed as , the optical flow gradient is expressed as , smoothing loss is the norm of the operator of the optical flow gradient, the specific smoothing loss The calculation formula is: ; Optical flow loss is the alignment loss and smoothing loss The sum of the values, the specific optical flow loss The calculation formula is: .
[0117] Exemplarily, the frequency domain loss is expressed as , the Fourier transform is expressed as , then the frequency domain result after the first training image frame is transformed to Fourier transform is , the frequency domain result after the third training image frame is transformed into Fourier transform is , then the frequency domain loss is the norm of the difference between the frequency domain result after the first training image frame is transformed into Fourier transform and the frequency domain result after the third training image frame is transformed into Fourier transform. The specific frequency domain loss The calculation formula is: .
[0118] Exemplarily, the total loss function between the first plurality of training image frames and the third plurality of training image frames is represented as L, and the total loss function L is the pixel loss , optical flow loss And the frequency domain loss The specific calculation formula of the total loss function L is: .
[0119] In this embodiment, the total loss function between the multiple first training image frames and the multiple third training image frames is determined based on pixel loss, optical flow loss and frequency domain loss. Thus, determining the total loss function based on optical flow loss can make the image alignment of the front and rear image frames more accurate, while avoiding the existence of unnatural curved edges; determining the total loss function based on frequency domain loss can generate more image details after image restoration. It can be seen that the target model obtained by training the total loss function of this embodiment can make the second image frame obtained after subsequent image restoration have more accuracy and higher definition.
[0120] The following is a detailed example of an application process of the above image restoration method, see FIG3 , which is as follows:
[0121] (1) Acquisition of the first image sequence
[0122] The terminal acquires a first image sequence; the first image sequence includes a plurality of first image frames arranged in time sequence.
[0123] (2) Image restoration process of target model
[0124] The terminal inputs a plurality of first image frames into the target model, so that the feature extraction module in the target model extracts features from each first image frame to obtain embedded features of each first image frame; the feature extraction module performs optical flow alignment on the embedded features of each first image frame with the embedded features of the first image frame at the corresponding adjacent time node, and performs splicing processing after the optical flow alignment to obtain a plurality of first spliced image features; there is a one-to-one correspondence between the first image frame and the first spliced image features; there is a one-to-one correspondence between the first image frame and the first spliced image features;
[0125] In the target model, the feature extraction module outputs a plurality of first stitched image features to the temporal fusion module, so that the temporal fusion module obtains a plurality of second stitched image features based on the attention window and each first stitched image feature; the temporal fusion module fuses each second stitched image feature with the fused image feature of the first image frame at the previous time node corresponding thereto, so as to obtain the fused image feature of each first image frame;
[0126] In the target model, the temporal fusion module outputs the fused image features of each first image frame to the reconstruction module, so that the reconstruction module obtains multiple second image frames based on the fused image features of each first image frame; the clarity of the second image frames is higher than that of the first image frames.
[0127] (3) Output of the second image frame
[0128] At this point, the terminal obtains a plurality of second image frames whose clarity output by the target model is higher than that of the plurality of first image frames.
[0129] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0130] Based on the same inventive concept, the embodiment of the present application also provides an image restoration device for implementing the above-mentioned image restoration method. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above-mentioned method, so the specific limitations in one or more image restoration device embodiments provided below can refer to the limitations on the image restoration method above, and will not be repeated here.
[0131] In one embodiment, as shown in FIG. 4 , an image restoration device is provided, including: an acquisition module 402 , a splicing module 404 , a fusion module 406 and a restoration module 408 , wherein:
[0132] The acquisition module 402 is used to acquire a first image sequence; the first image sequence includes a plurality of first image frames arranged in time sequence.
[0133] The stitching module 404 is used to obtain a plurality of first stitched image features based on each first image frame; there is a one-to-one correspondence between the first image frames and the first stitched image features.
[0134] The fusion module 406 is used to fuse each first spliced image feature with each first image frame based on the attention window to obtain a fused image feature of each first image frame.
[0135] The restoration module 408 is used to obtain a plurality of second image frames based on the fused image features of the first image frames; the clarity of the second image frames is higher than that of the first image frames.
[0136] In an exemplary embodiment, in terms of obtaining multiple first stitched image features based on each first image frame, the stitching module 404 is also used to extract features from each first image frame to obtain embedded features of each first image frame; optical flow alignment is performed on the embedded features of each first image frame with the embedded features of the first image frame at its corresponding adjacent time node, and stitching is performed after the optical flow alignment to obtain multiple first stitched image features; there is a one-to-one correspondence between the first image frames and the first stitched image features.
[0137] In an exemplary embodiment, in terms of fusing each first stitched image feature with each first image frame based on the attention window to obtain the fused image feature of each first image frame, the above-mentioned fusion module 406 is also used to obtain multiple second stitched image features based on the attention window and each first stitched image feature; and fuse each second stitched image feature with the fused image feature of the first image frame at the previous time node corresponding thereto to obtain the fused image feature of each first image frame.
[0138] In an exemplary embodiment, the first spliced image features, the fused image features of each first image frame, and the second image frame are obtained based on the target model; as shown in Figure 4, the above-mentioned device also includes a training module 410, and the training module 410 is used to obtain the training model and the second image sequence; the second image sequence includes multiple first training image frames arranged in time sequence; the multiple first training image frames are blurred to obtain multiple second training image frames; the clarity of the first training image frames is higher than that of the second training image frames; the multiple second training image frames are input into the training model to obtain multiple third training image frames; the total loss function between the multiple first training image frames and the multiple third training image frames is determined; the training model is iteratively optimized based on the total loss function until the total loss function reaches the preset loss condition, then it is determined that the target model is obtained.
[0139] In an exemplary embodiment, in terms of inputting multiple second training image frames into the training model to obtain multiple third training image frames, the above-mentioned training module 410 is also used to input multiple second training image frames into the training model, so that the training model obtains multiple first training spliced image features based on each second training image frame; there is a one-to-one correspondence between the second training image frames and the first training spliced image features; based on the attention window, each first training spliced image feature is fused with each second training image frame to obtain a fused image feature of each second training image frame; based on the fused image features of each second training image frame, multiple third training image frames are obtained.
[0140] In an exemplary embodiment, in terms of blurring multiple first training image frames to obtain multiple second training image frames, the above-mentioned training module 410 is also used to perform multiple interpolation processing on the multiple first training image frames based on an interpolation algorithm to obtain multiple third training image frames; convert each third training image frame from a red, green and blue domain to a linear domain to obtain multiple third training image frames in the linear domain; the maximum pixel value of the third training image frame in the linear domain is a first value; the maximum pixel value of each third training image frame in the linear domain is increased to obtain multiple fourth training image frames; the maximum pixel value of the fourth training image frame is a second value, and the second value is greater than the first value; average the pixel values of the multiple fourth training image frames, and convert the fourth training image frames after the pixel value averaging from the linear domain to the red, green and blue domain to obtain multiple fourth training image frames in the red, green and blue domain; sharpen and blur the multiple fourth training image frames in the red, green and blue domain to obtain multiple second training image frames.
[0141] In an exemplary embodiment, in terms of determining the total loss function between multiple first training image frames and multiple third training image frames, the above-mentioned training module 410 is also used to respectively determine the pixel loss, optical flow loss and frequency domain loss between the multiple first training image frames and the multiple third training image frames; based on the pixel loss, optical flow loss and frequency domain loss, determine the total loss function between the multiple first training image frames and the multiple third training image frames.
[0142] Each module in the above-mentioned image restoration device can be implemented in whole or in part by software, hardware or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute the operations corresponding to each module.
[0143] In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be shown in FIG5. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. The processor, the memory and the input / output interface are connected via a system bus, and the communication interface is connected to the system bus via the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store image sequence data. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal via a network connection. When the computer program is executed by the processor, an image restoration method is implemented.
[0144] In one embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be shown in FIG6. The computer device includes a processor, a memory, an input / output interface, a communication interface, a display unit, and an input device. The processor, the memory, and the input / output interface are connected via a system bus, and the communication interface, the display unit, and the input device are connected to the system bus via the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be implemented through WIFI, a mobile cellular network, NFC (near field communication) or other technologies. When the computer program is executed by the processor, an image recovery method is implemented. The display unit of the computer device is used to form a visually visible image, and can be a display screen, a projection device or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen. The input device of the computer device can be a touch layer covered on the display screen, or a button, trackball or touchpad set on the computer device casing, or an external keyboard, touchpad or mouse, etc.
[0145] Those skilled in the art will understand that the structure shown in FIG. 6 is merely a block diagram of a partial structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different arrangement of components.
[0146] In an exemplary embodiment, a computer device is further provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps in the above-mentioned method embodiments when executing the computer program.
[0147] In an exemplary embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments are implemented.
[0148] In an exemplary embodiment, a computer program product is provided, including a computer program, and when the computer program is executed by a processor, the steps in the above method embodiments are implemented.
[0149] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards of relevant countries and regions.
[0150] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.
[0151] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0152] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. An image restoration method, characterized in that: The method comprises: Acquire a first image sequence; the first image sequence includes a plurality of first image frames arranged in time sequence; Obtaining a plurality of first stitched image features based on each of the first image frames; the first image frames and the first stitched image features correspond one to one; Based on the attention window, each of the first spliced image features is fused with each of the first image frames to obtain a fused image feature of each of the first image frames; Based on the fused image features of each of the first image frames, a plurality of the second image frames are obtained; the clarity of the second image frames is higher than that of the first image frames.
2. The method according to claim 1, characterized in that The obtaining a plurality of first stitched image features based on each of the first image frames includes: Performing feature extraction on each of the first image frames to obtain embedded features of each of the first image frames; Optical flow alignment is performed on the embedded features of each of the first image frames with the embedded features of the first image frames at the corresponding adjacent time nodes, and after the optical flow alignment, stitching is performed to obtain multiple first stitched image features; there is a one-to-one correspondence between the first image frames and the first stitched image features.
3. The method according to claim 1, characterized in that The step of fusing each of the first spliced image features with each of the first image frames based on the attention window to obtain fused image features of each of the first image frames includes: Based on the attention window and each of the first stitched image features, obtaining a plurality of second stitched image features; Each of the second spliced image features and the fused image features of the first image frame at the previous time node corresponding thereto are fused to obtain the fused image features of each of the first image frames.
4. The method according to claim 1, characterized in that: The first spliced image feature, the fused image features of each of the first image frames, and the second image frame are obtained based on a target model; the method further includes: Acquire a training model and a second image sequence; the second image sequence includes a plurality of first training image frames arranged in time sequence; Performing blur processing on the plurality of the first training image frames to obtain a plurality of second training image frames; the clarity of the first training image frames is higher than that of the second training image frames; Inputting a plurality of the second training image frames into the training model to obtain a plurality of third training image frames; determining a total loss function between the plurality of the first training image frames and the plurality of the third training image frames; The training model is iteratively optimized based on the total loss function until the total loss function reaches a preset loss condition, thereby determining that the target model is obtained.
5. The method according to claim 4, characterized in that The step of inputting the plurality of second training image frames into the training model to obtain a plurality of third training image frames comprises: Inputting a plurality of the second training image frames into the training model, so that the training model obtains a plurality of first training spliced image features based on each of the second training image frames; and the second training image frames correspond one to one to the first training spliced image features; Based on the attention window, each of the first training spliced image features is fused with each of the second training image frames to obtain fused image features of each of the second training image frames; Based on the fused image features of each of the second training image frames, a plurality of third training image frames are obtained.
6. The method according to claim 4, characterized in that The step of performing blur processing on the plurality of first training image frames to obtain a plurality of second training image frames comprises: Based on a frame interpolation algorithm, performing multiple frame interpolation processing on the plurality of first training image frames to obtain a plurality of third training image frames; Convert each of the third training image frames from the red, green and blue domains to a linear domain to obtain a plurality of third training image frames in the linear domain; the maximum pixel value of the third training image frame in the linear domain is a first value; Increasing the maximum pixel value of each third training image frame in the linear domain to obtain a plurality of fourth training image frames; the maximum pixel value of the fourth training image frame is a second value, and the second value is greater than the first value; Averaging pixel values of a plurality of fourth training image frames, and converting the fourth training image frames after the pixel values are averaged from a linear domain to a red, green, and blue domain to obtain a plurality of fourth training image frames in the red, green, and blue domains; The plurality of fourth training image frames in the red, green and blue domains are subjected to sharpening processing and blurring processing to obtain a plurality of second training image frames.
7. The method according to claim 4, characterized in that The determining of a total loss function between the plurality of first training image frames and the plurality of third training image frames comprises: respectively determining pixel loss, optical flow loss, and frequency domain loss between the first training image frames and the third training image frames; Based on the pixel loss, the optical flow loss, and the frequency domain loss, a total loss function between the first training image frames and the third training image frames is determined.
8. An image restoration device, characterized in that: The device comprises: An acquisition module, configured to acquire a first image sequence; the first image sequence comprises a plurality of first image frames arranged in time sequence; A stitching module, configured to obtain a plurality of first stitched image features based on each of the first image frames; the first image frames and the first stitched image features correspond one to one; a fusion module, configured to fuse each of the first spliced image features with each of the first image frames based on an attention window to obtain a fused image feature of each of the first image frames; A restoration module is used to obtain multiple second image frames based on the fused image features of each of the first image frames; the clarity of the second image frames is higher than that of the first image frames.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
