Flux-based virtual mannequin and garment intelligent color changing method
By using a FLUX-based virtual model and intelligent clothing color-changing method, and leveraging a dual constraint mechanism of topological feature preservation and color guidance, the structural integrity problem of complex pattern areas is solved, achieving a high-fidelity and highly consistent clothing color-changing effect.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- SHANGHAI SHIJIE TECHNOLOGY GROUP CO LTD
- Filing Date
- 2026-02-14
- Publication Date
- 2026-05-29
AI Technical Summary
Existing virtual model and clothing color-changing technologies struggle to maintain the integrity of pattern structure and topological features when processing complex patterns. This results in blurred textures, loss of details, and unnatural edges after color changing. Furthermore, the lack of an effective topological constraint mechanism affects both visual appeal and practicality.
A FLUX-based intelligent color-changing method for virtual models and clothing is adopted. By introducing a dual constraint mechanism of topological feature preservation and color guidance, the clothing skeleton is extracted using Rips simple complex and Betti number topological features. A dual-constraint latent feature tensor is constructed, and iterative generation is performed with priority given to topological constraints. Combined with SIFT feature registration and Poisson fusion algorithms, high-fidelity color changing is achieved.
It accurately extracts clothing areas while maintaining the connectivity of complex pattern structures, avoiding color overflow and structural distortion, and outputs high-fidelity, visually natural clothing color-changing results, thus improving the accuracy and reliability of color-changing processing.
Smart Images

Figure CN122115068A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image processing technology, specifically to a method for intelligent color-changing of virtual models and clothing based on FLUX. Background Technology
[0002] With the rapid development of virtual try-on and the digital fashion industry, intelligent color-changing technology for virtual models and clothing images has become a research hotspot. Traditional methods mainly rely on image segmentation, color transfer, and generative adversarial networks to identify and replace the colors of clothing areas. For example, some methods use semantic segmentation models to extract clothing areas and then achieve color changing through color histogram matching or color transfer based on optimization algorithms. Other methods use conditional generation models to locally recolor clothing areas based on color cues provided by the user. These methods perform well in simple scenes and solid-color clothing and can achieve a certain degree of automated color changing.
[0003] However, existing methods often struggle to maintain the structural integrity and topological features of garments with complex patterns, leading to issues such as blurred textures, loss of details, and unnatural edges after color replacement. This is especially true in areas with dense textures and complex structures, where colors can easily spill into non-garment areas or disrupt the connectivity and geometric structure of the original pattern, severely impacting visual appeal and usability. Furthermore, most methods lack topological constraints on the color filling process, making it impossible to achieve accurate regional coloring while preserving the pattern's skeletal structure, resulting in significant discrepancies between the generated results and user expectations. Additionally, existing methods have limitations in iteration stopping conditions, multi-feature fusion, and edge optimization, making it difficult to simultaneously achieve high-fidelity color replacement and structural preservation, thus limiting their application in high-end virtual try-on and digital design. Summary of the Invention
[0004] (a) Technical problems to be solved To address the shortcomings of existing technologies, this invention provides a FLUX-based intelligent color-changing method for virtual models and clothing. By introducing a dual constraint mechanism of topological feature preservation and color guidance, it solves the problems of traditional color-changing methods, such as loss of structural details, severe color overflow, and unnatural edge blending in complex pattern areas, thus achieving high-fidelity and high-consistency intelligent clothing color-changing.
[0005] (II) Technical Solution To achieve the above objectives, the present invention provides the following technical solution: a FLUX-based intelligent color-changing method for virtual models and clothing, comprising: The original images of the virtual model and clothing are obtained, and after preprocessing, standardized images are obtained. The standardized images are divided into clothing areas and non-clothing areas. Individual images of clothing are extracted from the clothing areas, and complex pattern areas and solid color areas are distinguished to generate corresponding area masks. Based on the extraction of grayscale images of complex patterns using complex pattern region masks, Rips simplex is constructed and Betti number topological features are calculated to generate a topological feature set. The skeleton of the complex pattern grayscale image is extracted to generate a topological skeleton map. With the topological skeleton map as a constraint, the color-filled region is divided by a region growing algorithm to generate a color-filled region mask, which is then merged with the solid color region mask to form a color-changeable region mask and a non-color-changeable region mask. The standardized image, topological skeleton map, region mask, and topological feature set are encoded into a fusion latent feature tensor. The topological constraint vector and the target color guidance vector input by the user are embedded to construct a double-constraint latent feature tensor. The conditional guidance chain of the FLUX model is modified to prioritize topological constraints over color guidance, and constrained iterative generation is performed to output the intermediate color-changing image. The intermediate color-changing image is aligned with the topological skeleton map and the normalized image using SIFT feature registration, and the edges are smoothed using the Poisson fusion algorithm to output the final clothing color-changing result image.
[0006] Furthermore, a bilinear interpolation algorithm is used to normalize the original image to a preset resolution, an adaptive histogram equalization algorithm is used to optimize brightness and contrast, and a Gaussian bilateral filtering algorithm is used to filter noise, resulting in a denoised standardized image. The U-Net semantic segmentation model is used as input, and a 5-channel semantic segmentation map is output. After binarization, a clothing region mask and a non-clothing region mask are generated. The non-clothing region can be any one of the following: skin, hair, background, or accessories.
[0007] Furthermore, based on the clothing region mask, a mask multiplication operation is used to extract individual clothing images from the standardized image; the LBP texture feature extraction algorithm is used to extract the texture features of the clothing image, calculate the texture complexity of each window, and determine the regions with texture complexity greater than the texture complexity threshold as complex pattern regions, and the regions with texture complexity less than or equal to the texture complexity threshold as solid color regions, thereby generating complex pattern region masks and solid color region masks.
[0008] Furthermore, based on the complex pattern region mask, a mask multiplication operation is used to separate the complex pattern individual image from the standardized image; an RGB-to-grayscale algorithm is used to convert the complex pattern individual image into a single-channel grayscale image, obtaining the complex pattern grayscale image; the complex pattern grayscale image is regarded as a two-dimensional pixel cloud, and the grayscale difference is used as a distance metric. For any two adjacent 8-neighbor pixels, if the difference in their grayscale values is less than the grayscale difference threshold, the two pixels are connected to form the edge of a simplex; any three interconnected edges that form a triangle constitute a two-dimensional simplex; a filtering sequence is generated in the order of progressively increasing scale parameter ε.
[0009] Furthermore, at each scale ε of the filtered sequence, the zero-dimensional Betti number, which statistically represents the number of connected components, is calculated. The 1-dimensional Betti number representing the number of holes The 2D Betti number represents the number of closed regions. Calculate the lifetime of each topological feature in the filtered sequence. The lifetime is the difference between the disappearance and appearance of ε. Remove false topological features whose lifetime is less than or equal to the lifetime threshold. Then, filter the remaining topological features. , , Numerical values, filter sequences, the lifetime of each topological feature, and the ε values at the time of appearance and disappearance are saved as a topological feature set.
[0010] Furthermore, a thinning algorithm based on distance transform is used to extract the skeleton from the grayscale image of the complex pattern and generate a topological skeleton map. Using the topological skeleton map as a boundary constraint, the region in the grayscale image of the complex pattern other than the topological skeleton is divided into several independent color-filled regions, and corresponding region masks are generated. The color-filled region mask and the solid color region mask are bitwise ORed to obtain the color-changeable region mask. The topological skeleton region and the non-clothing region are marked as non-color-changeable regions, and a non-color-changeable region mask is generated.
[0011] Furthermore, from the topological feature set, the Betti number, filtering sequence, and survival time parameters are extracted and normalized to the 0~1 interval using min-max to obtain the topological constraint vector. The topological constraint vector is then embedded into the fusion latent feature tensor. The user-inputted target color-changing instruction is obtained, and the RGB value of each target color is converted into a color feature vector. Based on the color-changeable region mask, a region color mapping table is constructed, which includes the color-changeable region number, region type, target color RGB value, and corresponding color feature vector. All color feature vectors are integrated into a color guidance tensor, which is then concatenated with the fusion latent feature tensor after embedding the topological constraint vector to form a double-constraint latent feature tensor.
[0012] Furthermore, the constructed region color mapping table and the dual-constraint latent feature tensor are integrated into the conditional guidance chain of the FLUX model. A dual-constraint guidance chain is constructed to mark three key denoising nodes: color-changeable region shaping, color filling refinement, and final image optimization, and to activate the corresponding constraints at each node. An iteration stop judgment criterion is set, including: the color similarity between the color-changeable region and the target color after color change is ≥95%, and the similarity between the topological features of the complex pattern and the topological feature set after color change is ≥98%. If both conditions are met, the iteration stops and the intermediate color-change image is output.
[0013] Furthermore, the Canny edge detection algorithm is used to perform edge detection on the intermediate color-changing image and the topological skeleton map. The offset between the edge of the color-changing area in the intermediate color-changing image and the edge of the topological skeleton map is calculated. If the offset is ≥1 pixel, the edge alignment algorithm is used to align the edge of the color-changing area with the edge of the topological skeleton map.
[0014] Furthermore, the SIFT feature matching algorithm is used to perform pixel-level registration and alignment of the intermediate color-changing image, the topological skeleton map, and the standardized image. The SIFT feature points of the three are extracted and matched to ensure that the coordinate deviation of the corresponding pixels in each layer is no more than 1 pixel. Using the aligned topological skeleton map as the boundary constraint, the Poisson fusion algorithm is used to perform gradient smoothing on the connecting edges of the color-filled area, the solid color area of the clothing, and the topological skeleton area in the intermediate color-changing image, and output the final virtual model clothing color-changing result image.
[0015] (III) Beneficial Effects This invention provides a FLUX-based intelligent color-changing method for virtual models and clothing, which has the following beneficial effects: (1) By image preprocessing and semantic segmentation, the clothing area is accurately extracted and complex patterns and solid color areas are distinguished to generate a high-quality mask, which provides accurate area constraints for subsequent color-changing operations, effectively avoids color overflow and structural distortion, and improves the accuracy and reliability of color-changing processing.
[0016] (2) By extracting the topological features of complex patterns and generating skeleton diagrams, the structural connectivity and geometric characteristics of patterns are accurately quantified and maintained; the color filling area is divided by topological skeleton as a constraint, which effectively avoids the distortion of pattern structure, loss of details and color overflow during the color change process, and provides high-fidelity area constraints and structural guarantees for subsequent intelligent color change.
[0017] (3) By constructing a double-constraint latent feature tensor and modifying the conditional guidance chain of the FLUX model, the topological constraints are prioritized over the color guidance for iterative generation, which effectively ensures the structural integrity and topological feature consistency of complex patterns. At the same time, it accurately realizes the color filling specified by the user, avoids color overflow and structural distortion, and significantly improves the fidelity and visual naturalness of the color replacement result.
[0018] (4) By using SIFT feature registration and Poisson fusion algorithm, the intermediate color-changing image, topological skeleton and original image are accurately aligned to eliminate layer misalignment and edge jaggedness, and to ensure seamless connection between color area and structural boundary; at the same time, gradient smoothing is used to process the fusion edge, which effectively avoids color discontinuity and hard boundary phenomenon, and finally outputs a high-fidelity, visually natural clothing color-changing result image. Attached Figure Description
[0019] Figure 1This is a schematic diagram illustrating the steps of the FLUX-based intelligent color-changing method for virtual models and clothing in this invention. Figure 2 This is a schematic diagram of the process of the intelligent color-changing method for virtual models and clothing based on FLUX according to the present invention. Detailed Implementation
[0020] 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 embodiments of the present invention, and not all embodiments. 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.
[0021] Please see Figures 1-2 This invention provides a method for intelligent color-changing of virtual models and clothing based on FLUX, comprising the following steps: Step 1: Obtain the original images of the virtual model and clothing. After preprocessing, obtain standardized images. Divide the standardized images into clothing areas and non-clothing areas. Extract individual clothing images from the clothing areas and distinguish between complex pattern areas and solid color areas to generate corresponding area masks. Step one includes the following: Step 101: Obtain the original images of the virtual model and clothing generated by the FLUX model. The original clothing images are RGB color images. Use bilinear interpolation to normalize the original images to a preset resolution of 1024×1024 pixels. For the size-normalized images, use the adaptive histogram equalization (CLAHE) algorithm to optimize brightness and contrast. The clipLimit parameter of the CLAHE algorithm is set to 2, and the grid size is set to 8×8. For the brightness and contrast-normalized images, use the Gaussian bilateral filtering algorithm to filter noise. The filter kernel size is set to 5×5, the spatial standard deviation is set to 1.5, and the gray value standard deviation is set to 2 to obtain the denoised and standardized image. Step 102: An improved U-Net semantic segmentation model incorporating the CBAM channel attention mechanism is adopted. The standardized image is used as input. The improvement to the U-Net semantic segmentation model is as follows: a CBAM channel attention mechanism module is embedded at the skip connection between the encoder and decoder of the U-Net semantic segmentation model. This CBAM channel attention mechanism module first adaptively allocates the channel weights of the feature map through a channel attention branch, increasing the weight of the edge feature channels of the clothing region and suppressing the weights of the feature channels of the skin and background regions. Then, it strengthens the edge contour differences between the clothing region and the non-clothing region through a spatial attention branch, thereby improving the edge segmentation accuracy. Five semantic labels are preset: clothing region, skin region, hair region, background region, and accessory region. Specifically, the accessory region refers to areas on the clothing that are independent of the main pattern and solid color areas. The decorative components of the domain include buttons, zippers, belts, and pocket decorations, and the accessory area does not participate in the subsequent clothing color-changing operation; after the U-Net semantic segmentation model is trained, a denoised and standardized image is input, the image features are extracted by the encoder, the feature differences are enhanced by the CBAM channel attention mechanism module, and the decoder outputs a 5-channel semantic segmentation map, each channel corresponding to a semantic label; the 5-channel semantic segmentation map is binarized to generate clothing area masks and non-clothing area masks. When the pixel value of the clothing area mask is 1, it means that the corresponding pixel belongs to the clothing area, and when the pixel value is 0, it means that the corresponding pixel does not belong to the clothing area. When the pixel value of the non-clothing area mask is 1, it means that the corresponding pixel belongs to any one of the skin, hair, background, and accessory areas, and when the pixel value is 0, it means that the corresponding pixel does not belong to any one of the skin, hair, background, and accessory areas. Step 103: Based on the generated clothing region mask, a mask multiplication operation is used to retain only clothing region pixels with a mask pixel value of 1 from the standardized image, and remove non-clothing region pixels to extract individual clothing images; for the extracted individual clothing images, the LBP (Local Pattern) texture feature extraction algorithm is used to extract the texture features of the clothing image, and the texture complexity of each window is calculated through a 3×3 sliding window. The texture complexity is the variance of the LBP feature values within the window. The preset texture complexity threshold is 0.7. Regions with a texture complexity greater than the texture complexity threshold are identified as complex pattern regions, and regions with a texture complexity less than or equal to the texture complexity threshold are identified as solid color regions. Complex pattern region masks and solid color region masks are generated. A mask pixel value of 1 represents the corresponding region, and a pixel value of 0 represents a non-corresponding region. Step 104: For the generated clothing area mask, non-clothing area mask, complex pattern area mask, and solid color area mask, a 3×3 square structuring element is used. First, an expansion operation is performed to fill the small gaps at the edge of the mask, and then an erosion operation is performed to eliminate the jagged noise at the edge of the mask, so that the edges of all masks are smooth and completely fit the actual edge of the corresponding image area.
[0022] When using this method, refer to steps 101 to 104: By using image preprocessing and semantic segmentation, the clothing area is accurately extracted and complex patterns and solid color areas are distinguished, generating a high-quality mask. This provides accurate regional constraints for subsequent color-changing operations, effectively avoiding color overflow and structural distortion, and improving the accuracy and reliability of color-changing processing.
[0023] Step 2: Extract the grayscale image of the complex pattern based on the complex pattern region mask, construct the Rips simplex and calculate the Betti number topological features to generate a topological feature set, extract the skeleton of the complex pattern grayscale image to generate a topological skeleton map, use the topological skeleton map as a constraint, divide the color-filled region through the region growing algorithm to generate a color-filled region mask, and merge it with the solid color region mask to form a color-changeable region mask and a color-non-color-changeable region mask; Step two includes the following: Step 201: Based on the complex pattern region mask, use the mask multiplication operation to retain only the complex pattern region pixels with a mask pixel value of 1 from the normalized image, and remove the non-complex pattern region pixels to separate the complex pattern individual image; use the RGB to grayscale algorithm to convert the complex pattern individual image into a single-channel grayscale image to obtain the complex pattern grayscale image. Step 202: Treat the complex pattern grayscale image as a two-dimensional pixel point cloud. Each vertex of this point cloud corresponds to a pixel in the complex pattern grayscale image. The coordinates of the vertex are the two-dimensional pixel coordinates of that pixel in the image, and the feature parameters of the vertex are the grayscale values corresponding to that pixel. Use the grayscale value difference as a distance metric between pixels. Based on the above distance metric, construct a Rips simplex complex. The specific operation is as follows: Treat each pixel as a vertex of the simplex complex. Set the grayscale value difference threshold to 10. For any two pixels that are adjacent in their 8-neighborhoods, i.e., the two pixels are adjacent horizontally, vertically, or diagonally, if the two... If the grayscale difference is less than the grayscale difference threshold, then the two pixels are connected to form the edge of a simple complex. For any three interconnected edges forming a triangle, if the grayscale difference between the pixels corresponding to the three edges is less than the grayscale difference threshold, then these three edges form a two-dimensional simple complex. A filtering sequence is generated in order of increasing scale parameter ε, where ε ranges from 0 to 255 and the step size is set to 1. Each ε value corresponds to a simple complex. As ε increases, the connection relationships of pixels with grayscale differences less than or equal to the current ε value are gradually added to the simple complex, forming a series of progressively embedded simple complexes. Step 203: At each scale ε of the generated filtered sequence, count the core topological feature parameter Betti number of the complex pattern, specifically as follows: 0-dimensional Betti number The number of connected components used to describe a complex pattern, i.e., the number of independent and disconnected pattern units in the complex pattern, takes a non-negative integer value; 1-dimensional Betti number. Used to describe the number of holes in complex patterns, i.e., the number of blank areas within each pattern unit, with a value that is a non-negative integer; 2D Betti number. Used to describe the number of closed regions in a complex pattern, that is, the number of independent regions surrounded by skeleton lines in each pattern unit, with a value that is a non-negative integer; through , , Three parameters are used to fully quantify the topological connectivity and structural features of complex patterns. A threshold filtering method is employed to remove false topological features caused by image noise and grayscale fluctuations. The specific steps are as follows: The survival time of each topological feature (connected branches, holes, and closed regions) in the filtered sequence is calculated. The survival time is the difference between the disappearance and appearance of ε, where appearance is the scale parameter value when the topological feature first appears in the filtered sequence, and disappearance is the scale parameter value when the topological feature disappears in the filtered sequence. The unit of survival time is scale units. A survival threshold is set according to the complexity of the complex pattern: if the pattern density is ≥50 patterns / 100×100 pixels, the survival threshold is set to 10 scale units; if the pattern density is <50 patterns / 100×100 pixels, the survival threshold is set to 5 scale units. Topological features with survival times greater than the corresponding survival threshold are retained, while false topological features with survival times less than or equal to the survival threshold are removed. The filtered... , , Numerical values, complete filtered sequences, the lifetime of each topological feature, and the ε values at the time of appearance and disappearance are saved as a topological feature set; Step 204: Employ a distance-transform-based thinning algorithm to extract the skeleton from the grayscale image of the complex pattern. The specific steps are as follows: Perform a distance transform on the grayscale image of the complex pattern and calculate the distance from each pixel to the nearest background pixel. Set a distance threshold of 2 pixels and retain pixels with distance values greater than or equal to the distance threshold. Gradually refine the image to obtain the core skeleton lines of the complex pattern. The thickness of these skeleton lines is uniformly set to 1 pixel. The connection relationships, branch structures, and hole outlines of the skeleton lines are completely consistent with the original complex pattern. Only the structural information of the pattern is retained, without any color information. Generate a topological skeleton diagram. This topological skeleton diagram is a single-channel image with a skeleton line pixel value of 255 and a background pixel value of 0. Step 205: Using the topological skeleton graph as boundary constraint, a region growing algorithm is employed to segment the region in the grayscale image of the complex pattern, excluding the topological skeleton lines, into several independent color-filled regions. The specific operation is as follows: Each pixel in the non-skeleton region is used as an initial seed point. The region growing threshold is set to 5, meaning that when the grayscale value difference between adjacent pixels is no greater than 5, they are classified into the same filling region. During the growing process, the topological skeleton lines are not crossed, ensuring that each color-filled region is surrounded by the topological skeleton lines and that the filling regions are not interconnected. After segmentation, a color-filled region mask is generated. Each color-filled region corresponds to an independent mask channel. A mask pixel value of 1 indicates that the corresponding pixel belongs to the color-filled region, and a pixel value of 0 indicates that it does not belong to the color-filled region. Step 206: Perform a bitwise OR operation on the color fill area mask and the clothing solid color area mask to form a unified color-changeable area mask. A pixel value of 1 indicates that the corresponding area is a color-changeable area, and a pixel value of 0 indicates that the corresponding area is a non-color-changeable area. At the same time, mark the topological skeleton area and non-clothing area as non-color-changeable areas to generate a non-color-changeable area mask.
[0024] When using this method, refer to steps 201 to 206: By extracting the topological features of complex patterns and generating skeleton diagrams, the structural connectivity and geometric properties of the patterns are accurately quantified and preserved. The color filling areas are divided with the topological skeleton as a constraint, which effectively avoids the distortion of pattern structure, loss of details and color overflow during the color changing process, and provides high-fidelity regional constraints and structural guarantees for subsequent intelligent color changing.
[0025] Step 3: Encode the standardized image, topological skeleton map, region mask, and topological feature set into a fusion latent feature tensor, embed the topological constraint vector and the target color guidance vector input by the user, construct a double-constraint latent feature tensor, modify the conditional guidance chain of the FLUX model, prioritize topological constraints over color guidance, perform constrained iterative generation, and output the intermediate color-changing image. Step three includes the following: Step 301: Initialize the FLUX model. Take the standardized image, topological skeleton diagram, color-changeable region mask and non-color-changeable region mask, and topological feature set as input data and feed them into the latent space encoder of the FLUX model. The encoder transforms the above input data into a latent space feature tensor of a unified dimension. Specifically, the standardized image is transformed into a basic feature tensor, the topological skeleton diagram is transformed into a structural feature tensor, the color-changeable / non-color-changeable region mask is transformed into a region constraint tensor, and the topological feature file is transformed into a topological feature tensor. All tensor dimensions are uniformly matched to achieve multi-feature fusion encoding and obtain a fused latent feature tensor. Step 302: Extract the filtered 0-dimensional Betti number, 1-dimensional Betti number, 2-dimensional Betti number, filter sequence, and survival time parameters of each topological feature from the topological feature set. Normalize the above topological feature parameters to the 0~1 range using the feature normalization algorithm min-max normalization, and transform them into a topological constraint vector that the FLUX model can recognize. Match the dimension of the fusion latent feature tensor. Set the topological constraint weight to 0.85~0.9 and the color guidance weight to 0.5~0.7. Embed the topological constraint vector into the fusion latent feature tensor. A hard binding of the topological constraint is achieved through weight assignment, forcing the FLUX model to maintain the topological structure of the complex pattern consistent with the topological feature set during the generation process. Step 303: Obtain the user-inputted target color change command. This command can input a single target color or a multi-color combination command. The target color adopts the RGB color mode, and the R, G, and B values are all in the range of 0~255. The multi-color combination command must specify the type of the color changeable area corresponding to each target color, either a solid color area of clothing or a color-filled area. A color feature extraction algorithm is used to convert the RGB value of each target color into a color feature vector. Each dimension of the color feature vector corresponds to the hue, saturation, brightness, and color texture features of the color. Based on the color changeable area mask, a region color mapping table is constructed, which includes four items: color changeable area number, area type, target color RGB value, and corresponding color feature vector. The color fill area number corresponds one-to-one with the color fill area mask channel, and the area type includes solid color area of clothing / color fill area. All color feature vectors are integrated into a color guidance tensor, which is then concatenated with the fusion latent feature tensor after embedding topological constraints to form a double-constraint latent feature tensor with topological constraints and color guidance. Step 304: Modify the native conditional guidance chain of the FLUX model by integrating the constructed region color mapping table and the double-constraint latent feature tensor into the conditional guidance chain of the FLUX model, replacing the native single text guidance chain of the FLUX model, and constructing a double-constraint guidance chain; the priority of the double-constraint guidance chain is set as follows: topological constraints have higher priority than color guidance, that is, during the generation process, the FLUX model prioritizes satisfying constraints that maintain the topological structure before performing color filling; drive the FLUX model to perform constrained generation iterations along the diffusion denoising path, specifically as follows: mark three key denoising nodes, namely the color-changeable region shaping node, the color filling refinement node, and the final image optimization node; at the color-changeable region shaping node, only enable... Dynamic topological and regional constraints are applied to freeze the features of non-changeable regions, ensuring that the outline of changeable regions is completely consistent with their masks. At the color fill refinement node, color guidance constraints are activated, injecting the corresponding color feature vectors into each changeable region according to the regional color mapping table, while maintaining topological constraints. The color fill process is monitored in real time; if color pixels overflow into non-changeable regions (i.e., color pixels appear at positions with a pixel value of 0 in the non-changeable region mask), the color guidance weight of the corresponding region is immediately reduced to below 0.3, and a color suppression mechanism is activated to prevent further color overflow. At the final image optimization node, both topological constraints and color optimization are activated simultaneously to fine-tune the color uniformity of changeable regions and correct color deviations. Step 305: Set the iteration stopping criteria, including: the color similarity between the color-changeable area and the target color after color change is ≥95%, and the color similarity is calculated using cosine similarity; the similarity between the topological features of the complex pattern and the topological feature set after color change is ≥98%, and the topological feature similarity is calculated using the proportion of the difference in Betti numbers. The calculation formula is: Topological feature similarity = 1 - (| After color change - Original |+| After color change - Original |+| After color change - Original | ÷ ( Original + Original + (original), among which, original, original, The original number is the Betti count after filtering in step two. After changing the color, After changing the color, The Betti number of the complex pattern after color change is obtained. If both conditions are met, the iteration stops and the intermediate color-change image is output. If neither condition is met, the topological constraint weight and color guidance weight are adjusted, and the generation iteration of step 304 is re-executed until both judgment conditions are met. Step 306: Perform local detail calibration on the intermediate color-swapping image. The specific operations are as follows: Use the Canny edge detection algorithm to perform edge detection on the intermediate color-swapping image and the generated topological skeleton map. Set the high threshold of the Canny algorithm to 200 and the low threshold to 100, and extract the edge contours of both; calculate the offset between the edge of the color-swappable area in the intermediate color-swapping image and the edge of the topological skeleton map. If the offset is ≥1 pixel, use the edge alignment algorithm to accurately align the edge of the color-swappable area with the edge of the topological skeleton map; based on the topological feature set, compare the topological structure of the complex pattern in the intermediate color-swapping image. If details such as broken branches or abnormal hole filling are found, use the detail repair algorithm to repair the fine structure of the complex pattern based on the topological feature set; perform local fine-tuning of the color in the color-swappable area. Use the histogram equalization algorithm to adjust the brightness and saturation of the color and correct problems such as uneven color and color deviation; after calibration, the calibrated intermediate color-swapping image is obtained.
[0026] When using this method, refer to steps 301 to 306: By constructing a dual-constraint latent feature tensor and modifying the conditional guidance chain of the FLUX model, iterative generation is performed with topological constraints taking precedence over color guidance. This effectively ensures the structural integrity and topological feature consistency of complex patterns, while accurately achieving user-specified color filling, avoiding color overflow and structural distortion, and significantly improving the fidelity and visual naturalness of the color replacement results.
[0027] Step 4: Align the intermediate color-changing image with the topological skeleton image and the normalized image using SIFT feature registration, and smooth the edges using the Poisson fusion algorithm to output the final clothing color-changing result image.
[0028] Step four includes the following: Step 401: Using the SIFT feature matching algorithm, the intermediate color-changing image, the topological skeleton map and the standardized image are registered and aligned at the pixel level. The SIFT feature points of the three are extracted and matched. The offset misalignment between layers is eliminated by homography matrix transformation, so that the coordinate deviation of the corresponding pixels of each layer is no more than 1 pixel, thus completing the precise alignment. Step 402: Using the aligned topological skeleton map as boundary constraints, the Poisson fusion algorithm is used to perform gradient smoothing on the connecting edges of the color-filled area, the solid color area of the clothing, and the topological skeleton area in the intermediate color-changing image. This maintains the continuity of pixel gradients in the connecting areas, eliminates hard boundaries, jagged edges, and color block fragmentation caused by layer splicing, and completes seamless edge fusion, outputting the final virtual model clothing color-changing result image.
[0029] When using this method, refer to the content of steps 401 to 402: By using SIFT feature registration and Poisson fusion algorithms, the intermediate color-changing image, topological skeleton, and original image are accurately aligned, eliminating layer misalignment and jagged edges, and ensuring seamless connection between color areas and structural boundaries. At the same time, gradient smoothing is used to process the fusion edges, effectively avoiding color breaks and hard boundary phenomena, and finally outputting a high-fidelity, visually natural clothing color-changing result image.
[0030] In the application, the various formulas mentioned are all calculated by removing dimensions and taking their numerical values. The formulas are derived from software simulations based on a large amount of collected data to obtain the most recent real-world results. The coefficients in the formulas are set by those skilled in the art according to the actual situation.
[0031] The above embodiments can be implemented, in whole or in part, by software, hardware, firmware, or any other combination thereof. When implemented in software, the above embodiments can be implemented, in whole or in part, as a computer program product. Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, and combinations thereof. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution.
[0032] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment, depending on actual needs.
[0033] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any changes or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application.
Claims
1. A FLUX-based intelligent color-changing method for virtual models and clothing, characterized by: include: The original images of the virtual model and clothing are obtained, and after preprocessing, standardized images are obtained. The standardized images are divided into clothing areas and non-clothing areas. Individual images of clothing are extracted from the clothing areas, and complex pattern areas and solid color areas are distinguished to generate corresponding area masks. Based on the extraction of grayscale images of complex patterns using complex pattern region masks, Rips simplex is constructed and Betti number topological features are calculated to generate a topological feature set. The skeleton of the complex pattern grayscale image is extracted to generate a topological skeleton map. With the topological skeleton map as a constraint, the color-filled region is divided by a region growing algorithm to generate a color-filled region mask, which is then merged with the solid color region mask to form a color-changeable region mask and a non-color-changeable region mask. The standardized image, topological skeleton map, region mask, and topological feature set are encoded into a fusion latent feature tensor. The topological constraint vector and the target color guidance vector input by the user are embedded to construct a double-constraint latent feature tensor. The conditional guidance chain of the FLUX model is modified to prioritize topological constraints over color guidance, and constrained iterative generation is performed to output the intermediate color-changing image. The intermediate color-changing image is aligned with the topological skeleton map and the normalized image using SIFT feature registration, and the edges are smoothed using the Poisson fusion algorithm to output the final clothing color-changing result image.
2. The FLUX-based intelligent color-changing method for virtual models and clothing according to claim 1, characterized in that: A bilinear interpolation algorithm is used to normalize the original image to a preset resolution. An adaptive histogram equalization algorithm is used to optimize brightness and contrast, and a Gaussian bilateral filtering algorithm is used to filter noise, resulting in a denoised standardized image. The U-Net semantic segmentation model is used as input, and a 5-channel semantic segmentation map is output. After binarization, a clothing region mask and a non-clothing region mask are generated. The non-clothing region can be any one of the following: skin, hair, background, or accessories.
3. The FLUX-based intelligent color-changing method for virtual models and clothing according to claim 2, characterized in that: Based on clothing region masks, a mask multiplication operation is used to extract individual clothing images from a standardized image. The LBP texture feature extraction algorithm is used to extract the texture features of the clothing image, calculate the texture complexity of each window, and determine regions with texture complexity greater than the texture complexity threshold as complex pattern regions and regions with texture complexity less than or equal to the texture complexity threshold as solid color regions, thereby generating complex pattern region masks and solid color region masks.
4. The FLUX-based intelligent color-changing method for virtual models and clothing according to claim 1, characterized in that: Based on complex pattern region masks, a mask multiplication operation is used to separate individual images of complex patterns from a standardized image. An RGB-to-grayscale algorithm is then used to convert these individual complex pattern images into single-channel grayscale images, resulting in a grayscale image of the complex pattern. This grayscale image is treated as a two-dimensional pixel cloud, and the difference in grayscale values is used as a distance metric. For any two adjacent pixels in their 8-neighborhood, if the difference in their grayscale values is less than a threshold, these two pixels are connected to form the edges of a simplex. Any three interconnected edges forming a triangle constitute a two-dimensional simplex. A filtering sequence is generated by progressively increasing the scale parameter ε.
5. The FLUX-based intelligent color-changing method for virtual models and clothing according to claim 4, characterized in that: At each scale ε of the filtered sequence, the zero-dimensional Betti number, which statistically represents the number of connected components, is used. The 1-dimensional Betti number representing the number of holes The 2D Betti number represents the number of closed regions. Calculate the lifetime of each topological feature in the filtered sequence. The lifetime is the difference between the disappearance and appearance of ε. Remove false topological features whose lifetime is less than or equal to the lifetime threshold. Then, filter the remaining topological features. , , Numerical values, filter sequences, the lifetime of each topological feature, and the ε values at the time of appearance and disappearance are saved as a topological feature set.
6. The FLUX-based intelligent color-changing method for virtual models and clothing according to claim 5, characterized in that: A distance-transform-based thinning algorithm is used to extract the skeleton from the grayscale image of a complex pattern, generating a topological skeleton map. Using the topological skeleton map as a boundary constraint, the region in the grayscale image of the complex pattern other than the topological skeleton is divided into several independent color-filled regions, and corresponding region masks are generated. The color-filled region mask and the solid color region mask are bitwise ORed to obtain the color-changeable region mask. The topological skeleton region and the non-clothing region are marked as non-color-changeable regions, and a non-color-changeable region mask is generated.
7. The FLUX-based intelligent color-changing method for virtual models and clothing according to claim 1, characterized in that: From the topological feature set, the Betti number, filter sequence and survival time parameters are extracted, and the topological constraint vector is obtained by min-max normalization to the 0~1 interval. The topological constraint vector is then embedded into the fusion latent feature tensor. The system obtains the target color change command input by the user, converts the RGB value of each target color into a color feature vector, constructs a region color mapping table based on the color changeable region mask, which includes the color changeable region number, region type, target color RGB value, and corresponding color feature vector, integrates all color feature vectors into a color guidance tensor, and concatenates it with the fusion latent feature tensor after embedding the topological constraint vector to form a double-constraint latent feature tensor.
8. The FLUX-based intelligent color-changing method for virtual models and clothing according to claim 7, characterized in that: The constructed region color mapping table and the dual-constraint latent feature tensor are integrated into the conditional guidance chain of the FLUX model. A dual-constraint guidance chain is constructed, marking three key denoising nodes: color-changeable region shaping, color filling refinement, and final image optimization, and starting the corresponding constraints at each node. An iteration stop judgment criterion is set, including: the color similarity between the color-changeable region and the target color after color change is ≥95%, and the similarity between the topological features of the complex pattern and the topological feature set after color change is ≥98%. If both conditions are met, the iteration stops and the intermediate color-change image is output.
9. The FLUX-based intelligent color-changing method for virtual models and clothing according to claim 8, characterized in that: The Canny edge detection algorithm is used to perform edge detection on the intermediate color-changing image and the topological skeleton map. The offset between the edge of the color-changing region in the intermediate color-changing image and the edge of the topological skeleton map is calculated. If the offset is ≥1 pixel, the edge alignment algorithm is used to align the edge of the color-changing region with the edge of the topological skeleton map.
10. The FLUX-based intelligent color-changing method for virtual models and clothing according to claim 1, characterized in that: The SIFT feature matching algorithm is used to perform pixel-level registration and alignment of the intermediate color-changing image, the topological skeleton map, and the standardized image. The SIFT feature points of the three are extracted and matched to ensure that the coordinate deviation of the corresponding pixels in each layer is no more than 1 pixel. Using the aligned topological skeleton map as the boundary constraint, the Poisson fusion algorithm is used to perform gradient smoothing on the connecting edges of the color-filled area, the solid color area of the clothing, and the topological skeleton area in the intermediate color-changing image, and output the final virtual model clothing color-changing result image.