A warp and weft dyeing method for fabric images based on Mahalanobis distance

Through the fabric picture dyeing method based on Martensa distance, the problem of segmentation and dyeing of warp and weft yarns in fabric pictures is solved, and the rapid and accurate fabric picture dyeing effect is achieved, simplifying the designer's operation process.

CN114463463BActive Publication Date: 2025-08-29HANGZHOU DIANZI UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111658825.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-30
Publication Date
2025-08-29
Estimated Expiration
2041-12-30

AI Technical Summary

Technical Problem

The existing dyeing methods are mostly aimed at natural pictures, and it is difficult to effectively process the warp and weft yarns in fabric pictures, especially textile pictures with clear textures. Traditional methods are time-consuming to dye fabric pictures and it is difficult to accurately divide the warp and weft yarn areas.

Method used

The warp and weft yarns based on the Martial distance are used to dye the warp and weft yarns. Through main color sampling, Martial distance calculation and warp and weft yarn segmentation diagram, efficient segmentation and dyeing of fabric pictures is achieved, and the warp and weft yarn segmentation diagram is used to dye it in the LAB space.

Benefits of technology

High-quality dyeing of fabric pictures is achieved, and the textures of different color combinations can be quickly and accurately divided, simplifying the designer's operation process and reducing the time for manually changing the knitting pattern.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114463463B_ABST
    Figure CN114463463B_ABST
Patent Text Reader

Abstract

This paper implements a warp and weft dyeing method for fabric images based on Mahalanobis distance. The method can dye specific yarns in a single fabric image, such as yarns in the weaving area of ​​a pattern or background. The user does not need to perform manual operations, but only needs to input a reference image of the target color to complete the dyeing. The present invention provides the following method, comprising the following steps: step 1, sampling the main color of the fabric image obtained after being photographed with a camera; step 2, using the sampling results of step 1 to form a color sample set, and calculating the Mahalanobis distance of each pixel in the image to each sample set; step 3, calculating the probability distribution using the Mahalanobis distance to obtain a warp and weft segmentation map of the fabric image; step 4, using the warp and weft segmentation map of the fabric image obtained in step 3, the original image, and the reference image of the color migration as input; step 5, using the warp and weft segmentation map of the fabric image as a segmentation condition, to dye the warp and weft of the fabric image in LAB space.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer vision, and in particular to a warp and weft dyeing method for fabric images based on Mahalanobis distance. The method can dye a certain woven yarn in a single fabric image, such as the yarn in the woven area corresponding to a pattern or background. The user only needs to input a reference image of the target color to complete the dyeing. Background Art

[0002] Image recolorization aims to manipulate the RGB color values ​​of an image to give it a new appearance and convey a different look and feel. Color manipulation for this purpose can be achieved through various methods, such as color transfer, appearance transfer, and style transfer. Image editing software, such as Photoshop, provides tools for automatic image recolorization, providing users with interesting variations of input images. In the field of colorization research, a wide range of applied methods have been developed, including palette-based colorization methods, deep learning-based methods, and methods using clustering.

[0003] Dyeing methods are now diverse and user-friendly. Simply changing the color palette or selecting a target color will instantly display the dyeing result. However, most current dyeing targets are natural images, with limited research on textile images. Furthermore, the processing of textile images with fewer colors or clearer textures still needs improvement.

[0004] Weaving is a textile production method in which two different sets of yarns or threads are interwoven at right angles to form a fabric or cloth. A textile pattern defines the relationship between the warp and weft yarns. With the rapid advancement of modern production technology, the textile industry has undergone tremendous changes. A wide variety of textile patterns have been created to meet the diverse needs of users. Furthermore, textile patterns can be woven in a variety of color combinations. Designers often desire a weaving effect that differs from the color of previously woven textiles. In actual production, yarn color is dependent on the settings of the textile machines: by changing the yarn color on the textile machine, different color combinations of the same pattern can be achieved. However, changing the settings of textile machines is time-consuming, especially when changing yarn color. In jacquard weaving, changing the warp color can take from several hours to several days.

[0005] 3D simulators require well-defined textile patterns and a large number of parameters to render the results. The displacement of grid points is difficult to represent and computationally expensive. Although weaving patterns can be simulated by 3D simulators and colors can be changed digitally, it is difficult to fully represent fine lines and subtle shading through computer graphics even with the most advanced rendering techniques. Therefore, designers often have to weave fabrics with yarns of different colors to check their appearance. Manually changing the color of a weaving pattern is difficult, but designers want to see the results of different color combinations of the same pattern. Moreover, traditional image recoloring methods use color and position information to identify areas painted with the same color, but for textile observation images, it is sometimes difficult to identify areas due to the shading and shadows of the warp and weft yarns.

[0006] In summary, how to simply and effectively dye fabric images with high quality is a technical problem that researchers in this field urgently need to solve. However, most current methods target natural images, so providing a method that is more suitable for dyeing fabric images is an urgent problem to be solved. Summary of the Invention

[0007] The present invention realizes a warp and weft dyeing method for a fabric image based on Mahalanobis distance, which can obtain multiple textile images with the same pattern and different color combinations from a single textile image.

[0008] To solve the above technical problems, the present invention provides a warp and weft dyeing method for a fabric image based on Mahalanobis distance, comprising the following steps:

[0009] Step 1: sampling the main color of the fabric image obtained by taking a camera;

[0010] Step 2: Use the sampling results of step 1 to form a color sample set, and calculate the Mahalanobis distance between the pixel points in the image and each sample set;

[0011] Step 3: Calculate the probability distribution by Mahalanobis distance to obtain the warp and weft segmentation map of the fabric image;

[0012] Step 4: The warp and weft segmentation map of the fabric image obtained in step 3, the original image, and the reference image for color migration are used as input;

[0013] Step 5: Use the warp and weft segmentation map of the fabric image as a segmentation condition to dye the warp and weft of the fabric image in the LAB space.

[0014] Preferably, the step 2 includes the following sub-steps:

[0015] Sub-step 1: Composition of the sample set:

[0016] a. The sampled color values ​​are classified according to the weaving color of the fabric yarn Ci (i=1,2,3), select 3 RGB values ​​(R i ,G i ,B i );

[0017] b. Combine the three RGB values ​​into a 3*3 matrix Cov i , calculate the average value Aver i ∈R 1*3 ;

[0018] c. Check whether there is an inverse matrix If it does not exist, you need to replace it with a sample with the same color value;

[0019] Sub-step 2: Calculation of pixel Mahalanobis distance:

[0020] a. Calculate the RGB value P of each pixel n n and the mean Aver i The difference A n,i =P n -Aver i , calculate A n,i The transposed vector of

[0021] b. Calculate the Mahalanobis distance from pixel n to each sample set i: Preferably, the main steps of the warp and weft yarn segmentation diagram in step three include:

[0022] a. Calculate the maximum value DMax of the Mahalanobis distance from pixel n to sample set i n The sum of the Mahalanobis distances from pixel n to all sample sets Sum n =∑ i Dis n,i ;

[0023] b. Calculate the gray value of pixel n, Get the final warp and weft yarn segmentation map.

[0024] Preferably, the dyeing process in step 5 includes:

[0025] a. Calculate the mean (Mean1, Mean2) and standard deviation (Std1, Std2) of the overall target image and original image in LAB space;

[0026] b. Using the warp and weft segmentation map obtained in step 3, distinguish between background yarns and pattern yarns, and only perform subsequent processing on the pattern yarn pixels;

[0027] c. For the pattern yarn pixel point P targetPerform the calculation:

[0028] P target =P target -Mean2,

[0029]

[0030] P target =P target +Mean1;

[0031] d. Since Opencv quantizes the LAB values ​​to a range of [0, 255], we clip the values ​​that exceed the range and finally convert them to RGB space to complete the coloring.

[0032] Compared with the existing technology, the present invention has the following beneficial effects: by sampling the main color of the yarn in the fabric image, and using the Mahalanobis distance to calculate the pixel point attribution probability, calculating the grayscale value, and obtaining the warp and weft yarn segmentation map, a better warp and weft yarn segmentation result of the fabric image can be achieved, and different weaving areas can be better separated; using the warp and weft yarn segmentation map, the traditional dyeing method is improved, and the patterned woven yarn can be dyed separately, instead of only modifying the overall color. BRIEF DESCRIPTION OF THE DRAWINGS

[0033] Figure 1 This is the process of generating the warp and weft yarn segmentation graph based on Mahalanobis distance in the present invention.

[0034] Figure 2 This is the yarn dyeing process based on the warp and weft yarn segmentation diagram in the present invention. DETAILED DESCRIPTION

[0035] The core of this invention is to provide a warp and weft dyeing method for fabric images based on Mahalanobis distance. This method facilitates designers to dye fabric images to consider various styles. To further illustrate this invention, specific examples and accompanying drawings are provided below.

[0036] Figure 1 The flowchart of generating a warp and weft yarn segmentation diagram based on Mahalanobis distance in the present invention is as follows: Figure 1 As shown, the flow chart includes:

[0037] Step 1: Obtain the main color sample set:

[0038] a. The sampled color values ​​are classified according to the weaving color of the fabric yarn C i (i=1,2,3), select 3 RGB values ​​(R i ,G i ,B i ).

[0039] b. Combine the three RGB values ​​into a 3*3 matrix Cov i , calculate the average value Aver i ∈R 1*3 .

[0040] c. Check whether there is an inverse matrix If it does not exist, you need to replace it with a sample with the same color value.

[0041] Step 2: Calculation of Mahalanobis distance:

[0042] a. Calculate the RGB value P of each pixel n n and the mean Aver i The difference A n,i =P n -Aver i , calculate A n,i The transposed vector of

[0043] b. Calculate the Mahalanobis distance from pixel n to each sample set i:

[0044] Step 3: Calculate the grayscale value to obtain the warp and weft segmentation map:

[0045] a. Calculate the maximum value DMax of the Mahalanobis distance from pixel n to sample set i n The sum of the Mahalanobis distances from pixel n to all sample sets Sum n =∑ i Dis n,i

[0046] b. Calculate the gray value of the pixel. Get the final warp and weft yarn segmentation map.

[0047] Figure 2 This is a warp and weft dyeing process of a fabric image based on Mahalanobis distance in the present invention. The flowchart includes:

[0048] Step 1: Divide the original image, reference image, and warp and weft yarns Figure 1 As input.

[0049] Step 2: Calculate the mean (Mean1, Mean2) and standard deviation (Std1, Std2) of the entire target image and the original image in the LAB space.

[0050] Step 3: Use the obtained warp and weft segmentation map to make a judgment, distinguish the background and pattern yarn weaving areas, and only perform subsequent processing on the pattern weaving yarn pixels.

[0051] Step 4: Pixel P of pattern yarntarget Perform the calculation:

[0052] P target =P target -Mean2,

[0053]

[0054] P target =P target +Mean1,

[0055] Step 5. Since Opencv quantizes the LAB values ​​so that their value range is [0, 255], we clip the values ​​that exceed the range and finally convert them to RGB space to complete the coloring.

[0056] The above description is merely a basic example of the present invention, and is intended only to help understand the technical solution and core concept of the present invention. It should be noted that, without departing from the principles of the present invention, a number of improvements and modifications may be made to the present invention, and such improvements and modifications also fall within the scope of protection of the claims of the present invention.

Claims

1. A warp and weft dyeing method for a fabric image based on Mahalanobis distance, characterized in that: The following steps are involved: Step 1: sampling the main color of the fabric image obtained by taking a camera; Step 2: Use the sampling results of step 1 to form a color sample set, and calculate the Mahalanobis distance between the pixel points in the image and each sample set; Sub-step 1: Composition of the sample set: a. The sampled color values ​​are classified according to the weaving color of the fabric yarn C i , i=1,2,3, select 3 RGB values ​​(R i ,G i ,B i ); b. Combine the three RGB values ​​into a 3*3 matrix Cov i , calculate the average value Aver i ∈R 1*3 ; c. Check whether there is an inverse matrix Cov i -1 If it does not exist, you need to replace it with a sample with the same color value; Sub-step 2: Calculation of pixel Mahalanobis distance: a. Calculate the RGB value P of each pixel n n and the mean Aver i Difference A n,i =P n -Aver i , calculate A n,i The transposed vector of b. Calculate the Mahalanobis distance from pixel n to each sample set i: Step 3: Calculate the probability distribution by Mahalanobis distance to obtain the warp and weft segmentation map of the fabric image; The main steps of warp and weft segmentation diagram include: a. Calculate the maximum value DMax of the Mahalanobis distance from pixel n to sample set i n The sum of the Mahalanobis distances from pixel n to all sample sets Sum n =∑ i Dis n,i ; b. Calculate the gray value of the pixel. Get the final warp and weft yarn segmentation map; Step 4: The warp and weft segmentation map of the fabric image obtained in step 3, the original image, and the reference image for color migration are used as input; Step 5: Using the warp and weft segmentation map of the fabric image as a segmentation condition, the warp and weft of the fabric image are dyed in the LAB space; The dyeing process includes: a. Calculate the mean (Mean1, Mean2) and standard deviation (Std1, Std2) of the entire target image 1 and the original image 2 in LAB space; b. Using the warp and weft segmentation map obtained in step three to distinguish between background yarns and pattern yarns, and only performing subsequent processing on the pixels of the patterned woven yarns; c. For the pattern yarn pixel point P target Perform calculations; d. Since OpenCV quantizes the LAB values ​​to a range of [0, 255], the values ​​that exceed the range are clipped and finally converted to RGB space to complete the coloring.

Citation Information

Patent Citations

  • Method for automatically segmenting warp yarn area of yarn dyed fabric

    CN105118058A

  • Real-time pattern recognition system

    CN108053399A