CN114463463A - Fabric picture warp and weft yarn dyeing method based on Mahalanobis distance - Google Patents
Fabric picture warp and weft yarn dyeing method based on Mahalanobis distance Download PDFInfo
- Publication number
- CN114463463A CN114463463A CN202111658825.9A CN202111658825A CN114463463A CN 114463463 A CN114463463 A CN 114463463A CN 202111658825 A CN202111658825 A CN 202111658825A CN 114463463 A CN114463463 A CN 114463463A
- Authority
- CN
- China
- Prior art keywords
- warp
- mahalanobis distance
- calculating
- fabric
- color
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T11/00—2D [Two Dimensional] image generation
- G06T11/40—Filling a planar surface by adding surface attributes, e.g. colour or texture
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T7/00—Image analysis
- G06T7/0002—Inspection of images, e.g. flaw detection
- G06T7/0004—Industrial image inspection
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T7/00—Image analysis
- G06T7/10—Segmentation; Edge detection
- G06T7/11—Region-based segmentation
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T7/00—Image analysis
- G06T7/10—Segmentation; Edge detection
- G06T7/194—Segmentation; Edge detection involving foreground-background segmentation
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T7/00—Image analysis
- G06T7/90—Determination of colour characteristics
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T2207/00—Indexing scheme for image analysis or image enhancement
- G06T2207/10—Image acquisition modality
- G06T2207/10024—Color image
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T2207/00—Indexing scheme for image analysis or image enhancement
- G06T2207/20—Special algorithmic details
- G06T2207/20112—Image segmentation details
- G06T2207/20132—Image cropping
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T2207/00—Indexing scheme for image analysis or image enhancement
- G06T2207/30—Subject of image; Context of image processing
- G06T2207/30108—Industrial image inspection
- G06T2207/30124—Fabrics; Textile; Paper
Landscapes
- Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Theoretical Computer Science (AREA)
- Computer Vision & Pattern Recognition (AREA)
- Quality & Reliability (AREA)
- Coloring (AREA)
Abstract
The method for dyeing the warp and weft yarns of the fabric picture based on the Mahalanobis distance is realized, specific yarns can be dyed on a single fabric picture, such as yarns in a pattern or background yarn weaving area, and a user can finish dyeing only by inputting a reference picture of a target color without manual operation. The invention provides a method comprising the following steps: the method comprises the following steps of firstly, sampling a main color of a fabric picture obtained after shooting by a camera; step two, forming color sample sets by using the sampling results in the step one, and calculating the Mahalanobis distance from the pixel points in the image to each sample set; calculating probability distribution through the Mahalanobis distance to obtain a warp and weft yarn segmentation chart of the fabric picture; step four, taking the warp and weft yarn segmentation images of the fabric image obtained in the step three, and taking the original image and the reference image of color migration as input; and fifthly, dyeing the warp and weft yarns of the fabric picture in an LAB space by using the warp and weft yarn segmentation picture of the fabric picture as a segmentation condition.
Description
Technical Field
The invention relates to the field of computer vision, in particular to a mahalanobis distance-based fabric picture warp and weft yarn dyeing method, which can dye certain weaving yarn in a single fabric picture, such as the yarn in a corresponding weaving area of a pattern or a background, and a user can finish dyeing only by inputting a reference picture of a target color.
Background
Image recoloring is intended to manipulate the RGB color values of an image, giving it a new look, conveying a different look and feel. The color processing for this purpose can be realized in different ways, such as color transfer, appearance transfer, and style transfer. Image editing software, such as Photoshop, provides tools for automatic image recoloring, thereby providing users with interesting changes to the input image. In the field of dyeing research, more application methods are available: a palette-based staining method, a deep learning-based method, a clustering-applied method, and the like.
As the dyeing methods are developed up to now, the operation of the user becomes simpler and simpler, and only the color palette needs to be changed or the target color needs to be selected, the dyeing result can be displayed in a short time. However, most of the current dyeing targets are natural pictures, the research on fabric pictures is not much, and the processing effect on textile pictures with less colors or clear textures is still to be improved.
Weaving is a textile production process in which two different sets of yarns or threads are interwoven at right angles to form a fabric or cloth. The weave pattern defines the relationship between the warp and weft yarns. With the rapid development of modern production technology, the textile industry has changed over the world. In order to meet different requirements of users, various textile patterns are created for selection. In addition, the textile pattern may be knitted in various color combinations. The designer wishes to see the effect of the weave in a different colour to the previously woven textile. In the actual production process, the colour of the yarn is related to the settings of the textile machine: by varying the color of the yarns on the textile machine, different color combinations of the same pattern can be obtained. However, changing the settings of the textile machine is time-consuming, in particular changing the color of the yarn. In jacquard weaving, changing the color of the warp yarns takes a period of several hours to several days.
The 3D simulator needs well-defined textile patterns and a large number of parameters to render results, the displacement of the grid points is difficult to represent, and the calculation cost is high. Although the weave pattern can be simulated by a 3D simulator and the color can be changed digitally, it is difficult to completely represent fine lines and subtle shadows by computer graphics even with the most advanced rendering techniques. Therefore, designers in many cases must knit fabrics with different colored yarns to check their appearance. While it is difficult to manually change the color of the weave pattern, the designer wants to see the result of different color combinations of the same pattern. Also, the conventional image recoloring method uses color and position information to identify areas painted with the same color, but it is sometimes difficult to identify areas due to shadows and shades of warp and weft yarns for a textile viewing image.
In conclusion, how to simply and effectively dye fabric pictures with high quality is a technical problem which needs to be solved urgently by researchers in the field. However, most current methods target natural pictures, and therefore, providing a method more suitable for dyeing fabric pictures is an urgent problem.
Disclosure of Invention
The invention realizes a mahalanobis distance-based fabric picture warp and weft yarn dyeing method, and can obtain multiple fabric pictures with the same patterns and different color combinations from a single fabric picture.
In order to solve the technical problem, the invention provides a method for dyeing warp and weft yarns of a fabric picture based on the mahalanobis distance, which comprises the following steps:
firstly, sampling a main color of a fabric picture obtained after shooting by using a camera;
step two, forming color sample sets by using the sampling results in the step one, and calculating the Mahalanobis distance from the pixel points in the image to each sample set;
calculating probability distribution through the Mahalanobis distance to obtain a warp and weft yarn segmentation graph of the fabric picture;
step four, taking the warp and weft yarn segmentation images of the fabric image obtained in the step three, and taking the original image and the reference image of color migration as input;
and fifthly, dyeing the warp and weft yarns of the fabric picture in an LAB space by using the warp and weft yarn segmentation picture of the fabric picture as a segmentation condition.
Preferably, the second step comprises the following substeps:
step one, composition of a sample set:
a. sorting C of sampled color values according to weaving colors of textile yarnsi(i ═ 1,2,3), 3 RGB values (R) were selected from the sampled data for each color yarn, respectivelyi,Gi,Bi);
b. The 3 RGB values are grouped into 1 matrix Cov of 3 x 3iCalculating the average value Averi∈R1*3;
c. Check if it has an inverse matrixIf the color value does not exist, the sample with the same color value needs to be replaced again;
and step two, calculating the Mahalanobis distance of the pixel points:
a. calculating the RGB value P of each pixel point nnAnd average AveriDifference A ofn,i=Pn-AveriCalculating An,iIs transposed vector
b. Calculating the mahalanobis distance from the pixel point n to each sample set i:preferably, the warp and weft dividing map in the third step mainly comprises the following steps:
a. calculating the maximum value DMax in the Mahalanobis distance from the pixel point n to the sample set inSum of Mahalanobis distances from pixel point n to all sample sets Sumn=∑iDisn,i;
b. The gray value of the pixel point n is calculated,and obtaining a final warp and weft yarn cutting chart.
Preferably, the dyeing process in the fifth step comprises:
a. calculating an average (Mean) of the target image and the original image of the whole in the LAB space1,Mean2) And standard deviation (Std)1,Std2);
b. Judging by using the warp and weft yarn segmentation chart obtained in the step three, distinguishing background yarns and pattern yarns, and only carrying out subsequent processing on the weaving yarn pixel points of the patterns;
c. pixel point P of register yarntargetAnd (3) calculating:
Ptarget=Ptarget-Mean2,
Ptarget=Ptarget+Mean1;
d. because Opencv quantizes LAB values, the value range of the LAB values is [0,255], values beyond the range are cut, and finally the values are converted into RGB space to finish dyeing.
Compared with the prior art, the invention has the following beneficial effects: the main color of the yarn is sampled for the fabric picture, the pixel point attaching probability is calculated by using the Mahalanobis distance, the gray value is calculated, the warp and weft yarn segmentation picture is obtained, the good warp and weft yarn segmentation result of the fabric picture can be realized, and different weaving areas can be well segmented; the warp and weft yarn dividing picture is utilized to improve the traditional dyeing method, and the weaving yarns with patterns can be dyed independently, but the whole color can not be modified.
Drawings
FIG. 1 is a process for generating a warp and weft segmentation map based on Mahalanobis distance in the present invention.
FIG. 2 is a yarn dyeing process based on a warp and weft yarn segmentation chart in accordance with the present invention.
Detailed Description
The core of the invention is to provide a fabric picture warp and weft yarn dyeing method based on the Mahalanobis distance. The designer is facilitated to dye the fabric picture to account for the composition of the various styles. For a more detailed description of the invention, reference is now made to the following examples, taken in conjunction with the accompanying drawings.
Fig. 1 is a flow chart for generating a partition chart of warp and weft yarns based on mahalanobis distance in the present invention, as shown in fig. 1, the flow chart includes:
step 1, obtaining a main color sample set:
a. sorting C of sampled color values according to weaving colors of textile yarnsi(i ═ 1,2,3), 3 RGB values (R) were selected from the sampled data for each color yarn, respectivelyi,Gi,Bi)。
b. The 3 RGB values are grouped into 1 matrix Cov of 3 x 3iCalculating the average value Averi∈R1*3。
c. Check if it has an inverse matrixIf the color value does not exist, the sample with the same color value needs to be replaced again.
Step 2, calculating the Mahalanobis distance:
a. calculating the RGB value P of each pixel point nnAnd average AveriDifference A ofn,i=Pn-AveriCalculating An,iIs transposed vector
step 3, calculating the gray value to obtain a warp and weft yarn segmentation chart:
a. calculating the maximum value DMax in the Mahalanobis distance from the pixel point n to the sample set inAnd the sum S of the Mahalanobis distances from the pixel point n to all the sample setsumn=∑iDisn,i
b. The gray value of the pixel point is calculated,and obtaining a final warp and weft yarn cutting chart.
Fig. 2 is a mahalanobis distance-based fabric picture warp and weft yarn dyeing process in the invention, and the flow chart comprises:
step 1, taking an original image, a reference image and a warp and weft yarn segmentation image as input.
Step 2, calculating the average value (Mean) of the whole target image and the original image in the LAB space1,Mean2) And standard deviation (Std)1,Std2)。
And 3, judging by using the obtained warp and weft yarn segmentation images, distinguishing background and pattern yarn weaving areas, and only carrying out subsequent processing on the pattern weaving yarn pixel points.
Step 4, aligning the pixel points P of the patterned yarnstargetAnd (3) calculating:
Ptarget=Ptarget-Mean2,
Ptarget=Ptarget+Mean1,
and 5, quantizing the LAB value by Opencv to enable the value range to be [0,255], clipping the value out of the range, and finally converting the value into an RGB space to finish dyeing.
The above examples are only basic embodiments of the present invention, and are only for assisting understanding of the technical solutions of the present invention and the core ideas thereof. It should be noted that, for those skilled in the art, it is possible to make various improvements and modifications to the present invention without departing from the principle of the present invention, and those improvements and modifications also fall within the scope of the claims of the present invention.
Claims (4)
1. A method for dyeing warp and weft yarns of a fabric picture based on Mahalanobis distance is characterized by comprising the following steps:
firstly, sampling a main color of a fabric picture obtained after shooting by using a camera;
step two, forming color sample sets by using the sampling results in the step one, and calculating the Mahalanobis distance from the pixel points in the image to each sample set;
calculating probability distribution through the Mahalanobis distance to obtain a warp and weft yarn segmentation graph of the fabric picture;
step four, taking the warp and weft yarn segmentation images of the fabric image obtained in the step three, and taking the original image and the reference image of color migration as input;
and fifthly, dyeing the warp and weft yarns of the fabric picture in an LAB space by using the warp and weft yarn segmentation picture of the fabric picture as a segmentation condition.
2. The method for dyeing the warp and weft yarns of the fabric picture based on the mahalanobis distance as claimed in claim 1, wherein the second step comprises the following substeps:
step one, composition of a sample set:
a. sorting C of sampled color values according to weaving colors of textile yarnsi(i ═ 1,2,3), 3 RGB values (R) were selected from the sampled data for each color yarn, respectivelyi,Gi,Bi);
b. The 3 RGB values are grouped into 1 matrix Cov of 3 x 3iCalculating the average value Averi∈R1*3;
c. Check if it has an inverse matrixIf the color value does not exist, the sample with the same color value needs to be replaced again;
and step two, calculating the Mahalanobis distance of the pixel points:
a. calculating the RGB value P of each pixel point nnAnd average AveriDifference A ofn,i=Pn-AveriCalculating An,iIs transposed vector
3. the method for dyeing warp and weft yarns of fabric pictures based on Mahalanobis distance as claimed in claim 1, wherein the dividing of the warp and weft yarns in the third step comprises the following steps:
a. calculating the maximum value DMax in the Mahalanobis distance from the pixel point n to the sample set inSum of Mahalanobis distances from pixel point n to all sample sets Sumn=∑iDisn,i;
4. The mahalanobis distance based fabric picture warp and weft dyeing method according to claim 1, wherein the dyeing process in the fifth step is as follows:
a. calculating an average (Mean) of the target image 1 and the original image 2 as a whole in the LAB space1,Mean2) And standard deviation (Std)1,Std2);
b. Judging by using the warp and weft yarn segmentation chart obtained in the third step, distinguishing background yarns and pattern yarns, and only carrying out subsequent processing on the weaving yarn pixel points of the patterns;
c. pixel point P of register yarntargetAnd (3) calculating:
Ptarget=Ptarget-Mean2,
Ptarget=Ptarget+Mean1,;
d. because Opencv quantizes LAB values, the value range of the LAB values is [0,255], values beyond the range are cut, and finally the values are converted into RGB space to finish dyeing.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111658825.9A CN114463463A (en) | 2021-12-30 | 2021-12-30 | Fabric picture warp and weft yarn dyeing method based on Mahalanobis distance |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111658825.9A CN114463463A (en) | 2021-12-30 | 2021-12-30 | Fabric picture warp and weft yarn dyeing method based on Mahalanobis distance |
Publications (1)
Publication Number | Publication Date |
---|---|
CN114463463A true CN114463463A (en) | 2022-05-10 |
Family
ID=81407461
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202111658825.9A Pending CN114463463A (en) | 2021-12-30 | 2021-12-30 | Fabric picture warp and weft yarn dyeing method based on Mahalanobis distance |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN114463463A (en) |
-
2021
- 2021-12-30 CN CN202111658825.9A patent/CN114463463A/en active Pending
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN1786308B (en) | Digital code manufacturing method for jacquard weave double surface embroidery | |
US8050791B2 (en) | Method of fabricating color jacquard fabric | |
CN101109121A (en) | Method for manufacturing jacquard fabric with different material quality and style | |
CN104357999A (en) | Manufacturing method of simulation brocade weaving painting | |
CN106875459B (en) | Self-adaptive equalization method for color jacquard weave structure based on image segmentation | |
CN114622322B (en) | System and method for quickly generating brocade makeup satin fabric pattern | |
CN109063781B (en) | Design method of fuzzy image fabric imitating natural color function and form | |
KR100403332B1 (en) | A design method provide with 3D rendering for fashion goods | |
CN110060326A (en) | A kind of model Texture Generating Approach based on generation confrontation network | |
Zelinka et al. | Interactive material replacement in photographs | |
CN114463463A (en) | Fabric picture warp and weft yarn dyeing method based on Mahalanobis distance | |
CN107886549A (en) | A kind of dermatoglyphic pattern of the fabric color transfer method based on braiding grain details enhancing | |
CN103911717B (en) | Method for adjusting visual effect of tapestry | |
Toyoura et al. | Generating jacquard fabric pattern with visual impressions | |
CN114581557A (en) | Clothing image generation method for unwrapping representation of design attributes | |
TW554102B (en) | Manufacturing method for double knitting jacquard weave fabric appearing color image | |
CN106997471A (en) | A kind of determination method and system of Tangka's image type | |
Ju et al. | Intelligent Recognition of Colour and Contour from Ancient Chinese Embroidery Images | |
CN110264564A (en) | A kind of video display style emulation mode based on colour atla mapping and Histogram Mapping | |
CN112507524B (en) | Gray scale simulation jacquard fabric design method with information hiding function | |
CN115341323B (en) | Preparation method of double-sided woven-printed combined fabric | |
CN117454453A (en) | Jacquard fabric design method based on continuous texture blurring diffusion | |
Arnăutu | WHAT IS YOUR SOURCE OF INSPIRATION? | |
CN112070876B (en) | Software processing method for simulating fabric attribute | |
CN112215793B (en) | Method for drawing hand-embroidered carpet pattern detection texture and applying hand-embroidered carpet pattern detection texture to carpet weaving |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |