Multi-region adaptive matting method and device based on visual semantics and storage medium
By employing a multi-region adaptive matting method based on visual semantic analysis and dynamic resource allocation, this method addresses the issues of excessive computational resource consumption and poor processing results in existing technologies, achieving efficient and natural transparent object matting effects.
Patent Information
- Application Number
- CN202611290841.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-25
- Publication Date
- 2026-11-24
AI Technical Summary
Existing image matting techniques consume excessive computational resources when processing transparent or semi-transparent objects, making it difficult to balance processing accuracy and efficiency. Furthermore, the processing effect is poor for objects of different materials, and problems such as distortion of transparency and unnatural edges easily occur during the fusion stage.
By identifying the main objects and region types in the image through visual semantic analysis, the allocation of computing resources is dynamically adjusted, and an adaptive matting process is performed for different regions to generate transparency masks and perform fusion processing to ensure the realism of transparent areas and the naturalness of edges.
It improves the accuracy and efficiency of matting transparent or semi-transparent objects, reduces the overall consumption of computing resources, and enhances the naturalness and visual effect of fused masked images.
Smart Images

Figure CN123160601A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image processing technology, specifically to a multi-region adaptive matting method, apparatus, and storage medium based on visual semantics. Background Technology
[0002] With the development of artificial intelligence and digital image processing technologies, image matting technology has been widely applied in AI-powered image retouching, generative artificial intelligence (AIGC), e-commerce image processing, film and television post-production, digital human generation, and virtual live streaming. Traditional image matting technology mainly targets foreground separation of entities with relatively clear boundaries, such as people and goods. However, as application demands continue to increase, existing image processing tasks are gradually expanding to complex objects with transparent or semi-transparent features, such as wedding dresses, tulle, glass, water mist, feathers, hair, and decorative objects with transparent material characteristics.
[0003] For the aforementioned transparent or semi-transparent objects, their image areas typically lack a clear boundary between foreground and background. Their edge areas simultaneously contain subject information, background information, and varying degrees of light transmission information. Therefore, when performing image matting, it is necessary not only to accurately identify the position of the subject object but also to preserve the object's own transparency and edge transition effects to achieve a natural and realistic image fusion effect.
[0004] Currently, image matting for complex objects typically employs deep learning-based target segmentation or matting methods. These methods generally use trained models to perform a holistic analysis of the input image and output masking information corresponding to the subject region. Target segmentation methods usually output a binary mask, which can only represent the relationship between the target region and the background region, making it difficult to accurately express the degree of transparency at different locations within a transparent object. While matting-based methods can generate continuous transparency information, they typically require high computational resources and struggle to simultaneously balance processing accuracy and computational efficiency when dealing with objects of different materials.
[0005] In practical applications, existing technologies have at least the following problems:
[0006] First, existing high-precision image matting models typically process the entire input image directly. However, in real images, there may only be localized complex transparent areas, while a large number of ordinary areas do not require high-precision calculations. This results in a large computational load for the overall inference process, consuming a significant amount of graphics processing unit (GPU) resources and reducing the efficiency of batch image processing.
[0007] Second, existing processing methods based on a unified model typically employ the same processing strategy to process objects with different materials. However, different objects have different texture features, edge features, and transparency properties. For example, objects such as hair, feathery structures, gauze materials, glass, and water mist exhibit significant differences in edge representation and light transmission. Using a unified processing method makes it difficult to achieve the best restoration results for different objects.
[0008] Third, existing image matting techniques typically output binary masks to represent the subject's boundaries, failing to accurately preserve the continuously changing transparency information within transparent objects. When applied to transparent or semi-transparent objects such as wedding dresses, tulle, glass, and water mist, problems such as distorted transparency relationships and unnatural edge transitions can easily occur.
[0009] Fourth, after completing the image cutout processing of different areas, existing technologies usually lack comprehensive optimization processing for transparent areas during the fusion stage. This can easily lead to phenomena such as white edges, black edges, edge breaks, and color discontinuities at the junction of the subject edge and the background, affecting the realism and visual effect of the final image.
[0010] Therefore, existing technologies still need to be improved to enhance the quality and efficiency of image matting processing. Summary of the Invention
[0011] In view of the above problems, this application provides a multi-region adaptive matting method based on visual semantics to solve the technical problems of low matting quality and efficiency.
[0012] To achieve the above objectives, this application provides a multi-region adaptive matting method based on visual semantics, including:
[0013] The input image to be processed is acquired, and visual semantic analysis is performed on the input image to identify the main object in the input image, and a candidate processing region containing the main object is generated based on the identification result;
[0014] The main candidate processing region is divided into regions and the region type is identified. The region type corresponding to each region is determined according to the texture features, edge features and visual semantic information of each region in the main candidate processing region. The region type includes solid region, semi-transparent or transparent region.
[0015] The computing resource allocation strategy is dynamically adjusted according to the region type of different regions in the main candidate processing region, and the corresponding matting process is executed for different regions. Among them, a fine-grained restoration process is executed for semi-transparent or transparent regions to generate a transparency mask. The transparency mask is used to represent the outline information and transparency information of the main object in the transparent region; and a solid region matting process is executed for solid regions.
[0016] The processing results for each region are fused together to generate a fused mask image.
[0017] Furthermore, the visual semantic analysis of the input image includes:
[0018] The input image is used to perform target recognition using a visual semantic analysis model in order to determine the main object in the input image;
[0019] Based on the identification results of the subject object, the foreground subject region and the background region are distinguished;
[0020] A candidate processing region for the subject is generated based on the foreground subject region, so that subsequent fine-tuning processing is performed only on the candidate processing region for the subject.
[0021] Furthermore, the process of dividing the candidate processing region into regions and identifying region types includes:
[0022] Extract texture features, edge features, and visual semantic features from the main candidate processing region;
[0023] The candidate processing region of the main body is divided into two or more regions based on the extracted texture features, edge features, and visual semantic features, and the region type of each region is determined.
[0024] Generate the corresponding region type label;
[0025] The region type labels include at least solid region labels and semi-transparent or transparent region labels.
[0026] Furthermore, the region type corresponding to the semi-transparent or transparent region label includes one or more of the following:
[0027] Hair-like areas, feather-like structures, transparent gauze areas, transparent glass-like areas, water-mist-like areas, and semi-transparent decorative areas;
[0028] The feather-like structure region includes feather objects and wing-like objects with feather-like texture features, while the gauze-like transparent region includes wedding dress objects, tulle objects, and other transparent objects with gauze-like texture features.
[0029] Furthermore, the refined recovery process includes:
[0030] Transparency information is calculated based on the image data corresponding to the semi-transparent or transparent areas;
[0031] Generate a transparency mask containing multiple consecutive gray levels;
[0032] In this process, different grayscale values in the transparency mask correspond to different degrees of transparency, so as to preserve the true transparency relationship of the main object within the transparent area.
[0033] Furthermore, the dynamic adjustment strategy for computing resource allocation includes:
[0034] The processing method is determined based on the proportion of the main candidate processing area, the total proportion of semi-transparent or transparent areas, and the complexity of the area.
[0035] When the total area of the semi-transparent or transparent region is less than the preset condition, high-precision restoration processing is performed only on the semi-transparent or transparent local region.
[0036] When the area of the transparent region meets the preset conditions, the transparent region is divided into blocks;
[0037] When the input image does not have any semi-transparent or transparent areas, the solid region cutout process is executed directly.
[0038] Furthermore, the fusion process includes:
[0039] The region fusion weights are calculated based on transparency continuity, edge gradient variation, color continuity, illumination consistency, and local texture variation.
[0040] The processing results corresponding to different regions are fused based on the fusion weights.
[0041] Output a blended mask image with correct transparency and natural, continuous edges.
[0042] Furthermore, after generating the fused mask image, the process also includes:
[0043] The grayscale value of each pixel in the fused mask image is used as the transparency channel value of the corresponding pixel in the input image;
[0044] The transparency channel value is merged pixel-by-pixel with the red, green, and blue channels of the input image to obtain the cutout result in RGBA format.
[0045] To solve the above-mentioned technical problems, the present invention provides another basic solution:
[0046] A multi-region adaptive image matting device based on visual semantics includes:
[0047] The visual semantic analysis module is used to acquire the input image, identify the main object in the input image, and generate candidate processing regions for the main object;
[0048] The region type identification module is used to divide the main candidate processing region into regions and identify the region type, and generate region type labels;
[0049] The regional scheduling module is used to invoke the corresponding processing flow according to the regional type;
[0050] The fine-grained restoration module is used to perform a fine-grained restoration process on semi-transparent or transparent areas and generate a transparency mask;
[0051] The dynamic resource allocation module is used to adjust the computing resource allocation strategy based on the regional characteristics of the main candidate processing area;
[0052] The image fusion module is used to generate a fused mask image based on the transparency mask and the processing results of each region.
[0053] To solve the above-mentioned technical problems, the present invention provides another basic solution:
[0054] A computer-readable storage medium storing a computer program that, when executed by a processor, causes the processor to implement the visual semantic-based multi-region adaptive matting method described above.
[0055] Unlike existing technologies, the above-mentioned technical solution identifies the main object in the input image through visual semantic analysis and generates candidate processing regions for the main object. It further classifies these candidate processing regions based on region texture features, edge features, and visual semantic information, and calls corresponding matting processing flows for different region types, achieving adaptive processing of regions with different materials. Simultaneously, this invention generates transparency masks containing contour and transparency information for transparent regions to preserve the true transparency relationship of transparent objects; and dynamically adjusts the computational resource allocation strategy based on region features to reduce unnecessary computation. Through the above technical solution, this invention can improve the accuracy of matting transparent or semi-transparent objects while reducing overall computational resource consumption and enhancing the naturalness and visual effect of the fused masked image.
[0056] The above description of the invention is merely an overview of the technical solution of this application. In order to enable those skilled in the art to better understand the technical solution of this application and to implement it based on the description and drawings, and to make the above-mentioned objectives and other objectives, features and advantages of this application easier to understand, the following description is provided in conjunction with the specific embodiments and drawings of this application. Attached Figure Description
[0057] The accompanying drawings are only used to illustrate the principles, implementation methods, applications, features, and effects of specific embodiments of the present invention and other related contents, and should not be considered as limitations on this application.
[0058] In the accompanying drawings of the instruction manual:
[0059] Figure 1This is a flowchart illustrating the multi-region adaptive matting based on visual semantics as described in a specific implementation method;
[0060] Figure 2 This is a schematic diagram illustrating the generation of the fused mask image as described in a specific implementation.
[0061] Figure 3 This is a schematic diagram illustrating the generation of matting results using the fused mask image in a specific implementation method.
[0062] Figure 4 This is a block diagram of the multi-region adaptive image matting device based on visual semantics described in a specific implementation.
[0063] Figure 5 A schematic diagram of the computer-readable storage medium described in a specific embodiment;
[0064] The reference numerals used in the above figures are explained as follows:
[0065] 200. A multi-region adaptive image matting device based on visual semantics;
[0066] 201. Visual semantic analysis module; 202. Region type recognition module; 203. Region scheduling module;
[0067] 204. Refined Restoration Module; 205. Dynamic Resource Allocation Module; 206. Image Fusion Module;
[0068] 300. Computer-readable storage medium; Detailed Implementation
[0069] To illustrate the possible application scenarios, technical principles, implementable specific solutions, and achievable objectives and effects of this application in detail, the following description, in conjunction with the listed specific embodiments and accompanying drawings, provides a detailed explanation. The embodiments described herein are merely illustrative of the technical solutions of this application and are therefore intended to limit the scope of protection of this application.
[0070] In this document, the term "embodiment" means that a specific feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of this application. The term "embodiment" appearing in various places throughout the specification does not necessarily refer to the same embodiment, nor does it specifically limit its independence or connection with other embodiments. In principle, in this application, as long as there are no technical contradictions or conflicts, the technical features mentioned in each embodiment can be combined in any way to form corresponding implementable technical solutions.
[0071] Unless otherwise defined, the technical terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application pertains; the use of related terms herein is merely for the purpose of describing particular embodiments and is not intended to limit this application.
[0072] In the description of this application, the term "and / or" is used to describe the logical relationship between objects, indicating that three relationships can exist. For example, A and / or B means: A exists, B exists, and A and B exist simultaneously. Additionally, the character " / " in this document generally indicates that the preceding and following objects have an "or" logical relationship.
[0073] In this application, 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 actual quantity, hierarchy or order relationship between these entities or operations.
[0074] Without further limitations, the use of terms such as “comprising,” “including,” “having,” or other similar open-ended expressions in this application is intended to cover non-exclusive inclusion, which does not exclude the presence of additional elements in a process, method, or product that includes the stated elements, such that a process, method, or product that includes a list of elements may include not only those defined elements but also other elements not expressly listed, or elements inherent to such a process, method, or product.
[0075] As understood in the Examination Guidelines, in this application, expressions such as "greater than," "less than," and "exceeding" are understood to exclude the stated number; expressions such as "above," "below," and "within" are understood to include the stated number. Furthermore, in the description of the embodiments in this application, "multiple" means two or more (including two), and similar expressions related to "multiple" are also understood in this way, such as "multiple groups" and "multiple times," unless otherwise explicitly specified.
[0076] In the description of the embodiments of this application, the space-related expressions used, such as "center," "longitudinal," "lateral," "length," "width," "thickness," "upper," "lower," "front," "rear," "left," "right," "vertical," "horizontal," "vertical," "top," "bottom," "inner," "outer," "clockwise," "counterclockwise," "axial," "radial," and "circumferential," indicate the orientation or positional relationship based on the orientation or positional relationship shown in the specific embodiments or drawings. They are only for the purpose of describing the specific embodiments of this application or for the reader's understanding, and do not indicate or imply that the device or component referred to must have a specific position, a specific orientation, or be constructed or operated in a specific orientation. Therefore, they should not be construed as limitations on the embodiments of this application.
[0077] Unless otherwise expressly specified or limited, the terms "installation," "connection," "linking," "fixing," and "setting," as used in the description of the embodiments of this application, should be interpreted broadly. For example, "connection" can be a fixed connection, a detachable connection, or an integral setting; it can be a mechanical connection, an electrical connection, or a communication connection; it can be a direct connection or an indirect connection through an intermediate medium; it can be the internal connection of two components or the interaction between two components. For those skilled in the art to which this application pertains, the specific meaning of the above terms in the embodiments of this application can be understood according to the specific circumstances.
[0078] This embodiment provides a multi-region adaptive matting method based on visual semantics, which can be applied to application scenarios that require separation of the main subject and replacement of the background in images, such as artificial intelligence image retouching, film and television post-production, digital human generation, and AIGC image generation.
[0079] Please see Figure 1 The multi-region adaptive matting method based on visual semantics in this embodiment includes the following steps:
[0080] S101. Obtain the input image to be processed, and perform visual semantic analysis on the input image to identify the main object in the input image, and generate a candidate processing region containing the main object based on the identification result;
[0081] S102. Divide the main candidate processing area into regions and identify the region type. Determine the region type corresponding to each region based on the texture features, edge features and visual semantic information of each region in the main candidate processing area. The region type includes solid regions, semi-transparent or transparent regions.
[0082] S103. Dynamically adjust the computing resource allocation strategy according to the region type of different regions in the main candidate processing region, and perform corresponding matting processing flow for different regions. For semi-transparent or transparent regions, perform a fine-grained restoration process to generate a transparency mask. The transparency mask is used to characterize the outline information and transparency information of the main object in the transparent region. For solid regions, perform a solid region matting process.
[0083] S104. Perform fusion processing based on the processing results of each region to generate a fused mask image.
[0084] In step S101, the input image to be processed is first acquired, and visual semantic analysis is performed on the input image to identify the main object in the input image. The main object includes a person, clothing, accessories, and other foreground objects, which can be props such as toys, tables, and models placed in front of the background. Based on the visual semantic analysis results, the area where the main object is located is distinguished from the background area, and a candidate processing area for the main object is generated. Unlike existing technologies that directly perform high-precision processing on the entire input image, this embodiment only performs subsequent fine-tuning processing on the candidate processing area for the main object, thereby reducing the participation of irrelevant background areas in the calculation and reducing the overall computational load.
[0085] In step S102, the candidate processing region is divided into regions and its type is identified. Based on texture features, edge features, and visual semantic information at different locations within the candidate processing region, the region is divided into multiple regions, and corresponding region type labels are determined. These region type labels represent the material properties and visual features corresponding to different regions, such as solid regions, hair-like regions, feather-like structure regions, transparent gauze regions, transparent glass-like regions, and mist-like regions. Figure 2 As shown on the left, the main candidate processing area is divided into a semi-transparent hair area, an opaque body area, and an opaque prop area (i.e., Figure 2 (The basket and mushrooms shown).
[0086] In step S103, the corresponding processing flow is invoked according to the region type label of each region. For solid regions, a solid region matting process is used; for semi-transparent or transparent regions, a refined restoration process is used to achieve targeted processing for objects of different materials. For hair-like regions with complex edge features, which also have a certain degree of light transmittance, they can be classified as semi-transparent or transparent regions, and therefore a refined processing flow can also be used. In the semi-transparent or transparent region restoration process, this embodiment does not use a traditional binary mask to represent the relationship between the subject and the background, but generates a transparency mask containing multiple consecutive gray levels based on the transparency of each pixel position in the semi-transparent or transparent region. The transparency mask is a two-dimensional data matrix corresponding to the spatial position of the semi-transparent or transparent region, where each data element corresponds to the transparency information of a pixel position within the semi-transparent or transparent region. The transparency information can be represented by a value in the range of 0 to 255, where a smaller value indicates a higher degree of transparency, and a larger value indicates a higher degree of opacity. For example, a value of 0 indicates that the corresponding position is completely transparent, and a value of 255 indicates that the corresponding position is completely opaque. Gray values in between represent different degrees of semi-transparency. Figure 2As shown in the middle, the hair area undergoes a fine-grained processing flow to obtain a transparency mask, while the body area and prop area undergo a solid area cutout process to generate an opaque mask.
[0087] The aforementioned transparency mask allows for the simultaneous recording of both the outline information and transparency variations of semi-transparent or transparent areas. For example, when processing semi-transparent areas of fabrics such as wedding dresses or tulle, the transparency mask preserves the continuous transition from opaque to transparent areas at the fabric edge. When processing objects such as glass or water vapor, the transparency mask preserves the differences in light transmission at different locations within the object, thus avoiding the loss of transparency due to the use of binary masks in existing technologies. Preferably, to ensure more consistent transparency variations in semi-transparent or transparent areas, a transparency mask with continuous grayscale levels can be used.
[0088] In step S103, this embodiment dynamically adjusts the computing resource allocation strategy based on the regional characteristics of the main candidate processing area. In specific implementation, the system determines the processing method based on the area ratio of the main candidate processing area, the total proportion of semi-transparent or transparent areas, and the complexity of the region. For example, when the proportion of semi-transparent or transparent areas in the main candidate processing area is small, a high-precision transparency restoration process is called only for the semi-transparent or transparent areas, while a normal processing process is used for other entity areas; when the area of the semi-transparent or transparent areas is large, for example, when the area of the semi-transparent or transparent areas in the main candidate processing area reaches a preset proportion threshold, the semi-transparent or transparent areas are divided into multiple sub-regions, and transparency restoration processing is performed separately to reduce the data scale of a single processing and improve processing efficiency; when the input image does not have any semi-transparent or transparent areas, the entity region matting process is directly executed.
[0089] Finally, in step S104, the processing results corresponding to different regions are fused. During the fusion process, the fusion weights between regions are calculated based on transparency continuity, edge gradient changes, color continuity, lighting consistency, and local texture changes. For example, at the edge of a semi-transparent or transparent region, if the transparency changes between adjacent pixels are continuous, the color difference is small, and the lighting direction is consistent, the fusion weight of the corresponding region is increased, allowing the semi-transparent or transparent region to blend naturally into the background. If there are obvious color differences, abrupt changes in transparency, or texture discontinuities at the edge, the fusion weight of the corresponding region is reduced, and the edge transition processing ratio is increased to reduce white edges, black edges, and edge breakage phenomena.
[0090] Through the above methods, this embodiment can reduce the overall computational resource consumption while ensuring the accuracy of restoring semi-transparent or transparent areas, and improve the realism and visual continuity of the fused masked image.
[0091] Based on the above embodiment one, this embodiment further illustrates the specific implementation methods of subject object recognition, region type recognition, region processing scheduling, and dynamic resource allocation in the multi-region adaptive matting method based on visual semantics.
[0092] In this embodiment, the visual semantic analysis process is used to determine the main objects that need to be refined from the input image. Specifically, after acquiring the input image, the system inputs the input image into the visual semantic analysis model. By performing feature extraction and semantic understanding on the image content in the input image, the system identifies the main objects contained in the input image and determines the candidate processing regions of the main objects based on their spatial location information.
[0093] The visual semantic analysis model can be implemented based on a deep learning network. It extracts features from target regions in the input image to obtain recognition results containing target category information and spatial location information. For example, when the input image is a person image, the visual semantic analysis model can identify the person, their clothing, and accessories. The visual semantic analysis model can be open-source or closed-source, such as Qwen2.5-VL, DINOv2, or the SAM series.
[0094] When generating candidate processing regions for the main subject based on visual semantic analysis results, the region location can be determined according to the boundary range corresponding to the main object, or a candidate processing region containing the edge region of the main object can be generated based on a preset extended range around the main object. For example, for regions with complex edge or transparent features such as hair or wedding dress in a portrait image, the range of the candidate processing region can be appropriately expanded so that the complete edge transition region can be included in the subsequent processing.
[0095] In this embodiment, visual semantic analysis is first used to determine the main object in the image, and then subsequent fine processing is performed on the candidate processing area of the main object. Compared with the existing technology, which directly performs high-precision matting on the complete input image, the amount of computation caused by the background area can be reduced, and the interference of complex background on the matting result can be reduced.
[0096] Furthermore, after generating the candidate processing region for the main body, this embodiment performs region type identification on the candidate processing region for the main body to determine the processing strategy corresponding to different regions.
[0097] Specifically, the system performs feature analysis on the candidate processing region of the main body, extracting texture features, edge features, and visual semantic features corresponding to different positions within the candidate processing region. Texture features describe the structural changes within the region, edge features describe the changes in the region's boundary positions, and visual semantic features describe the category information of the object corresponding to the region.
[0098] Based on the aforementioned texture features, edge features, and visual semantic features, the candidate processing regions are classified and corresponding region type labels are generated.
[0099] In one specific embodiment, the area type label includes at least a solid area label and a semi-transparent or transparent area label, wherein the semi-transparent or transparent area label includes one or more of the following: hair-like area label, feather-like structure area label, gauze-like transparent area label, glass-like transparent area label, water mist-like area label, and other semi-transparent structure area labels.
[0100] It should be noted that the region type classification in this embodiment is not based solely on object names, but rather on the visual characteristics and transparency properties exhibited by the objects. For example, wing-like objects typically have feather-like textures and can therefore be categorized into the feather-like structure region; wedding dress objects typically have a gauze texture and transparency, and can therefore be categorized into the gauze semi-transparent region. By classifying according to material and visual characteristics, the problem of ambiguous classification caused by inclusion relationships between different objects can be avoided, and subsequent processing flows can more accurately match the corresponding processing strategies.
[0101] Furthermore, based on the generated region type labels, the corresponding processing flow is invoked for different regions.
[0102] For solid regions, since these regions usually have relatively clear boundary information, the solid region matting process is invoked to generate the corresponding subject region result by recognizing the edge information of the solid region.
[0103] For hair-like regions, since hair typically has a filamentous structure, its edge areas contain a large number of fine structures and semi-transparent pixels. Therefore, the hair edge refinement process is invoked to further restore the edge pixels of the hair region in order to improve the integrity of the fine structures.
[0104] For feather-like structures, since feathers or objects with feather-like textures usually have a large number of fine edges and a certain degree of transparency, the focus of the processing is to restore the continuity of the feather-like structure edges and the transparency variation.
[0105] For transparent areas of gauze, since these areas usually contain both the main texture information and the background transmission information, a refined restoration process is used to generate a transparency mask in order to preserve the transparency relationship of the gauze material.
[0106] For glass-like transparent areas and water-mist-like areas, since their transparency is usually affected by background content, lighting, and local color changes, the fine-grained restoration process generates continuously changing transparency information based on the transparency of different locations within the transparent area.
[0107] By calling different processing flows for different region types, this embodiment avoids the problem of poor processing results caused by using a single model to uniformly process all material objects in the prior art, and enables different types of regions to adopt more suitable recovery methods.
[0108] Furthermore, this embodiment also dynamically adjusts the computing resource allocation strategy based on regional characteristics.
[0109] Specifically, the system determines the allocation of computing resources based on the proportion of the main candidate processing area, the total proportion of semi-transparent or transparent areas, and the complexity of the area.
[0110] Among them, the area of the main candidate processing region is used to represent the data scale of the region that needs to be processed; the total proportion of semi-transparent or transparent regions is used to represent the proportion of data in the input image that needs to be transparently restored; and the region complexity is used to represent the degree of change of region edges, texture complexity, and transparency.
[0111] In one specific implementation, multiple resource allocation levels can be set. For example:
[0112] When the proportion of semi-transparent or transparent areas to the main candidate processing area is low, for example, when the total area of semi-transparent or transparent areas is less than 10% of the area of the main candidate processing area, the system only calls high-precision transparent recovery processing for semi-transparent or transparent areas, while other entity areas use the normal processing flow, thereby avoiding repeated high-precision calculations in a large number of areas.
[0113] When the proportion of semi-transparent or transparent areas in the main candidate processing area is high, for example, when the total area of semi-transparent or transparent areas reaches more than 50% of the main candidate processing area, due to the large amount of data processed in a single operation, the system divides the semi-transparent or transparent areas into multiple sub-regions and performs transparency restoration processing on each sub-region separately. During the division process, the semi-transparent or transparent areas can be divided into multiple processing units of the same or different sizes based on their spatial location, allowing each processing unit to independently calculate transparency information. Finally, the results of multiple processing units are merged.
[0114] For example, for a semi-transparent or transparent area with a size of 2000×2000 pixels, if inputting the entire area into a high-precision restoration model may result in excessive memory usage, it can be divided into multiple sub-regions for separate processing (for example, further subdivided into hair-like areas and gauze-like transparent areas for processing), and the results can be fused based on the edge information between adjacent sub-regions.
[0115] When the input image does not have any semi-transparent or transparent areas, there is no need to perform the semi-transparent or transparent area restoration process. Instead, the solid area matting process is performed directly, thereby further reducing the consumption of computing resources.
[0116] Through the above-described dynamic resource allocation method, this embodiment can select different processing strategies according to the actual complexity of different input images, so that high-precision computing resources are concentrated on areas that truly require fine processing, thereby improving overall processing efficiency.
[0117] Furthermore, after completing the processing procedures for different regions, this embodiment merges the processing results from each region.
[0118] During the fusion process, the system calculates the fusion weights between different regions based on factors such as transparency continuity, edge gradient changes, color continuity, lighting consistency, and local texture changes.
[0119] Specifically, for the pixels at the location to be fused, the system can calculate the transparency difference parameter, edge gradient difference parameter, color difference parameter, illumination difference parameter, and texture similarity parameter respectively, and determine the fusion weight based on the above parameters.
[0120] For example, at the boundary between a semi-transparent or transparent area and the background:
[0121] If the transparency of the current pixel and its neighboring pixels change continuously, the color difference is small, and the lighting direction is consistent, it indicates that the region has high fusion reliability. Therefore, the fusion weight corresponding to this region is increased, so that the semi-transparent or transparent region can naturally transition to the background region.
[0122] If the current pixel has obvious abrupt changes in transparency, large color differences, or discontinuous texture, the fusion weight of that area is reduced and the edge smoothing ratio is increased to reduce edge anomalies after fusion.
[0123] By using the above fusion method, this embodiment can comprehensively consider transparency information, edge information, color information, and lighting information, so that the semi-transparent or transparent area and the background can achieve a more natural transition, reducing the white edges, black edges, and edge breakage problems that are easy to occur in traditional methods.
[0124] In summary, this embodiment achieves adaptive and refined matting processing for objects of different materials through visual semantic analysis, region type recognition, adaptive region scheduling, transparency information recovery, and dynamic resource allocation. While improving the recovery effect of semi-transparent or transparent regions, it reduces the overall computational resource consumption and improves image processing efficiency and fusion quality.
[0125] Based on the above embodiments, this embodiment further illustrates the image fusion process in the multi-region adaptive matting method based on visual semantics, as well as the apparatus and storage medium for implementing the above method.
[0126] After completing the processing flow for different regions in the input image, the system obtains the processing results for the solid regions and the processing results for the semi-transparent or transparent regions. The processing results for the semi-transparent or transparent regions include a transparency mask corresponding to the semi-transparent or transparent region, which records the transparency information corresponding to the pixel positions within the semi-transparent or transparent region. To ensure that the processed subject object can be naturally integrated into the new background image, this embodiment further performs a fusion process based on the transparency mask and the processing results for each region, generating a fused mask image.
[0127] Specifically, during the fusion process, the system first determines the fusion range between the subject object and the background image based on the transparency mask, and then calculates the corresponding fusion weights for the edge regions of the subject object. These fusion weights represent the degree of contribution of the processing results of different regions to the final fused masked image.
[0128] In one specific implementation, the system calculates the fusion weight based on multiple factors such as transparency continuity, edge gradient change, color continuity, illumination consistency, and local texture change.
[0129] Transparency continuity is used to represent the change in transparency between adjacent pixels. When the transparency change is continuous within a semi-transparent or transparent area, it indicates that the area has a natural transition characteristic, so the blending weight of the corresponding area can be increased; when the transparency change is large between adjacent pixels, it indicates that the area may be at the edge of the subject, so the blending weight is reduced and edge smoothing is increased.
[0130] Edge gradient changes are used to represent the degree of brightness variation at image edges. The system analyzes the gradient changes in the edge regions of the main object to determine whether there are obvious boundaries in the current region. When the edge gradient change is relatively gentle, it indicates a natural transition between the subject and the background, and the fusion weight can be increased; when the edge gradient change is more obvious, the fusion weight is decreased to reduce the appearance of obvious boundaries after fusion.
[0131] Color continuity is used to represent the degree of color difference between the subject area and the background area. When the colors of the subject area and the background area are similar, the blending weight of the corresponding position is increased; when the color difference is large, adjustments are made based on the transparency information to avoid obvious color abrupt changes.
[0132] Illumination consistency is used to represent the degree of lighting matching between the subject object and the target background. The system can determine illumination consistency based on information such as the brightness distribution and shadow change direction of the subject and background areas, and adjust the blending weights according to the judgment results, so that the blended subject object can better match the target background environment.
[0133] Local texture variations are used to represent the degree of texture continuity in the edge region of the subject. When the texture of the subject's edge blends naturally with the background texture, the blending weight is increased; when there are obvious breaks in the texture, the blending weight is decreased.
[0134] In one specific implementation, the fusion weight can be calculated comprehensively based on the above-mentioned multiple evaluation parameters.
[0135] In the above embodiments, after generating the fused mask image, the method further includes:
[0136] The grayscale value of each pixel in the fused mask image is used as the transparency channel value of the corresponding pixel in the input image (i.e., the original image);
[0137] The transparency channel value is merged pixel-by-pixel with the red, green, and blue channels of the input image to obtain the cutout result in RGBA format.
[0138] like Figure 3 As shown, the input image in the middle (i.e., the original color image) and the fused mask image with the same spatial dimensions on the left undergo multi-channel merging processing to generate a matting result with color and transparency information. For example, if the RGB value of a pixel in the input image is [120, 200, 80], and the corresponding grayscale value in the fused mask image is 153, then the RGBA value of that pixel in the matting result is: [120, 200, 80, 153]. The opacity corresponding to the transparency channel value of 153 is: 153 / 255 = 60%, meaning that the pixel is displayed with 60% opacity and 40% transparency.
[0139] like Figure 4 As shown, another embodiment provides a multi-region adaptive matting device 200 based on visual semantics, which is used to implement the multi-region adaptive matting method based on visual semantics in the above embodiment.
[0140] The multi-region adaptive matting device 200 based on visual semantics includes a visual semantic analysis module 201, a region type recognition module 202, a region scheduling module 203, a fine-grained restoration module 204, a dynamic resource allocation module 205, and an image fusion module 206.
[0141] The visual semantic analysis module 201 is used to acquire the input image and perform visual semantic analysis on the input image to identify the main object in the input image and generate the main object candidate processing region according to the positional relationship of the main object.
[0142] The region type recognition module 202 is used to divide the candidate processing region of the subject into regions and recognize the region type. It determines the corresponding region type label based on the texture features, edge features and visual semantic information in the candidate processing region of the subject.
[0143] The region scheduling module 203 is used to determine the corresponding processing flow based on the region type. Specifically, for solid regions, the solid region matting process is invoked, and for semi-transparent or transparent regions, the fine-grained restoration process is invoked.
[0144] The fine-grained restoration module 204 is used to perform a fine-grained restoration process on semi-transparent or transparent areas and generate a transparency mask. The transparency mask is used to record the transparency information and the outline information of the main object at each position within the transparent area.
[0145] The dynamic resource allocation module 205 is used to adjust the computing resource allocation strategy according to the area ratio of the main candidate processing region, the total ratio of semi-transparent or transparent regions, and the complexity of the region, so that different input images can be processed in the corresponding way.
[0146] The image fusion module 206 is used to fuse images based on the transparency mask and the processing results of each region, and to calculate the fusion weights based on transparency continuity, edge gradient change, color continuity, illumination consistency and local texture change to generate the final fused mask image.
[0147] Through the above-described module structure, this embodiment can realize a complete processing flow of automatic input image analysis, region adaptive processing, transparent information recovery, and fusion output.
[0148] like Figure 5 As shown, another embodiment provides a computer-readable storage medium 300.
[0149] The computer-readable storage medium stores a computer program that, when executed by a processor, causes the processor to perform the visual semantic-based multi-region adaptive matting method described in any of the above embodiments.
[0150] The computer-readable storage medium can be volatile memory or non-volatile memory, or it can include both. The non-volatile memory can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), ferromagnetic random access memory (FRAM), flash memory, magnetic surface memory, optical disc, or compact disc read-only memory (CD-ROM); the magnetic surface memory can be disk storage or magnetic tape storage.
[0151] The volatile memory may be random access memory (RAM), which serves as an external cache. By way of example, but not limitation, many forms of RAM are available, such as static random access memory (SRAM), synchronous static random access memory (SSRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synclink dynamic random access memory (SLDRAM), and direct memory bus random access memory (DRRAM). The computer-readable storage media described in the embodiments of the present invention are intended to include these and any other suitable types of memory.
[0152] In some embodiments, the processor may be implemented by software, hardware, firmware, or a combination thereof, and may be a circuit, one or more of an application-specific integrated circuit (ASIC), a digital signal processor (DSP), a digital signal processing device (DSPD), a programmable logic device (PLD), a field-programmable gate array (FPGA), a central processing unit (CPU), a controller, a microcontroller, or a microprocessor, thereby enabling the processor to execute some or all of the steps or any combination thereof in the visual semantic-based multi-region adaptive matting method described in the various embodiments of this application.
[0153] Finally, it should be noted that although the above embodiments have been described in the text and drawings of this application, this should not limit the scope of patent protection of this application. Any technical solutions that are based on the essential concept of this application and utilize the content described in the text and drawings of this application, resulting in equivalent structural or procedural substitutions or modifications, as well as the direct or indirect application of the technical solutions of the above embodiments to other related technical fields, are all included within the scope of patent protection of this application.
Claims
1. A multi-region adaptive image matting method based on visual semantics, characterized in that, include: The input image to be processed is acquired, and visual semantic analysis is performed on the input image to identify the main object in the input image, and a candidate processing region containing the main object is generated based on the identification result; The main candidate processing region is divided into regions and the region type is identified. The region type corresponding to each region is determined according to the texture features, edge features and visual semantic information of each region in the main candidate processing region. The region type includes solid region, semi-transparent or transparent region. The computing resource allocation strategy is dynamically adjusted according to the region type of different regions in the main candidate processing region, and the corresponding matting process is executed for different regions. Among them, a fine-grained restoration process is executed for semi-transparent or transparent regions to generate a transparency mask. The transparency mask is used to represent the outline information and transparency information of the main object in the semi-transparent or transparent region. For solid regions, a solid region matting process is executed. The processing results for each region are fused together to generate a fused mask image.
2. The multi-region adaptive matting method based on visual semantics according to claim 1, characterized in that, The visual semantic analysis of the input image includes: The input image is used to perform target recognition using a visual semantic analysis model in order to determine the main object in the input image; Based on the identification results of the subject object, the foreground subject region and the background region are distinguished; A candidate processing region for the subject is generated based on the foreground subject region, so that subsequent fine-tuning processing is performed only on the candidate processing region for the subject.
3. The multi-region adaptive matting method based on visual semantics according to claim 1, characterized in that, The process of dividing the candidate processing region into regions and identifying region types includes: Extract texture features, edge features, and visual semantic features from the main candidate processing region; The candidate processing region of the main body is divided into two or more regions based on the extracted texture features, edge features, and visual semantic features, and the region type of each region is determined. Generate the corresponding region type label; The region type labels include at least solid region labels and semi-transparent or transparent region labels.
4. The multi-region adaptive matting method based on visual semantics according to claim 3, characterized in that, The area type corresponding to the semi-transparent or transparent area label includes one or more of the following: Hair-like areas, feather-like structures, transparent gauze areas, transparent glass-like areas, water-mist-like areas, and semi-transparent decorative areas; The feather-like structure region includes feather objects and wing-like objects with feather-like texture features, while the gauze-like transparent region includes wedding dress objects, tulle objects, and other transparent objects with gauze-like texture features.
5. The multi-region adaptive matting method based on visual semantics according to claim 1, characterized in that, The refined recovery process includes: Transparency information is calculated based on the image data corresponding to the semi-transparent or transparent areas; Generate a transparency mask containing multiple consecutive gray levels; In this process, different grayscale values in the transparency mask correspond to different degrees of transparency, so as to preserve the true transparency relationship of the main object within the transparent area.
6. The multi-region adaptive matting method based on visual semantics according to claim 1, characterized in that, The dynamic adjustment strategy for computing resource allocation includes: The processing method is determined based on the proportion of the main candidate processing area, the total proportion of semi-transparent or transparent areas, and the complexity of the area. When the total area of the semi-transparent or transparent region is less than the preset condition, high-precision restoration processing is performed only on the semi-transparent or transparent local region. When the total area of the semi-transparent or transparent area meets the preset conditions, the semi-transparent or transparent area is divided into blocks. When the input image does not have any semi-transparent or transparent areas, the solid region cutout process is executed directly.
7. The multi-region adaptive matting method based on visual semantics according to any one of claims 1 to 6, characterized in that, The fusion process includes: The region fusion weights are calculated based on transparency continuity, edge gradient variation, color continuity, illumination consistency, and local texture variation. The processing results corresponding to different regions are fused based on the fusion weights. Output a blended mask image with correct transparency and natural, continuous edges.
8. The multi-region adaptive matting method based on visual semantics according to claim 1, characterized in that, Following the generation of the fused mask image, the following is also included: The grayscale value of each pixel in the fused mask image is used as the transparency channel value of the corresponding pixel in the input image; The transparency channel value is merged pixel-by-pixel with the red, green, and blue channels of the input image to obtain the cutout result in RGBA format.
9. A multi-region adaptive image matting device based on visual semantics, characterized in that, include: The visual semantic analysis module is used to acquire the input image, identify the main object in the input image, and generate candidate processing regions for the main object; The region type identification module is used to divide the main candidate processing region into regions and identify the region type, and generate region type labels; The regional scheduling module is used to invoke the corresponding processing flow according to the regional type; The fine-grained restoration module is used to perform a fine-grained restoration process on semi-transparent or transparent areas and generate a transparency mask; The dynamic resource allocation module is used to adjust the computing resource allocation strategy based on the regional characteristics of the main candidate processing area; The image fusion module is used to generate a fused mask image based on the transparency mask and the processing results of each region.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, causes the processor to implement the visual semantic-based multi-region adaptive matting method according to any one of claims 1 to 8.
