Image processing method, device, apparatus and storage medium
By performing masking and morphological restoration on video frame images, combined with an information propagation model, the image blurring problem caused by object occlusion and complex textures was solved, improving the accuracy and quality of image processing.
Patent Information
- Application Number
- CN202211029204.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-26
- Publication Date
- 2026-11-27
- Estimated Expiration
- 2042-08-26
AI Technical Summary
Existing technologies struggle to guarantee the accuracy and image quality of video frame image processing when faced with object occlusion and complex textures.
By performing masking on the target video frame image, initial and target mask templates are generated. Combined with morphological processing and information propagation models, blurred areas are repaired, and a neural network model is used for repair processing.
It improves the image quality of video frames, ensuring processing accuracy in situations with object occlusion and complex textures.
Smart Images

Figure CN117011156B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image processing technology, and in particular to an image processing method, apparatus, device and storage medium. Background Technology
[0002] With the development of technology, more and more applications support video playback. The videos played are processed. In order to ensure the accuracy of video processing, video filling technology has been proposed. Video filling is the process of processing video frame images in a video.
[0003] Currently, video filling technologies include optical flow-based methods and neural network model-based methods.
[0004] When processing video frame images based on optical flow, optical flow estimation is performed using adjacent video frame images. The optical flow is then applied to propagate the pixel gradient of the unmasked area to the masked area to fill the masked area with optical flow, thus completing the filling of the video frame image. However, the optical flow-based approach is only suitable for cases where the background moves simply, and is not suitable for cases where objects are occluded or the background undergoes complex motion.
[0005] When processing video frame images using a neural network model, the neural network model, being a single model, can achieve good reference pixel propagation even with complex background motion, thus filling in the video frame image. However, the generation capability of a single model is limited; for complex textures or object occlusion, the filled content is blurry, and the image quality of the video frame cannot be guaranteed.
[0006] Therefore, how to ensure the accuracy of image processing and further improve the image quality of processed video frames when there is object occlusion and complex textures is a technical problem that needs to be solved. Summary of the Invention
[0007] This application provides an image processing method, apparatus, device, and storage medium to ensure the accuracy of image processing and improve the image quality of processed video frame images.
[0008] In a first aspect, embodiments of this application provide an image processing method, the method comprising: The first type of objects contained in the acquired target video frame image are masked to obtain the masked image to be processed; the first type of objects are the image elements to be repaired. The first type of object in the image to be processed is repaired to obtain the first repaired image, and the corresponding initial image mask template is generated based on the initial blurred area in the first repaired image that does not meet the image quality. When the first number of initial blurred pixels contained in the initial image mask template reaches the first threshold, morphological processing is performed on the initial blurred region corresponding to the initial blurred pixels to obtain the image target mask template. When the second number of intermediate blurred pixels contained in the image target mask template reaches the second threshold, the pixel region corresponding to the intermediate blurred pixels is repaired in the first repaired image to obtain the second repaired image. Based on the second repaired image, the target repaired image corresponding to the image to be processed is determined.
[0009] Secondly, embodiments of this application provide an image processing apparatus, the apparatus comprising: The first processing unit is used to perform masking processing on the first type of objects contained in the acquired target video frame image to obtain the image to be processed after masking; the first type of objects are the image elements to be repaired. The second processing unit is used to repair the first type of object in the image to be processed, obtain the first repaired image, and generate the corresponding initial image mask template based on the initial blurred area in the first repaired image that does not meet the image quality. The third processing unit is used to perform morphological processing on the initial blurred region corresponding to the initial blurred pixels to obtain the image target mask template when the first number of initial blurred pixels contained in the initial image mask template reaches the first threshold. The fourth processing unit is used to perform repair processing on the pixel region corresponding to the intermediate blurred pixels in the first repair image when the second number of intermediate blurred pixels contained in the image target mask template reaches the second threshold, so as to obtain the second repair image. The determining unit is used to determine the target repair image corresponding to the image to be processed based on the second repair image.
[0010] In one possible implementation, the second processing unit is specifically used for: Input the video sequence containing the images to be processed into the trained information propagation model; In the trained information propagation model, based on the image elements in other video frames in the video sequence, the first type of object in the image to be processed is repaired to obtain the first repaired image, and based on the initial blurred area in the first repaired image that does not meet the image quality, the corresponding initial image mask template is generated.
[0011] In one possible implementation, the second processing unit is specifically used for: The initial object mask template is input into the trained information propagation model. The initial object mask template is determined after identifying the second type of object contained in the video frame image. The second type of object is the image element that needs to be retained. In the trained information propagation model, the object contour completion process is performed on the second type of object in the initial object mask template to obtain the object target mask template.
[0012] In one possible implementation, the determining unit is specifically used for: The initial mask template of the object is compared with the target mask template of the object to obtain the first comparison result, wherein the first comparison result is used to characterize whether the contours of the second type of object are consistent; Based on the first comparison result, the second repaired image is processed to obtain the target repaired image.
[0013] In one possible implementation, the determining unit is specifically used for: If the first comparison result indicates that the outlines of the second type of objects are inconsistent, then in the second repaired image, the pixel regions corresponding to the second type of objects are repaired to obtain the third repaired image, and the third repaired image is used as the target repaired image. If the first comparison result indicates that the outlines of the second type of object are consistent, then the second repaired image is used as the target repaired image.
[0014] In one possible implementation, the trained information propagation model is obtained by training it in the following way: Based on the training samples in the training sample dataset, perform iterative training on the information propagation model to be trained to obtain the trained information propagation model. During one iteration, the following operations are performed: Training samples are selected from the training sample dataset; the training samples are: historical images after masking the image elements to be repaired, and the object history mask templates corresponding to the image elements to be retained in the historical images; The training samples are input into the information propagation model to predict the predicted restoration image corresponding to the historical image. Based on the predicted blurred areas in the predicted restoration image that do not meet the image quality requirements, an image prediction mask template and an object prediction mask template corresponding to the object historical mask template are generated. The parameters of the information propagation model are adjusted by using a target loss function constructed based on the predicted inpainted image, the image prediction mask template, and the object prediction mask template.
[0015] In one possible implementation, the training samples also include: the actual repaired image corresponding to the historical image, and the actual object mask template corresponding to the object historical mask template; The target loss function is constructed as follows: A first type of loss function is constructed based on the predicted restoration image and the actual restoration image; a second type of loss function is constructed based on the image prediction mask template and the image intermediate mask template; and a third type of loss function is constructed based on the object prediction mask template and the object actual mask template. The image intermediate mask template is determined based on the predicted restoration image and the actual restoration image. The target loss function is constructed based on the first type of loss function, the second type of loss function, and the third type of loss function.
[0016] In one possible implementation, the first type of loss function is determined as follows: The first sub-loss function is determined based on the pixel values of the image difference between the predicted restored image and the actual restored image. Based on the second comparison result between the predicted restored image and the actual restored image, a second sub-loss function is determined, wherein the second comparison result is used to characterize whether the predicted restored image and the actual restored image are consistent; The first type of loss function is determined based on the first sub-loss function and the second sub-loss function.
[0017] In one possible implementation, the second type of loss function is determined as follows: Based on the pixel values of the mask difference between the image prediction mask template and the intermediate image mask template, a third sub-loss function is determined and used as the second type of loss function.
[0018] In one possible implementation, the third type of loss function is determined as follows: The fourth sub-loss function is determined based on the object difference pixel values between the object prediction mask template and the historical object actual mask template; The fifth sub-loss function is determined based on the similarity between the predicted object mask template and the actual historical object mask template; Based on the fourth and fifth sub-loss functions, the third type of loss function is determined.
[0019] In one possible implementation, after the second processing unit generates the corresponding initial image mask template, it is also used for: When the first number of initial blurred pixels contained in the initial mask template of the image is less than the first threshold, the first repaired image is used as the target repaired image corresponding to the image to be processed.
[0020] In one possible implementation, after obtaining the image target mask template, the third processing unit is further used for: When the second number of intermediate blurred pixels contained in the image target mask template is less than the second threshold, the first repaired image is used as the target repaired image corresponding to the image to be processed.
[0021] Thirdly, embodiments of this application provide an electronic device, including: a memory and a processor, wherein the memory is used to store computer instructions; and the processor is used to execute the computer instructions to implement the steps of the image processing method provided in embodiments of this application.
[0022] Fourthly, embodiments of this application provide a computer-readable storage medium storing computer instructions, which, when executed by a processor, implement the steps of the image processing method provided in embodiments of this application.
[0023] Fifthly, embodiments of this application provide a computer program product, which includes computer instructions stored in a computer-readable storage medium; when the processor of an electronic device reads the computer instructions from the computer-readable storage medium, the processor executes the computer instructions, causing the electronic device to perform the steps of the image processing method provided in embodiments of this application.
[0024] The beneficial effects of this application are as follows: This application provides an image processing method, apparatus, device, and storage medium, relating to the field of artificial intelligence, and particularly to the field of image processing technology. In this application embodiment, a first repaired image is further detected, and a corresponding initial image mask template is generated. When the first number of initial blurred pixels contained in the initial image mask template reaches a first threshold, morphological processing is performed on the blurred regions corresponding to the initial blurred pixels to obtain an image target mask template. Next, when the second number of intermediate blurred pixels contained in the image target mask template reaches a second threshold, repair processing is performed on the pixel regions corresponding to the intermediate blurred pixels in the first repaired image to obtain a second repaired image. Finally, based on the second repaired image, a target repaired image corresponding to the image to be processed is determined. Repair processing is performed on the blurred regions in the first repaired image, i.e., enhancement processing is performed on the low-quality regions in the first repaired image; therefore, the image quality of the second repaired image is improved, further ensuring the image quality of the target repaired image.
[0025] Other features and advantages of this application will be set forth in the description which follows, and will be apparent in part from the description, or may be learned by practicing the application. The objectives and other advantages of this application may be realized and obtained by means of the structures particularly pointed out in the written description, claims, and drawings. Attached Figure Description
[0026] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0027] Figure 1 This is a schematic diagram of the first type of image processing in the related technology; Figure 2 This is a schematic diagram of the second type of image processing in the related technology; Figure 3 This is a schematic diagram of an application scenario provided by an embodiment of this application; Figure 4 A flowchart of an image processing method provided in an embodiment of this application; Figure 5 This is a schematic diagram illustrating the filling process for a first type of object provided in an embodiment of this application; Figure 6 This is a schematic diagram of a first type of image processing provided in an embodiment of this application; Figure 7 This is a schematic diagram of a second type of image processing provided in an embodiment of this application; Figure 8 This is a schematic diagram of a third image processing method provided in an embodiment of this application; Figure 9 This is a schematic diagram illustrating morphological processing of an initial blurred region, provided as an embodiment of this application. Figure 10 This is a schematic diagram illustrating a method for repairing pixel regions corresponding to intermediate blurred pixels in an embodiment of this application. Figure 11 A flowchart of another image processing method provided in this application embodiment; Figure 12 A flowchart illustrating a specific implementation method for image processing provided in this application embodiment; Figure 13 This is a schematic diagram illustrating a specific implementation method of image processing provided in an embodiment of this application; Figure 14 A flowchart illustrating a training method for an information propagation model provided in this application embodiment; Figure 15 A structural diagram of an image processing apparatus provided in an embodiment of this application; Figure 16 A structural diagram of an electronic device provided in an embodiment of this application; Figure 17 This is another electronic device structure diagram provided for an embodiment of this application. Detailed Implementation
[0028] To make the objectives, technical solutions, and beneficial effects of this application clearer, the technical solutions in the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0029] To facilitate a better understanding of the technical solutions of this application by those skilled in the art, some of the concepts involved in this application are introduced below.
[0030] Video inpainting is a technique that uses information from unobstructed areas in a video to repair obscured areas; in other words, it uses information from unobstructed areas to appropriately fill in the obscured areas. Video inpainting requires two capabilities: one is the ability to utilize temporal information, which propagates available pixels from one frame to corresponding areas in other frames; the other is the ability to generate pixels for the corresponding areas if no available pixels are available in other frames, using both spatial and temporal information.
[0031] A visual identity system (VIS) is used to pre-identify the mask templates corresponding to objects in an image.
[0032] Image mask template: A selected image, graphic, or object is used to cover all or part of the image to be processed, thereby controlling the area or process of image processing. The specific image or object used for covering is called the image mask template. In optical image processing, image mask templates can be films, filters, etc. In digital image processing, image mask templates are two-dimensional matrix arrays, and sometimes multi-valued images are also used. In digital image processing, image mask templates are mainly used for: 1. Extracting regions of interest (ROIs): Multiplying a pre-made ROI mask template with the image to be processed yields the ROI image. Image values within the ROI remain unchanged, while image values outside the ROI are all 0; 2. Masking: Using a mask template to mask certain areas of an image, preventing them from participating in processing or the calculation of processing parameters, or processing or statistically analyzing only the masked area; 3. Structural feature extraction: Detecting and extracting structural features in the image similar to the mask using similarity variables or image matching methods; 4. Creating images with special shapes.
[0033] Morphological processing: This involves extracting image components from an image that are meaningful for expressing and describing the shape of regions, enabling subsequent recognition work to capture the most essential shape features of the target object. Morphological processing includes, but is not limited to: dilation and erosion, opening and closing operations, and morphology of grayscale images.
[0034] The word “exemplary” as used below means “serving as an example, embodiment, or illustration.” Any embodiment illustrated as an “exemplary” need not be construed as superior to or better than other embodiments.
[0035] The terms "first" and "second" used in this document are for descriptive purposes only and should not be construed as indicating relative importance or implying the number of technical features indicated. Therefore, features defined as "first" or "second" may explicitly or implicitly include one or more features. In the description of the embodiments of this application, unless otherwise stated, "multiple" means two or more.
[0036] The design concept of the embodiments of this application is briefly introduced below: With the development of technology, more and more applications support video playback. The videos played are processed. In order to ensure the accuracy of video processing, video restoration technology has been proposed. Video restoration is the process of processing video frame images in a video.
[0037] Currently, video restoration technologies include optical flow-based methods and neural network model-based methods.
[0038] The optical flow-based approach includes the following steps: Step 1, perform optical flow estimation using adjacent frames; Step 2, fill the occluded area with optical flow; Step 3, apply optical flow to propagate the pixel gradients of the unoccluded area to the occluded area; Step 4, perform Poisson reconstruction on the pixel gradients to generate RGB pixels; Step 5, if an image inpainting module is included, perform image inpainting on areas that cannot be filled by optical flow.
[0039] However, optical flow-based video inpainting methods perform well when the background is simply moving, producing images without blurring. With a good optical flow estimation module, the inpainting artifacts are difficult to detect. However, when the background undergoes complex movement or object occlusion occurs, the inpainting effect of optical flow-based methods is significantly affected. Furthermore, errors in optical flow estimation propagate and gradually increase in size, leading to inaccuracies in the inpainted content. See also... Figure 1 , Figure 1 This is a schematic diagram of the first type of image processing in the related technology.
[0040] The neural network model-based approach typically uses an encoder-decoder structure, which needs to balance inter-frame consistency with the naturalness of the generated pixels. It receives frame sequence information as input, processes it through the network, and directly outputs the repaired frame.
[0041] In related technologies, algorithms based on neural network models can achieve good reference pixel propagation effects and perform restoration effectively even in situations with complex background motion. However, current neural network models are single models, and the generation capacity of a single model is limited. For complex textures and object occlusion, the restoration results often exhibit blurriness, and limitations in graphics memory make it difficult to handle high-resolution inputs. Therefore, in cases of complex textures and object occlusion, the restored content remains blurry. (See also...) Figure 2 , Figure 2 This is a schematic diagram of the second type of image processing in related technologies.
[0042] It is evident that current image processing methods, limited by optical flow quality and model generation quality, cannot achieve truly robust results regardless of the approach employed. Therefore, ensuring accuracy and improving the image quality of processed video frames in situations involving object occlusion and complex textures remains a critical technical challenge.
[0043] In view of this, embodiments of this application provide an image processing method, apparatus, device, and storage medium to ensure the accuracy of image processing and improve the image quality of processed video frames.
[0044] In the image processing method provided in this application embodiment, a neural network model is applied to complete three types of video restoration; namely: 1. When there is complex background motion in the video, the video frame image is repaired based on the inter-frame pixel propagation model; 2. When the texture of a video frame image is complex, the blurred areas in the video frame image are repaired based on the image inpainting model; 3. When there is object occlusion in the video frame image, the object region in the video frame image is repaired based on the object repair model.
[0045] In this embodiment of the application, when it is determined that other elements need to be used to repair the first type of object in the video frame image, that is, when other elements are used to repair the image elements to be repaired in the video frame image: First, the first type of object contained in the acquired target video frame image is masked to obtain the masked image to be processed. At the same time, in order to ensure that the second type of object that needs to be retained during the processing is not affected, the second type of object contained in the video image is also identified to determine the corresponding object initial mask template. Then, the image to be processed and the object initial mask template are input into the trained information propagation model. The first type of object in the image to be processed is repaired through the information propagation model to obtain the first repaired image. At this time, the image elements to be repaired are repaired, and the initial blurred area in the first repaired image that does not meet the image quality is detected. The corresponding image initial mask template is generated based on the initial blurred area, and the object target mask template in the image to be processed is determined.
[0046] To ensure the accuracy of image processing during image restoration, after obtaining the first restored image, this embodiment further detects initial blurred regions in the first restored image that do not meet image quality requirements and generates corresponding initial image mask templates. When the first number of initial blurred pixels contained in the initial image mask template reaches a first threshold, morphological processing is performed on the initial blurred regions corresponding to the initial blurred pixels to obtain an image target mask template, making the blurred regions more regular. Next, the second number of intermediate blurred pixels contained in the image target mask template is determined. When the second number reaches a second threshold, the pixel regions corresponding to the intermediate blurred pixels in the first restored image are restored using an image restoration model to obtain a second restored image, thereby restoring the blurred regions in the first restored image, i.e., enhancing the low-quality regions in the first restored image. Finally, when it is determined that the outlines of the second type of objects in the object initial mask template and the object target mask template are inconsistent, the pixel regions corresponding to the second type of objects in the second restored image are restored using an object restoration model to obtain a third restored image, thereby restoring the occluded object regions, i.e., enhancing the low-quality regions in the second restored image.
[0047] In this embodiment, the blurred areas caused by complex textures and object occlusion are repaired, and the low-quality areas are enhanced, thereby improving the image quality of the target repair image.
[0048] In the embodiments of this application, the information propagation model, image restoration model, and object restoration model involve artificial intelligence (AI) and machine learning technologies, and are designed based on speech technology, natural language processing technology, and machine learning (ML) in artificial intelligence.
[0049] Artificial intelligence (AI) is the theory, methods, technology, and application systems that use digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, perceive the environment, acquire knowledge, and use that knowledge to achieve optimal results. In other words, AI is a comprehensive technology within computer science that attempts to understand the essence of intelligence and produce a new kind of intelligent machine that can react in a way similar to human intelligence.
[0050] Artificial intelligence (AI) studies the design principles and implementation methods of various intelligent machines, enabling them to perceive, reason, and make decisions. AI technology mainly includes computer vision, natural language processing, and machine learning / deep learning. With the research and advancement of AI technology, it is being researched and applied in multiple fields, such as smart homes, intelligent customer service, virtual assistants, smart speakers, intelligent marketing, autonomous driving, robotics, and smart healthcare. It is believed that with further technological development, AI will be applied in even more fields and play an increasingly important role.
[0051] Machine learning is a multidisciplinary field involving probability theory, statistics, approximation theory, convex analysis, and algorithm complexity theory, among others. It specifically studies how computers can simulate or implement human learning behavior to acquire new knowledge or skills and reorganize existing knowledge structures to continuously improve their performance. Compared to data mining, which focuses on finding patterns in large datasets, machine learning emphasizes algorithm design, enabling computers to automatically "learn" patterns from data and use these patterns to predict unknown data.
[0052] Machine learning is the core of artificial intelligence and the fundamental way to endow computers with intelligence. Its applications span all areas of artificial intelligence. Machine learning and deep learning typically include techniques such as artificial neural networks, belief networks, reinforcement learning, transfer learning, and inductive learning. Reinforcement learning (RL), also known as reward learning, evaluation learning, or enhancement learning, is one of the paradigms and methodologies of machine learning. It is used to describe and solve problems where an agent learns strategies to maximize rewards or achieve specific goals during its interaction with the environment.
[0053] The preferred embodiments of this application are described below with reference to the accompanying drawings. It should be understood that the preferred embodiments described herein are for illustration and explanation only and are not intended to limit this application. Furthermore, the embodiments and features in the embodiments of this application can be combined with each other without conflict.
[0054] See Figure 3 , Figure 3 This is a schematic diagram of an application scenario according to an embodiment of this application. The application scenario includes a terminal device 310 and a server 320, and the terminal device 310 and the server 320 can communicate with each other through a communication network.
[0055] In one alternative implementation, the communication network can be a wired network or a wireless network. Therefore, the terminal device 310 and the server 320 can be connected directly or indirectly via wired or wireless communication. For example, the terminal device 310 can be indirectly connected to the server 320 via a wireless access point, or the terminal device 310 can be directly connected to the server 320 via the Internet; this application does not impose any limitations on this.
[0056] In this embodiment, the terminal device 310 includes, but is not limited to, mobile phones, tablets, laptops, desktop computers, e-book readers, smart voice interaction devices, smart home appliances, vehicle terminals, and other devices; various clients can be installed on the terminal device, which can be applications that support video editing, video playback, and other functions (such as browsers, game software, etc.), or web pages, mini-programs, etc. Server 320 is the backend server corresponding to the client installed in terminal device 310. Server 320 can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDN), and big data and artificial intelligence platforms.
[0057] It should be noted that the image processing method in the embodiments of this application can be executed by an electronic device, which can be a server 320 or a terminal device 310. That is, the method can be executed by the server 320 or the terminal device 310 alone, or by the server 320 and the terminal device 310 together.
[0058] When the terminal device 310 executes independently, for example, the terminal device 310 can acquire the image to be processed after masking, perform repair processing on the image to be processed to obtain a first repaired image, determine the image initial mask template corresponding to the first repaired image, process the image initial mask template when the first number of initial blurred pixels contained in the image initial mask template reaches a first threshold, obtain the image target mask template, continue to repair the blurred positions in the first repaired image when the second number of intermediate blurred pixels contained in the image target mask template reaches a second threshold, obtain a second repaired image, and finally determine the target repaired image corresponding to the image to be processed based on the second repaired image.
[0059] When the server 320 executes independently, for example, the terminal device 310 can acquire video frame images and then send the video frame images to the server 320. The server 320 performs masking processing on the first type of objects contained in the acquired video frame images to obtain the masked image to be processed. The image to be processed is then repaired to obtain a first repaired image. The initial image mask template corresponding to the first repaired image is determined. When the first number of initial blurred pixels contained in the initial image mask template reaches a first threshold, the initial image mask template is processed to obtain an image target mask template. When the second number of intermediate blurred pixels contained in the image target mask template reaches a second threshold, the blurred positions in the first repaired image are further repaired to obtain a second repaired image. Finally, based on the second repaired image, the target repaired image corresponding to the image to be processed is determined.
[0060] When the server 320 and the terminal device 310 work together, for example, the terminal device 310 can obtain the image to be processed and perform repair processing on the image to be processed to obtain a first repaired image. Then, the first repaired image is sent to the server 320, and the server 320 determines the image initial mask template corresponding to the first repaired image. When the first number of initial blurred pixels contained in the image initial mask template reaches a first threshold, the image initial mask template is processed to obtain an image target mask template. When the second number of intermediate blurred pixels contained in the image target mask template reaches a second threshold, the blurred positions in the first repaired image are further repaired to obtain a second repaired image. Finally, based on the second repaired image, the target repaired image corresponding to the image to be processed is determined.
[0061] It should be noted that the following text mainly uses the example of the server running alone, and no specific limitations are made here.
[0062] In a specific implementation, a video frame image can be input into the terminal device 310, and the terminal device 310 sends the video frame image to the server 320. The server 320 can use the image processing method of the embodiment of this application to determine the target repair image corresponding to the image to be processed.
[0063] It should be noted that, Figure 3 The examples shown are merely illustrative; in reality, the number of terminal devices 310 and servers 320 is not limited and is not specifically limited in this embodiment.
[0064] In this embodiment of the application, when there are multiple servers 320, the multiple servers 320 can form a blockchain, and the server 320 is a node on the blockchain; as disclosed in the image processing method of this embodiment, the processing method of repair processing, morphological processing, etc. involved can be stored on the blockchain.
[0065] The image processing method provided by the exemplary embodiments of this application will be described below with reference to the accompanying drawings and the application scenarios described above. It should be noted that the above application scenarios are only shown to facilitate understanding of the spirit and principles of this application, and the embodiments of this application are not limited in any way in this respect.
[0066] See Figure 4 , Figure 4 A flowchart of an image processing method provided in this application embodiment includes the following steps: Step S400: Perform masking on the first type of objects contained in the acquired target video frame image to obtain the masked image to be processed; the first type of objects are the image elements to be repaired.
[0067] When performing video restoration, the first step is to obtain the video sequence that needs to be restored. and the corresponding mask template sequence ,in, This refers to the video frame image that needs video restoration, i.e., the video frame image before processing. This represents the mask template corresponding to the video frame image; the mask template is used to indicate the image elements to be repaired, that is, the mask area corresponding to the first type of object can be determined by the mask template.
[0068] Then, based on the mask region in the mask template, the corresponding video frame image is masked to obtain the masked image to be processed. Masking is Among them, mask template It is generally a binary matrix. "This is element-wise multiplication. Therefore, the image to be processed contains the repair area that needs to be repaired based on the mask region; it should be noted that the mask region is the repair area."
[0069] Image processing mainly involves repairing the areas of the image to be processed, that is, processing video frame images. The masked area in the image is repaired to obtain the processed video sequence. ,in, This indicates the video frame image after repair processing.
[0070] To ensure the quality of the repaired video frame images Compared to the video frame images before restoration processing The image content differs only in the masked area; the image content in other areas is natural and consistent in time and space. In this embodiment, firstly, the repaired area in the image to be processed is repaired to obtain a first repaired image; then, the first repaired image is detected to determine whether the image content in the first repaired image, except for the repaired area, is the same as the image content of the video frame image or the image to be processed before the repair processing, and to determine whether further filling of the first filling image is needed to obtain a target filling image in which the image content in the other areas, except for the repaired area, is consistent with the image content of the video frame image or the image to be processed before the repair processing.
[0071] Step S401: Perform repair processing on the first type of object in the image to be processed to obtain a first repaired image, and generate a corresponding initial image mask template based on the initial blurred area in the first repaired image that does not meet the image quality requirements.
[0072] The initial image mask template contains an initial blurred region; that is, the initial image mask template is the mask template for the initial blurred region.
[0073] In one possible implementation, firstly, a video sequence containing the images to be processed is... Input to the trained information propagation model Next, the trained information propagation model is used. The first type of object in the image to be processed is repaired to obtain the first repaired image. Based on the initial blurred areas in the first repaired image that do not meet image quality requirements, a corresponding initial image mask template is generated. Finally, through the trained information propagation model Output the first repaired image and image initial mask template The initial image mask template It indicates the areas in the first restored image where the restoration effect is poor, that is, the blurred areas in the first restored image.
[0074] Through the trained information propagation model When performing fill processing on the first type of object in the image to be processed: First, the video sequence containing the images to be processed is input into the trained information propagation model. ; Then, in the trained information propagation model In this process, referring to temporal and spatial information, and based on pixels in other video frames contained within the video sequence, the first type of object in the image to be processed is repaired. Specifically, in two or more adjacent video frames containing the image to be processed, the first pixel in the other video frames is used to fill the second pixel in the image to be processed, wherein the first pixel in the other video frames and the second pixel in the image to be processed are located in the same position in the video frame image. See also Figure 5 , Figure 5 This is a schematic diagram illustrating a filling process for a first type of object in an embodiment of this application.
[0075] Based on the initial blurred areas in the first repaired image that do not meet image quality requirements, a corresponding initial image mask template is generated. hour: First, the first restored image is divided into multiple pixel blocks according to its size; for example, the size of the first restored image is 7cm. If the pixel size is 7cm, then the size of each pixel block can be 0.7cm. 0.7cm. It should be noted that dividing the first restored image into multiple pixel blocks is only an example and not the only way. Next, the resolution of each pixel block is determined. Based on the resolution of each pixel block in the first filled image, pixel blocks that do not meet the image quality requirements are identified and used as initial blurred regions. Specifically, since higher resolution results in a clearer image and better image quality, the image quality in this embodiment can be set as a resolution threshold. When the resolution of a pixel block is lower than the resolution threshold, the pixel block is used as an initial blurred region that does not meet the image quality requirements. Finally, based on the initial blurred region, a masking process is performed on the initial blurred region to obtain the corresponding initial image mask template. .
[0076] In the embodiments of this application, the first type of object includes, but is not limited to: logo removal, subtitle removal, object removal, etc.; wherein, the object can be a moving person or thing, or a stationary person or thing.
[0077] For example, a video clip is created based on a video from a certain platform website. However, because the video obtained from the platform contains a station logo, it affects the viewing experience. In this case, the first type of object is the station logo, and the image processing technology provided in the embodiments of this application can be used to remove the station logo from the video frame image. See [link to relevant documentation]. Figure 6 , Figure 6 This is a schematic diagram of image processing provided in an embodiment of this application.
[0078] Similarly, subtitles can be removed from video frame images, see [link to relevant documentation]. Figure 7 , Figure 7 This is a schematic diagram of image processing provided in an embodiment of this application; or, to remove certain moving objects, such as pedestrians or vehicles, from a video frame image, see [link to relevant documentation]. Figure 8 , Figure 8 This is a schematic diagram of image processing provided in an embodiment of this application.
[0079] Step S402: When the first number of initial blurred pixels contained in the initial image mask template reaches the first threshold, morphological processing is performed on the initial blurred region corresponding to the initial blurred pixels to obtain the image target mask template.
[0080] Since the initial image mask template is determined based on pixel blocks that do not meet the image quality requirements, and each pixel block has its own corresponding resolution, where the resolution represents the number of pixels in the horizontal and vertical directions of the pixel block; therefore, based on the resolution of each pixel block, the number of pixels contained in that pixel block is determined, and the number of pixels contained in all pixel blocks that do not meet the image quality requirements in the initial image mask template is added together to obtain the first number of initial blurred pixels contained in the initial image mask template.
[0081] Specifically, the number of pixels in a pixel block equals the number of pixels in the horizontal direction. The number of pixels in the vertical direction.
[0082] In one possible implementation, when the first number of initially blurred pixels contained in the initial mask template of the image reaches a first threshold, it indicates that there are a large number of pixel blocks in the first repaired image that do not meet the image quality requirements.
[0083] However, when the pixel blocks that do not meet the image quality requirements in the first restored image are relatively scattered, that is, the initial blurred area is not concentrated, even if there are many pixel blocks that do not meet the image quality requirements in the first restored image, the blurred area of the image cannot be clearly displayed in the first restored image. At this time, it is determined that the restoration effect of the first restored image meets the standard, and there is no need to perform restoration processing on the first restored image, thus reducing the amount of computation.
[0084] Therefore, to ensure the accuracy of the repaired image and reduce computational load, it is essential to verify the first repaired image to determine whether its repair effect meets the standards. Based on this, in this embodiment, morphological processing is performed on the initial blurred regions corresponding to the initial blurred pixels in the initial image mask template to obtain the image target mask template, thereby connecting the initial blurred regions in the first repaired image and making the blurred regions more regular.
[0085] In one possible implementation, morphological processing is performed on the initial blurred region corresponding to the initial blurred pixels in the initial image mask template. When obtaining the image target mask template, dilation is employed. Operation and corrosion The operation involves performing an expansion followed by an erosion process on multiple initially blurred regions to connect them and obtain an image target mask template. The image target mask template is... .
[0086] See Figure 9 , Figure 9 This is a schematic diagram illustrating morphological processing of an initial blurred region according to an embodiment of this application. Assume the first restored image includes multiple initial blurred regions, A1 to A8. First, the initial blurred regions A1 to A8 are expanded according to a set expansion ratio to obtain expanded initial blurred regions B1 to B8, for example, by a factor of 10. Then, it is determined whether there is overlap among the expanded initial blurred regions B1 to B8, and the overlapping regions are merged to obtain at least one merged region. Finally, the merged region is eroded according to a shrinkage ratio to obtain an intermediate blurred region. The shrinkage ratio is determined based on the expansion ratio; when the expansion ratio is 10, the shrinkage ratio is 1 / 10.
[0087] At this point, the scattered initial blurred regions are connected to generate intermediate blurred regions. Each intermediate blurred region is equal to or larger than the initial blurred region. When the intermediate blurred region is relatively large, the blurred areas will be clearly visible in the first restored image, indicating that the restoration effect of the first restored image is not good and further restoration processing is needed. Therefore, the determination of whether to perform restoration processing on the first restored image is based on the image target mask template, which reduces the amount of computation while ensuring the restoration effect.
[0088] In another possible implementation, when the first number of initial blurred pixels contained in the initial mask template of the image is less than the first threshold, it indicates that the number of pixel blocks that do not meet the image quality requirements in the first repaired image has decreased, and the blurred areas of the image cannot be clearly displayed in the first repaired image. At this time, it is determined that the repair effect of the first repaired image is good, and the first repaired image is used as the target repaired image corresponding to the image to be processed. There is no need to perform morphological processing on the blurred areas corresponding to the initial blurred pixels, and there is no need to perform further processing on the first repaired image, so as to reduce the calculation process and improve the image processing efficiency.
[0089] Step S403: When the second number of intermediate blurred pixels contained in the image target mask template reaches the second threshold, in the first repaired image, the pixel region corresponding to the intermediate blurred pixels is repaired to obtain the second repaired image.
[0090] Since the scattered initial blurred regions have been connected in the image target mask template, when the second number of intermediate blurred pixels contained in the image target mask template reaches the second threshold, it indicates that the blurred regions of the image can be clearly displayed in the first repaired image, and it is determined that the repair effect of the first repaired image is not good. At this time, in order to ensure the accuracy of image processing, it is necessary to repair the pixel regions corresponding to the intermediate blurred pixels in the first repaired image.
[0091] In one possible implementation, when repairing the pixel region corresponding to the blurred pixel in the first repaired image: First, the first image to be repaired and the image target mask template are input into the trained image inpainting model. ; Next, in the trained image inpainting model In the first repaired image In the middle, based on the image target mask template is The pixel regions corresponding to the blurred pixels in the middle are repaired to obtain the second repaired image; the repair process of the trained image inpainting model is denoted as follows:
[0092] in, This indicates the second repaired image.
[0093] The pixel region corresponding to the blurred pixel in the middle is generally a region without reference or a region of moving objects.
[0094] In this embodiment of the application, the trained image inpainting model It is an image generation tool for blurred areas, such as Latent Diffusion Models (LDM) or Large Mask Inpainting (LaMa).
[0095] Among them, the LDM model is a high-resolution image synthesis training tool that has achieved highly competitive performance in image inpainting and various tasks (e.g., unconditional image generation, semantic scene synthesis, and super-resolution). The LaMa model is an image generation tool that can generalize well to higher resolution images.
[0096] The following section uses the LaMa model as an example to illustrate the repair process for the pixel region corresponding to the blurred pixels in the middle of the first repaired image.
[0097] When using the LaMa model to repair pixel regions corresponding to blurred pixels in the first repaired image: First, the 3-channel first repaired image and the 1-channel image target mask template are input into the LaMa model. Second, in the LaMa model, the image target mask template is inverted and multiplied with the first repaired image to obtain a first color image with the masked region. Next, the first color image and the image mask template are superimposed to obtain a 4-channel image. Then, the 4-channel image is downsampled, processed by Fast Fourier Convolutions (FFC), and the FFC-processed image is upsampled to obtain the second repaired image. During the FFC processing, the input image is divided into two parts based on channels, and these two parts follow two different branches. One branch is responsible for extracting local information, called the local branch. The other branch is responsible for extracting global information, called the global branch. The global branch uses FFC to extract global features. Finally, local and global information are cross-fused and then stitched together based on channels to obtain the final second restored image. See also Figure 10 , Figure 10 This is a schematic diagram illustrating a method for repairing pixel regions corresponding to intermediate blurred pixels in an embodiment of this application.
[0098] In this embodiment, Fast Fourier Convolution (FFT) enables the LaMa model to capture the receptive field of the entire image even in shallow layers. FFT not only improves the restoration quality of the LaMa model but also reduces its parameter count. Furthermore, the bias in FFT gives the LaMa model better generalization capabilities, allowing it to generate high-resolution image restoration results from low-resolution images. Using FFT allows it to operate simultaneously in the spatial and frequency domains without needing to revert to previous layers to understand the image context.
[0099] It should be noted that the first threshold and the second threshold can be the same or different. The method for determining the second number of intermediate blurred pixels is similar to the method for determining the first number of initial blurred pixels, and will not be repeated here.
[0100] In another possible implementation, when the second number of intermediate blurred pixels contained in the image target mask template is less than the second threshold, it indicates that the number of pixel blocks that do not meet the image quality requirements in the first repair image has decreased, the blurred areas of the image cannot be clearly displayed in the first repair image, and the repair effect of the first repair image is good. At this time, the first repair image is used as the target repair image corresponding to the image to be processed, and there is no need to continue to repair the blurred areas in the first repair image, so as to reduce the calculation process and improve the image processing efficiency.
[0101] Step S404: Based on the second repaired image, determine the target repaired image corresponding to the image to be processed.
[0102] In this application, a first type of object in the image to be processed is repaired to obtain a first repaired image. After the image elements to be repaired are repaired, in order to ensure the accuracy of image processing during the image repair process, initial blurred regions in the first repaired image that do not meet the image quality requirements are further detected, and corresponding initial image mask templates are generated. When it is determined that the first number of initial blurred pixels contained in the initial image mask template reaches a first threshold, morphological processing is performed on the blurred regions corresponding to the initial blurred pixels to obtain an image target mask template, so as to connect the scattered initial blurred regions and make the blurred regions more regular. Next, when it is determined that the second number of intermediate blurred pixels contained in the image target mask template reaches a second threshold, the pixel regions corresponding to the intermediate blurred pixels in the first repaired image are repaired to obtain a second repaired image. Finally, based on the second repaired image, the target repaired image corresponding to the image to be processed is determined. Repairing the blurred regions in the first repaired image is equivalent to enhancing the regions with low quality in the first repaired image. Since the regions with low quality in the first repaired image are enhanced to obtain the second repaired image, the image quality of the second repaired image is improved, thus further ensuring the image quality of the target repaired image.
[0103] In step S404 above, when determining the target repair image corresponding to the image to be processed based on the second repair image, the second repair image can be used as the target repair image, or the third repair image obtained after repairing the second repair image can be used as the target repair image.
[0104] Specifically, whether to use the second repaired image or the third repaired image as the target repaired image is determined based on whether the outline of the second type of object in the object's initial mask template and the object's target mask template are consistent.
[0105] The target mask template is determined as follows: First, set the initial mask template for the object. Input the trained information propagation model Next, in the already trained information propagation model In the middle, based on the trained information propagation model The object completion capability performs object contour completion processing on the second type of object in the initial object mask template to obtain the object target mask template. The initial mask template for the object is determined after identifying the second type of object contained in the video frame image. The second type of object is the image element that needs to be retained.
[0106] In one possible implementation, a visual recognition model is used. (Visual Identity System, VIS) determines the initial mask template for the second type of object in a video frame image. ; Record the visual recognition model Determine the initial mask template for the object. The process is as follows:
[0107] in, This is a video frame image.
[0108] In another possible implementation, a visual recognition model is used. (Visual Identity System, VIS) determines the initial mask template for the second type of object in the image to be processed. .
[0109] The visual recognition model is obtained by training on images with mask templates.
[0110] In this embodiment of the application, the initial mask template of the object is first compared with the target mask template of the object to obtain a first comparison result, wherein the first comparison result is used to characterize whether the contours of the second type of object are consistent; then, based on the first comparison result, the second repair image is processed to obtain the target repair image.
[0111] When comparing the initial object mask template with the target object mask template, the initial object mask template and the target object mask template can be completely overlapped to determine whether the second type of object mask region in the initial object mask template and the second type of object mask region in the target mask template are completely overlapped. If they are completely overlapped, the first comparison result is determined to characterize the contours of the second type of object as consistent; otherwise, the first comparison result is determined to characterize the contours of the second type of object as inconsistent.
[0112] When comparing the initial object mask template with the target object mask template, the number of third pixels in the second type of object mask region in the initial object mask template and the number of fourth pixels in the second type of object mask region in the target object mask template are determined. Based on the difference between the number of third pixels and the number of fourth pixels, a first comparison result is determined, wherein the difference between the number of third pixels and the number of fourth pixels characterizes the difference between the second type of object mask region in the initial object mask template and the target object mask template.
[0113] When determining the comparison result based on the difference between the number of third pixels and the number of fourth pixels, if the difference between the number of third pixels and the number of fourth pixels is less than a threshold, then the first comparison result is determined to be used to characterize the contours of the second type of objects as consistent; otherwise, the first comparison result is determined to be used to characterize the contours of the second type of objects as inconsistent.
[0114] In one possible implementation, when the first comparison result indicates that the contours of the second type of object are consistent, the second repaired image is used as the target repaired image.
[0115] In another possible implementation, when the first comparison result indicates that the contours of the second type of object are inconsistent, the second repaired image is processed to obtain the target repaired image: First, the second inpainted image and the object target mask template are input into the trained object inpainting model. ; Next, the object repair model is trained. In the second repaired image In the middle, based on object target mask template The pixel regions corresponding to the second type of object are repaired to obtain a third repaired image, which is then used as the target repaired image. The trained object repair model is denoted as... The repair process is as follows:
[0116] in, This represents the third restored image. This represents the visible pixel portion of the image to be processed, and That is, a color image including the mask regions of the first type of object and the mask regions of the second type of object.
[0117] In this embodiment, the trained object restoration model includes a Transformations structure. When using the object restoration model to restore the pixel region corresponding to the second type of object in the first restored image, the visible pixel portion is used to restore the pixel region corresponding to the second type of object based on the self-attention characteristics of Transformations.
[0118] See Figure 11 , Figure 11 Here is a flowchart of another image processing method in this application embodiment, which includes the following steps: Step S1100: Perform masking on the first type of objects contained in the acquired target video frame image to obtain the masked image to be processed; the first type of objects are the image elements to be repaired.
[0119] Step S1101: Identify the second type of object contained in the acquired video frame image, and determine the initial mask template of the object based on the identification result.
[0120] Step S1102: Perform repair processing on the first type of object in the image to be processed to obtain a first repaired image, and generate a corresponding initial image mask template based on the initial blurred area in the first repaired image that does not meet the image quality requirements.
[0121] Step S1103: Perform object outline completion processing on the second type of object in the initial object mask template to obtain the object target mask template.
[0122] Step S1104: When the first number of initial blurred pixels contained in the initial image mask template reaches the first threshold, morphological processing is performed on the blurred region corresponding to the initial blurred pixels to obtain the image target mask template.
[0123] Step S1105: When the second number of intermediate blurred pixels contained in the image target mask template reaches the second threshold, in the first repaired image, the pixel region corresponding to the intermediate blurred pixels is repaired to obtain the second repaired image.
[0124] Step S1106: Compare the initial mask template of the object with the target mask template of the object to determine whether the outline of the second type of object is consistent. If so, proceed to step S1107; otherwise, proceed to step S1108.
[0125] Step S1107: Use the second repair image as the target repair image.
[0126] In step S1108, the pixel regions corresponding to the second type of object are repaired in the second repaired image to obtain the third repaired image, and the third repaired image is used as the target repaired image.
[0127] See Figure 12 , Figure 12 An exemplary flowchart of a specific implementation method for image processing in this application is provided, including the following steps: Step S1200: Perform masking on the first type of objects contained in the acquired target video frame image to obtain the masked image to be processed. The first type of objects are the image elements to be repaired.
[0128] Step S1201: Using a visual recognition model, identify the second type of object contained in the acquired target video frame image, and determine the initial mask template of the second type of object based on the recognition result.
[0129] Step S1202: Input the video sequence containing the image to be processed and the mask template sequence containing the initial mask template of the object containing the image to be processed into the trained information propagation model, and obtain the first repair image, the initial mask template of the image and the target mask template of the object through the trained information propagation model.
[0130] That is, the trained information propagation model corresponds to two input parameters, namely: First input parameter: ,in ; The first input parameter is a video sequence containing images to be processed, where each frame of the video sequence can be an image to be processed. ; Second input parameter: ,in, ; The first input parameter is a sequence of mask templates containing initial mask templates for objects of the image to be processed. Each mask template in this sequence can be an initial mask template for an object corresponding to the image to be processed; for example: for Initial mask template for the object; Let the trained information propagation model be denoted as... The first restored image is denoted as . Let the target mask template be denoted as Let the initial image mask template be... Then we have:
[0131] Step S1203: Determine whether the first number of initial blurred pixels contained in the initial mask template of the image has reached the first threshold. If yes, proceed to step S1204; otherwise, proceed to step S1210.
[0132] Step S1204: Perform morphological processing on the blurred region corresponding to the initial blurred pixels to obtain the image target mask template.
[0133] Step S1205: Determine whether the second number of intermediate blurred pixels contained in the image target mask template has reached the second threshold. If yes, proceed to step S1206; otherwise, proceed to step S1210.
[0134] Step S1206: Input the image target mask template and the first repair image into the trained image repair model, and obtain the second repair image through the trained image repair model.
[0135] Step S1207: Determine whether the outline of the second type of object contained in the object's initial mask template is consistent with that in the object's target mask template. If yes, proceed to step S1211; otherwise, proceed to step S1208.
[0136] Step S1208: Input the second repaired image and the object target mask template into the trained object repair model, and obtain the third repaired image through the trained object repair model.
[0137] Step S1209: Use the third repaired image as the target repaired image corresponding to the image to be processed.
[0138] Step S1210: Use the first repair image as the target repair image corresponding to the image to be processed.
[0139] Step S1211: Use the second repaired image as the target repaired image corresponding to the image to be processed.
[0140] See Figure 13 , Figure 13 and Figure 12 Correspondingly, Figure 13 A schematic diagram of a specific implementation method for image processing in the embodiments of this application is provided.
[0141] from Figure 13 As can be seen from the model used, the image processing process is divided into three stages, which will be explained in detail below.
[0142] Phase 1: The image to be processed and the initial object mask template are input into the trained information propagation model. In this model, based on inter-frame reference information, available pixels in corresponding regions of other video frames continuous with the image to be processed are used to perform inter-frame reference information inpainting. This trained model also possesses a certain image generation capability, using spatial and temporal information to generate pixels for areas without available pixels in other video frames, thus completing the image inpainting and obtaining the first repaired image. Simultaneously, the model also has object completion capability, performing contour completion processing on the second type of object in the image to be processed to obtain the object target mask template. Furthermore, the trained model can determine the initial image mask template corresponding to the initial blurred region based on the repaired image. Finally, the trained model in Phase 1 simultaneously outputs the first repaired image, the initial image mask template corresponding to the initially blurred region in the first repaired image, and the object target mask template.
[0143] Phase Two: First, determine the first number of initial blurred pixels in the initial blurred region of the initial image mask template. Then, determine if this first number is greater than a first threshold. If the first number of initial blurred pixels in the initial blurred region is less than the first threshold, ignore the initial blurred region and output the first repaired image as the target repaired image without further processing. If the first number of initial blurred pixels in the initial blurred region reaches the first threshold, apply dilation and erosion operations to connect the scattered initial blurred regions to obtain the processed image target mask template. After obtaining the image target mask template, determine the second number of intermediate blurred pixels in the blurred region of the image target mask template. Then, determine if this second number is greater than a second threshold. If the second number of intermediate blurred pixels is less than the second threshold, ignore the blurred region and output the first repaired image as the target repaired image without further processing. If the second number of intermediate blurred pixels reaches the second threshold, call the image repair model and repair the pixel positions of the blurred region in the image target mask template on the first repaired image based on the processed image target mask template.
[0144] Phase 3: Based on Phase 2, if the target mask template is relatively... Mask of the second type of object If the number of changed pixels is less than the third threshold, the mask of the second type of object is considered to be... If there is no object contour to be completed, the second repaired image is used as the target repaired image; if the object target mask template is relative Mask of the second type of object If the number of changed pixels reaches the third threshold, the object repair model is invoked to apply the mask to the second type of object. The pixels are repaired, overwriting the repair content of the image repair module, to obtain a third repaired image, and the third repaired image is used as the target repaired image.
[0145] In this application, a first repair image, an initial image mask template, and an object target mask template are determined based on the image to be processed and the initial object mask template using a trained information propagation model. Reference pixel propagation is achieved based on the trained information propagation model, enabling better repair of image content with complex background motion. After the image elements to be repaired are repaired and the first repaired image is obtained, to ensure the accuracy of image processing during the image repair process, when the first number of initial blurred pixels contained in the initial image mask template reaches a first threshold, morphological processing is performed on the blurred regions corresponding to the initial blurred pixels to obtain the image target mask template. This connects the scattered initial blurred regions and makes the blurred regions more regular, improving the accuracy of judgment. Next, the second number of intermediate blurred pixels contained in the image target mask template is determined. When the second number reaches a second threshold, the pixel regions corresponding to the intermediate blurred pixels in the first repaired image are repaired using the image repair model to obtain the second repaired image. This achieves the repair processing of the blurred regions in the first repaired image, that is, the enhancement of the low-quality regions in the first repaired image. Finally, when it is determined that the contours of the second type of object in the object initial mask template and the object target mask template are inconsistent, the pixel regions corresponding to the second type of object are repaired using the object repair model in the second repaired image to obtain the third repaired image. This achieves the repair processing of the occluded object region, that is, the enhancement of the low-quality regions in the second repaired image. It can repair blurred areas caused by complex textures and object occlusion, and enhance areas with low quality, thereby improving the image quality of the target repair image.
[0146] In the embodiments of this application, the image processing of the image to be processed involves a trained information propagation model, a trained image inpainting model, and a trained object inpainting model. Before using the models, they need to be trained to ensure the accuracy of the model output. The model training process will be described in detail below.
[0147] I. Information dissemination model.
[0148] In this embodiment, the trained information propagation model is obtained by performing iterative training on the information propagation model to be trained based on the training samples in the training sample dataset.
[0149] The following section uses a single iterative cycle as an example to illustrate the training process of the information propagation model to be trained.
[0150] See Figure 14 , Figure 14 The training method for an information propagation model in this application includes the following steps: Step S1400: Obtain the training sample dataset. The training sample dataset includes at least one set of training samples. Each set of training samples includes: a historical image after masking the image elements to be repaired and the corresponding actual repaired image, as well as the object historical mask template and the corresponding object actual mask template corresponding to the image elements to be retained in the historical image.
[0151] Step S1401: Select training samples from the training sample dataset and input the training samples into the information propagation model to be trained.
[0152] Step S1402: Using the information propagation model to be trained, predict the predicted restoration image corresponding to the historical image, and based on the predicted blurred areas in the predicted restoration image that do not meet the image quality requirements, generate an image prediction mask template and an object prediction mask template corresponding to the object historical mask template.
[0153] Step S1403: Construct a first type of loss function based on the predicted repair image and the actual repair image; construct a second type of loss function based on the image prediction mask template and the image intermediate mask template; and construct a third type of loss function based on the object prediction mask template and the object actual mask template. The image intermediate mask template is determined based on the predicted repair image and the actual repair image.
[0154] In one possible implementation, the first type of loss function is determined as follows: Based on the pixel value difference between the predicted and actual restored images, the first sub-loss function is determined; that is, using... The loss function is used to construct the first sub-loss function, which is denoted as . ; Based on the second comparison result between the predicted and actual restored images, a second sub-loss function is determined, where the second comparison result characterizes whether the predicted and actual restored images are consistent; that is, adversarial loss is used. Construct a second sub-loss function, denoted as . ; The first type of loss function is determined based on the first sub-loss function and the second sub-loss function.
[0155] In one possible implementation, the second type of loss function is determined as follows: Based on the pixel values of the mask difference between the image prediction mask template and the intermediate image mask template, a third sub-loss function is determined and used as the second type of loss function; whereby the image prediction mask template is the number of pixels in the predicted blurred regions of the inpainted image that are not of satisfactory image quality. This is obtained when the value exceeds a set threshold.
[0156] That is, use The loss function is used to construct a third sub-loss function, which is denoted as . ,and
[0157] in, For RGB 3 channels, H W represents an H Let W be a matrix of size W. for The predicted value, To predict the actual difference between the restored image and the actual restored image, that is, to predict the number of pixels in the actual blurred area in the restored image compared to the actual restored image, and , Indicates the predicted image restoration. For the actual image restoration.
[0158] In one possible implementation, the third type of loss function is determined as follows: The fourth sub-loss function is determined based on the object difference pixel values between the predicted object mask template and the historical actual object mask template; that is, using... The loss constructs a fourth sub-loss function, denoted as . ,and ,in Represents the object prediction mask template. This represents the actual mask template of the historical object; Based on the similarity between the predicted object mask template and the actual historical object mask templates, a fifth sub-loss function is determined; that is, the Dice loss is used. Construct a fifth sub-loss function, denoted as . , ,in Represents the object prediction mask template. This represents the actual mask template of the historical object; Based on the fourth and fifth sub-loss functions, the third type of loss function is determined.
[0159] Step S1404: Construct the target loss function based on the first type of loss function, the second type of loss function, and the third type of loss function.
[0160] The target loss function is:
[0161] Step S1405: Based on the target loss function, adjust the parameters of the information propagation model to be trained.
[0162] II. Image Restoration Model.
[0163] In this embodiment of the application, the image restoration model uses latent diffusion models (LDM) or large mask inpainting (LaMa) and other image generation tools for blurred areas.
[0164] When training the LDM model, the original image, the corresponding image mask template, the guiding text, and the target image are input into the LDM model to be trained. In the LDM model, the foreground and background parts are repeatedly mixed based on the guiding text to obtain the predicted image. A loss function is constructed based on the predicted image and the original image, and the parameters of the LDM model to be trained are adjusted based on the loss function. The foreground part is the part that needs to be repaired, the background part is the part of the original image other than the part that needs to be repaired, and the target image is the image that meets the repair standard after the original image is repaired.
[0165] When training the LaMa model, the original image, its corresponding image mask template, and the target image are input into the LaMa model to be trained. Within the LaMa model, the original image containing the image mask and the image mask of the original image are superimposed to obtain a 4-channel image. This 4-channel image is downsampled, then processed by Fast Fourier Convolution, and finally upsampled to obtain the predicted image. An adversarial loss and a receptive field perception loss are constructed based on the original and predicted images to create a loss function. The parameters of the LaMa model to be trained are then adjusted based on this loss function. The receptive field is the size of the region mapped onto the original image from the feature map output by each layer of the convolutional neural network.
[0166] III. Object Repair Model.
[0167] In this embodiment, the object repair model uses a transformer as the network structure, such as the Spatio-Temporal Transformations for Video Inpainting (STTN).
[0168] During the training of the object restoration model, the original image and the original image containing the masked region are input into the object restoration model to be trained. The model then uses self-attention to simultaneously fill in the masked regions of all input images to obtain the predicted image. A loss function is constructed based on the predicted image and the original image, and the parameters of the object restoration model to be trained are adjusted based on this loss function. The loss function used during training employs... Losses and Countermeasures .
[0169] It should be noted that the models involved in the embodiments of this application can be trained individually or jointly.
[0170] This application proposes training methods for information propagation models, image restoration models, and object restoration models to characterize the accuracy of the output results of these models. Furthermore, in the embodiments of this application, when using the models for image processing, the accuracy of image processing is improved, thereby enhancing the image quality of the processed video frame images.
[0171] Based on the same inventive concept as the above-described method embodiments, this application also provides a digital image processing device. The principle of the device in solving the problem is similar to that of the above-described method. Therefore, the implementation of the device can refer to the implementation of the above-described method, and repeated details will not be described again.
[0172] See Figure 15 , Figure 15 An exemplary embodiment of this application provides an image processing apparatus 1500, which includes: The first processing unit 1501 is used to perform masking processing on the first type of objects contained in the acquired target video frame image to obtain the image to be processed after masking; the first type of objects are image elements to be repaired. The second processing unit 1502 is used to perform repair processing on the first type of object in the image to be processed, obtain the first repaired image, and generate a corresponding initial image mask template based on the initial blurred area in the first repaired image that does not meet the image quality. The third processing unit 1503 is used to perform morphological processing on the initial blurred region corresponding to the initial blurred pixels to obtain the image target mask template when the first number of initial blurred pixels contained in the initial image mask template reaches the first threshold. The fourth processing unit 1504 is used to perform repair processing on the pixel region corresponding to the intermediate blurred pixels in the first repair image when the second number of intermediate blurred pixels contained in the image target mask template reaches the second threshold, so as to obtain the second repair image. The determining unit 1505 is used to determine the target repair image corresponding to the image to be processed based on the second repair image.
[0173] In one possible implementation, the second processing unit 1502 is specifically used for: Input the video sequence containing the images to be processed into the trained information propagation model; In the trained information propagation model, based on the image elements in other video frames in the video sequence, the first type of object in the image to be processed is repaired to obtain the first repaired image, and based on the initial blurred area in the first repaired image that does not meet the image quality, the corresponding initial image mask template is generated.
[0174] In one possible implementation, the second processing unit 1502 is specifically used for: The initial object mask template is input into the trained information propagation model. The initial object mask template is determined after identifying the second type of object contained in the video frame image. The second type of object is the image element that needs to be retained. In the trained information propagation model, the object contour completion process is performed on the second type of object in the initial object mask template to obtain the object target mask template.
[0175] In one possible implementation, the determining unit 1505 is specifically used for: The initial mask template of the object is compared with the target mask template of the object to obtain the first comparison result, wherein the first comparison result is used to characterize whether the contours of the second type of object are consistent; Based on the first comparison result, the second repaired image is processed to obtain the target repaired image.
[0176] In one possible implementation, the determining unit 1505 is specifically used for: If the first comparison result indicates that the outlines of the second type of objects are inconsistent, then in the second repaired image, the pixel regions corresponding to the second type of objects are repaired to obtain the third repaired image, and the third repaired image is used as the target repaired image. If the first comparison result indicates that the outlines of the second type of object are consistent, then the second repaired image is used as the target repaired image.
[0177] In one possible implementation, the trained information propagation model is obtained by training it in the following way: Based on the training samples in the training sample dataset, perform iterative training on the information propagation model to be trained to obtain the trained information propagation model. During one iteration, the following operations are performed: Training samples are selected from the training sample dataset; the training samples are: historical images after masking the image elements to be repaired, and the object history mask templates corresponding to the image elements to be retained in the historical images; The training samples are input into the information propagation model to predict the predicted restoration image corresponding to the historical image. Based on the predicted blurred areas in the predicted restoration image that do not meet the image quality requirements, an image prediction mask template and an object prediction mask template corresponding to the object historical mask template are generated. The parameters of the information propagation model are adjusted by using a target loss function constructed based on the predicted inpainted image, the image prediction mask template, and the object prediction mask template.
[0178] In one possible implementation, the training samples also include: the actual repaired image corresponding to the historical image, and the actual object mask template corresponding to the object historical mask template; The target loss function is constructed as follows: A first type of loss function is constructed based on the predicted restoration image and the actual restoration image; a second type of loss function is constructed based on the image prediction mask template and the image intermediate mask template; and a third type of loss function is constructed based on the object prediction mask template and the object actual mask template. The image intermediate mask template is determined based on the predicted restoration image and the actual restoration image. The target loss function is constructed based on the first type of loss function, the second type of loss function, and the third type of loss function.
[0179] In one possible implementation, the first type of loss function is determined as follows: The first sub-loss function is determined based on the pixel values of the image difference between the predicted restored image and the actual restored image. Based on the second comparison result between the predicted restored image and the actual restored image, a second sub-loss function is determined, wherein the second comparison result is used to characterize whether the predicted restored image and the actual restored image are consistent; The first type of loss function is determined based on the first sub-loss function and the second sub-loss function.
[0180] In one possible implementation, the second type of loss function is determined as follows: Based on the pixel values of the mask difference between the image prediction mask template and the intermediate image mask template, a third sub-loss function is determined and used as the second type of loss function.
[0181] In one possible implementation, the third type of loss function is determined as follows: The fourth sub-loss function is determined based on the object difference pixel values between the object prediction mask template and the historical object actual mask template; The fifth sub-loss function is determined based on the similarity between the predicted object mask template and the actual historical object mask template; Based on the fourth and fifth sub-loss functions, the third type of loss function is determined.
[0182] In one possible implementation, after the second processing unit 1502 generates the corresponding initial image mask template, it is further used for: When the first number of initial blurred pixels contained in the initial mask template of the image is less than the first threshold, the first repaired image is used as the target repaired image corresponding to the image to be processed.
[0183] In one possible implementation, after obtaining the image target mask template, the third processing unit 1503 is further used for: When the second number of intermediate blurred pixels contained in the image target mask template is less than the second threshold, the first repaired image is used as the target repaired image corresponding to the image to be processed.
[0184] For ease of description, the above sections are divided into units (or modules) according to their functions and described separately. Of course, in implementing this application, the functions of each unit (or module) can be implemented in one or more software or hardware components.
[0185] Those skilled in the art will understand that various aspects of this application can be implemented as a system, method, or program product. Therefore, various aspects of this application can be specifically implemented in the following forms: a completely hardware implementation, a completely software implementation (including firmware, microcode, etc.), or a combination of hardware and software implementations, collectively referred to herein as a "circuit," "module," or "system."
[0186] Having described the image processing method and apparatus according to exemplary embodiments of this application, we will now describe an electronic device for image processing according to another exemplary embodiment of this application.
[0187] Based on the same inventive concept as the method embodiments described above, this application also provides an electronic device, which can be a server. In this embodiment, the structure of the electronic device can be as follows: Figure 16 As shown, it includes a memory 1601, a communication module 1603, and one or more processors 1602.
[0188] The memory 1601 is used to store computer programs executed by the processor 1602. The memory 1601 may mainly include a program storage area and a data storage area. The program storage area may store the operating system and programs required to run instant messaging functions, etc.; the data storage area may store various instant messaging information and operation instruction sets, etc.
[0189] Memory 1601 may be volatile memory, such as random-access memory (RAM); memory 1601 may also be non-volatile memory, such as read-only memory, flash memory, hard disk drive (HDD), or solid-state drive (SSD); or memory 1601 may be any other medium capable of carrying or storing a desired computer program having the form of instructions or data structures and accessible by a computer, but is not limited thereto. Memory 1601 may be a combination of the above-described memories.
[0190] The processor 1602 may include one or more central processing units (CPUs) or digital processing units, etc. The processor 1602 is used to implement the above-described image processing method when it calls a computer program stored in the memory 1601.
[0191] The communication module 1603 is used to communicate with terminal devices and other servers.
[0192] This application embodiment does not limit the specific connection medium between the memory 1601, communication module 1603, and processor 1602. This application embodiment... Figure 16 The memory 1601 and the processor 1602 are connected via a bus 1604, and the bus 1604 is in Figure 16 The diagram uses thick lines to describe the connections between other components; these are for illustrative purposes only and should not be considered limiting. The 1604 bus can be divided into address bus, data bus, control bus, etc. For ease of description, Figure 16 It is described using only a thick line, but does not indicate that there is only one bus or one type of bus.
[0193] The memory 1601 stores a computer storage medium containing computer-executable instructions for implementing the image processing method of this application embodiment. The processor 1602 executes the image processing method described above.
[0194] In another embodiment, the electronic device may also be other electronic devices, such as... Figure 3 The terminal device 310 is shown. In this embodiment, the electronic device can be structured as follows: Figure 17As shown, it includes components such as: communication component 1710, memory 1720, display unit 1730, camera 1740, sensor 1750, audio circuit 1760, Bluetooth module 1770, processor 1780, etc.
[0195] The communication component 1710 is used to communicate with the server. In some embodiments, it may include a Wireless Fidelity (WiFi) module, which is a short-range wireless transmission technology, and the electronic device can help the user send and receive information through the WiFi module.
[0196] The memory 1720 can be used to store software programs and data. The processor 1780 executes various functions of the terminal device 310 and performs data processing by running the software programs or data stored in the memory 1720. The memory 1720 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other volatile solid-state storage device. The memory 1720 stores an operating system that enables the terminal device 310 to run. In this application, the memory 1720 may store the operating system and various application programs, and may also store code that executes the image processing method of the embodiments of this application.
[0197] The display unit 1730 can also be used to display information input by the user or information provided to the user, as well as a graphical user interface (GUI) for various menus of the terminal device 310. Specifically, the display unit 1730 may include a display screen 1732 disposed on the front of the terminal device 310. The display screen 1732 may be configured as a liquid crystal display, a light-emitting diode, or the like. The display unit 1730 can be used to display the target repair image, etc., in the embodiments of this application.
[0198] The display unit 1730 can also be used to receive input digital or character information and generate signal inputs related to user settings and function control of the terminal device 310. Specifically, the display unit 1730 may include a touch screen 1731 disposed on the front of the terminal device 310, which can collect touch operations of the user on or near it, such as clicking a button, dragging a scroll box, etc.
[0199] The touchscreen 1731 can be placed over the display screen 1732, or the touchscreen 1731 and the display screen 1732 can be integrated to realize the input and output functions of the terminal device 310. After integration, it can be referred to as a touch display screen. In this application, the display unit 1730 can display the application program and the corresponding operation steps.
[0200] Camera 1740 can be used to capture still images. There can be one or multiple cameras 1740. An object is projected onto a photosensitive element through a lens, generating an optical image. 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, which is then transmitted to processor 1780 to be converted into a digital image signal.
[0201] The terminal device may also include at least one sensor 1750, such as an accelerometer 1751, a proximity sensor 1752, a fingerprint sensor 1753, and a temperature sensor 1754. The terminal device may also be equipped with other sensors such as a gyroscope, barometer, hygrometer, thermometer, infrared sensor, light sensor, and motion sensor.
[0202] Audio circuitry 1760, speaker 1761, and microphone 1762 provide an audio interface between the user and terminal device 310. Audio circuitry 1760 converts received audio data into electrical signals, which are then transmitted to speaker 1761, where they are converted into sound signals for output. Terminal device 310 may also be equipped with volume buttons for adjusting the volume of the sound signal. Conversely, microphone 1762 converts collected sound signals into electrical signals, which are then received by audio circuitry 1760, converted back into audio data, and output to communication component 1710 for transmission to, for example, another terminal device 310, or to memory 1720 for further processing.
[0203] The Bluetooth module 1770 is used to interact with other Bluetooth devices that also have a Bluetooth module via the Bluetooth protocol. For example, a terminal device can establish a Bluetooth connection with a wearable electronic device (such as a smartwatch) that also has a Bluetooth module through the Bluetooth module 1770, thereby exchanging data.
[0204] The processor 1780 is the control center of the terminal device, connecting various parts of the terminal through various interfaces and lines. It executes various functions and processes data by running or executing software programs stored in the memory 1720 and calling data stored in the memory 1720. In some embodiments, the processor 1780 may include one or more processing units; the processor 1780 may also integrate an application processor and a baseband processor, wherein the application processor mainly handles the operating system, user interface, and applications, and the baseband processor mainly handles wireless communication. It is understood that the baseband processor may not be integrated into the processor 1780. In this application, the processor 1780 can run the operating system, applications, user interface display and touch response, and the image processing method of the embodiments of this application. Furthermore, the processor 1780 is coupled to the display unit 1730.
[0205] In some possible implementations, various aspects of the image processing method provided in this application may also be implemented in the form of a program product, which includes a computer program that, when run on an electronic device, causes the electronic device to perform the steps of the image processing method according to the various exemplary embodiments of this application described above.
[0206] The program product may employ any combination of one or more readable media. A readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of readable storage media (a non-exhaustive list) include: electrical connections having one or more wires, portable disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.
[0207] The program product of the embodiments of this application may employ a portable compact disc read-only memory (CD-ROM) and include a computer program, and may run on a computing device. However, the program product of this application is not limited thereto. In this document, the readable storage medium may be any tangible medium that contains or stores a program that may be used by or in conjunction with a command execution system, apparatus, or device.
[0208] A readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, carrying a readable computer program. This propagated data signal may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A readable signal medium may also be any readable medium other than a readable storage medium, capable of sending, propagating, or transmitting a program for use by or in conjunction with a command execution system, apparatus, or device.
[0209] Computer programs contained on readable media may be transmitted using any suitable medium, including but not limited to wireless, wired, optical fiber, RF, etc., or any suitable combination thereof.
[0210] It should be noted that although several units or sub-units of the device have been mentioned in the detailed description above, this division is merely exemplary and not mandatory. In fact, according to embodiments of this application, the features and functions of two or more units described above can be embodied in one unit. Conversely, the features and functions of one unit described above can be further divided and embodied by multiple units.
[0211] Furthermore, although the operations of the method of this application are described in a specific order in the accompanying drawings, this does not require or imply that these operations must be performed in that specific order, or that all the operations shown must be performed to achieve the desired result. Additionally or alternatively, certain steps may be omitted, multiple steps may be combined into one step, and / or one step may be broken down into multiple steps.
[0212] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing a computer-usable computer program.
[0213] Although preferred embodiments of this application have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of this application.
[0214] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the spirit and scope of this application. Therefore, if such modifications and variations fall within the scope of the claims of this application and their equivalents, this application also intends to include such modifications and variations.
Claims
1. An image processing method, characterized in that, The method includes: The first type of objects contained in the acquired target video frame image are masked to obtain the masked image to be processed; the first type of objects are the image elements to be repaired. The first type of object in the image to be processed is repaired to obtain a first repaired image, and a corresponding initial image mask template is generated based on the initial blurred area in the first repaired image that does not meet the image quality requirements. When the first number of initial blurred pixels contained in the initial image mask template reaches a first threshold, morphological processing is performed on the initial blurred region corresponding to the initial blurred pixels to obtain the image target mask template. When the second number of intermediate blurred pixels contained in the image target mask template reaches the second threshold, the pixel region corresponding to the intermediate blurred pixels is repaired in the first repaired image to obtain the second repaired image. Based on the second repaired image, the target repaired image corresponding to the image to be processed is determined; The step of generating a corresponding initial image mask template based on the initial blurred regions in the first repaired image that do not meet image quality requirements includes: According to the size of the first restored image, the first restored image is divided into multiple pixel blocks, and the resolution of each pixel block is determined; Based on the resolution of each pixel block, pixel blocks in the first repaired image that do not meet the image quality requirements are identified, and these pixel blocks are used as the initial blurred region. The initial blurred area is masked to obtain the corresponding initial image mask template; The step of performing morphological processing on the initial blurred region corresponding to the initial blurred pixel to obtain the image target mask template includes: The first repaired image includes multiple initial blurred regions that are first expanded and then eroded to connect the dispersed multiple initial blurred regions and obtain the image target mask template.
2. The method as described in claim 1, characterized in that, The step of repairing the first type of object in the image to be processed to obtain a first repaired image, and generating a corresponding initial image mask template based on the initial blurred areas in the first repaired image that do not meet image quality requirements, includes: The video sequence containing the image to be processed is input into the trained information propagation model; In the trained information propagation model, based on image elements in other video frames in the video sequence, the first type of object in the image to be processed is repaired to obtain a first repaired image, and based on the initial blurred areas in the first repaired image that do not meet the image quality requirements, a corresponding initial image mask template is generated.
3. The method as described in claim 2, characterized in that, The method further includes: The initial object mask template is input into the trained information propagation model, wherein the initial object mask template is determined after identifying the second type of object contained in the target video frame image, and the second type of object is the image element that needs to be retained; In the trained information propagation model, the second type of object in the initial object mask template is subjected to object contour completion processing to obtain the object target mask template.
4. The method as described in claim 3, characterized in that, Based on the second repaired image, the target repaired image corresponding to the image to be processed is determined, including: The initial mask template of the object is compared with the target mask template of the object to obtain a first comparison result, wherein the first comparison result is used to characterize whether the contours of the second type of object are consistent; Based on the first comparison result, the second repaired image is processed to obtain the target repaired image.
5. The method as described in claim 4, characterized in that, The step of processing the second restored image based on the first comparison result to obtain the target restored image includes: If the first comparison result indicates that the outlines of the second type of object are inconsistent, then in the second repaired image, the pixel region corresponding to the second type of object is repaired to obtain a third repaired image, and the third repaired image is used as the target repaired image; If the first comparison result indicates that the outlines of the second type of object are consistent, then the second repaired image is used as the target repaired image.
6. The method as described in claim 2 or 3, characterized in that, The trained information propagation model was obtained through training in the following manner: Based on the training samples in the training sample dataset, perform iterative training on the information propagation model to be trained to obtain the trained information propagation model. During one iteration, the following operations are performed: Training samples are selected from the training sample dataset; wherein, the training samples are: historical images after masking the image elements to be repaired, and object history mask templates corresponding to the image elements to be retained in the historical images; The training samples are input into the information propagation model to predict the predicted restoration image corresponding to the historical image. Based on the predicted blurred areas in the predicted restoration image that do not meet the image quality requirements, an image prediction mask template and an object prediction mask template corresponding to the object history mask template are generated. The information propagation model is parameter-adjusted using a target loss function constructed based on the predicted inpainted image, the image prediction mask template, and the object prediction mask template.
7. The method as described in claim 6, characterized in that, The training samples also include: the actual repaired image corresponding to the historical image, and the actual object mask template corresponding to the object historical mask template; The target loss function is constructed as follows: A first type of loss function is constructed based on the predicted repair image and the actual repair image; a second type of loss function is constructed based on the image prediction mask template and the image intermediate mask template; and a third type of loss function is constructed based on the object prediction mask template and the object actual mask template. The image intermediate mask template is determined based on the predicted repair image and the actual repair image. The target loss function is constructed based on the first type of loss function, the second type of loss function, and the third type of loss function.
8. The method as described in claim 7, characterized in that, The first type of loss function is determined as follows: Based on the image difference pixel values between the predicted repaired image and the actual repaired image, a first sub-loss function is determined; Based on the second comparison result between the predicted restored image and the actual restored image, a second sub-loss function is determined, wherein the second comparison result is used to characterize whether the predicted restored image and the actual restored image are consistent; The first type of loss function is determined based on the first sub-loss function and the second sub-loss function.
9. The method as described in claim 8, characterized in that, The second type of loss function is determined as follows: Based on the mask difference pixel values between the image prediction mask template and the image intermediate mask template, a third sub-loss function is determined, and the third sub-loss function is used as the second type of loss function.
10. The method as described in claim 8, characterized in that, The third type of loss function is determined in the following way: The fourth sub-loss function is determined based on the object difference pixel values between the predicted object mask template and the actual object mask template. The fifth sub-loss function is determined based on the similarity between the predicted mask template of the object and the actual mask template of the object; The third type of loss function is determined based on the fourth sub-loss function and the fifth sub-loss function.
11. The method according to any one of claims 1 to 5, characterized in that, After generating the corresponding initial image mask template, the method further includes: When the first number of initial blurred pixels contained in the initial mask template of the image is less than a first threshold, the first repaired image is used as the target repaired image corresponding to the image to be processed.
12. The method according to any one of claims 1 to 5, characterized in that, After obtaining the image target mask template, the method further includes: When the second number of intermediate blurred pixels contained in the image target mask template is less than the second threshold, the first repaired image is used as the target repaired image corresponding to the image to be processed.
13. An image processing apparatus, characterized in that, The device includes: The first processing unit is used to perform masking processing on a first type of object contained in the acquired target video frame image to obtain a masked image to be processed; the first type of object is the image element to be repaired. The second processing unit is used to repair the first type of object in the image to be processed, obtain a first repaired image, and generate a corresponding initial image mask template based on the initial blurred area in the first repaired image that does not meet the image quality requirements. The third processing unit is used to perform morphological processing on the initial blurred region corresponding to the initial blurred pixels to obtain the image target mask template when the first number of initial blurred pixels contained in the initial image mask template reaches a first threshold. The fourth processing unit is used to perform repair processing on the pixel region corresponding to the intermediate blurred pixels in the first repaired image when the second number of intermediate blurred pixels contained in the image target mask template reaches the second threshold, so as to obtain the second repaired image. The determining unit is configured to determine, based on the second repaired image, the target repaired image corresponding to the image to be processed; Specifically, the second processing unit is used for: According to the size of the first restored image, the first restored image is divided into multiple pixel blocks, and the resolution of each pixel block is determined; Based on the resolution of each pixel block, pixel blocks in the first repaired image that do not meet the image quality requirements are identified, and these pixel blocks are used as the initial blurred region. The initial blurred area is masked to obtain the corresponding initial image mask template; Specifically, the third processing unit is used for: The first repaired image includes multiple initial blurred regions that are first expanded and then eroded to connect the dispersed multiple initial blurred regions and obtain the image target mask template.
14. An electronic device, characterized in that, The electronic device includes: a memory and a processor, wherein: The memory is used to store computer programs; The processor is configured to execute the computer program to implement the steps of the method according to any one of claims 1 to 12.
15. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the steps of the method as described in any one of claims 1 to 12.
16. A computer program product, characterized in that, The computer program product includes a computer program stored in a computer-readable storage medium; when the computer program is executed by a processor, it implements the steps of the method as described in any one of claims 1 to 12.
Citation Information
Patent Citations
Image detection method and device
CN109614900A
Iterative image inpainting with confidence feedback
US20210342983A1
