An AI-based picture correction method and device and related medium thereof
By generating masks and comparison images through AI-powered image cutout and simultaneously binding and correcting them, the problem of large errors in AI cutout correction is solved, achieving efficient and accurate image correction and improving the user experience.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- AFIRSTSOFT CO LTD
- Filing Date
- 2023-09-25
- Publication Date
- 2026-05-29
AI Technical Summary
Existing technologies for AI-based image cutout correction have large errors and involve cumbersome steps, making them difficult to meet the needs of ordinary users.
By using AI algorithms to cut out images, a mask image and a comparison image are generated. Data is synchronized and bound using mutual pointer objects. Correction operations are performed according to user instructions until the correction result is within the preset range, providing real-time feedback and historical record functions.
It simplifies the image correction process, reduces correction errors, improves the accuracy and efficiency of correction, reduces user workload, and enhances user experience.
Smart Images

Figure CN117152194B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image processing technology, and in particular to an image correction method, apparatus and related media based on AI-based image matting. Background Technology
[0002] AI background removal is an image processing method that uses artificial intelligence to automatically and accurately separate the main object from the background of an image. While AI background removal has many advantages, manual intervention and correction are often still required in practice to ensure the final result meets requirements. Traditional image editing tools like Photoshop, although powerful, are highly specialized and not universally applicable to ordinary users. Currently, a common correction method is to use selective correction tools, which reapply AI algorithms to handle errors in the background removal. This approach can help improve the accuracy of the background removal, but the correction error is still relatively large, and the correction steps are cumbersome. Summary of the Invention
[0003] The present invention provides an image correction method, apparatus and related medium based on AI image matting, which aims to solve the problems of large correction error and cumbersome correction steps after AI image matting in the prior art.
[0004] In a first aspect, embodiments of the present invention provide an image correction method based on AI-based image matting, comprising:
[0005] AI algorithms are used to perform AI cutout on the original image to obtain the cutout result; wherein, the cutout result includes a mask image and a comparison image;
[0006] The mask image and the comparison image are synchronized and bound using a mutual pointer object;
[0007] The mask image is corrected according to user instructions to obtain the correction result, and the correction result is simultaneously displayed on the comparison image.
[0008] Determine whether the correction result is within a preset range. If not, perform the correction operation again according to the user's instruction until the correction result is within the preset range. If yes, output the comparison image.
[0009] Secondly, embodiments of the present invention provide an image correction device based on AI-based image matting, comprising:
[0010] The image cutout unit is used to perform AI cutout on the original image using AI algorithms to obtain the cutout result; wherein, the cutout result includes a mask image and a comparison image;
[0011] The image binding unit is used to synchronize and bind the mask image and the comparison image using a mutual pointer object;
[0012] The image correction unit is used to perform correction operations on the mask image according to user instructions to obtain correction results, and to synchronously display the correction results on the comparison image.
[0013] The image judgment unit is used to determine whether the correction result is within a preset range. If not, the correction operation is performed again according to the user instruction until the correction result is within the preset range. If yes, the comparison image is output.
[0014] Thirdly, embodiments of the present invention provide a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the AI-based image correction method of the first aspect.
[0015] Fourthly, embodiments of the present invention provide a computer-readable storage medium, wherein a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, it implements the AI-based image correction method of the first aspect.
[0016] This invention provides an image correction method based on AI background removal, comprising: performing AI background removal on the original image using an AI algorithm to obtain a background removal result; wherein, the background removal result includes a mask image and a comparison image; using a mutual storage pointer object to synchronize and bind the mask image and the comparison image; performing a correction operation on the mask image according to user instructions to obtain a correction result, and synchronously displaying the correction result on the comparison image; determining whether the correction result is within a preset range; if not, performing the correction operation again according to user instructions until the correction result is within the preset range; if yes, outputting the comparison image. This invention simplifies the image correction steps by performing correction operations on the mask image and synchronously correcting the comparison image, while also enabling precise correction and significantly reducing correction errors.
[0017] The present invention also provides an image correction device, computer equipment, and storage medium based on AI image matting, which have the same beneficial effects as described above. Attached Figure Description
[0018] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the following description of the embodiments will be briefly introduced. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0019] Figure 1 A flowchart illustrating an AI-based image correction method provided in an embodiment of the present invention;
[0020] Figure 2 This is another flowchart illustrating an image correction method based on AI image matting provided in an embodiment of the present invention;
[0021] Figure 3 Image correction effect provided in the embodiments of the present invention Figure 1 ;
[0022] Figure 4 Image correction effect provided in the embodiments of the present invention Figure 2 ;
[0023] Figure 5 This is a schematic block diagram of an image correction device based on AI image matting, provided for an embodiment of the present invention. Detailed Implementation
[0024] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0025] It should be understood that, when used in this specification and the appended claims, the terms "comprising" and "including" indicate the presence of the described features, integrals, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components and / or collections thereof.
[0026] It should also be understood that the terminology used in this specification is for the purpose of describing particular embodiments only and is not intended to limit the invention. As used in this specification and the appended claims, the singular forms “a,” “an,” and “the” are intended to include the plural forms unless the context clearly indicates otherwise.
[0027] It should also be further understood that the term "and / or" as used in this specification and the appended claims refers to any combination of one or more of the associated listed items and all possible combinations, and includes such combinations.
[0028] Please see below. Figure 1 , Figure 1 The flowchart of an image correction method based on AI matting provided in an embodiment of the present invention specifically includes steps S101 to S104.
[0029] S101. Use AI algorithms to perform AI cutout on the original image to obtain the cutout result; wherein, the cutout result includes a mask image and a comparison image;
[0030] S102. Use a mutual pointer object to synchronize and bind the mask image with the comparison image;
[0031] S103. Perform a correction operation on the mask image according to the user's instructions to obtain a correction result, and simultaneously display the correction result on the comparison image;
[0032] S104. Determine whether the correction result is within a preset range. If not, perform the correction operation again according to the user instruction until the correction result is within the preset range. If yes, output the comparison image.
[0033] Combination Figure 2 and Figure 3 As shown, in step S101, firstly, an original image is selected as input, and the objects in the original image need to be separated from the background. Then, a trained AI matting algorithm is used to process the original image. AI matting algorithms are typically based on deep learning and convolutional neural networks, and can automatically detect object boundaries and separate objects from the background. The final result is as follows: Figure 3 The mask image shown on the right and the comparison image shown on the left are contrasting. The mask image is a binary image containing the area corresponding to the object and the area corresponding to the background. The comparison image is a visual image showing the cutout effect. Usually, the cutout object and the background are displayed with different colors or transparency so that users can visually check the accuracy of the cutout.
[0034] Furthermore, AI-powered image matting can accept various inputs, such as images, videos, and depth information. Combining information from different modalities can improve the understanding and accuracy of matting algorithms in complex scenes. Semi-automated tools can also be designed to help users guide the matting process more easily, such as providing guide lines or region selection. More information and real-time interaction can help matting algorithms separate objects and backgrounds more accurately, reducing errors. Semi-automated tools and adaptive learning can accelerate the matting process and reduce the user's workload. Users can more easily check and adjust the matting results, improving the user experience.
[0035] In one embodiment, step S101 includes:
[0036] Create a transparent image with the same resolution as the original image;
[0037] The original image is subjected to AI background removal to obtain a background image;
[0038] Iterate through all pixels of the cut-out image and determine whether the alpha value of the pixel is 0. If it is, do not set a color for the pixel corresponding to the transparent image; otherwise, set the mask color for the pixel corresponding to the transparent image.
[0039] The mask image is obtained by integrating all the pixels of the transparent image.
[0040] In this embodiment, firstly, a fully transparent image with the same resolution as the original image is created, which will serve as the basis for the mask image. AI-based image matting is then performed on the original image to obtain the matted result, which includes an image with a transparent background. Next, all pixels in the matted image are iterated over, and the alpha value (transparency value) of each pixel is checked. If the alpha value is 0, it indicates that the pixel is part of the background, and the corresponding pixel in the transparent image is not colored. If the alpha value is not 0, it indicates that the pixel belongs to an object, and the corresponding pixel in the transparent image is set to the mask color. Finally, after iterating over all pixels, only the pixels marked with the mask color remain transparent on the transparent image, while the rest remain transparent. This yields the mask image, which marks the location of the object.
[0041] Furthermore, this invention allows for the generation of multiple mask layers, each of which can use different colors or opacities to represent different objects or specific areas, thus enabling more precise mask definition. It allows users to manually edit the mask for more accurate control over which areas need to be masked, thereby improving the accuracy of image cutout. Real-time feedback is provided during mask generation, allowing users to immediately view and adjust the mask effect. Multiple masks can be combined into a single final mask, which is extremely useful for complex image cutout tasks. In short, by combining AI cutout results with transparent images, a high-precision mask is generated, accurately marking the object's position and providing real-time feedback to help users quickly check and adjust the mask effect, improving work efficiency.
[0042] In step S102, this invention provides a mask image marking the areas of the object and background, and a comparison image for visually demonstrating the cutout effect. Typically, the cutout object and background are displayed on the same image with different colors or transparency. The mask image is a pointer object, and the comparison image is a pointer object. The mask object stores the comparison image object, and the comparison image object stores the mask image object. Both objects support the same functionality. When the user edits, whether drawing or erasing on the mask image, or dragging and moving on the comparison image, both objects simultaneously call their corresponding editing interfaces, thus achieving synchronization. Because data synchronization is real-time, the comparison image immediately reflects the editing operations on the mask image, allowing the user to instantly view the repair effect.
[0043] Furthermore, it allows for the simultaneous synchronization of multiple images, which is extremely useful for processing images with multiple layers or versions simultaneously. It also enables a history function, allowing users to view and revert to previous editing states. By using inter-reference pointer objects for data synchronization, it ensures real-time reflection of the comparison images, allowing users to instantly view and adjust the cutout effect. This synchronization method eliminates the need for users to manually apply edits to comparison images, reducing workload and the possibility of errors. By implementing features such as history and difference recording, users can have more precise control over the editing process while easily undoing and reverting to previous states. For multi-user collaborative projects, this synchronization method helps ensure that all users are working on the same version of the image, resulting in higher collaborative efficiency.
[0044] In one embodiment, step S102 includes:
[0045] Create an interface class for calling;
[0046] Create a mask image object and a comparison image object based on the aforementioned call interface class;
[0047] The mask image object and the comparison image object are saved to each other to achieve data synchronization and binding.
[0048] In this embodiment, an interface class is created. This class contains methods and properties for managing and synchronizing the mask image and the comparison image. This interface class provides a set of public methods for manipulating the mask image object and the comparison image object. The interface class creates the mask image object and the comparison image object. This can be done by calling the API of an image processing library or image editing tool, or by creating custom image objects. The interface class implements the logic for saving the mask image object and the comparison image object to each other. This can be achieved by maintaining references or pointers to these two objects within the interface class. The interface class implements methods for synchronization operations, including applying editing results from the mask image object to the comparison image object, or applying changes from the comparison image to the mask image object. Data synchronization is ensured to be real-time so that when the user edits the mask image, the comparison image immediately reflects the editing results.
[0049] Additionally, multiple pairs of mask images and comparison images can be managed simultaneously within the interface class, which is extremely useful for processing multiple images or multiple versions of images concurrently. The interface class records data synchronization differences so users can view and undo previous edits at any time. A history function can be implemented, allowing users to view and revert to previous editing states. By using the interface class for data synchronization, real-time reflection of the comparison images is ensured, enabling users to instantly view and adjust the cutout effect. This synchronization method eliminates the need for users to manually apply edits to the comparison images, reducing workload and the possibility of errors. By implementing history and difference recording functions, users can have more precise control over the editing process while easily undoing and reverting to previous states.
[0050] Combination Figure 4 As shown, in step S103, the system receives user instructions, including operations such as drawing, erasing, filling, and selecting areas. The user can send these instructions using a graphical user interface or command line. Based on the user's instructions, corresponding correction operations are performed on the mask image. For example, if the user draws areas using a drawing tool, these areas are marked as objects, or if the user uses an erasing tool, certain areas are marked as background. Based on the user's operations, correction results are generated on the mask image. The correction results are synchronously displayed on a comparison image so that the user can immediately view the correction effect. Synchronization is ensured to be real-time, allowing the user to immediately see the correction effect and further adjust it as needed. Figure 4 As shown, the image on the right is a schematic diagram of the correction, and the image on the left is a display of the effect after the correction.
[0051] Of course, this invention provides a variety of correction tools, such as brushes, erasers, fillers, and selection tools, to meet different editing needs. Users can see the correction effect immediately during the correction process and can adjust the cutout more intuitively.
[0052] In one embodiment, step S103 includes:
[0053] Use the paint function of QQuickPaintItem to draw a mask canvas;
[0054] Add the starting and ending coordinates of the mouse movement to QPainterPath to obtain the Bézier curve;
[0055] The correction result is obtained by writing on the mask canvas using QPainter based on the Bézier curve.
[0056] The drag function of MouseArea is called based on QQuickPaintItem to move the mask canvas;
[0057] The mask canvas is scaled by modifying the scale value of the QQuickPaintItem.
[0058] Furthermore, the QBrush of the comparison image is filled with the texture color based on the QPainterPath;
[0059] The QBrush of the mask image is filled with the mask color based on the QPainterPath.
[0060] Furthermore, the QPainterPath and QBrush are stored in tables respectively, and then the tables are added to QUndoCommand;
[0061] The QUndoCommand returns a list.pop_back() function to undo the action; or the QUndoCommand returns a list to redo the action.
[0062] In this embodiment, a canvas is created and drawn using QPainter within the `paint` function of `QQuickPaintItem` (a key class in the Qt Quick framework used to display custom drawings in the Qt Quick interface. It allows developers to use custom drawing logic to fill a rectangular area and embed it into the Qt Quick user interface). When the user starts moving the mouse, the starting and ending coordinates are recorded and added to `QPainterPath`, generating a Bézier curve. Based on the generated Bézier curve, writing operations are performed on the masked canvas using QPainter. Writing operations typically modify the pixels of the masked image, marking parts of it as objects or background to obtain the correction result. The masked canvas can be moved by calling the `drag` function of `MouseArea` using `QQuickPaintItem`. When the user drags the mouse, the canvas moves accordingly. The masked canvas can be scaled by modifying the `scale` value of `QQuickPaintItem`. This allows adjustment of the canvas size for fine-tuning operations.
[0063] Furthermore, based on the generated QPainterPath, QPainter is used to fill the comparison image, typically involving filling the QPainterPath area with QBrush to change the area's color or texture. The fill can be an opaque color, texture pattern, or other visual effects to visually distinguish the object from the background. Also based on the generated QPainterPath, a fill operation is performed on the mask image; this fill usually uses different colors or textures to mark the areas of the object and background so that subsequent processing can be based on these marks. By filling the comparison image and the mask image with different colors or textures, users can visually see the difference between the object and the background, making further editing and adjustments easier.
[0064] Furthermore, after each editing operation, the generated QPainterPath and QBrush objects are stored in a table. This table can be a list, stack, or other data structure to save the history of editing operations. A QUndoCommand object is created using the table storing the QPainterPath and QBrush as a parameter. QUndoCommand is a class in the Qt framework used to manage undo and redo operations. The QUndoCommand object is added to a QUndoStack, a container for managing multiple QUndoCommand objects, which is responsible for handling the order and logic of undo and redo operations. When the user chooses to perform an undo operation, QUndoStack retrieves the last QUndoCommand from the history and executes its undo operation, restoring the QPainterPath and QBrush stored in the table to their previous state, thus achieving the undo effect. When the user chooses to perform a redo operation, QUndoStack re-executes the undoed QUndoCommand, reapplying the previous editing operation, thus achieving the redo effect.
[0065] Specifically, by storing the editing history in QUndoStack, undo and redo operations can be easily managed and executed, improving control over the editing process. This invention provides undo and redo functionality to enhance the user experience, allowing users to experiment with different editing operations more freely without worrying about irreversible errors. Saving and managing the editing history can be used for version control, allowing users to revert to previous editing states or restore to different historical versions at any time, which is helpful for managing editing projects.
[0066] In step S104, the correction result is evaluated, including checking the accuracy of the cutout, the sharpness of the edges, and color matching. This evaluation can be performed using various image processing algorithms and metrics. A preset range is defined, which is the standard or quality requirement that the correction result should meet. For example, the blurriness of the cutout edges can be set to not exceed a certain threshold, and the color matching accuracy can reach a certain percentage. The correction result is checked to see if it falls within the preset range by comparing it with the standard of the preset range to determine if it meets the conditions. If the correction result is not within the preset range, further correction operations are performed according to the user's instructions. The checking steps are repeated until the correction result meets the preset range. This can be done through loops, iterations, or interactive methods to ensure that the final editing result achieves a satisfactory quality level.
[0067] Specifically, automatic correction algorithms are introduced into the correction process to reduce manual work for users. For example, edges can be automatically smoothed or color matching adjusted. A user feedback mechanism is provided, allowing users to check the correction results and provide feedback to guide further correction operations. Machine learning algorithms are used to optimize correction operations based on users' historical edits and feedback, improving the accuracy of automatic correction. Different preset ranges are defined for different types of editing operations to adapt to different editing needs, such as portrait cutout and scene cutout. By comparing the correction results with the preset ranges, it can be ensured that the edited image quality meets the requirements. Automatic correction and iterative correction operations can reduce the user's workload, especially in complex image editing tasks.
[0068] In summary, this invention provides an AI-powered image cutout correction method, aiming to improve the efficiency and quality of image editing. This invention introduces a left view (comparison image, hereinafter the same) and a right view (mask image, hereinafter the same). This dual-view design allows users to intuitively compare the cutout result with the original image, making corrections easier. The left view displays the correction result in real-time, meaning users can immediately see the impact of their corrections on the image without waiting for additional rendering or processing time. The right view supports various operations such as zooming, moving, undoing, and redoing, providing more flexible editing tools to meet different correction needs. The method's operation is more intuitive, making it easier for users to correct problems in images without a cumbersome learning curve, making it more lightweight and concise compared to professional software like Photoshop. This invention provides an efficient, intuitive, and flexible method that allows users to more easily achieve fine-tuning of cutout results, thereby improving the efficiency and quality of image editing. It has significant application value for a wide range of image processing tasks, such as advertising design, image compositing, and portrait cutout.
[0069] Combination Figure 5 As shown, Figure 5A schematic block diagram of an image correction device based on AI background removal provided in an embodiment of the present invention. The image correction device 500 based on AI background removal includes:
[0070] Image cutout unit 501 is used to perform AI cutout on the original image using AI algorithms to obtain a cutout result; wherein, the cutout result includes a mask image and a comparison image;
[0071] Image binding unit 502 is used to perform data synchronization binding between the mask image and the comparison image using a mutual pointer object;
[0072] Image correction unit 503 is used to perform correction operations on the mask image according to user instructions to obtain correction results, and synchronously display the correction results on the comparison image;
[0073] Image judgment unit 504 is used to determine whether the correction result is within a preset range. If not, the correction operation is performed again according to the user instruction until the correction result is within the preset range. If yes, the comparison image is output.
[0074] In this embodiment, the image cutout unit 501 uses an AI algorithm to perform AI cutout on the original image to obtain a cutout result; wherein, the cutout result includes a mask image and a comparison image; the image binding unit 502 uses a mutual storage pointer object to synchronously bind the mask image and the comparison image; the image correction unit 503 performs a correction operation on the mask image according to user instructions to obtain a correction result, and synchronously displays the correction result on the comparison image; the image judgment unit 504 judges whether the correction result is within a preset range. If not, it performs a correction operation again according to user instructions until the correction result is within the preset range; if so, it outputs the comparison image.
[0075] In one embodiment, the image cutout unit 501 includes:
[0076] A creation unit is used to create a transparent image with the same resolution as the original image;
[0077] The image cutout unit is used to perform AI image cutout on the original image to obtain a cutout image;
[0078] The color unit is used to traverse all pixels of the cutout image and determine whether the alpha value of the pixel is 0. If it is, no color is set for the pixel corresponding to the transparent image; otherwise, the pixel corresponding to the transparent image is set to the mask color.
[0079] The integration unit is used to integrate all the pixels of the transparent image to obtain the mask image.
[0080] In one embodiment, the image binding unit 502 includes:
[0081] The interface unit is used to create and call interface classes;
[0082] An object unit is used to create a mask image object and a comparison image object based on the calling interface class;
[0083] The storage unit is used to save the mask image object and the comparison image object to each other in order to achieve data synchronization and binding.
[0084] In one embodiment, the image correction unit 503 includes:
[0085] The drawing unit is used to draw the mask canvas using the paint function of QQuickPaintItem;
[0086] The coordinate unit is used to add the starting and ending coordinates of the mouse movement to the QPainterPath to obtain the Bézier curve;
[0087] The writing unit is used to write on the mask canvas using QPainter based on the Bézier curve to obtain the correction result.
[0088] The moving unit is used to call the drag function of MouseArea based on the QQuickPaintItem to move the mask canvas;
[0089] A scaling unit is used to scale the mask canvas by modifying the scale value of the QQuickPaintItem.
[0090] Furthermore, the writing unit includes:
[0091] Texture unit, used to fill the comparison image with a texture color using QBrush based on the QPainterPath;
[0092] A mask unit is used to fill the mask image with the mask color using QBrush based on the QPainterPath.
[0093] Furthermore, the writing unit also includes:
[0094] A storage unit is used to store the QPainterPath and QBrush into a table respectively, and then add the table to QUndoCommand;
[0095] The undo unit is used to return list.pop_back() based on the QUndoCommand to undo; or to return list based on the QUndoCommand to redo.
[0096] Since the embodiments of the apparatus and the embodiments of the method correspond to each other, please refer to the description of the embodiments of the method for the embodiments of the apparatus, which will not be repeated here.
[0097] This invention also provides a computer-readable storage medium storing a computer program thereon, which, when executed, can perform the steps provided in the above embodiments. The storage medium may include various media capable of storing program code, such as a USB flash drive, a portable hard drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.
[0098] This invention also provides a computer device, which may include a memory and a processor. The memory stores a computer program, and when the processor calls the computer program in the memory, it can implement the steps provided in the above embodiments. Of course, the computer device may also include various network interfaces, power supplies, and other components.
[0099] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the systems disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the descriptions are relatively simple; relevant parts can be referred to in the method section. It should be noted that those skilled in the art can make various improvements and modifications to this application without departing from the principles of this application, and these improvements and modifications also fall within the protection scope of the claims of this application.
[0100] It should also be noted that, in this specification, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
Claims
1. An image correction method based on AI-based image matting, characterized in that, include: AI algorithms are used to perform AI cutout on the original image to obtain the cutout result; wherein, the cutout result includes a mask image and a comparison image; The mask image and the comparison image are synchronized and bound using a mutual pointer object; The mask image is corrected according to user instructions to obtain the correction result, and the correction result is simultaneously displayed on the comparison image. Determine whether the correction result is within a preset range. If not, perform the correction operation again according to the user instruction until the correction result is within the preset range. If yes, output the comparison image. The step of using AI algorithms to perform AI image cutout on the original image to obtain the cutout result includes: creating a transparent image with the same resolution as the original image; performing AI image cutout on the original image to obtain the cutout image; iterating through all pixels of the cutout image and determining whether the alpha value of each pixel is 0. If it is, then no color is set for the corresponding pixel of the transparent image; otherwise, the corresponding pixel of the transparent image is set to the mask color; and integrating all pixels of the transparent image to obtain the mask image. The step of using a mutual pointer object to synchronize and bind the mask image and the comparison image includes: creating a calling interface class; creating a mask image object and a comparison image object based on the calling interface class; and saving the mask image object and the comparison image object to each other to achieve data synchronization and binding. The step of correcting the mask image according to user instructions to obtain the correction result includes: drawing a mask canvas using the paint function of QQuickPaintItem; adding the starting and ending coordinates of the mouse movement to QPainterPath to obtain a Bézier curve; and writing on the mask canvas using QPainter based on the Bézier curve to obtain the correction result. The step of writing on the mask canvas using QPainter based on the Bézier curve to obtain the correction result includes: filling the QBrush of the comparison image with the texture color based on the QPainterPath; and filling the QBrush of the mask image with the mask color based on the QPainterPath.
2. The image correction method based on AI background removal according to claim 1, characterized in that, The process of writing on the mask canvas using QPainter based on the Bézier curve to obtain the correction result also includes: Store the QPainterPath and QBrush into tables respectively, and then add the tables to QUndoCommand; The QUndoCommand returns a list.pop_back() function to undo the action; or the QUndoCommand returns a list to redo the action.
3. The image correction method based on AI background removal according to claim 1, characterized in that, The step of correcting the mask image according to user instructions to obtain the correction result also includes: The drag function of MouseArea is called based on QQuickPaintItem to move the mask canvas; The mask canvas is scaled by modifying the scale value of the QQuickPaintItem.
4. An image correction device based on AI background removal, characterized in that, include: The image cutout unit is used to perform AI cutout on the original image using AI algorithms to obtain the cutout result; wherein, the cutout result includes a mask image and a comparison image; The image binding unit is used to synchronize and bind the mask image and the comparison image using a mutual pointer object; The image correction unit is used to perform correction operations on the mask image according to user instructions to obtain correction results, and to synchronously display the correction results on the comparison image. The image judgment unit is used to determine whether the correction result is within a preset range. If not, the correction operation is performed again according to the user instruction until the correction result is within the preset range. If yes, the comparison image is output. The image cutout unit is specifically used to create a transparent image with the same resolution as the original image; perform AI cutout on the original image to obtain a cutout image; iterate through all pixels of the cutout image and determine whether the alpha value of the pixel is 0. If it is, no color is set for the corresponding pixel of the transparent image; otherwise, the corresponding pixel of the transparent image is set to the mask color; and integrate all pixels of the transparent image to obtain the mask image. The image binding unit is specifically used to create a calling interface class; create a mask image object and a comparison image object based on the calling interface class; and save the mask image object and the comparison image object to each other to achieve data synchronization binding. The image correction unit is specifically used to draw a mask canvas using the paint function of QQuickPaintItem; add the starting and ending coordinates of the mouse movement to QPainterPath to obtain a Bézier curve; and use QPainter to write on the mask canvas based on the Bézier curve to obtain the correction result, including filling the QBrush of the comparison image with the texture color based on the QPainterPath; and filling the QBrush of the mask image with the mask color based on the QPainterPath.
5. A computer device, characterized in that, The method includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the AI-based image correction method as described in any one of claims 1 to 3.
6. 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 AI-based image correction method as described in any one of claims 1 to 3.