A visual saliency based skein color photometric measurement method and system
By using a visually saliency skein color photographic measurement method, the problems of strong human subjectivity and inaccuracy in skein color measurement are solved, and adaptive extraction of yarn color is achieved, improving measurement accuracy and consistency.
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
Smart Images

Figure CN122243896A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of computer digital image processing and textile color measurement technology, specifically relating to a method and system for photographic measurement of yarn color based on visual salience. Background Technology
[0002] Currently, the textile industry primarily relies on manual visual inspection or spectrophotometers to measure the color of skein yarn. However, manual visual inspection is highly subjective and inconsistent. Traditional spectrophotometers, when measuring skein yarn, suffer from inaccurate measurement area positioning due to the uneven texture and light transmission characteristics of the yarn surface, are easily affected by background interference, and struggle to capture the true color of the yarn itself. Existing photogrammetry techniques generally treat skein yarn as a planar object, directly averaging the entire image, causing measurements to deviate from the true color of the yarn. Furthermore, they lack adaptive extraction algorithms specific to the skein yarn structure, failing to separate effective yarn pixels from complex backgrounds. Therefore, there is an urgent need for a new method that can adaptively extract the main yarn pixels and directly output the yarn's true color. Summary of the Invention
[0003] The purpose of this invention is to solve the problems described in the background art. Based on photographic colorimetry, this invention replaces human visual observation of yarn strands and, by simulating the experience of color judges using the surface floating lines of the yarn strands for color determination, proposes a photographic measurement method for yarn strand color based on visual salience. The implementation of this technology first requires the construction of a photographic colorimetry system; secondly, high-resolution digital images of the yarn strand samples are captured using a digital camera, ensuring consistency in image quality and lighting conditions; then, visual salience color extraction is performed on the yarn strands, specifically including calculating the yarn strand brightness image, visually enhancing the features of the yarn strand brightness image, extracting the visual salience feature regions of the yarn strands, and optimizing the visual salience feature regions of the yarn strands; finally, based on the visual salience regions of the yarn strands, the visual salience color results of the yarn strands are extracted, completing the photographic measurement of yarn strand color based on visual salience, which is used to determine the color depth and qualification during the yarn strand production process.
[0004] The technical solution of this invention is a photographic measurement method for yarn color based on visual salience, specifically including the following steps:
[0005] Step 1: Set up a photographic colorimetry system;
[0006] Step 2: Use a digital camera to take digital images of the standard color chart and yarn sample;
[0007] Step 3: Construct a spectral reconstruction matrix based on the standard color chart;
[0008] Step 4: Calculate the brightness image of the yarn strands;
[0009] Step 5: Visually enhance the brightness image features of the yarn strands;
[0010] Step 6: Extract the visual saliency feature region of the yarn strand based on the enhanced brightness image;
[0011] Step 7: Optimize the region for extracting the visual saliency features of the yarn strand;
[0012] Step 8: Extract RGB color information from the visual saliency optimization area of the yarn strand;
[0013] Step 9: Calculate the color information of all pixels of the extracted yarn using the spectral reconstruction matrix;
[0014] Step 10: Average the color information of all pixels of the yarn to obtain the visual saliency color value of the yarn.
[0015] Furthermore, in step 3, the RGB values of the standard color chart digital image are first extracted, and then a spectral reconstruction matrix is constructed based on the standard color chart;
[0016] For a standard color chart, extract the RGB data of all pixels within its central m×m pixel area, and average the RGB data of the m×m pixels using the following formula:
[0017]
[0018] In the formula, i is the i-th color patch in the standard color chart; j is the j-th pixel in the extracted area; r i,j g i,j b i,j These are the RGB values of the red, green, and blue channels of the j-th pixel in the i-th color block, respectively; d i Let be the RGB value of the i-th color block, and be a 1×3 row vector.
[0019] First, the raw response values of the standard color chart are polynomially extended using a third-order homogeneous polynomial. The extended form is as follows, containing a total of 13 extension terms:
[0020]
[0021] In the formula, r, g, and b are the RGB values of the R, G, and B channels of the color block, respectively, and d... *,exp Let T be the extended RGB value vector of a color patch, denoteing transpose. After homogeneous polynomial expansion, the RGB value extension matrix of the standard color chart is as follows:
[0022]
[0023] In the formula, the subscript j indicates the j-th pixel, P is the number of pixels, and d train,exp,j Let D be the expanded vector of the raw response value of the j-th pixel. train,exp An extended RGB matrix for the standard color chart;
[0024] Then, the spectral reconstruction matrix is solved using the spectral matrix and extended RGB matrix of the standard color chart. The Tikhonov regularization method is used to constrain the solution process to overcome the influence of imaging noise on the accuracy of the spectral reconstruction matrix. Specifically, the solution method is as follows: First, the extended RGB matrix D of the standard color chart... train,exp Singular value decomposition is performed, and then a minimal number α is added to the eigenvalues to obtain constrained eigenvalues, thereby reducing the condition number of the extended RGB matrix. The extended RGB matrix D after regularization constraint is then reconstructed. train,exp,rec Finally, the pseudo-inverse algorithm is used to solve for the spectral reconstruction matrix Q;
[0025]
[0026]
[0027]
[0028]
[0029] In the formula, U and V are the orthogonal decomposition matrices obtained by singular value decomposition, S and P are diagonal matrices containing eigenvalues, I is the identity matrix, pinv() is the pseudo-inverse operator, and R train This is the spectral data matrix of the standard color chart.
[0030] Furthermore, step 4, calculating the yarn brightness image, includes converting the RGB three-channel information into single-channel brightness values using a weighted average method. The conversion formula is as follows:
[0031]
[0032] In the formula, Gray is the brightness value, and R, G, and B are the pixel values of the red, green, and blue channels, respectively.
[0033] Furthermore, step 5 involves visually enhancing the brightness image features of the yarn by using a Gaussian filter for blurring to reduce noise, and enhancing image contrast and detail through adaptive histogram equalization.
[0034] The Gaussian blur processing method is as follows: A Gaussian filter of size kernel_size is used to smooth the brightness image. The Gaussian blur kernel function is as follows:
[0035]
[0036] In the formula, G(x,y) is the filter weight value at the position coordinates (x,y), and x and y are the offset coordinates relative to the kernel center. The standard deviation parameter;
[0037] The adaptive histogram equalization method is as follows: the image is divided into several sub-blocks, and histogram equalization is performed on each sub-block. The cumulative distribution function of each sub-block is calculated using the following formula:
[0038]
[0039] In the formula, CDF(i) is the cumulative distribution function value of gray level i, i is the current gray level, j is the summation variable, h(j) is the number of pixels at gray level j, and N is the total number of pixels in the sub-block; the formula for calculating the pixel value after equalization is as follows:
[0040]
[0041] In the formula, i is the current gray level, g(i) is the new pixel value after gray level i is equalized, L is the total number of gray levels, CDF(i) is the cumulative distribution function value of gray level i, and round is the rounding function; then the final result is synthesized by bilinear interpolation.
[0042] Furthermore, step 6, which involves extracting the visually salient feature region of the yarn based on the enhanced brightness image, includes: performing precise binarization segmentation using the improved Otsu automatic threshold selection algorithm, and optimizing the separation effect between the foreground and background by dynamically adjusting the threshold parameters; subsequently, using a morphological operating system to systematically remove image noise and irrelevant small regions, accurately extracting the outline of the yarn body while maintaining its complete geometric structure.
[0043] The method for binarization using the improved Otsu thresholding method is as follows: First, calculate the global threshold T0 of the image, and then use the Otsu algorithm to determine the optimal segmentation threshold. The calculation formula is as follows:
[0044]
[0045] In the formula, The inter-class variance is the variance at a threshold t, where t is the current threshold. (t) and (t) represents the weights of the foreground and background, respectively. and Let t be the average gray values of the foreground and background, respectively; calculate the inter-class variance for each possible gray value t∈[0,255] by iterating through all possible gray values t∈[0,255]. The optimal threshold T0 is chosen as the t-value that maximizes the inter-class variance.
[0046]
[0047] Where T0 is the optimal threshold. Let T be the inter-class variance at threshold t, where t is the current threshold and argmax is the operator that finds the maximum value of the function. Then, the threshold is adjusted, and T = k × T0 is taken as the final binarization threshold, where k is the adjustment coefficient to better separate the yarn body and the background.
[0048] The method for removing small noise regions using morphological operations is as follows: 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 a connected region is as follows:
[0049]
[0050] In the formula, Area(C i ) represents the i-th connected region C i The area of C, where i is the index of the connected region. i Let (x, y) be the i-th connected region, and (x, y) be the pixel coordinates within the region. l represents the number of pixels to be counted. Connected regions with an area smaller than the area threshold are removed to eliminate noise interference.
[0051] Furthermore, the optimization of the visual saliency feature extraction region in step 7 includes: using an iterative refinement skeletonization algorithm to extract the centerline skeleton structure of the yarn, and using the extracted skeleton region as the effective measurement region for visual saliency.
[0052] The method for extracting the centerline structure of yarn strands using a skeletonization algorithm is as follows: 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 as follows:
[0053]
[0054] In the formula, S k S is the image after the k-th iteration, where k is the iteration number. k-1 This is the result of the (k-1)th iteration, where S0 is the original binary image and B is the structuring element. This represents the erosion operation; the iterative process continues until the convergence condition S is met. k =S k-1 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;
[0055] Then, a closing operation is performed on the skeleton to connect the breakpoints. A rectangular structuring element is defined, and a morphological closing operation is performed on the skeleton image. The closing operation is defined as follows:
[0056] SE
[0057] In the formula, Close(S) is the result of performing a closing operation on the skeleton image S, where S is the skeleton image and SE is the structuring element. This indicates the expansion operation. This represents the erosion operation;
[0058] After the closing operation, morphological operations are used again to remove small regions with areas smaller than a set threshold. The effective region filtering formula is as follows:
[0059]
[0060] In the formula, Region eff C represents the final set of valid measurement areas. i For the i-th connected region, Area( ) represents the area of the region, and skeleton_threshold is the area threshold.
[0061] Furthermore, in step 8, the method for extracting RGB color information within the visual saliency optimization region of the yarn strand is as follows: Obtain the set of pixel coordinates of the effective measurement region determined in step 7, and extract the RGB pixel values corresponding to these coordinate positions in the original RGB image. The pixel extraction function is:
[0062]
[0063] In the formula, i is the index of the pixel within the effective measurement area, RGB(i) is the RGB value of the i-th pixel, Image_RGB is the original RGB image, (x i ,y i ) represents the coordinates of the i-th valid pixel.
[0064] Furthermore, the color information of all pixels in the extracted yarn is calculated using the spectral reconstruction matrix, including:
[0065] First, the spectrum of each pixel in the visual saliency optimization region of the yarn strand is reconstructed using a spectral reconstruction matrix, specifically:
[0066]
[0067] In the formula, d is the extended RGB value of the visual saliency optimization region of the yarn; Q is the calculated spectral reconstruction matrix; and r is the reconstructed spectral data.
[0068] Then, based on colorimetric theory, the CIEXYZ tristimulus values of the skein were calculated from the reconstructed spectral data. The calculation method is as follows:
[0069]
[0070] in,
[0071]
[0072] In the formula, x(λ), y(λ) and z(λ) are standard observer color matching functions, S(λ) is the relative spectral power distribution function of the light source, λ is the wavelength, η is the adjustment factor, and X, Y and Z are the tristimulus values of the yarn, respectively.
[0073] Finally, the corresponding CIELab color data is calculated. Based on colorimetry theory, the method for calculating the corresponding CIELab color data from the tristimulus values CIEXYZ is as follows:
[0074]
[0075] in,
[0076]
[0077] In the formula, L, a, and b are the brightness, red-green, and yellow-blue color values of the yarn in the CIELab color space, respectively; X, Y, and Z are the tristimulus color data of the yarn, respectively; X n Y n and Z n The tristimulus color data for the reference light source are H and H, respectively. n These represent the CIEXYZ tristimulus values of the yarn and the reference light source, respectively.
[0078] The present invention also provides a yarn color photographic measurement system based on visual salience, 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 yarn color photographic measurement method based on visual salience as described in the above technical solution.
[0079] The present invention also provides a computer-readable storage medium, including a readable storage medium on which a computer program is stored, wherein when the computer program is executed, it implements the skein color photographic measurement method based on visual salience as described in the above technical solution. Attached Figure Description
[0080] Figure 1 This is a flowchart of an embodiment of the present invention.
[0081] Figure 2 This is a physical image of the photographic colorimetric system built according to the present invention.
[0082] Figure 3 This is the original yarn twist image in an embodiment of the present invention.
[0083] Figure 4 This is a brightness diagram from an embodiment of the present invention.
[0084] Figure 5 This is a blurred image in an embodiment of the present invention.
[0085] Figure 6 This is the equilibrium diagram in an embodiment of the present invention.
[0086] Figure 7 This is the initial binary image in an embodiment of the present invention.
[0087] Figure 8 This is a denoised binary image in an embodiment of the present invention.
[0088] Figure 9 This is a skeleton diagram from an embodiment of the present invention.
[0089] Figure 10 This is a diagram of the skeleton closure in an embodiment of the present invention.
[0090] Figure 11 This is a skeleton filtering diagram in an embodiment of the present invention. Detailed Implementation
[0091] 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.
[0092] The technical solution of this invention can be implemented by those skilled in the art using computer software technology.
[0093] Combined with appendix Figure 1 This invention proposes a method for photographic measurement of yarn color based on visual salience, specifically including the following steps:
[0094] Step 1: Set up a photographic colorimetry system;
[0095] Step 2: Use a digital camera to take digital images of the standard color chart and yarn sample;
[0096] Step 3: Construct a spectral reconstruction matrix based on the standard color chart;
[0097] Step 4: Calculate the brightness image of the yarn strands;
[0098] Step 5: Visually enhance the brightness image features of the yarn strands;
[0099] Step 6: Extract the visual saliency feature region of the yarn strand based on the enhanced brightness image;
[0100] Step 7: Optimize the region for extracting the visual saliency features of the yarn strand;
[0101] Step 8: Extract RGB color information from the visual saliency optimization area of the yarn strand;
[0102] Step 9: Calculate the color information of all pixels of the extracted yarn using the spectral reconstruction matrix;
[0103] Step 10: Average the color information of all pixels of the yarn to obtain the visual saliency color value of the yarn.
[0104] 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 21 different colored yarns, to test the method of the present invention.
[0105] 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.
[0106] [1] Liang Jinxing, Hu Xinrong, Peng Tao, et al. A type of enclosed daylighting light box [P]. Hubei Province: CN218585157U, 2023-03-07.
[0107] In step 2, the method for capturing digital images of the yarn skein using a digital camera is as follows:
[0108] First, prepare samples of yarn that are free from contamination, have no obvious color variations, and are uniformly colored. Place the 21 different colored yarn samples sequentially on the shooting platform, ensuring that the center of each yarn is within the effective shooting range of the camera lens.
[0109] Next, set the shooting parameters of the digital camera. In this embodiment, the imaging parameters of the digital camera are: focal length 35mm, ISO 100, exposure time 1 / 25s, and aperture size f5.6. After shooting, save the image as a JPG file, maintaining the original shooting resolution, and name it according to the yarn color.
[0110] Finally, the image is cropped according to the area where the yarn is located, retaining only the stranded portion and avoiding the inclusion of background or other interfering information. The resulting original stranded image is shown in the attached image. Figure 3 As shown.
[0111] In step 3, the RGB values of the standard color chart digital image are first extracted, and then a spectral reconstruction matrix is constructed based on the standard color chart.
[0112] For a standard color chart, extract the RGB data of all pixels within its central m×m pixel area, and average the RGB data of the m×m pixels using the following formula:
[0113]
[0114] In the formula, i is the i-th color patch in the standard color chart; j is the j-th pixel in the extracted area; r i,j g i,j b i,j These are the RGB values of the red, green, and blue channels of the j-th pixel in the i-th color block, respectively; d i Let be the RGB value of the i-th color block, and be a 1×3 row vector.
[0115] First, the raw response values of the standard color chart are polynomially extended using a third-order homogeneous polynomial. The extended form is as follows, containing a total of 13 extension terms:
[0116]
[0117] In the formula, r, g, and b are the RGB values of the R, G, and B channels of the color block, respectively, and d... *,exp Let T be the extended RGB value vector of a color patch, denoteing transpose. After homogeneous polynomial expansion, the RGB value extension matrix of the standard color chart is as follows:
[0118]
[0119] In the formula, the subscript j indicates the j-th pixel, P is the number of pixels, and d train,exp,j Let D be the expanded vector of the raw response value of the j-th pixel. train,exp An extended RGB matrix for the standard color chart;
[0120] Then, the spectral reconstruction matrix is solved using the spectral matrix and extended RGB matrix of the standard color chart. The Tikhonov regularization method is used to constrain the solution process to overcome the influence of imaging noise on the accuracy of the spectral reconstruction matrix. Specifically, the solution method is as follows: First, the extended RGB matrix D of the standard color chart... train,exp Singular value decomposition is performed, and then a minimal number α is added to the eigenvalues to obtain constrained eigenvalues, thereby reducing the condition number of the extended RGB matrix. The extended RGB matrix D after regularization constraint is then reconstructed. train,exp,rec Finally, the pseudo-inverse algorithm is used to solve for the spectral reconstruction matrix Q;
[0121]
[0122]
[0123]
[0124]
[0125] In the formula, U and V are the orthogonal decomposition matrices obtained by singular value decomposition, S and P are diagonal matrices containing eigenvalues, I is the identity matrix, pinv() is the pseudo-inverse operator, and R train This is the spectral data matrix of the standard color chart.
[0126] In step 4, calculating the brightness image of the yarn includes: converting the RGB three-channel information into single-channel brightness information using a weighted average method, as shown in equation (1):
[0127] (1)
[0128] In the formula, Gray represents the converted grayscale pixel value, i.e., the brightness value; R, G, and B are the pixel values of 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 highest weight, followed by the red component, and the blue component having the lowest weight. The converted grayscale image is shown in the attached figure. Figure 4 As shown.
[0129] Step 5 involves visually enhancing the brightness image features of the yarn by using a Gaussian filter for blurring to reduce noise, and enhancing image contrast and detail through adaptive histogram equalization.
[0130] The method for Gaussian blurring of grayscale images is as follows: A Gaussian filter of 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 (2).
[0131] (2)
[0132] In the formula, G(x,y) is the filter weight value at the position coordinates (x,y), x and y are the offset coordinates relative to the kernel center, and σ is the standard deviation parameter. The blurred image after Gaussian blurring is shown in the attached figure. Figure 5 As shown in the example. In this example, σ and kernel_size are set to 1.0 and 5, respectively.
[0133] In step 5, the adaptive histogram equalization process is performed as follows: the image is divided into 8×8 sub-blocks, and histogram equalization is performed on each sub-block. The cumulative distribution function of each sub-block is calculated as shown in equation (3):
[0134] (3)
[0135] In the formula, CDF(i) is the cumulative distribution function value of gray level i, i is the current gray level, j is the summation variable, h(j) is the number of pixels at gray level j, and N is the total number of pixels in the sub-block. The formula for calculating the pixel value after equalization is shown in formula (4):
[0136] (4)
[0137] In the formula, i represents the current gray level, g(i) is the new pixel value after equalization of gray level i, L is the total number of gray levels, CDF(i) is the cumulative distribution function value of gray level i, and round is the rounding function. The final result is then synthesized through bilinear interpolation. This method can enhance local contrast while preserving the overall characteristics of the image. The equalization image after histogram equalization is shown in the attached figure. Figure 6 As shown.
[0138] Step 6, which involves extracting the visually salient feature region of the yarn based on the enhanced brightness image, includes: performing precise binarization segmentation using the improved Otsu automatic threshold selection algorithm, and optimizing the separation effect between the foreground and background by dynamically adjusting the threshold parameters; subsequently, using a morphological operating system to systematically remove image noise and irrelevant small regions, accurately extracting the main outline of the yarn while maintaining its complete geometric structure.
[0139] The method for binarization using the improved Otsu thresholding method is as follows: First, calculate the global threshold T0 of the image, and then use the Otsu algorithm to determine the optimal segmentation threshold. The calculation formula is shown in equation (5).
[0140] (5)
[0141] In the formula, The inter-class variance is the variance at a threshold t, where t is the current threshold. (t) and (t) represents the weights of the foreground and background, respectively. and Let t represent the average gray values of the foreground and background, respectively. The inter-class variance is calculated for each possible gray value t∈[0,255]. The optimal threshold T0 is selected as the t value that maximizes the inter-class variance, as shown in equation (6):
[0142] (6)
[0143] Where T0 is the optimal threshold. Let be the inter-class variance at threshold t, where t is the current threshold, and argmax is the operator that maximizes the function. Then, the threshold is adjusted, and T = k × T0 is taken as the final binarization threshold, where k is an adjustment coefficient to better separate the yarn strand and the background. The initial binary image after binarization is attached. Figure 7 As shown. In this embodiment, the value of k is 0.53.
[0144] The method for removing small noise regions using morphological operations is as follows: Connected regions are marked in 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 (7):
[0145] (7)
[0146] In the formula, Area(C i ) represents the i-th connected region C i The area of C, where i is the index of the connected region. i Let (x, y) be the i-th connected region, and (x, y) be 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. The denoised binary image after morphological denoising is shown in the attached image. Figure 8 As shown in the example. In this embodiment, the value of area_threshold is 618.
[0147] Step 7 optimizes the region for extracting visual saliency features of the yarn by using an iterative and refined skeletonization algorithm to extract the centerline skeleton structure of the yarn and using the extracted skeleton region as the effective measurement region for visual saliency.
[0148] A method for extracting the centerline structure of yarn strands using a skeletonization algorithm: A morphological thinning algorithm is used to extract the skeleton from the binary image, using a 3×3 cross-shaped structural element. The skeletonization process is achieved by iteratively applying morphological erosion operations, and the iterative formula is shown in equation (8).
[0149] (8)
[0150] In the formula, S k S is the image after the k-th iteration, where k is the iteration number. k-1 This is the result of the (k-1)th iteration, where S0 is the original binary image and B is the structuring element. This represents the erosion operation. The iterative process continues until the convergence condition S is met. k =S k-1 The desired result is obtained, showing the centerline structure of the yarn strand. The skeletonization process preserves the original image's topological structure. The extracted yarn strand skeleton diagram is attached. Figure 9 As shown.
[0151] Then, a closing operation is performed on the skeleton to connect the breakpoints: a 3×3 rectangular structural element is defined, and a morphological closing operation is performed on the skeleton image. The closing operation is defined as shown in equation (9):
[0152] SE (9)
[0153] In the formula, Close(S) is the result of performing a closing operation on the skeleton image S, where S is the skeleton image and SE is the structuring element. This indicates the expansion operation. This represents the erosion operation. The closing operation can connect broken skeleton segments to form a complete yarn centerline structure. A closed diagram of the complete skeleton after the closing operation is attached. Figure 10 As shown.
[0154] After the closing operation, morphological operations are used again to remove small regions with areas smaller than the set threshold. The effective region filtering formula is shown in equation (10):
[0155] (10)
[0156] In the formula, Region eff C represents the final set of valid measurement areas. i For the i-th connected region, Area(C) i The area is represented by , and the area threshold is skeleton_hreshold. 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. The final effective measurement region skeleton filter diagram is attached. Figure 11 As shown in the example. In this embodiment, the value of keleton_hreshold is 19.
[0157] In step 8, the method for extracting RGB color information within the visual saliency optimization region of the yarn strand is as follows: Obtain the set of pixel coordinates of the effective measurement region determined in step 7, and extract the RGB pixel values corresponding to these coordinate positions in the original RGB image. The pixel extraction function is shown in equation (11):
[0158] (11)
[0159] In the formula, i is the index of the pixel within the effective measurement area, RGB(i) is the RGB value of the i-th pixel, Image_RGB is the original RGB image, (x i ,y i ) represents the coordinates of the i-th valid pixel.
[0160] In step 9, the color information of all pixels of the extracted yarn is calculated using the spectral reconstruction matrix, including:
[0161] First, the spectrum of each pixel in the visual saliency optimization region of the yarn strand is reconstructed using a spectral reconstruction matrix, specifically:
[0162] (12)
[0163] In the formula, d is the extended RGB value of the visual saliency optimization region of the yarn; Q is the calculated spectral reconstruction matrix; and r is the reconstructed spectral data.
[0164] Then, based on colorimetric theory, the CIEXYZ tristimulus values of the skein were calculated from the reconstructed spectral data. The calculation method is as follows:
[0165] (13)
[0166] in,
[0167]
[0168] In the formula, x(λ), y(λ) and z(λ) are standard observer color matching functions, S(λ) is the relative spectral power distribution function of the light source, λ is the wavelength, η is the adjustment factor, and X, Y and Z are the tristimulus values of the yarn, respectively.
[0169] Finally, the corresponding CIELab color data is calculated. Based on colorimetry theory, the method for calculating the corresponding CIELab color data from the tristimulus values CIEXYZ is as follows:
[0170] (14)
[0171] in,
[0172]
[0173] In the formula, L, a, and b are the brightness, red-green, and yellow-blue color values of the yarn in the CIELab color space, respectively; X, Y, and Z are the tristimulus color data of the yarn, respectively; X n Y n and Z n The tristimulus color data for the reference light source are H and H, respectively. n These represent the CIEXYZ tristimulus values of the yarn and the reference light source, respectively.
[0174] 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. A method for photographic measurement of yarn color based on visual salience, characterized in that, Includes the following steps: Step 1: Set up a photographic colorimetry system; Step 2: Use a digital camera to take digital images of the standard color chart and yarn sample; Step 3: Construct a spectral reconstruction matrix based on the standard color chart; Step 4: Calculate the brightness image of the yarn strands; Step 5: Visually enhance the brightness image features of the yarn strands; Step 6: Extract the visual saliency feature region of the yarn strand based on the enhanced brightness image; Step 7: Optimize the region for extracting the visual saliency features of the yarn strand; Step 8: Extract RGB color information from the visual saliency optimization area of the yarn strand; Step 9: Calculate the color information of all pixels of the extracted yarn using the spectral reconstruction matrix; Step 10: Average the color information of all pixels of the yarn to obtain the visual saliency color value of the yarn.
2. The method for photographic measurement of yarn color based on visual salience as described in claim 1, characterized in that: In step 3, the RGB values of the standard color chart digital image are first extracted, and then a spectral reconstruction matrix is constructed based on the standard color chart. For a standard color chart, extract the RGB data of all pixels within its central m×m pixel area, and average the RGB data of the m×m pixels using the following formula: ; In the formula, i is the i-th color patch in the standard color chart; j is the j-th pixel in the extracted area; r i,j g i,j b i,j These are the RGB values of the red, green, and blue channels of the j-th pixel in the i-th color block, respectively; d i Let be the RGB value of the i-th color block, and let be a 1×3 row vector; First, the raw response values of the standard color chart are polynomially extended using a third-order homogeneous polynomial. The extended form is as follows, containing a total of 13 extension terms: ; In the formula, r, g, and b are the RGB values of the R, G, and B channels of the color block, respectively, and d... *,exp Let T be the extended RGB value vector of a color patch, denoteing transpose. After homogeneous polynomial expansion, the RGB value extension matrix of the standard color chart is as follows: ; In the formula, the subscript j indicates the j-th pixel, P is the number of pixels, and d train,exp,j Let D be the expanded vector of the raw response value of the j-th pixel. train,exp An extended RGB matrix for the standard color chart; Then, the spectral reconstruction matrix is solved using the spectral matrix and extended RGB matrix of the standard color chart. The Tikhonov regularization method is used to constrain the solution process to overcome the influence of imaging noise on the accuracy of the spectral reconstruction matrix. Specifically, the solution method is as follows: First, the extended RGB matrix D of the standard color chart... train,exp Singular value decomposition is performed, and then a minimal number α is added to the eigenvalues to obtain constrained eigenvalues, thereby reducing the condition number of the extended RGB matrix. The extended RGB matrix D after regularization constraint is then reconstructed. train,exp,rec Finally, the pseudo-inverse algorithm is used to solve for the spectral reconstruction matrix Q; ; ; ; ; In the formula, U and V are the orthogonal decomposition matrices obtained by singular value decomposition, S and P are diagonal matrices containing eigenvalues, I is the identity matrix, pinv() is the pseudo-inverse operator, and R train This is the spectral data matrix of the standard color chart.
3. The method for photographic measurement of yarn color based on visual salience as described in claim 1, characterized in that: Step 4, calculating the yarn brightness image, includes converting the RGB three-channel information into single-channel brightness values using a weighted average method. The conversion formula is as follows: ; In the formula, Gray is the brightness value, and R, G, and B are the pixel values of the red, green, and blue channels, respectively.
4. The method for photographic measurement of yarn color based on visual salience as described in claim 1, characterized in that: Step 5 involves visually enhancing the brightness image features of the yarn by using a Gaussian filter for blurring to reduce noise, and enhancing image contrast and detail through adaptive histogram equalization. The Gaussian blur processing method is as follows: A Gaussian filter of size kernel_size is used to smooth the brightness image. The Gaussian blur kernel function is as follows: ; In the formula, G(x,y) is the filter weight value at the position coordinates (x,y), and x and y are the offset coordinates relative to the kernel center. The standard deviation parameter; The adaptive histogram equalization method is as follows: the image is divided into several sub-blocks, and histogram equalization is performed on each sub-block. The cumulative distribution function of each sub-block is calculated using the following formula: ; In the formula, CDF(i) is the cumulative distribution function value of gray level i, i is the current gray level, j is the summation variable, h(j) is the number of pixels at gray level j, and N is the total number of pixels in the sub-block; the formula for calculating the pixel value after equalization is as follows: ; In the formula, i is the current gray level, g(i) is the new pixel value after gray level i is equalized, L is the total number of gray levels, CDF(i) is the cumulative distribution function value of gray level i, and round is the rounding function; then the final result is synthesized by bilinear interpolation.
5. The method for photographic measurement of yarn color based on visual salience as described in claim 1, characterized in that: Step 6 involves extracting the visually salient feature region of the yarn based on the enhanced brightness image, including: using the improved Otsu automatic threshold selection algorithm for accurate binarization segmentation, and dynamically adjusting the threshold parameters to optimize the separation effect between the foreground and background; then, using a morphological operating system to systematically remove image noise and irrelevant small regions, accurately extracting the outline of the yarn body while maintaining its complete geometric structure. The method for binarization using the improved Otsu thresholding method is as follows: First, calculate the global threshold T0 of the image, and then use the Otsu algorithm to determine the optimal segmentation threshold. The calculation formula is as follows: ; In the formula, The inter-class variance is the variance at a threshold t, where t is the current threshold. (t) and (t) represents the weights of the foreground and background, respectively. and Let t be the average gray values of the foreground and background, respectively; calculate the inter-class variance for each possible gray value t∈[0,255] by iterating through all possible gray values t∈[0,255]. The optimal threshold T0 is chosen as the t-value that maximizes the inter-class variance. ; Where T0 is the optimal threshold. Let T be the inter-class variance at threshold t, where t is the current threshold and argmax is the operator that finds the maximum value of the function. Then, the threshold is adjusted, and T = k × T0 is taken as the final binarization threshold, where k is the adjustment coefficient to better separate the yarn body and the background. The method for removing small noise regions using morphological operations is as follows: 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 a connected region is as follows: ; In the formula, Area(C i ) represents the i-th connected region C i The area of C, where i is the index of the connected region. i Let (x, y) be the i-th connected region, and (x, y) be the pixel coordinates within the region. l represents the number of pixels to be counted. Connected regions with an area smaller than the area threshold are removed to eliminate noise interference.
6. The method for photographic measurement of yarn color based on visual salience as described in claim 1, characterized in that: Step 7 optimizes the region for extracting visual saliency features of the yarn by using an iterative and refined skeletonization algorithm to extract the centerline skeleton structure of the yarn and using the extracted skeleton region as the effective measurement region for visual saliency. The method for extracting the centerline structure of yarn strands using a skeletonization algorithm is as follows: 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 as follows: ; In the formula, S k S is the image after the k-th iteration, where k is the iteration number. k-1 This is the result of the (k-1)th iteration, where S0 is the original binary image and B is the structuring element. This represents the erosion operation; the iterative process continues until the convergence condition S is met. k =S k-1 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; Then, a closing operation is performed on the skeleton to connect the breakpoints. A rectangular structuring element is defined, and a morphological closing operation is performed on the skeleton image. The closing operation is defined as follows: SE; In the formula, Close(S) is the result of performing a closing operation on the skeleton image S, where S is the skeleton image and SE is the structuring element. This indicates the expansion operation. This represents the erosion operation; After the closing operation, morphological operations are used again to remove small regions with areas smaller than a set threshold. The effective region filtering formula is as follows: ; In the formula, Region eff C represents the final set of valid measurement areas. i For the i-th connected region, Area( ) represents the area of the region, and skeleton_threshold is the area threshold.
7. The method for photographic measurement of yarn color based on visual salience as described in claim 1, characterized in that: In step 8, the method for extracting RGB color information within the visual saliency optimization region of the yarn strand is as follows: Obtain the set of pixel coordinates of the effective measurement region determined in step 7, and extract the RGB pixel values corresponding to these coordinate positions in the original RGB image. The pixel extraction function is: ; In the formula, i is the index of the pixel within the effective measurement area, RGB(i) is the RGB value of the i-th pixel, Image_RGB is the original RGB image, (x i ,y i ) represents the coordinates of the i-th valid pixel.
8. The method for photographic measurement of yarn color based on visual salience as described in claim 1, characterized in that: The color information of all pixels extracted from the yarn was calculated using the spectral reconstruction matrix, including: First, the spectrum of each pixel in the visual saliency optimization region of the yarn strand is reconstructed using a spectral reconstruction matrix, specifically: ; In the formula, d is the extended RGB value of the visual saliency optimization region of the yarn; Q is the calculated spectral reconstruction matrix; and r is the reconstructed spectral data. Then, based on colorimetric theory, the CIEXYZ tristimulus values of the skein were calculated from the reconstructed spectral data. The calculation method is as follows: ; in, ; In the formula, x(λ), y(λ) and z(λ) are standard observer color matching functions, S(λ) is the relative spectral power distribution function of the light source, λ is the wavelength, η is the adjustment factor, and X, Y and Z are the tristimulus values of the yarn, respectively. Finally, the corresponding CIELab color data is calculated. Based on colorimetry theory, the method for calculating the corresponding CIELab color data from the tristimulus values CIEXYZ is as follows: ; in, ; In the formula, L, a, and b are the brightness, red-green, and yellow-blue color values of the yarn in the CIELab color space, respectively; X, Y, and Z are the tristimulus color data of the yarn, respectively; X n Y n and Z n The tristimulus color data for the reference light source are H and H, respectively. n These represent the CIEXYZ tristimulus values of the yarn and the reference light source, respectively.
9. A photographic measurement system for yarn color based on visual salience, 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 yarn color photographic measurement method based on visual salience as described in any one of claims 1-8.
10. A computer-readable storage medium, characterized in that, It includes a readable storage medium on which a computer program is stored, which, when executed, implements the skein color photographic measurement method based on visual salience as described in any one of claims 1-8.