A method and system for automatically grading quality of hank dyeing based on photometric colorimetry

By optimizing parameters and analyzing color distribution clustering based on photographic colorimetry, color clustering areas and discrete points in skein dyeing are identified, and an automatic grading evaluation system is constructed. This solves the subjectivity and consistency problems of traditional skein dyeing quality evaluation and realizes intelligent quantitative analysis of skein dyeing quality.

CN122243898APending Publication Date: 2026-06-19WUHAN TEXTILE UNIV

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
WUHAN TEXTILE UNIV
Filing Date
2026-03-10
Publication Date
2026-06-19

AI Technical Summary

Technical Problem

Traditional methods for evaluating the quality of yarn dyeing suffer from strong subjectivity, poor consistency, and difficulty in quantifying the color distribution characteristics of batch products. Existing photographic colorimetry technology cannot automatically identify color clusters and discrete points, and lacks automatic quality grading functionality.

Method used

Based on photometric colorimetry, combined with parameter optimization algorithms and color distribution clustering analysis, the robust minimum covariance determination factor (MCD) method is used to identify clustered regions and discrete data. Through Mahalanobis distance calculation and chi-square distribution critical value determination, a three-dimensional Lab color space visualization system is constructed, and an automatic hierarchical evaluation system is established.

Benefits of technology

It has enabled intelligent, quantitative, and automatic grading of yarn dyeing quality, improved the scientificity and consistency of dyeing quality evaluation, and provided a digital quality management tool for the textile industry.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122243898A_ABST
    Figure CN122243898A_ABST
Patent Text Reader

Abstract

This invention discloses an automatic grading method and system for skein dyeing quality based on photographic colorimetry, comprising: constructing a photographic colorimetry system; acquiring digital images of skein samples; determining optimal colorimetry parameters using a parameter optimization algorithm; acquiring batch skein Lab color data based on the optimal colorimetry parameters; loading and preprocessing the batch Lab color data; estimating color clustering regions using a robust MCD method; calculating Mahalanobis distance to identify clustered and discrete data; determining the boundaries and center positions of clustered regions; constructing a three-dimensional Lab space visualization display; calculating the central chromaticity reference value of the clustered regions; automatically dividing regions based on color difference thresholds; performing automatic grading based on clustering characteristics; and outputting grading results. This invention overcomes the shortcomings of traditional skein dyeing quality evaluation methods, such as strong subjectivity, poor consistency, and difficulty in quantifying the color distribution characteristics of batch products, providing a scientific and reliable automatic grading scheme for intelligent evaluation of skein dyeing quality in the textile industry.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of computer digital image processing and textile quality inspection technology, specifically relating to an automatic grading method and system for yarn dyeing quality based on photographic color measurement. Background Technology

[0002] In the textile industry, the dyeing quality control of skeins is a crucial step in ensuring product quality. Typically, skein dyeing involves treating the same dye vat with the same dye. However, due to various factors such as different yarn textures, fluctuations in the dyeing process, and differences in dyeing time and temperature, the same batch of yarn may exhibit varying depths of color during dyeing, leading to uneven dyeing. Therefore, accurately evaluating and controlling dyeing quality has become a significant challenge in textile production. Traditional dyeing quality evaluation methods mainly rely on manual visual inspection or single-point spectrophotometer measurement. These methods suffer from high subjectivity, poor consistency, and low efficiency. Manual visual inspection is heavily influenced by the inspector's experience and ambient lighting, making quantitative evaluation difficult. While single-point spectrophotometers offer high accuracy, they cannot reflect the color distribution characteristics and consistency level of the entire batch of skeins and cannot perform batch analysis on multiple samples. Existing photographic colorimetry techniques can quickly acquire color data, but they often neglect the analytical capabilities for the color distribution characteristics of batch skeins, failing to automatically identify clustered areas and discrete points, and lacking the function of quality grading based on the clustering characteristics of color distribution. In actual production, evaluating dyeing quality requires considering not only the color accuracy of individual samples but also the color consistency and distribution characteristics of the entire batch of products. Currently, there is a lack of intelligent methods capable of automatically analyzing the color distribution clustering of batches of yarn and performing automatic quality grading based on these clustering characteristics. Therefore, there is an urgent need for a new method that can automatically analyze the color distribution characteristics of batches of yarn, identify clustered regions and discrete data, and perform automatic quality grading based on color clustering. Summary of the Invention

[0003] The purpose of this invention is to solve the problems described in the background art. Based on existing photographic colorimetry technology and combined with the analysis method of color distribution of batch samples, this invention proposes an automatic grading method for yarn dyeing quality based on photographic colorimetry. This method comprehensively utilizes photographic colorimetry technology, parameter optimization algorithms, color distribution clustering analysis technology, and an automatic grading evaluation system to achieve intelligent evaluation of the dyeing quality of batch yarn. In specific implementation of this invention, firstly, a photographic color measurement method based on visual saliency is used to obtain Lab color data of batch yarn samples; then, a parameter optimization method driven by fabric color is used to calibrate the parameters of the photographic colorimetry system; next, the robust minimum covariance determinant (MCD) method is used to analyze the color distribution clustering of batch samples, and clustered regions and discrete data points are automatically identified through Mahalanobis distance calculation and chi-square distribution critical value determination; further, a three-dimensional Lab color space visualization system is constructed to intuitively display the boundaries of clustered regions and data distribution characteristics; finally, an automatic grading evaluation system is established based on the central chromaticity value of the clustered regions, and the samples are divided into three levels—AAA, AA, and A—according to the color difference threshold, achieving quantitative automatic grading of dyeing quality. The technical solution of this invention is an automatic grading method for yarn dyeing quality based on photographic color measurement, specifically including the following steps: Step 1: Set up a photographic colorimetry system; Step 2: Acquire digital images of the yarn sample; Step 3: Use a parameter optimization algorithm to determine the optimal colorimetric parameters; Step 4: Obtain batch skein Lab color data based on optimal color measurement parameters; Step 5: Load and preprocess batch skein Lab color data; Step 6: Use the robust MCD method to estimate the color clustering regions; Step 7: Calculate Mahalanobis distance to identify clustered and discrete data; Step 8: Determine the boundaries and center location of the cluster area; Step 9: Construct a 3D Lab space visualization display; Step 10: Calculate the central chromaticity reference value of the clustered region as a reference standard for quality evaluation; Step 11: Determine the rigidity threshold based on the minor semi-axis of the ellipsoid, and calculate the color difference value between each data point and the center of the clustering region in turn; Step 12: Perform automatic rating based on clustering characteristics; Step 13: Output the grading results and quality evaluation report.

[0004] Furthermore, in step 1, when setting up the photographic colorimetric system, the system's lighting needs to be unaffected by natural light, and the uniformity of lighting within the effective photographic area should be ensured. This ensures that the digital response values ​​of the same sample object are consistent at different locations within the photographic area, thus avoiding photographic system deviation problems.

[0005] Furthermore, in step 2, the method for acquiring digital images of the yarn samples is as follows: Prepare N yarn samples to be tested, ensuring that the samples are free from contamination and obvious color variations; lay the yarn samples flat in the effective imaging area of ​​the photometric system, and set the standard digital camera shooting parameters; use the digital camera to photograph the yarn samples at a fixed distance and angle, ensuring image clarity and uniform illumination; obtain digital images in RGB format and save them according to their numbers to establish a complete sample image database.

[0006] Furthermore, in step 3, the method for determining the optimal colorimetric parameters using a parameter optimization algorithm is as follows: Step 3.1, Prepare fabric pieces corresponding to the skeins: Select skein samples with similar but slightly different colors as the research object; use the same weaving process parameters to weave each skein into a corresponding plain weave fabric piece sample; ensure that the fabric structure, warp and weft density, fabric thickness and other parameters are consistent to avoid the influence of fabric structure parameters on color measurement results; perform standardized finishing treatment on the woven fabric pieces to ensure that the fabric surface is flat and free of obvious defects.

[0007] Step 3.2, Collect sample data: Prepare m different placement patterns for each strand of yarn, including loose placement, tight placement, single-layer flat laying, double-layer stacking, random placement, etc., to simulate different states in actual use; set standard digital camera shooting parameters to ensure that all samples are image acquired under the same conditions; take high-resolution digital images of each of the m patterns of each strand of yarn, taking x images for each pattern; also take high-resolution digital images of each fabric sample, taking x images for each fabric sample; establish a sample image database and numbering system to provide a complete data foundation for subsequent parameter optimization analysis.

[0008] Step 3.3, Measure the standard color parameters of the fabric: Use the same photometric colorimetry system as the yarn measurement to acquire high-resolution digital images of the fabric sample to ensure consistency of measurement conditions; preprocess the fabric image and crop the effective measurement area, avoiding fabric edges and areas with obvious weaving defects; calculate the RGB average value of all pixels in the cropped area using the average pixel method; convert the RGB average value into CIE Lab color parameters according to the colorimetric theory conversion algorithm; establish a correspondence table between yarn number and standard Lab value of the fabric to provide a reference target for subsequent parameter optimization.

[0009] Step 3.4, define the parameter optimization space and constraints: determine the key parameters to be optimized, including the Gaussian filter standard deviation σ, Gaussian filter kernel size kernel_size, binarization threshold adjustment coefficient k, connected region area threshold area_threshold, and skeleton minimum retained area threshold skeleton_threshold; set reasonable value ranges and constraints for each parameter, as shown in equation (3.1): (3.1) In the formula, The standard deviation of the Gaussian filter. This is the size of the Gaussian filter kernel. This is the binarization threshold adjustment coefficient. The threshold value for the area of ​​the connected region. This is the minimum area threshold for the skeleton to be retained.

[0010] Step 3.5, construct a composite objective function as the fitness: The objective function consists of two sub-objectives, namely the relevance objective and the stability objective, and the composite objective function is defined as shown in equation (3.2): (3.2) In the formula, For the composite objective function value, The objective function is the correlation. Let the stability objective function be... and These are the weight coefficients for the two sub-objectives. The formula for calculating the correlation objective function is shown in equation (3.3): (3.3) In the formula, The objective function is the correlation. For skein yarn Values ​​and corresponding fabric pieces The coefficient of determination between the values. The formula for calculating the stability objective function is shown in equation (3.4): (3.4) In the formula, This is the sample number for the skein yarn. Let the stability objective function be... For the first Average color difference of the yarn samples This represents the number of yarn strands.

[0011] The formula for calculating the correlation coefficient is shown in equation (3.5): (3.5) In the formula, Sample numbering, For the first Measurement of individual yarn samples value, For the corresponding fabric pieces value, For fabric pieces The average value The total number of samples is given. The measurement stability of each group of yarn strands is calculated using the stability evaluation formula shown in equation (3.6): (3.6) In the formula, Number the yarn strands. Number the number of measurements for the same group of yarn strands. For the first Average color difference of stranded yarn The number of measurements for each group of yarn strands. For the first Grouped yarn The Lab value of this measurement, For the first Lab average value of the twisted yarn This is the CIE DE2000 color difference formula.

[0012] Step 3.6, Initialize optimization algorithm parameters: Select genetic algorithm as the optimization method, and set algorithm parameters including population size, crossover probability, mutation probability, maximum number of iterations, etc.; the algorithm parameter settings are shown in equation (3.7): (3.7) In the formula, For population size, For crossover probability, The mutation probability, It is the largest algebra.

[0013] Step 3.7, execute the parameter optimization process: randomly generate an initial population within the defined parameter space; evaluate the fitness of each individual; perform genetic operations such as selection, crossover, and mutation; update the population and record the optimal solution; repeat the iteration until the stopping criterion is met.

[0014] Step 3.8, Determine the stopping criteria: Set multiple stopping conditions to ensure the effectiveness of the optimization process. The stopping criteria include maximum running time, target... The stopping condition is determined by the following factors: value, continuous no-improvement algebra, convergence tolerance, minimum improvement ratio, etc., as shown in equation (3.8): (3.8) In the formula, This is the current running time. For maximum runtime, For the present value, For the goal value, For continuous unimproved algebras, Tolerance algebra, The objective function value of the current generation. This represents the optimal objective function value to date. The objective function value of the previous generation. To reduce convergence tolerance, This represents the minimum improvement ratio.

[0015] Step 3.9, update the parameter population and output the optimal parameter combination: If the stopping criterion is not met, continue the iterative process of the genetic algorithm; perform the selection operation to retain individuals with higher fitness; perform the crossover operation to generate new parameter combinations; perform the mutation operation to increase population diversity; update the population and prepare for the next round of iteration; When the stopping criterion is met, output the current optimal parameter combination; record the objective function value, correlation coefficient, stability index, etc. corresponding to the optimal parameters; save before... The optimal parameters are provided for user selection, and the parameter output format is shown in equation (3.9): (3.9) In the formula, For the optimal parameter combination, This represents the optimal value for the standard deviation of the Gaussian filter. This is the size of the Gaussian filter kernel. This represents the optimal value for the binarization threshold adjustment coefficient. This represents the optimal value for the area threshold of the connected region. This represents the optimal value for the minimum retained area threshold of the skeleton. Thus, the method for optimizing the colorimetric parameters of yarn skeletal photography is complete, and the optimal parameter combination has been obtained.

[0016] Furthermore, in step 4, the method for obtaining batch skein Lab color data based on optimal color measurement parameters is as follows: Step 4.1: Convert the RGB color image to a grayscale image: Use a weighted average method to convert the RGB three-channel information into single-channel grayscale information. The grayscale conversion formula is shown in equation (4.1): (4.1) In the formula, These are the converted grayscale pixel values. These are the pixel values ​​for the red, green, and blue channels, respectively. The weighting coefficients are determined based on the human eye's sensitivity to different colors, with the green component having the largest weight, followed by the red component, and the blue component having the smallest weight.

[0017] Step 4.2, Gaussian blur processing is performed on the grayscale image: A Gaussian filter of size kernel_size is used to smooth the grayscale image to reduce image noise and detail interference. The Gaussian blur kernel function is shown in equation (4.2): (4.2) In the formula, Position coordinates The filter weight value at that point, and These are the offset coordinates relative to the center of the kernel. The standard deviation is the Gaussian filter value.

[0018] Step 4.3, perform adaptive histogram equalization: Divide the image into several sub-blocks, and perform histogram equalization on each sub-block. The cumulative distribution function of each sub-block is calculated as shown in equation (4.3): (4.3) In the formula, grayscale The cumulative distribution function value, The current grayscale level, For the summation variable, grayscale The number of pixels, This represents the total number of pixels within the sub-block. The formula for calculating the equalized pixel value is shown in equation (4.4): (4.4) In the formula, The current grayscale level, grayscale The new pixel value after equalization The total number of gray levels. grayscale The cumulative distribution function value, This is a rounding function. The final result is then synthesized using bilinear interpolation. This method enhances local contrast while preserving the overall characteristics of the image.

[0019] Step 4.4, utilizing the improved Binarization using thresholding: First, calculate the global threshold of the image. ,use The algorithm determines the optimal segmentation threshold, and the calculation formula is shown in Equation (4.5): (4.5) In the formula, Threshold Inter-class variance The current threshold, and The weights for the foreground and background are respectively. and These are the average gray values ​​for the foreground and background, respectively. The algorithm iterates through all possible gray values. Calculate each inter-class variance corresponding to the value The t-value that maximizes the inter-class variance is selected as the optimal threshold. As shown in equation (4.6): (4.6) in, To be the optimal threshold, Threshold Inter-class variance The current threshold, To find the operator of the argument that maximizes the function. Then adjust the threshold to take... As the final binarization threshold, where The threshold adjustment coefficient is used for binarization to better separate the yarn body and the background.

[0020] Step 4.5, morphological operations are used to remove small noise regions: Connected regions are marked on the binarized image, and region analysis is performed using the 8-connectivity criterion. The formula for calculating the area of ​​connected regions is shown in Equation (4.7): (4.7) In the formula, For the first Connected regions area, The index of the connected region. For the first A connected region, These are the pixel coordinates within the region. This indicates the number of pixels counted. Connected regions with an area smaller than area_threshold are removed to eliminate noise interference.

[0021] Step 4.6, extract the center line structure of the yarn strand using a skeletonization algorithm: A morphological thinning algorithm is used to extract the skeleton from the binary image. The skeletonization process is achieved by iteratively applying morphological erosion operations, and the iterative formula is shown in equation (4.8). (4.8) In the formula, For the first The image after the next iteration For the number of iterations, For the first The result of the iteration The original binary image, As a structural element, This represents the erosion operation; the iterative process continues until the convergence condition is met. If the conditions are met, the centerline structure of the yarn is obtained, and the skeletonization process maintains the original image's topological structure unchanged; Step 4.7, perform closing operation on the skeleton to connect breakpoints: Define a rectangular structuring element and perform morphological closing operation on the skeleton image. The closing operation is defined as shown in equation (4.9): (4.9) In the formula, For skeleton image The result of the closing operation. For skeleton images, As a structural element, This represents the expansion operation. This represents the erosion operation. The closing operation can connect broken skeleton line segments to form a complete strand centerline structure.

[0022] Step 4.8, determine the effective measurement region based on visual saliency region: After the closing operation, morphological operations are used again to remove small regions with an area smaller than the set threshold. The formula for selecting the effective region is shown in equation (4.10): (4.10) In the formula, This is the final set of valid measurement areas. Let be the i-th connected region. The area of ​​the region, This is the area threshold. This region represents the core structure of the yarn, has the highest visual salience, and can accurately reflect the body color characteristics of the yarn.

[0023] Step 4.9, Extract RGB color information within the effective area: Obtain the set of pixel coordinates of the effective measurement area determined in Step 4.8, and extract the RGB pixel values ​​corresponding to these coordinate positions in the original RGB image. The pixel extraction function is shown in Equation (4.11): (4.11) In the formula, To determine the sequence number of the pixels within the effective measurement area, For the first The RGB values ​​of each pixel The original RGB image, For the first The coordinates of each valid pixel.

[0024] Step 4.10: Convert the RGB color information extracted in Step 4.9 into LAB color space data and calculate the average color value: First, normalize the RGB values ​​to the range [0,1]. The normalization formula is shown in Equation (4.12). (4.12) In the formula, These are the normalized RGB values. The data consists of the original RGB values. Then, the RGB data is converted to the Lab color space using a standard color space conversion algorithm. The conversion process from RGB to Lab color space first requires conversion to... The color space conversion formula is shown in equation (4.13): (4.13) In the formula, These are the tristimulus values ​​for the XYZ color space. These are the normalized RGB values. Then... The conversion formulas for color space to Lab color space are shown in equations (4.14)-(4.15): (4.14) (4.15) In the formula, The samples are respectively in The brightness, red-green, and yellow-blue color values ​​of the color space. for The tristimulus values ​​of the color space, The tristimulus values ​​of the standard illuminant. This is a non-linear transformation function. Finally, the average Lab value of all pixels within the effective area is calculated as the color measurement result of the yarn, as shown in equation (4.16): (4.16) In the formula, They are respectively The average value of the components, where N is the total number of pixels in the effective measurement area. , , These are the Lab color component values ​​for the i-th pixel. Thus, the Lab color data for all yarn strands is obtained.

[0025] Furthermore, in step 5, the method for loading and preprocessing the batch Lab color data is as follows: The data obtained in step 4... The Lab color data matrix is ​​loaded into the analysis system to check data integrity and validity, remove outliers and invalid data points, count the number of data points, and display the loading results.

[0026] Furthermore, in step 6, robustness is used. The method for estimating color clustering regions is as follows: Set an appropriate outlier ratio parameter, and use a robust covariance estimation algorithm to calculate the minimum covariance determinant (MPD). The robust covariance matrix is ​​calculated using the formula shown in equation (1): (1) In the formula, The robust covariance matrix, For the minimum covariance subset, For the size of the subset, For indexing data points, For the first Data points, For robust center location estimation. Simultaneously calculate the robust center location; the robust center calculation formula is shown in equation (2): (2) In the formula, This is the robust center position vector, containing the center values ​​of the three Lab components. For the minimum covariance subset, For the size of the subset, For indexing data points, For the first Data points.

[0027] Furthermore, in step 7, the method for calculating Mahalanobis distance to identify clustered and discrete data is as follows: Based on the robust covariance matrix and center position obtained in step 6, the Mahalanobis distance of each data point is calculated. The Mahalanobis distance calculation formula is shown in equation (3): (3) In the formula, For indexing data points, For the first Mahalanobis distance of data points For the first Lab data points, For the robust center position, It is the inverse of the robust covariance matrix. Let represent the transpose matrix. Then, calculate the chi-square distribution critical value as the judgment threshold. The critical value calculation formula is shown in equation (4): (4) In the formula, This is the critical value of the chi-square distribution. For confidence level parameters, For the degree of freedom parameter, For confidence level The lower degree of freedom is Chi-square distribution critical value.

[0028] Furthermore, in step 8, the method for determining the boundary and center location of the clustered region is as follows: Based on the comparison results of Mahalanobis distance and critical value, the data points are classified into clustered data and discrete data, and the classification determination formula is shown in equation (5): (5) In the formula, For indexing data points, For the first The classification results for each data point The Mahalanobis distance, The critical threshold, Indicates aggregated data, This represents discrete data. It involves statistically analyzing the number and proportion of data points within clustered regions, calculating the number and proportion of outliers, and determining the central location and covariance characteristics of the clustered regions.

[0029] Furthermore, in step 9, the method for constructing the 3D Lab space visualization is as follows: A Lab color space distribution map is drawn in a 3D coordinate system, and an ellipsoidal boundary representing the clustering region is constructed based on the robust covariance matrix. The ellipsoidal parameter equation is shown in equation (6). (6) In the formula, These represent the lightness, red-green, and yellow-blue values ​​in the Lab color space. The coordinates of the ellipsoid center are: The length of the ellipsoidal semi-axis corresponding to the eigenvalues ​​of the covariance matrix. Set a threshold for Mahalanobis distance. Use different colors and markers to distinguish clustered and discrete data points, and add axis labels, legends, and statistical information.

[0030] Furthermore, in step 10, the method for calculating the central chromaticity reference value of the clustered region is as follows: Based on the identified clustered data points, the central chromaticity value of the clustered region is calculated as a reference standard for quality evaluation. The formula for calculating the cluster center is shown in equation (7): (7) In the formula, These are the Lab reference values ​​at the center of the cluster region, The total number of data points within the aggregation area. For indexing data points, For the first Lab values ​​of clustered data points It is a set of aggregated data points.

[0031] Furthermore, in step 11, the method for determining the rigidity threshold based on the minor semi-axis of the ellipsoid is as follows: calculate the eigenvalue decomposition of the covariance matrix to determine the geometric parameters of the ellipsoid. The eigenvalue decomposition formula of the covariance matrix is ​​shown in equation (8): (8) In the formula, The robust covariance matrix, The eigenvector matrix, It is an eigenvalue diagonal matrix. The feature values ​​are sorted in descending order; calculate the just-discriminating threshold. The formula for calculating the discrimination threshold is shown in equation (9): (9) In the formula, The threshold value is the difference threshold, corresponding to the length of the minor semi-axis of the ellipsoid. The smallest eigenvalue of the covariance matrix is ​​. The Mahalanobis distance threshold is used for determination. Then, the color difference value between each data point and the center of the clustered region is calculated sequentially. .

[0032] Furthermore, in step 12, the method for automatic rating based on clustering characteristics is as follows: Based on the classification results and color difference values ​​of the data points, a three-level evaluation standard is formulated for automatic rating, and the rating rules are shown in equation (10): (10) In the formula, For the first The quality grade of each sample For sample index, For clustered classification results, To aggregate data, For discrete data, For the first Color difference values ​​of each sample This is the threshold for just being distinguished. The grade indicates that the color difference is less than the minimum discrimination threshold and the color consistency is excellent; The grade indicates that the color difference is within the clustered area but exceeds the minimum discrimination threshold, and the color consistency is good. The rank represents discrete data located outside the ellipsoid, and the color consistency is generally average.

[0033] Furthermore, in step 13, the method for outputting the grading results and quality evaluation report is as follows: Statistically calculate the sample size and proportion of each grade, and calculate the quality indicators of the entire batch of products, including parameters such as clustering degree, consistency coefficient, and pass rate. The formula for calculating the quality indicators of the entire batch is shown in equation (11): (11) In the formula, represents aggregation. Rate, representing the percentage of samples within a clustered region out of the total sample. The percentage of excellent grades indicates the level. Percentage of the total sample. The pass rate represents... and The percentage of graded samples out of the total sample. The number of samples within the clustered area. This represents the total number of samples. for Number of graded samples for Number of graded samples. At this point, the automatic grading of yarn dyeing quality based on photographic color measurement is complete.

[0034] The present invention also provides an automatic grading system for yarn dyeing quality based on photographic color measurement, including a processor and a memory. The memory is used to store program instructions, and the processor is used to call the program instructions in the memory to execute the automatic grading method for yarn dyeing quality based on photographic color measurement as described in the above technical solution.

[0035] This invention addresses the problems of traditional skein dyeing quality evaluation methods, such as strong subjectivity, poor consistency, and difficulty in quantifying the color distribution characteristics of batch products. Based on photographic colorimetry, parameter optimization algorithms, and color distribution clustering analysis theory, it proposes an intelligent automatic grading method for skein dyeing quality. This method automatically identifies color clustering regions and discrete data through robust statistical analysis, establishes a three-level evaluation system based on clustering characteristics, and realizes the transformation from qualitative evaluation to quantitative analysis. This significantly improves the scientific rigor, objectivity, and consistency of dyeing quality evaluation, providing a new technical means for digital quality management in the textile industry. Attached Figure Description

[0036] Figure 1 This is a flowchart of an embodiment of the present invention.

[0037] Figure 2 This is a physical image of the photographic colorimetric system built according to the present invention.

[0038] Figure 3 This is a schematic diagram of the three-dimensional distribution of the Lab color space in this invention. Detailed Implementation

[0039] To facilitate understanding and implementation of the present invention by those skilled in the art, the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the embodiments described herein are for illustration and explanation only and are not intended to limit the present invention.

[0040] The technical solution of this invention can be implemented by those skilled in the art using computer software technology.

[0041] Combined with appendix Figure 1 This invention proposes an automatic grading method for yarn dyeing quality based on photographic color measurement, which specifically includes the following steps: Step 1: Set up a photographic colorimetry system; Step 2: Acquire digital images of the yarn sample; Step 3: Use a parameter optimization algorithm to determine the optimal colorimetric parameters; Step 4: Obtain batch skein Lab color data based on optimal color measurement parameters; Step 5: Load and preprocess batch skein Lab color data; Step 6: Use the robust MCD method to estimate the color clustering regions; Step 7: Calculate Mahalanobis distance to identify clustered and discrete data; Step 8: Determine the boundaries and center location of the cluster area; Step 9: Construct a 3D Lab space visualization display; Step 10: Calculate the central chromaticity reference value of the clustered region as a reference standard for quality evaluation; Step 11: Determine the rigidity threshold based on the minor semi-axis of the ellipsoid, and calculate the color difference value between each data point and the center of the clustering region in turn; Step 12: Perform automatic rating based on clustering characteristics; Step 13: Output the grading results and quality evaluation report.

[0042] The following examples illustrate the processing procedure for each step: The examples are based on a self-developed enclosed daylighting light box, a Nikon D7200 digital camera, and yarn strands, and test the method of the present invention.

[0043] In step 1, based on a self-developed enclosed fluorescent lighting box and in conjunction with a Nikon D7200 digital camera, a photographic color measurement system was constructed. The constructed photographic color measurement system is shown in the attached figure. Figure 2 As shown. This system ensures that the system's illumination is unaffected by natural light, and that the illumination is uniform within the effective photographic area, effectively avoiding the problem of photographic system deviation. For a detailed implementation of the photographic colorimetric system, please refer to reference 1.

[0044] [1] Liang Jinxing, Hu Xinrong, Peng Tao, et al. A type of enclosed daylighting light box [P]. Hubei Province: CN218585157U, 2023-03-07. In step 2, the method for acquiring digital images of the yarn samples is as follows: Prepare N yarn samples to be tested, ensuring that the samples are free from contamination and obvious color variations; lay the yarn samples flat within the effective imaging area of ​​the photometric system, and set standard digital camera shooting parameters; use the digital camera to photograph the yarn samples at a fixed distance and angle, ensuring image clarity and uniform illumination; obtain RGB format digital images and save them according to their numbers to establish a complete sample image database. In this embodiment, N is 100.

[0045] In step 3, the method for determining the optimal colorimetric parameters using a parameter optimization algorithm is as follows: Step 3.1: Fabricating the corresponding fabric pieces for the skeins: In this example, m groups of gray skein samples with similar but slight differences in color are used as raw materials. Each group of skeins is woven into a corresponding plain weave fabric piece sample, ensuring that the fabric structural parameters are consistent, including warp and weft density, fabric thickness, and other parameters remain uniform. Standard processes are used in the weaving process to avoid the influence of fabric structural differences on color measurement. The fabric pieces are 10×10cm in size, meeting the measurement requirements of the spectrophotometer. A numbered correspondence is established between the skeins and the fabric pieces: skein 1 corresponds to fabric piece 1, skein 2 corresponds to fabric piece 2, and so on, ensuring that each skein has a unique corresponding fabric piece sample. In this example, m is taken as 100.

[0046] Step 3.2: Acquire digital images of the yarn strands and their corresponding fabric pieces: Prepare m yarn strand samples with similar colors but slight differences. For each yarn strand, prepare n different arrangement patterns, including loose arrangement, tight arrangement, single-layer flat laying, double-layer stacking, and random arrangement, to simulate different states in actual use. Photograph each of the n yarn strand patterns, taking x images consecutively for each pattern. Similarly, take x high-resolution digital images of each fabric piece sample. Establish a numbering system for subsequent data management and analysis; the image file naming format is "sample number_pattern number.jpg". In this example, m, n, and x are 100, 5, and 10 respectively, and the digital camera imaging parameters are a focal length of 140mm, ISO 100, exposure time of 1 / 25s, and aperture of f5.6.

[0047] Step 3.3, Measure the standard color parameters of the fabric: Use the same photometric colorimetry system as the yarn measurement to acquire high-resolution digital images of the fabric sample to ensure consistency of measurement conditions; preprocess the fabric image and crop the effective measurement area, avoiding fabric edges and areas with obvious weaving defects; calculate the RGB average value of all pixels in the cropped area using the average pixel method; convert the RGB average value into CIE Lab color parameters according to the colorimetric theory conversion algorithm; establish a correspondence table between yarn number and standard Lab value of the fabric to provide a reference target for subsequent parameter optimization.

[0048] Step 3.4, define the parameter optimization space and constraints: determine the key parameters to be optimized, including the Gaussian filter standard deviation σ, Gaussian filter kernel size kernel_size, binarization threshold adjustment coefficient k, connected region area threshold area_threshold, and skeleton minimum retained area threshold skeleton_threshold; set reasonable value ranges and constraints for each parameter, as shown in equation (3.1): (3.1) In the formula, The standard deviation of the Gaussian filter. This is the size of the Gaussian filter kernel. This is the binarization threshold adjustment coefficient. This is the threshold value for the area of ​​the connected region. In the example, and Take 1 and 5 respectively. and Take 5 and 10 respectively. and Take values ​​of 0.3 and 2 respectively. and Take 400 and 800 respectively. and Take 5 and 20 respectively.

[0049] Step 3.5, construct a composite objective function as the fitness: The objective function consists of two sub-objectives, namely the relevance objective and the stability objective, and the composite objective function is defined as shown in equation (3.2): (3.2) In the formula, For the composite objective function value, The objective function is the correlation. Let the stability objective function be... and These are the weighting coefficients for the two sub-objectives. In the example, and All are 0.5, and the formula for calculating the correlation objective function is shown in equation (3.3): (3.3) In the formula, The objective function is the correlation. For skein yarn Values ​​and corresponding fabric pieces The coefficient of determination between the values. The formula for calculating the stability objective function is shown in equation (3.4): (3.4) In the formula, This is the sample number for the skein yarn. Let the stability objective function be... For the first Average color difference of the yarn samples This represents the number of yarn strands.

[0050] The formula for calculating the correlation coefficient is shown in equation (3.5): (3.5) In the formula, Sample numbering, For the first Measurement of individual yarn samples value, For the corresponding fabric pieces value, For fabric pieces The average value The total number of samples is given. The measurement stability of each group of yarn strands is calculated using the stability evaluation formula shown in equation (3.6): (3.6) In the formula, Number the yarn strands. Number the number of measurements for the same group of yarn strands. For the first Average color difference of stranded yarn The number of measurements for each group of yarn strands. For the first Grouped yarn The Lab value of this measurement, For the first Lab average value of the twisted yarn This is the CIE DE2000 color difference formula. In this embodiment, the Lab value of the yarn sample can be calculated through step 4.

[0051] Step 3.6, Initialize optimization algorithm parameters: Select genetic algorithm as the optimization method, and set algorithm parameters including population size, crossover probability, mutation probability, maximum number of iterations, etc.; the algorithm parameter settings are shown in equation (3.7): (3.7) In the formula, For population size, For crossover probability, The mutation probability, It represents the maximum algebra. (Example) and Take values ​​of 50, 0.8, 0.1, and 100 respectively.

[0052] Step 3.7, execute the parameter optimization process: randomly generate an initial population within the defined parameter space; evaluate the fitness of each individual; perform genetic operations such as selection, crossover, and mutation; update the population and record the optimal solution; repeat the iteration until the stopping criterion is met.

[0053] Step 3.8, Determine the stopping criteria: Set multiple stopping conditions to ensure the effectiveness of the optimization process. The stopping criteria include maximum running time, target R² value, number of consecutive generations without improvement, convergence tolerance, minimum improvement ratio, etc. The stopping condition determination is shown in equation (3.8): (3.8) In the formula, This is the current running time. For maximum runtime, For the present value, For the goal value, For continuous unimproved algebras, Tolerance algebra, The objective function value of the current generation. This represents the optimal objective function value to date. The objective function value of the previous generation. To reduce convergence tolerance, This represents the minimum improvement ratio. In the example, , and The values ​​were 60, 0.96, 15, 0.00001, and 0.005, respectively.

[0054] Step 3.9: Update the parameter population and output the optimal parameters: If the stopping criterion is not met, continue the iterative process of the genetic algorithm; perform the selection operation to retain individuals with higher fitness; perform the crossover operation to generate new parameter combinations; perform the mutation operation to increase population diversity; update the population and prepare for the next round of iteration; When the stopping criterion is met, the current optimal parameter combination is output; the objective function value, correlation coefficient, stability index, etc. corresponding to the optimal parameters are recorded; the first N sets of optimal parameters are saved for the user to select, and the parameter output format is shown in equation (3.9): (3.9) In the formula, For the optimal parameter combination, This represents the optimal value for the standard deviation of the Gaussian filter. This is the size of the Gaussian filter kernel. This represents the optimal value for the binarization threshold adjustment coefficient. This represents the optimal value for the area threshold of the connected region. This represents the optimal value for the minimum retained area threshold of the skeleton. In the example, By setting the value to 100, the optimization calculation of the yarn skein photographic color measurement parameters is completed, and a set of optimal parameters is obtained.

[0055] In step 4, the method for obtaining batch Lab color data of skeins based on optimal colorimetric parameters is as follows: Step 4.1: Convert the RGB color image to a grayscale image: Use a weighted average method to convert the RGB three-channel information into single-channel grayscale information. The grayscale conversion formula is shown in equation (4.1): (4.1) In the formula, These are the converted grayscale pixel values. These are the pixel values ​​for the red, green, and blue channels, respectively. The weighting coefficients are determined based on the human eye's sensitivity to different colors, with the green component having the largest weight, followed by the red component, and the blue component having the smallest weight.

[0056] Step 4.2, Gaussian blur processing is performed on the grayscale image: A Gaussian filter of size kernel_size is used to smooth the grayscale image to reduce image noise and detail interference. The Gaussian blur kernel function is shown in equation (4.2): (4.2) In the formula, Position coordinates The filter weight value at that point, and These are the offset coordinates relative to the center of the kernel. σ is the standard deviation of the Gaussian filter. In this example, σ and kernel_size are obtained from step 3.

[0057] Step 4.3, perform adaptive histogram equalization: Divide the image into 8×8 sub-blocks, and perform histogram equalization on each sub-block. The cumulative distribution function of each sub-block is calculated as shown in equation (4.3): (4.3) In the formula, grayscale The cumulative distribution function value, The current grayscale level, For the summation variable, grayscale The number of pixels, This represents the total number of pixels within the sub-block. The formula for calculating the equalized pixel value is shown in equation (4.4): (4.4) In the formula, The current grayscale level, grayscale The new pixel value after equalization The total number of gray levels. grayscale The cumulative distribution function value, This is a rounding function. The final result is then synthesized using bilinear interpolation. This method enhances local contrast while preserving the overall characteristics of the image.

[0058] Step 4.4, binarization is performed using the improved Otsu thresholding method: First, the global threshold T0 of the image is calculated, and the optimal segmentation threshold is determined using the Otsu algorithm, as shown in equation (4.5): (4.5) In the formula, Threshold Inter-class variance The current threshold, and The weights for the foreground and background are respectively. and These are the average gray values ​​for the foreground and background, respectively. The algorithm iterates through all possible gray values. Calculate each inter-class variance corresponding to the value The t-value that maximizes the inter-class variance is selected as the optimal threshold. As shown in equation (4.6): (4.6) in, To be the optimal threshold, Threshold Inter-class variance The current threshold, To find the operator of the argument that maximizes the function. Then adjust the threshold to take... As the final binarization threshold, where This is a binarization threshold adjustment coefficient to better separate the yarn body and the background. In this embodiment, the value of k is obtained from step 3.

[0059] Step 4.5, morphological operations are used to remove small noise regions: Connected regions are marked on the binarized image, and region analysis is performed using the 8-connectivity criterion. The formula for calculating the area of ​​connected regions is shown in Equation (4.7): (4.7) In the formula, For the first Connected regions area, The index of the connected region. For the first A connected region, These are the pixel coordinates within the region. This represents the number of statistical pixels. Connected regions with an area smaller than area_threshold are removed to eliminate noise interference. In this embodiment, the value of area_threshold is obtained from step 3.

[0060] Step 4.6, extract the center line structure of the yarn strand using a skeletonization algorithm: A morphological thinning algorithm is used to extract the skeleton from the binary image, using 3×3 cross-shaped structural elements. The skeletonization process is achieved by iteratively applying morphological erosion operations, and the iterative formula is shown in equation (4.8). (4.8) In the formula, For the first The image after the next iteration For the number of iterations, For the first The result of the iteration The original binary image, As a structural element, This represents the erosion operation; the iterative process continues until the convergence condition is met. If the conditions are met, the centerline structure of the yarn is obtained, and the skeletonization process maintains the original image's topological structure unchanged.

[0061] Step 4.7, perform closing operation on the skeleton to connect breakpoints: Define a 3×3 rectangular structuring element, and perform morphological closing operation on the skeleton image. The closing operation is defined as shown in equation (4.9): (4.9) In the formula, For skeleton image The result of the closing operation. For skeleton images, As a structural element, This represents the expansion operation. This represents the erosion operation. The closing operation can connect broken skeleton line segments to form a complete strand centerline structure.

[0062] Step 4.8, determine the effective measurement region based on visual saliency region: After the closing operation, morphological operations are used again to remove small regions with an area smaller than the set threshold. The formula for selecting the effective region is shown in equation (4.10): (4.10) In the formula, This is the final set of valid measurement areas. Let be the i-th connected region. The area of ​​the region, This is the area threshold. This region represents the core structure of the yarn strand, has the highest visual saliency, and can accurately reflect the body color characteristics of the yarn strand. In this embodiment, the value of skeleton_threshold is obtained from step 3.

[0063] Step 4.9, Extract RGB color information within the effective area: Obtain the set of pixel coordinates of the effective measurement area determined in Step 4.8, and extract the RGB pixel values ​​corresponding to these coordinate positions in the original RGB image. The pixel extraction function is shown in Equation (4.11): (4.11) In the formula, To determine the sequence number of the pixels within the effective measurement area, For the first The RGB values ​​of each pixel The original RGB image, For the first The coordinates of each valid pixel.

[0064] Step 4.10, the method for converting the RGB color information extracted in Step 4.9 into LAB color space data and calculating the average color value is as follows: First, normalize the RGB values ​​to the range of [0,1]. The normalization formula is shown in Equation (4.12): (4.12) In the formula, These are the normalized RGB values. The data consists of the original RGB values. Then, the RGB data is converted to the Lab color space using a standard color space conversion algorithm. The conversion process from RGB to Lab color space first requires conversion to... The color space conversion formula is shown in equation (4.13): (4.13) In the formula, These are the tristimulus values ​​for the XYZ color space. These are the normalized RGB values. Then... The conversion formulas for color space to Lab color space are shown in equations (4.14)-(4.15): (4.14) (4.15) In the formula, The samples are respectively in The brightness, red-green, and yellow-blue color values ​​of the color space. for The tristimulus values ​​of the color space, The tristimulus values ​​of the standard illuminant. This is a non-linear transformation function. Finally, the average Lab value of all pixels within the effective area is calculated as the color measurement result of the yarn, as shown in equation (4.16): (4.16) In the formula, They are respectively The average value of the components, where N is the total number of pixels in the effective measurement area. , , These are the Lab color component values ​​for the i-th pixel. Thus, the Lab color data for all yarn strands is obtained.

[0065] Furthermore, in step 5, the method for loading and preprocessing the batch Lab color data is as follows: The data obtained in step 4... The Lab color data matrix is ​​loaded into the analysis system to check data integrity and validity, remove outliers and invalid data points, count the number of data points, and display the loading results.

[0066] In step 6, robustness is used. The method for estimating color clustering regions is as follows: Set an appropriate outlier ratio parameter, and use a robust covariance estimation algorithm to calculate the minimum covariance determinant (MPD). The robust covariance matrix is ​​calculated using the formula shown in equation (1): (1) In the formula, The robust covariance matrix, For the minimum covariance subset, For the size of the subset, For indexing data points, For the first Data points, For robust center location estimation. Simultaneously calculate the robust center location; the robust center calculation formula is shown in equation (2): (2) In the formula, This is the robust center position vector, containing the center values ​​of the three Lab components. For the minimum covariance subset, For the size of the subset, For indexing data points, For the first Data points.

[0067] In step 7, the method for calculating Mahalanobis distance to identify clustered and discrete data is as follows: Based on the robust covariance matrix and center position obtained in step 6, the Mahalanobis distance of each data point is calculated. The Mahalanobis distance calculation formula is shown in equation (3): (3) In the formula, For indexing data points, For the first Mahalanobis distance of data points For the first Lab data points, For the robust center position, It is the inverse of the robust covariance matrix. Let represent the transpose matrix. Then, calculate the chi-square distribution critical value as the judgment threshold. The critical value calculation formula is shown in equation (4): (4) In the formula, This is the critical value of the chi-square distribution. For confidence level parameters, For the degree of freedom parameter, For confidence level The lower degree of freedom is Chi-square distribution critical value. In the example, m and n are 0.95 and 3, respectively.

[0068] In step 8, the method for determining the boundary and center location of the clustered region is as follows: Based on the comparison results of Mahalanobis distance and critical value, the data points are classified into clustered data and discrete data, and the classification determination formula is shown in equation (5): (5) In the formula, For indexing data points, For the first The classification results for each data point The Mahalanobis distance, The critical threshold, Indicates aggregated data, This represents discrete data. It involves statistically analyzing the number and proportion of data points within clustered regions, calculating the number and proportion of outliers, and determining the central location and covariance characteristics of the clustered regions.

[0069] In step 9, the method for constructing the 3D Lab space visualization is as follows: A Lab color space distribution map is drawn in a 3D coordinate system. An ellipsoidal boundary is constructed based on the robust covariance matrix to represent the clustered region. The ellipsoidal parametric equation is shown in equation (6). (6) In the formula, These represent the lightness, red-green, and yellow-blue values ​​in the Lab color space. The coordinates of the ellipsoid center are: The length of the ellipsoidal semi-axis corresponding to the eigenvalues ​​of the covariance matrix. A threshold for Mahalanobis distance is set. Different colors and markers are used to distinguish clustered and discrete data points. Coordinate axis labels, legends, and statistical information are added. The three-dimensional distribution of the Lab color space in this embodiment is shown in the attached figure. Figure 3 As shown.

[0070] In step 10, the method for calculating the central chromaticity reference value of the clustered area is as follows: Based on the identified clustered data points, the central chromaticity value of the clustered area is calculated as a reference standard for quality evaluation. The formula for calculating the cluster center is shown in equation (7): (7) In the formula, These are the Lab reference values ​​at the center of the cluster region, The total number of data points within the aggregation area. For indexing data points, For the first Lab values ​​of clustered data points It is a set of aggregated data points.

[0071] In step 11, the method for determining the rigidity threshold based on the minor semi-axis of the ellipsoid is as follows: Calculate the eigenvalue decomposition of the covariance matrix to determine the geometric parameters of the ellipsoid. The eigenvalue decomposition formula of the covariance matrix is ​​shown in equation (8): (8) In the formula, The robust covariance matrix, The eigenvector matrix, It is an eigenvalue diagonal matrix. The feature values ​​are sorted in descending order; calculate the just-discriminating threshold. The formula for calculating the discrimination threshold is shown in equation (9): (9) In the formula, The threshold value is the difference threshold, corresponding to the length of the minor semi-axis of the ellipsoid. The smallest eigenvalue of the covariance matrix is ​​. The Mahalanobis distance threshold is used for determination. Then, the color difference value between each data point and the center of the clustered region is calculated sequentially. .

[0072] In step 12, the method for automatic rating based on clustering characteristics is as follows: Based on the classification results and color difference values ​​of the data points, a three-level evaluation standard is formulated for automatic rating, and the rating rules are shown in equation (10): (10) In the formula, For the first The quality grade of each sample For sample index, For clustered classification results, To aggregate data, For discrete data, For the first Color difference values ​​of each sample This is the threshold for just being distinguished. The grade indicates that the color difference is less than the minimum discrimination threshold and the color consistency is excellent; The grade indicates that the color difference is within the clustered area but exceeds the minimum discrimination threshold, and the color consistency is good. The rank represents discrete data located outside the ellipsoid, and the color consistency is generally average.

[0073] In step 13, the method for outputting the grading results and quality evaluation report is as follows: Statistically calculate the sample size and proportion of each grade, and calculate the quality indicators of the entire batch of products, including parameters such as clustering degree, consistency coefficient, and pass rate. The formula for calculating the quality indicators of the entire batch is shown in equation (11): (11) In the formula, represents aggregation. Rate, representing the percentage of samples within a clustered region out of the total sample. The percentage of excellent grades indicates the level. Percentage of the total sample. The pass rate represents... and The percentage of graded samples out of the total sample. The number of samples within the clustered area. This represents the total number of samples. for Number of graded samples for Number of graded samples. At this point, the automatic grading of yarn dyeing quality based on photographic color measurement is complete.

[0074] Table 1 Results Report

[0075]

[0076]

[0077] On the other hand, embodiments of the present invention also provide an automatic grading system for yarn dyeing quality based on photographic color measurement, including a processor and a memory. The memory is used to store program instructions, and the processor is used to call the program instructions in the memory to execute the automatic grading method for yarn dyeing quality based on photographic color measurement as described in the above technical solution.

[0078] The specific embodiments described herein are merely illustrative of the spirit of the invention. Those skilled in the art to which this invention pertains may make various modifications or additions to the described specific embodiments or use similar methods to substitute them, without departing from the spirit of the invention or exceeding the scope defined by the appended claims.

Claims

1. An automatic grading method for yarn dyeing quality based on photographic color measurement, characterized in that, Includes the following steps: Step 1: Set up a photographic colorimetry system; Step 2: Acquire digital images of the yarn sample; Step 3: Use a parameter optimization algorithm to determine the optimal colorimetric parameters; Step 4: Obtain batch skein Lab color data based on optimal color measurement parameters; Step 5: Load and preprocess batch skein Lab color data; Step 6: Use the robust MCD method to estimate the color clustering regions; Step 7: Calculate Mahalanobis distance to identify clustered and discrete data; Step 8: Determine the boundaries and center location of the cluster area; Step 9: Construct a 3D Lab space visualization display; Step 10: Calculate the central chromaticity reference value of the clustered region as a reference standard for quality evaluation; Step 11: Determine the rigidity threshold based on the minor semi-axis of the ellipsoid, and calculate the color difference value between each data point and the center of the clustering region in turn; Step 12: Perform automatic rating based on clustering characteristics; Step 13: Output the grading results and quality evaluation report.

2. The automatic grading method for yarn dyeing quality based on photographic color measurement as described in claim 1, characterized in that: In step 3, the method for determining the optimal colorimetric parameters using a parameter optimization algorithm is as follows: Step 3.1: Make the fabric pieces corresponding to the yarn strands; Step 3.2: Acquire digital images of the corresponding fabric pieces; Step 3.3, Measure the standard color parameters of the fabric: Use the same photometric colorimetry system as the yarn measurement to acquire high-resolution digital images of the fabric sample to ensure consistency of measurement conditions; preprocess the fabric image and crop the effective measurement area; calculate the RGB average value of all pixels in the cropped area using the average pixel method; convert the RGB average value into CIE Lab color parameters according to the colorimetric theory conversion algorithm; establish a correspondence table between yarn number and standard Lab value of the fabric to provide a reference target for subsequent parameter optimization; Step 3.4, define the parameter optimization space and constraints: determine the key parameters to be optimized, including the Gaussian filter standard deviation σ, Gaussian filter kernel size kernel_size, binarization threshold adjustment coefficient k, connected region area threshold area_threshold, and skeleton minimum retained area threshold skeleton_threshold; and set reasonable value ranges and constraints for each parameter. Step 3.5, construct a composite objective function as the fitness: the objective function consists of two sub-objectives, namely the relevance objective and the stability objective; the composite objective function is defined as: ; In the formula, For the composite objective function value, The objective function is the correlation. Let the stability objective function be... and These are the weight coefficients for the two sub-objectives, respectively. The formula for calculating the correlation objective function is: ; In the formula, The objective function is the correlation. For skein yarn Values ​​and corresponding fabric pieces The coefficient of determination between values; The formula for calculating the stability objective function is: ; In the formula, This is the sample number for the skein yarn. Let the stability objective function be... For the first Average color difference of the yarn samples This refers to the number of yarn strands. Step 3.6, Initialize optimization algorithm parameters: Select genetic algorithm as the optimization method, and set algorithm parameters including population size, crossover probability, mutation probability, and maximum number of iterations; Step 3.7, execute the parameter optimization process: randomly generate an initial population within the defined parameter space; evaluate the fitness of each individual; perform selection, crossover, and mutation genetic operations; update the population and record the optimal solution; repeat the iteration until the stopping criterion is met; Step 3.8, Determine the stopping criteria: Set multiple stopping conditions to ensure the effectiveness of the optimization process. The stopping criteria include maximum running time, target... Value, continuous no-improvement algebra, convergence tolerance, minimum improvement ratio; Step 3.9, update the parameter population and output the optimal parameter combination: If the stopping criterion is not met, continue the iterative process of the genetic algorithm; perform the selection operation to retain individuals with fitness greater than the threshold; perform the crossover operation to generate new parameter combinations; perform the mutation operation to increase population diversity; update the population and prepare for the next round of iteration; when the stopping criterion is met, output the current optimal parameter combination.

3. The automatic grading method for yarn dyeing quality based on photographic color measurement as described in claim 1, characterized in that: In step 4, batch Lab color data of skeins is obtained based on the optimal color measurement parameters. The specific implementation method is as follows: Step 4.1: Convert the RGB color image to a grayscale image; Step 4.2, perform Gaussian blur processing on the grayscale image: Use a Gaussian filter of size kernel_size to smooth the grayscale image to reduce image noise and detail interference; the Gaussian blur kernel function is as follows: ; In the formula, Position coordinates The filter weight value at that point, and These are the offset coordinates relative to the center of the kernel. The standard deviation of the Gaussian filter; Step 4.3: Perform adaptive histogram equalization. Step 4.4, binarization is performed using the improved Otsu thresholding method: First, the global threshold T0 of the image is calculated, and then the optimal segmentation threshold is determined using the Otsu algorithm. The calculation formula is as follows: ; In the formula, Threshold Inter-class variance The current threshold, and The weights for the foreground and background are respectively. and These are the average gray values ​​for the foreground and background, respectively. The algorithm iterates through all possible gray values. Calculate each inter-class variance corresponding to the value Choose the one that maximizes the inter-class variance. value as the optimal threshold : ; in, To be the optimal threshold, Threshold Inter-class variance Let argmax be the current threshold, and argmax be the operator that calculates the maximum value of the function; then the threshold is adjusted to take... As the final binarization threshold, where k is the binarization threshold adjustment coefficient; Step 4.5: Use morphological operations to remove small noise regions and remove connected regions whose area is smaller than the area threshold area_threshold. Step 4.6, Extract the centerline structure of the yarn strand using a skeletonization algorithm: A morphological thinning algorithm is used to extract the skeleton from the binary image. The skeletonization process is achieved by iteratively applying morphological erosion operations, with the following iterative formula: ; In the formula, For the first The image after the next iteration For the number of iterations, For the first The result of the iteration The original binary image, As a structural element, This represents the erosion operation; the iterative process continues until the convergence condition is met. If the conditions are met, the centerline structure of the yarn is obtained, and the skeletonization process maintains the original image's topological structure unchanged; Step 4.7: Perform a closing operation on the skeleton to connect the break points; Step 4.8, Determine the effective measurement area: After the closing operation, morphological operations are used again to remove small areas with an area smaller than the set threshold. The formula for selecting the effective area is: ; In the formula, This is the final set of valid measurement areas. For the first A connected region, The area of ​​the region, Area threshold; Step 4.9, Extract RGB color information within the effective area: Obtain the set of pixel coordinates of the effective measurement area determined in Step 4.8, and extract the RGB pixel values ​​corresponding to these coordinate positions in the original RGB image; Step 4.10: Convert the RGB color information extracted in Step 4.9 into LAB color space data and calculate the average color value as the color measurement result of the yarn.

4. The automatic grading method for yarn dyeing quality based on photographic color measurement as described in claim 1, characterized in that: In step 6, the method for estimating color clustering regions using the robust MCD method is as follows: Set appropriate outlier ratio parameters, and use the robust covariance estimation algorithm to calculate the minimum covariance determinant. The formula for calculating the robust covariance matrix is: ; In the formula, MCD The robust covariance matrix, For the minimum covariance subset, For the size of the subset, For indexing data points, For the first Data points, For robust center location estimation; simultaneously calculate the robust center location, the formula for robust center calculation is: ; In the formula, This is the robust center position vector, containing the center values ​​of the three Lab components. For the minimum covariance subset, For the size of the subset, For indexing data points, For the first Data points.

5. The automatic grading method for yarn dyeing quality based on photographic color measurement as described in claim 4, characterized in that: In step 7, the method for calculating Mahalanobis distance to identify clustered and discrete data is as follows: Based on the robust covariance matrix and center position obtained in step 6, the Mahalanobis distance of each data point is calculated. The formula for calculating the Mahalanobis distance is: ; In the formula, For indexing data points, For the first Mahalanobis distance of data points For the first Lab data points, For the robust center position, It is the inverse of the robust covariance matrix. Represent the transpose matrix; then calculate the chi-square distribution critical value as the decision threshold. The critical value calculation formula is: ; In the formula, This is the critical value of the chi-square distribution. For confidence level parameters, For the degree of freedom parameter, For confidence level The lower degree of freedom is Chi-square distribution critical value.

6. The automatic grading method for yarn dyeing quality based on photographic color measurement as described in claim 1, characterized in that: In step 8, the method for determining the boundaries and center locations of clustered regions is as follows: Based on the comparison between Mahalanobis distance and critical values, data points are classified into clustered data and discrete data. The classification determination formula is: ; In the formula, For indexing data points, For the first The classification results for each data point The Mahalanobis distance, The critical threshold, Indicates aggregated data, This represents discrete data. It involves statistically analyzing the number and proportion of data points within clustered regions, calculating the number and proportion of outliers, and determining the central location and covariance characteristics of the clustered regions.

7. The automatic grading method for yarn dyeing quality based on photographic color measurement as described in claim 1, characterized in that: In step 9, the method for constructing the 3D Lab space visualization is as follows: A Lab color space distribution map is plotted in a 3D coordinate system. An ellipsoidal boundary is constructed based on the robust covariance matrix to represent the clustering region. The ellipsoidal parametric equation is: ; In the formula, These represent the lightness, red-green, and yellow-blue values ​​in the Lab color space. The coordinates of the ellipsoid center are: The length of the ellipsoidal semi-axis corresponding to the eigenvalues ​​of the covariance matrix. Set a threshold for Mahalanobis distance; use different colors and markers to distinguish clustered and discrete data points; add axis labels, legends, and statistical information.

8. The automatic grading method for yarn dyeing quality based on photographic color measurement as described in claim 1, characterized in that: In step 10, the method for calculating the central chromaticity reference value of the clustered region is as follows: Based on the identified clustered data points, the central chromaticity value of the clustered region is calculated as a reference standard for quality evaluation. The formula for calculating the cluster center is: ; In the formula, These are the Lab reference values ​​at the center of the cluster region, The total number of data points within the aggregation area. For indexing data points, For the first Lab values ​​of clustered data points It is a set of aggregated data points.

9. The automatic grading method for yarn dyeing quality based on photographic color measurement as described in claim 1, characterized in that: In step 11, the method for determining the rigidity threshold based on the minor semi-axis of the ellipsoid is as follows: Calculate the eigenvalue decomposition of the covariance matrix to determine the geometric parameters of the ellipsoid. The formula for the eigenvalue decomposition of the covariance matrix is: ; In the formula, The robust covariance matrix, The eigenvector matrix, It is an eigenvalue diagonal matrix. The eigenvalues ​​are arranged in descending order; Calculate the threshold of just discrimination The formula for calculating the discrimination threshold is: ; In the formula, The threshold value is the difference threshold, corresponding to the length of the minor semi-axis of the ellipsoid. The smallest eigenvalue of the covariance matrix is ​​. This is the threshold for Mahalanobis distance determination.

10. An automatic grading system for yarn dyeing quality based on photographic color measurement, characterized in that: It includes a processor and a memory, the memory being used to store program instructions, and the processor being used to call the program instructions in the memory to execute the automatic grading method for yarn dyeing quality based on photographic color measurement as described in any one of claims 1-9.