Yarn dyeing quality evaluation method and system based on adaptive mean shift clustering

CN122617833APending Publication Date: 2026-08-21QINGDAO FENGZHIHAO SPIN CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202610790335.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-06-03
Publication Date
2026-08-21

AI Technical Summary

Technical Problem

在基于自适应均值漂移聚类实现纱线染色质量评估过程中,当纱线图像中出现一段颜色保持一致但亮度发生突变的染色区域时,会表现为视觉上颜色未发生变化但明暗程度突然改变的现象,这是由于纱线表面在染色后受到光照条件变化、纤维反射差异或局部表面状态改变的影响,使得同一染料在成像过程中产生不同亮度响应,从而导致该区域在特征空间中亮度分量发生突变,而颜色分量保持稳定,由此会改变像素之间的距离度量关系,而现有技术不能根据纱线中存在颜色保持一致但亮度发生突变的染色区域情况下的亮度变化程度去调整自适应均值漂移聚类中的特征权重分配以完成准确的染色质量评估,会使算法在密度估计过程中将该区域误认为存在差异,从而将原本属于同一染色区域的像素错误划分为不同类别,进而会导致染色均匀性评价结果被放大或失真,最终影响纱线染色质量评估的准确性和可靠性

Benefits of technology

本发明通过构建综合色度变量与亮度变化变量的解耦特征体系,并引入颜色一致引导因子实现颜色连续约束,在此基础上进一步通过一致性遍历精准识别颜色保持一致但亮度发生突变的染色区域,避免将亮度扰动误判为颜色差异;同时,通过对目标像素集合进行亮度变化序列重排与映射建模,实现亮度变化的结构化表达,并结合区段划分与多指标统计对亮度变化程度进行精细量化,从而为后续调控提供可靠依据;进一步地,通过参与比例重构与特征权重分配,将亮度变化程度直接映射到综合色度变量与亮度变化变量的影响比例中,使距离计算能够动态抑制亮度突变带来的干扰;在此基础上结合自适应均值漂移聚类迭代过程中的收敛状态对特征权重进行动态调控,形成基于反馈的闭环优化机制,最终使同一染色区域内的像素在亮度突变情况下仍保持聚类一致性,避免误分割问题,从而提升纱线染色均匀性评估的准确性与稳定性,同时增强算法对复杂光照及表面反射变化的适应能力。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122617833A_ABST
    Figure CN122617833A_ABST
Patent Text Reader

Abstract

The application discloses a yarn dyeing quality evaluation method and system based on adaptive mean shift clustering, relates to the technical field of yarn dyeing quality evaluation, and specifically comprises the following steps: feature reconstruction is performed on a yarn image, a comprehensive chroma variable and a brightness change variable are generated, a color consistency guide factor is constructed by using the comprehensive chroma variable, and a feature set with continuous color and separated brightness is formed; consistency traversal is performed by using the comprehensive chroma variable, the brightness change variable and the color consistency guide factor, it is judged whether there is a dyeing area with consistent color but with brightness mutation in the yarn, and in the case that there is a dyeing area with consistent color but with brightness mutation, constraints are applied to corresponding pixels to form a target pixel set. The application solves the problem of false judgment caused by brightness mutation interference clustering, realizes adaptive weight regulation based on the degree of brightness change, and thus improves the accuracy and stability of dyeing quality evaluation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of yarn dyeing quality assessment technology, specifically to a method and system for yarn dyeing quality assessment based on adaptive mean drift clustering. Background Technology

[0002] Adaptive mean-shift clustering-based yarn dyeing quality assessment is a method combining computer vision and unsupervised clustering analysis. It quantitatively evaluates dyeing uniformity and defects by estimating the density and recognizing patterns in the color distribution of yarn dyeing images. Its core lies in using a mean-shift algorithm to iteratively optimize the distribution of image pixels in the feature space (such as color space and spatial coordinates), and dynamically adjusting the bandwidth parameter through an adaptive mechanism to adapt to the color variation characteristics of different regions, thereby improving clustering accuracy and robustness. Existing techniques typically first acquire yarn surface images using an industrial camera and perform preprocessing such as noise reduction, illumination correction, and color space conversion. (e.g., RGB to Lab), then construct a multi-dimensional feature vector containing color and position information, and then use adaptive mean-shift clustering to group pixels to identify different stained regions. During the clustering process, the kernel function bandwidth is adaptively adjusted according to local density or color gradient to avoid oversegmentation or undersegmentation. After the clustering is completed, the statistical features of each cluster are extracted, such as mean color, variance and regional distribution, and further the staining uniformity index, color difference distribution and abnormal region ratio are calculated. Finally, the quality score or grade is output by constructing an evaluation model. The overall process generally includes key steps such as image acquisition, preprocessing, feature extraction, adaptive clustering analysis and quality evaluation output.

[0003] The existing technology has the following shortcomings: In the process of evaluating yarn dyeing quality based on adaptive mean-drift clustering, when a dyed area with consistent color but abrupt brightness changes appears in the yarn image, it manifests as a sudden change in brightness without a visual change in color. This is because the yarn surface is affected by changes in lighting conditions, differences in fiber reflection, or changes in local surface conditions after dyeing, causing the same dye to produce different brightness responses during imaging. This results in abrupt changes in the brightness component in the feature space of the region, while the color component remains stable. This alters the distance measurement relationship between pixels. Existing technologies cannot adjust the feature weight allocation in adaptive mean-drift clustering based on the degree of brightness change in dyed areas with consistent color but abrupt brightness changes to achieve accurate dyeing quality evaluation. This causes the algorithm to mistakenly identify the region as having differences during density estimation, thus incorrectly classifying pixels that originally belonged to the same dyed area into different categories. Consequently, the dyeing uniformity evaluation results are amplified or distorted, ultimately affecting the accuracy and reliability of yarn dyeing quality evaluation.

[0004] The information disclosed in the background section is only intended to enhance the understanding of the background of this disclosure, and therefore may include information that does not constitute prior art known to those skilled in the art. Summary of the Invention

[0005] The purpose of this invention is to provide a method and system for evaluating yarn dyeing quality based on adaptive mean drift clustering, so as to solve the problems in the background art mentioned above.

[0006] To achieve the above objectives, the present invention provides the following technical solution: a yarn dyeing quality assessment method based on adaptive mean-shift clustering, specifically including the following steps: S1. Reconstruct the features of the yarn image to generate a comprehensive chromaticity variable and a brightness change variable, and use the comprehensive chromaticity variable to construct a color consistency guiding factor to form a feature set with continuous color and separated brightness. S2. Using the comprehensive chromaticity variable, brightness change variable and color consistency guiding factor, perform consistency traversal to determine whether there are dyed areas in the yarn with consistent color but abrupt brightness changes. If there are dyed areas with consistent color but abrupt brightness changes, apply constraints to the corresponding pixels to form a target pixel set. S3. Rearrange the brightness change variables in the target pixel set to construct a brightness change mapping sequence, and determine the degree of brightness change based on the brightness change mapping sequence. S4. Based on the degree of brightness change, the participation ratio of the comprehensive chromaticity variable and the brightness change variable is reconstructed. The feature weight allocation in the adaptive mean drift clustering is adjusted according to the degree of brightness change, and the distance calculation is performed using the reconstructed feature set. S5. Perform adaptive mean-shift clustering iteration based on the distance calculation results. During the iteration process, dynamically adjust the feature weight allocation based on the clustering convergence state, and output the yarn dyeing quality evaluation results.

[0007] Preferably, S1 is as follows: The yarn image is reconstructed by performing feature reconstruction. The normalization ratio of the color components of each pixel in the yarn image is calculated to generate a comprehensive chromaticity variable. The color components are weighted and summed to generate a brightness change variable. A one-to-one correspondence between the comprehensive chromaticity variable and the brightness change variable is established under the same pixel coordinates. Based on the comprehensive chromaticity variables, the difference between the comprehensive chromaticity variables of adjacent pixels is calculated, and a difference sequence is formed according to the pixel spatial order. The continuity of the difference sequence is determined, and the continuous intervals in which the difference changes remain monotonically changing or the change amplitude is within a preset range are identified. Pixel pairs belonging to the same continuous interval are marked as the same association category, and a color consistency guiding factor is generated based on the association category of the pixel pair. Under the constraint of the color consistency guiding factor, the comprehensive chromaticity variable and the brightness variation variable are jointly rearranged. The comprehensive chromaticity variable is arranged continuously according to the correspondence of the color consistency guiding factor, and the brightness variation variable is arranged independently according to the pixel order. The comprehensive chromaticity variable and the brightness variation variable form a corresponding distribution relationship, which constitutes a feature set with continuous color and separated brightness.

[0008] Preferably, S2 specifically includes the following steps: S201. Perform a consistency traversal using the comprehensive chromaticity variable, brightness change variable and color consistency guide factor. Read the comprehensive chromaticity variable and brightness change variable point by point according to the pixel spatial order, and associate the pixels according to the color consistency guide factor. Pixels with the same color consistency guide factor are arranged in spatial order to form a consistency traversal sequence. S202. In the consistent traversal sequence, the difference calculation is performed on the comprehensive chromaticity variable of adjacent pixels and the difference calculation is performed on the brightness change variable of adjacent pixels. Pixel pairs with a comprehensive chromaticity variable difference less than the first threshold and a brightness change variable difference greater than the second threshold are marked as judgment pixel pairs. Based on the continuous distribution of judgment pixel pairs in the traversal sequence, it is determined whether there is a dyeing area in the yarn with consistent color but a sudden change in brightness. S203. In the case of a stained area where the color remains consistent but the brightness changes abruptly, a constraint is applied to the corresponding pixel, the brightness change variable is subjected to amplitude limiting processing while maintaining the arrangement relationship of the comprehensive chromaticity variable, and the pixels after amplitude limiting processing are divided into sets according to spatial order to form the target pixel set.

[0009] Preferably, S202 specifically refers to: In the consistent traversal sequence, adjacent pixels are selected one by one in the pixel space order. The difference between the comprehensive chromaticity variables of the adjacent pixels is calculated and recorded. At the same time, the difference between the brightness change variables of the adjacent pixels is calculated and recorded. The difference between the comprehensive chromaticity variables and the difference between the brightness change variables corresponding to each pair of adjacent pixels are paired and stored. The difference between the overall chromaticity variable and the difference between the brightness change variable in the paired storage are compared one by one. Pixel pairs with a difference between the overall chromaticity variable and a difference between the brightness change variable and a difference between the brightness change variable and a difference between the two thresholds are marked as judgment pixel pairs. The position index of the judgment pixel pairs is recorded according to the order of arrangement in the consistent traversal sequence to form a judgment pixel pair sequence. An interval calculation is performed on the adjacent position indices in the sequence of determined pixel pairs. When the interval between adjacent position indices is less than a preset interval threshold, the corresponding determined pixel pairs are divided into the same continuous segment, and the number of determined pixel pairs in the continuous segment is counted. When the number of determined pixel pairs is greater than a preset number threshold, the pixel position of the corresponding continuous segment is determined as a stained area with consistent color but a sudden change in brightness.

[0010] Preferably, S3 specifically includes the following steps: S301. Extract the position index of the brightness change variables in the target pixel set according to the pixel spatial order, and rearrange the brightness change variables according to the arrangement relationship of the pixels in the yarn extension direction, so as to convert the original discrete distribution of brightness change variables into a brightness change sequence arranged in an ordered manner along the spatial direction. S302. After the sequence rearrangement is completed, the difference calculation is performed on the brightness change variables of adjacent positions in the brightness change sequence, and the difference results are associated with the corresponding position indices according to the sequence order to form a brightness change mapping sequence containing position indices and difference information. S303. Based on the brightness change mapping sequence, the difference results are accumulated and segmented according to the position index order. The total difference and the difference distribution in each segment are statistically analyzed. Based on the statistical results, the brightness change variable of the target pixel set is numerically characterized to determine the corresponding brightness change degree.

[0011] Preferably, S303 is as follows: Based on the brightness change mapping sequence, the difference results are read item by item according to the position index order. The difference results corresponding to consecutive position indices are accumulated and calculated. The accumulation is terminated when the position index interval is greater than the set segment interval value, and the difference results are divided into multiple segments. The difference results within each segment are statistically analyzed in order of location index. The total difference, average difference, and maximum difference within each segment are calculated. The total difference, average difference, and maximum difference are then linked and recorded with the corresponding segment location index to form a segment statistical sequence. Based on the segment statistical sequence, the total difference, the average difference, and the maximum difference are compared with the first change threshold, the second change threshold, and the third change threshold, respectively. When the total difference is less than the first change threshold and the average difference is less than the second change threshold, the brightness change of the corresponding segment is determined to be low. When the total difference is between the first change threshold and the second change threshold, or when the average difference is between the second change threshold and the third change threshold, the brightness change of the corresponding segment is determined to be medium. When the total difference is greater than the second change threshold or the maximum difference is greater than the third change threshold, the brightness change of the corresponding segment is determined to be high.

[0012] Preferably, S4 is as follows: Based on the degree of brightness change, the participation ratio of the comprehensive chromaticity variable and the brightness change variable in the target pixel set is reconstructed. The participation ratio of the brightness change variable corresponding to the low, medium and high degree of brightness change is set as the first participation ratio, the second participation ratio and the third participation ratio, respectively. The comprehensive chromaticity variable and the brightness change variable are combined according to the corresponding participation ratio to form the reconstructed feature set. Based on the reconstruction results of the participation ratio, the feature weight allocation in the adaptive mean drift clustering is adjusted according to the degree of brightness change. The corresponding degree of brightness change is read for each pixel, and the first participation ratio, second participation ratio or third participation ratio is assigned as the weight of the brightness change variable. At the same time, the weight of the comprehensive chromaticity variable is set to a value that is complementary to the weight of the brightness change variable. The weights of the comprehensive chromaticity variable and the weights of the brightness change variable are normalized according to the pixel order so that the sum of the weights of the comprehensive chromaticity variable and the weights of the brightness change variable remains a fixed value, thus forming the feature weight allocation result. Distance calculation is performed using the reconstructed feature set and feature weight allocation results. The difference between the comprehensive chromaticity variable and the difference between the luminance change variable of each pair of pixels is multiplied by the corresponding weight and then accumulated. The accumulated results are recorded in the order of pixel space to obtain the distance metric results for adaptive mean drift clustering.

[0013] Preferably, S5 is as follows: Adaptive mean-shift clustering iteration is performed based on the distance calculation results. The position of each pixel in the feature space is used as the initial point. The neighborhood range is determined based on the distance calculation results. The features of the pixels in the neighborhood are weighted and summed to update the position of the current pixel in the feature space. The update is repeated for all pixels in the pixel space order to form an iterative sequence. Based on the iterative sequence, the feature weight allocation is dynamically adjusted in conjunction with the clustering convergence state. The change before and after each position update is recorded, and the clustering convergence state is determined by comparing the change with the set convergence judgment value. When the change is greater than the convergence judgment value, the feature weight allocation is adjusted proportionally. When the change is less than the convergence judgment value, the feature weight allocation remains unchanged, and the adjusted feature weight allocation is re-participated in the next iteration calculation. After completing the adaptive mean-shift clustering iteration, the pixels are assigned to clusters based on the final converged cluster centers. The comprehensive chromaticity and luminance variation variables are statistically calculated according to the pixel sets corresponding to the cluster centers. Based on the statistical results, each pixel set is classified into different levels to form the yarn dyeing quality assessment results.

[0014] Preferably, the yarn dyeing quality assessment system based on adaptive mean drift clustering includes a feature decoupling module, a consistency detection module, a change modeling module, a weight reconstruction module, and a clustering control module. The feature decoupling module reconstructs the yarn image, generates a comprehensive chromaticity variable and a brightness variation variable, and uses the comprehensive chromaticity variable to construct a color consistency guiding factor, forming a feature set that is color continuous and brightness separated. The consistency detection module uses comprehensive chromaticity variables, brightness change variables, and color consistency guiding factors to perform consistency traversal, determine whether there are dyed areas in the yarn with consistent color but abrupt brightness changes, and apply constraints to the corresponding pixels to form a target pixel set when dyed areas with consistent color but abrupt brightness changes exist. The change modeling module rearranges the brightness change variables in the target pixel set to construct a brightness change mapping sequence, and determines the degree of brightness change based on the brightness change mapping sequence. The weight reconstruction module reconstructs the participation ratio of the comprehensive chromaticity variable and the luminance change variable according to the degree of luminance change, adjusts the feature weight allocation in the adaptive mean drift clustering according to the degree of luminance change, and performs distance calculation using the reconstructed feature set. The clustering control module performs adaptive mean-drift clustering iteration based on the distance calculation results. During the iteration process, it dynamically controls the feature weight allocation based on the clustering convergence state and outputs the yarn dyeing quality assessment results.

[0015] The technical effects and advantages provided by the present invention in the above technical solution are as follows: This invention constructs a decoupled feature system of comprehensive chromaticity variables and brightness change variables, and introduces a color consistency guiding factor to achieve color continuity constraints. Based on this, it further accurately identifies dyeing regions with consistent color but abrupt brightness changes through consistency traversal, avoiding misjudging brightness disturbances as color differences. Simultaneously, it achieves a structured expression of brightness changes by rearranging and mapping the brightness change sequence of the target pixel set, and finely quantifies the degree of brightness change by combining segmentation and multi-index statistics, thus providing a reliable basis for subsequent control. Furthermore, by participating in proportional reconstruction and feature weight allocation, the degree of brightness change is directly mapped to the influence ratio of comprehensive chromaticity variables and brightness change variables, enabling distance calculation to dynamically suppress interference caused by brightness abrupt changes. Based on this, it dynamically adjusts feature weights by combining the convergence state during the adaptive mean-shift clustering iteration process, forming a feedback-based closed-loop optimization mechanism. Ultimately, this ensures that pixels within the same dyeing region maintain cluster consistency even under brightness abrupt changes, avoiding missegmentation problems, thereby improving the accuracy and stability of yarn dyeing uniformity assessment, and enhancing the algorithm's adaptability to complex lighting and surface reflection changes. Attached Figure Description

[0016] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in this invention. For those skilled in the art, other drawings can be obtained based on these drawings.

[0017] Figure 1 This is a schematic diagram of the process of the present invention.

[0018] Figure 2 This is a schematic diagram of the modules of the present invention. Detailed Implementation

[0019] Exemplary embodiments will now be described more fully with reference to the accompanying drawings. However, these exemplary embodiments can be implemented in many forms and should not be construed as limited to the examples set forth herein; rather, they are provided so that the description of this disclosure will be more complete and fully convey the concept of the exemplary embodiments to those skilled in the art.

[0020] This invention provides, for example Figure 1 The yarn dyeing quality assessment method based on adaptive mean-shift clustering shown includes the following steps: S1. Reconstruct the features of the yarn image to generate a comprehensive chromaticity variable and a brightness change variable, and use the comprehensive chromaticity variable to construct a color consistency guiding factor to form a feature set with continuous color and separated brightness. In this embodiment, S1 specifically refers to: The yarn image is reconstructed by performing feature reconstruction. The normalization ratio of the color components of each pixel in the yarn image is calculated to generate a comprehensive chromaticity variable. The color components are weighted and summed to generate a brightness change variable. A one-to-one correspondence between the comprehensive chromaticity variable and the brightness change variable is established under the same pixel coordinates. In practical implementation, the yarn image can be input into the computing environment first, and each pixel can be decomposed into multiple color components, such as the common red, green, and blue components. Then, the normalized ratio of multiple color components at the same pixel location is calculated, and the proportion of each color component to the total amount of all color components at that pixel location is divided to obtain a comprehensive chromaticity variable that reflects the color composition relationship. At the same time, the color components at the same pixel location are linearly combined according to a pre-set weight, and the different color components are superimposed according to their contribution to brightness perception to form a brightness change variable. For example, the red, green, and blue components can be assigned different weights and then summed to obtain a value reflecting the brightness intensity. Subsequently, under the same pixel coordinates, the comprehensive chromaticity variable and the brightness change variable are bound, so that each pixel corresponds to a set of comprehensive chromaticity variables and a set of brightness change variables. This can preserve the color proportion relationship and separately characterize the brightness change, thereby avoiding the interference of brightness fluctuations on color judgment.

[0021] A yarn image refers to two-dimensional pixel data containing the dyeing status of the yarn surface, acquired through an image acquisition device; feature reconstruction refers to splitting and reorganizing the color information directly used in the original image into a set of variables with clear physical meanings; color components are the basic elements constituting image colors, used to describe the comprehensive color information of pixels; normalized ratio calculation is to obtain a stable color composition representation by proportionalizing a single color component with all color components in that pixel; comprehensive chromaticity variable represents a set of values ​​reflecting the color ratio relationship after normalization; weighted summation calculation is a process of accumulating multiple color components according to preset weights, used to reflect the contribution of different colors to brightness; brightness variation variable is used to represent the change of pixels in brightness; the same pixel coordinate represents a uniquely determined pixel position index in the image; the one-to-one correspondence between comprehensive chromaticity variable and brightness variation variable means that there is one and only one set of comprehensive chromaticity variable and one set of brightness variation variable at each pixel position, thus ensuring the consistency of color information and brightness information in spatial position during subsequent processing.

[0022] Based on the comprehensive chromaticity variables, the difference between the comprehensive chromaticity variables of adjacent pixels is calculated, and a difference sequence is formed according to the pixel spatial order. The continuity of the difference sequence is determined, and the continuous intervals in which the difference changes remain monotonically changing or the change amplitude is within a preset range are identified. Pixel pairs belonging to the same continuous interval are marked as the same association category, and a color consistency guiding factor is generated based on the association category of the pixel pair. After arranging the pixels in the yarn image according to their spatial location, each pixel can be selected along with its directly adjacent pixels. The corresponding comprehensive chromaticity variables are then read, and the differences between the comprehensive chromaticity variables of adjacent pixels are calculated one by one. The resulting differences are then connected in an orderly manner according to the pixel arrangement path in the image, thus forming a difference sequence. After the difference sequence is formed, the changing trend of adjacent differences in the sequence is analyzed. Segments that maintain an increasing or decreasing relationship during continuous changes are identified, and segments whose difference changes are always within a preset range are extracted. Continuous segments that meet the above conditions are divided into continuous intervals. Subsequently, pixel pairs belonging to the same continuous interval are uniformly classified into the same association category, and the corresponding pixels are marked according to the association category. This constructs a color consistency guiding factor. This process can classify areas with stable color changes into a unified category, while distinguishing areas with prominent changes, thus providing a clear constraint basis for subsequent processing.

[0023] The composite chromaticity variable between adjacent pixels represents the composite chromaticity values ​​of two adjacent pixels in the image space; the difference calculation is used to measure the degree of difference between two composite chromaticity variables; the pixel spatial order represents the sequential organization of pixels according to the arrangement direction of pixels in the image; the difference sequence is a data set formed by arranging the differences of adjacent pixels in spatial order; the continuity determination is used to analyze whether the change trend in the difference sequence is consistent; the difference change remains monotonically changing, indicating that the difference always changes in the same direction within a continuous interval; the change amplitude is within a preset range, indicating that the difference change does not exceed the preset numerical range; the preset range is a limited interval set according to the color change characteristics; the continuous interval represents a continuous segment in the difference sequence that meets the monotonically changing or amplitude limit conditions; the same association category indicates that pixel pairs within the same continuous interval are assigned a unified identifier; the color consistency guiding factor represents a data set composed of association category identifiers, used to describe the pixel relationship with consistent color changes.

[0024] Under the constraint of the color consistency guiding factor, the comprehensive chromaticity variable and the brightness variation variable are jointly rearranged. The comprehensive chromaticity variable is arranged continuously according to the correspondence of the color consistency guiding factor, and the brightness variation variable is arranged independently according to the pixel order. The comprehensive chromaticity variable and the brightness variation variable form a corresponding distribution relationship, which constitutes a feature set with continuous color and separated brightness.

[0025] Under the constraint of the color consistency guiding factor, all pixels are first grouped according to the pixel association relationships recorded in the color consistency guiding factor. Pixels belonging to the same association category are reordered according to their spatial position in the yarn extension direction, thereby performing a continuous arrangement of the comprehensive chromaticity variables, so that the comprehensive chromaticity variables within the same category form a continuous distribution after arrangement. At the same time, the brightness change variables are not included in this grouping and sorting, but are arranged independently while maintaining the original spatial order of the pixels in the image, so that the brightness change variables still reflect the original brightness change path. Subsequently, the continuously arranged comprehensive chromaticity variables and the brightness change variables that maintain their original order are synchronously mapped according to the pixel correspondence relationship. For example, the position of each arranged comprehensive chromaticity variable still corresponds to the brightness change variable at its original pixel position, thus forming a one-to-one combination arrangement structure. This processing method can maintain a continuous and consistent distribution at the color level, while avoiding brightness abrupt changes that interrupt color continuity, providing a stable input data foundation for subsequent distance-based clustering.

[0026] Color consistency guiding factor constraint means grouping and sorting pixels using pre-established pixel association identifiers; comprehensive chromaticity variables and brightness variation variables are used to describe color proportion relationships and brightness variations, respectively; joint rearrangement means rearranging two types of variables according to different strategies in the same processing flow; color consistency guiding factor correspondence means grouping relationships determined by pixel association categories; continuous arrangement means uninterrupted sorting of comprehensive chromaticity variables within the same association category according to spatial location; pixel order means the original spatial arrangement order of pixels in the image; independent arrangement means arranging brightness variation variables while maintaining the original pixel order; corresponding distribution relationship means one-to-one matching relationship between comprehensive chromaticity variables and brightness variation variables at the same pixel location; color continuous and brightness separated feature set means a data set where comprehensive chromaticity variables are continuously distributed after arrangement, while brightness variation variables maintain independent change trajectories.

[0027] S2. Using the comprehensive chromaticity variable, brightness change variable and color consistency guiding factor, perform consistency traversal to determine whether there are dyed areas in the yarn with consistent color but abrupt brightness changes. If there are dyed areas with consistent color but abrupt brightness changes, apply constraints to the corresponding pixels to form a target pixel set. In this embodiment, S2 specifically includes the following steps: S201. Perform a consistency traversal using the comprehensive chromaticity variable, brightness change variable and color consistency guide factor. Read the comprehensive chromaticity variable and brightness change variable point by point according to the pixel spatial order, and associate the pixels according to the color consistency guide factor. Pixels with the same color consistency guide factor are arranged in spatial order to form a consistency traversal sequence. After constructing the comprehensive chromaticity and brightness variation variables, each pixel in the yarn image can be read point by point according to the spatial arrangement of pixels in the image. A color consistency guiding factor is then used to associate and identify each pixel. Specifically, the category identifier recorded in the color consistency guiding factor is assigned to the corresponding pixel position, thus adding an identifier to each pixel to represent the color consistency relationship. During point-by-point reading, pixels with the same identifier value can be classified and arranged according to their spatial order in the image. For example, these pixel positions can be connected sequentially along the yarn extension direction to logically form a continuous access path, thereby constructing a consistency traversal sequence. In this way, the traversal process no longer relies solely on spatial adjacency but is guided by color consistency relationships, ensuring that pixels with consistent colors can be processed continuously in subsequent analysis, while brightness variation information remains at their respective pixel positions, providing a basis for subsequent difference calculations and region determination.

[0028] The multidimensional descriptive information of a pixel is composed of chromaticity variables, brightness variation variables, and color consistency guiding factors. The chromaticity variables describe the color proportion relationship, the brightness variation variables describe the brightness variation, and the color consistency guiding factors identify the color consistency relationship. Consistency traversal represents the traversal process that considers both the spatial order of pixels and the color consistency relationship. The association identifier represents the identifier value attached to each pixel to distinguish the color consistency category. Pixels with the same color consistency guiding factor identifier represent the set of pixels classified into the same category in the color consistency relationship. The consistency traversal sequence represents the data sequence formed by orderly arranging pixels with the same identifier according to the pixel spatial order. This sequence retains both spatial order information and color consistency relationship, and is used for subsequent difference analysis and region identification.

[0029] S202. In the consistent traversal sequence, the difference calculation is performed on the comprehensive chromaticity variable of adjacent pixels and the difference calculation is performed on the brightness change variable of adjacent pixels. Pixel pairs with a comprehensive chromaticity variable difference less than the first threshold and a brightness change variable difference greater than the second threshold are marked as judgment pixel pairs. Based on the continuous distribution of judgment pixel pairs in the traversal sequence, it is determined whether there is a dyeing area in the yarn with consistent color but a sudden change in brightness. S203. In the case of a stained area where the color remains consistent but the brightness changes abruptly, a constraint is applied to the corresponding pixel, the brightness change variable is subjected to amplitude limiting processing while maintaining the arrangement relationship of the comprehensive chromaticity variable, and the pixels after amplitude limiting processing are divided into sets according to spatial order to form the target pixel set.

[0030] After identifying stained regions with consistent color but abrupt changes in brightness, constraint processing can be performed on each pixel within that region. The original brightness variation variable is compared with the set upper and lower limits. Brightness variation variables exceeding the limits are truncated or compressed to ensure their values ​​fall within the defined range. For example, if the brightness variation variable of some pixels is significantly high, it is adjusted to the upper limit to suppress the impact of brightness abrupt changes on subsequent calculations. At the same time, the original arrangement of the comprehensive chromaticity variable is maintained and it is not involved in the numerical adjustment, thus ensuring that the color proportion relationship is not disrupted. After adjusting the brightness variation variable, all processed pixels are reorganized according to their spatial order in the image. Adjacent pixels are divided into several continuous sets, each set corresponding to a continuous spatial region. Finally, these sets are organized into the target pixel set. For example, all pixels in a continuous region are uniformly grouped into the same set for subsequent unified processing and analysis.

[0031] Applying constraints means imposing numerical or structural restrictions on the identified pixel set; limiting means setting upper and lower bounds on the brightness variation variable to ensure its value does not exceed a set range; set partitioning means grouping pixels according to their spatial positional relationship, grouping pixels with consecutive positions into the same set; the target pixel set represents the pixel set after constraint processing and spatial partitioning, used for subsequent clustering calculations; the arrangement relationship of the comprehensive chromaticity variable means that the original order of pixels at the comprehensive chromaticity variable level remains unchanged; the brightness variation variable represents the set of values ​​reflecting the degree of brightness variation of pixels, and its variation range is controlled after limiting processing, thereby reducing the interference of abnormal brightness on the overall results in subsequent analysis.

[0032] In this embodiment, S202 specifically refers to: In the consistent traversal sequence, adjacent pixels are selected one by one in the pixel space order. The difference between the comprehensive chromaticity variables of the adjacent pixels is calculated and recorded. At the same time, the difference between the brightness change variables of the adjacent pixels is calculated and recorded. The difference between the comprehensive chromaticity variables and the difference between the brightness change variables corresponding to each pair of adjacent pixels are paired and stored. Based on the established consistent traversal sequence, we can sequentially select the current pixel and its next neighboring pixel along the pixel arrangement path in the image as a pair of adjacent pixels. We then perform pairwise difference calculations on the corresponding comprehensive chromaticity variables within each pixel pair to obtain the comprehensive chromaticity variable difference reflecting the degree of color ratio change. Simultaneously, we perform difference calculations on the brightness change variables within the same pixel pair to obtain the brightness change variable difference reflecting the magnitude of brightness change. For example, in a yarn region, when the comprehensive chromaticity variable of the preceding pixel differs little from that of the following pixel, but the brightness change variable differs significantly, this characteristic can be directly reflected through difference calculations. Subsequently, each... The differences in the comprehensive chromaticity variable and the difference in the brightness change variable corresponding to adjacent pixels are bound according to the correspondence and stored in the order of the consistent traversal sequence to form an ordered set of paired data. The selection of adjacent pixels in sequence according to the pixel space means selecting the pixel combination of adjacent positions one by one based on the pixel arrangement path in the image. The difference calculation means measuring the difference between the two variable values. The difference in the comprehensive chromaticity variable is used to describe the degree of change in color ratio, and the difference in the brightness change variable is used to describe the magnitude of change in brightness. Paired storage means recording the two types of differences of the same pixel pair in a one-to-one correspondence, thus providing a data foundation for subsequent joint determination based on color change and brightness change.

[0033] The difference between the overall chromaticity variable and the difference between the brightness change variable in the paired storage are compared one by one. Pixel pairs with a difference between the overall chromaticity variable and a difference between the brightness change variable and a difference between the brightness change variable and a difference between the two thresholds are marked as judgment pixel pairs. The position index of the judgment pixel pairs is recorded according to the order of arrangement in the consistent traversal sequence to form a judgment pixel pair sequence. After pairing and storing the differences in the overall chromaticity variable and the luminance change variable, each pair of differences can be read and compared sequentially according to the consistency traversal sequence. For each pair of difference data, the overall chromaticity variable difference is compared with a pre-set first threshold, and the luminance change variable difference is compared with a second threshold. When the overall chromaticity variable difference is lower than the first threshold and the luminance change variable difference is higher than the second threshold, the corresponding pixel pair is marked as a judgment pixel pair. For example, in a certain yarn area, adjacent pixels have a small overall chromaticity variable difference but a large luminance change variable difference; such pixel pairs can be marked. After marking, each judgment pixel pair is processed in the consistency traversal sequence. The positions in the column are numbered and recorded, and these numbers are used as position indices. These position indices are arranged sequentially according to the traversal order to form a sequence of decision pixel pairs. The pairwise comparison means that the numerical comparison operation is performed on each pair of difference data in turn. The first threshold is used to limit the upper limit of the difference of the comprehensive chromaticity variable to characterize the degree of color change, and the second threshold is used to limit the lower limit of the difference of the brightness change variable to characterize the degree of brightness change. The decision pixel pair represents the pixel combination that simultaneously satisfies the two types of difference comparison relationships. The position index is used to identify the specific position of the decision pixel pair in the consistency traversal sequence. The decision pixel pair sequence represents the set of all decision pixel pairs arranged in the order of position indices, which is used for subsequent continuity analysis and color region identification.

[0034] An interval calculation is performed on the adjacent position indices in the sequence of determined pixel pairs. When the interval between adjacent position indices is less than a preset interval threshold, the corresponding determined pixel pairs are divided into the same continuous segment, and the number of determined pixel pairs in the continuous segment is counted. When the number of determined pixel pairs is greater than a preset number threshold, the pixel position of the corresponding continuous segment is determined as a stained area with consistent color but a sudden change in brightness.

[0035] After obtaining the sequence of decision pixel pairs, adjacent position indices can be selected one by one according to their order, and the difference between them can be calculated to represent the distance between the two decision pixel pairs in the consistent traversal sequence. For example, when the difference between two position indices is small, it means that the corresponding pixels are spatially close. Then, this interval result is compared with a preset interval threshold. When the interval is less than the preset interval threshold, the corresponding decision pixel pairs are classified into the same continuous segment, and the number of decision pixel pairs in the continuous segment is accumulated and recorded. When the number of decision pixel pairs in a continuous segment exceeds a preset number threshold, the pixel position range corresponding to the continuous segment is marked as having the same color but different brightness. A region exhibiting abrupt changes in color, such as a section of yarn containing multiple consecutive pixel pairs that meet the criteria and have small positional intervals, is identified as an aberration in coloring. The interval calculation involves numerically measuring the distance between adjacent position indices. A preset interval threshold is used to limit the maximum allowable spacing between pixel pairs to determine whether they belong to a continuous region. The same continuous segment represents a set of multiple pixel pairs whose positional intervals meet the threshold constraint. The number of pixel pairs in a continuous segment indicates the scale of aberration pixel pairs within that region. A preset number threshold is used to limit the minimum scale requirement to avoid isolated pixel pairs interfering with the judgment. A coloring region with consistent color but abrupt changes in brightness represents a pixel region where the brightness changes significantly while the color ratio changes only slightly and the region is spatially continuous.

[0036] S3. Rearrange the brightness change variables in the target pixel set to construct a brightness change mapping sequence, and determine the degree of brightness change based on the brightness change mapping sequence. In this embodiment, S3 specifically includes the following steps: S301. Extract the position index of the brightness change variables in the target pixel set according to the pixel spatial order, and rearrange the brightness change variables according to the arrangement relationship of the pixels in the yarn extension direction, so as to convert the original discrete distribution of brightness change variables into a brightness change sequence arranged in an ordered manner along the spatial direction. The target pixel set has already been filtered and constrained in the preprocessing. Each pixel in the set corresponds to a set of brightness change variables. First, the pixels in the set can be scanned according to their spatial positions in the image to extract the position index information corresponding to each pixel. For example, the pixels can be identified by row and column coordinates or path numbers along the yarn direction. Then, these position indices are sorted according to the extension direction of the yarn in the image, for example, by arranging them point by point along the main direction of the yarn, so that the pixels that were originally scattered in space are reorganized according to the actual physical extension path. After sorting, the corresponding brightness change variables are rearranged according to the sorted index order, thus completing the sequence rearrangement process. For example, the brightness change variables that were originally distributed in different positions are rearranged to form a continuous numerical sequence. This sequence reflects the brightness change trajectory along the yarn direction. In this way, discrete brightness information can be converted into an expression with directional continuity, providing a basis for subsequent analysis of brightness change trends.

[0037] The brightness variation variables in the target pixel set represent the set of brightness values ​​corresponding to the filtered pixel range; position index extraction means assigning a unique spatial identifier to each pixel for subsequent sorting processing; yarn extension direction means the main directional path of the yarn in the image, which is the reference for sorting; arrangement relationship means the order in which pixels are formed according to this direction; sequence rearrangement means reorganizing the brightness variation variables according to the new arrangement relationship; the original discretely distributed brightness variation variables represent brightness data that are scattered in the image and not organized according to the path; the brightness variation sequence arranged in an ordered manner along the spatial direction represents the set of brightness values ​​that are continuously arranged according to the yarn extension path after rearrangement, and this sequence can reflect the continuous spatial distribution characteristics of brightness variation.

[0038] S302. After the sequence rearrangement is completed, the difference calculation is performed on the brightness change variables of adjacent positions in the brightness change sequence, and the difference results are associated with the corresponding position indices according to the sequence order to form a brightness change mapping sequence containing position indices and difference information. After rearranging the sequence of brightness change variables, the values ​​in the brightness change sequence can be read point by point along the established spatial order. The brightness change variables of the current pixel position and its immediate neighbors are compared one by one. The difference result is obtained by calculating the degree of difference between the two. For example, when the brightness change variable at a certain position is a small value and the next position shows a significant increase, the corresponding difference can reflect the brightness change amplitude at that position. After the difference calculation is completed, each difference result is bound and recorded with the corresponding pixel position index. The position index and the difference result are paired and stored sequentially according to the sequence order, thus forming a set of difference data with spatial position information. This processing method can expand the brightness change information from a single point value to a continuous change description, so that the brightness change is not only reflected as an attribute of a single pixel, but also as a trend of change along the yarn direction.

[0039] In a brightness change sequence, the brightness change variables at adjacent positions represent the brightness values ​​of two adjacent pixels in the sequence; difference calculation represents measuring the difference between these two brightness values ​​to obtain the magnitude of the change; associated records represent storing the difference results in a one-to-one correspondence with the corresponding pixel position indices; the position index is used to identify the specific position of the difference in the sequence; a brightness change mapping sequence containing position indexes and difference information represents a data sequence composed of position and magnitude of change. This sequence not only retains the numerical information of brightness changes but also includes the positional relationship of the changes, thus fully reflecting the spatial distribution characteristics of brightness changes.

[0040] S303. Based on the brightness change mapping sequence, the difference results are accumulated and segmented according to the position index order. The total difference and the difference distribution in each segment are statistically analyzed. Based on the statistical results, the brightness change variable of the target pixel set is numerically characterized to determine the corresponding brightness change degree.

[0041] In this embodiment, S303 specifically refers to: Based on the brightness change mapping sequence, the difference results are read item by item according to the position index order. The difference results corresponding to consecutive position indices are accumulated and calculated. The accumulation is terminated when the position index interval is greater than the set segment interval value, and the difference results are divided into multiple segments. After the brightness change mapping sequence has been constructed, each difference result can be read sequentially according to the order of the position indices. The current difference result and the difference results corresponding to the next adjacent position indices are then processed continuously. During the continuous processing, the difference results are gradually accumulated to obtain the total brightness change within a continuous position range. During the accumulation process, the interval between the current position index and the next position index is calculated. When the interval is less than the set segment interval value, the accumulation operation continues. When the interval between position indices is greater than the set segment interval value, the current accumulation process stops, and the difference results within the current accumulation range are divided into an independent segment. For example, in a yarn area, if multiple difference values ​​correspond to different position indices... If the differences are continuous and have small intervals, they will be grouped into the same accumulation process. When a position jump occurs, the difference will be divided into a new segment. In this way, the originally continuous brightness change mapping sequence can be decomposed into multiple segments with spatial continuity, thus providing a basis for subsequent statistical analysis of brightness changes in different regions. The step-by-step reading of difference results means accessing the difference data one by one in sequence. The accumulation calculation means continuously summing the continuous differences. The position index interval means the distance between the corresponding positions of adjacent differences. The segment interval value is set to limit the criteria for determining continuity. The termination of accumulation means stopping the accumulation process of the current segment when the interval exceeds the threshold. Multiple segments represent several independent sets of differences obtained by dividing based on position continuity.

[0042] The difference results within each segment are statistically analyzed in order of location index. The total difference, average difference, and maximum difference within each segment are calculated. The total difference, average difference, and maximum difference are then linked and recorded with the corresponding segment location index to form a segment statistical sequence. After segmenting, the difference results within each segment can be read sequentially according to their corresponding index positions. Statistical processing can then be performed on all differences within that segment. For example, the total difference can be accumulated by summing all differences within the segment, and the average difference can be calculated by matching the total difference with the number of differences within the segment. Simultaneously, the maximum difference value within the segment is recorded during the traversal to obtain the maximum difference value. Subsequently, the start and end indexes of each segment are recorded in a one-to-one correspondence with the total difference, average difference, and maximum difference value, and stored sequentially according to the segment's order within the overall sequence, thus forming a segment statistical sequence. For example, in a certain... If a segment contains difference data from multiple consecutive locations, the above statistics can comprehensively reflect the overall intensity, average level, and extreme value characteristics of brightness changes within that segment, providing a quantitative basis for subsequent determination of the degree of brightness change. The total difference within each segment represents the cumulative result of all differences within the segment, used to reflect the overall intensity of change; the average difference represents the average level of differences within the segment, used to reflect the uniformity of change; the maximum difference represents the largest single-point change amplitude within the segment, used to reflect extreme change situations; and the segment statistical sequence represents a data set formed by arranging the statistical results of multiple segments in the order of position index, used to describe the spatial distribution of brightness changes in the entire target pixel set.

[0043] Based on the segment statistical sequence, the total difference, the average difference, and the maximum difference are compared with the first change threshold, the second change threshold, and the third change threshold, respectively. When the total difference is less than the first change threshold and the average difference is less than the second change threshold, the brightness change of the corresponding segment is determined to be low. When the total difference is between the first change threshold and the second change threshold, or when the average difference is between the second change threshold and the third change threshold, the brightness change of the corresponding segment is determined to be medium. When the total difference is greater than the second change threshold or the maximum difference is greater than the third change threshold, the brightness change of the corresponding segment is determined to be high.

[0044] After the segment statistical sequence is formed, the total difference, average difference, and maximum difference of each segment can be read one by one according to the order of the segments in the sequence. These three statistical results are then compared with the pre-set first, second, and third change thresholds. For example, when the total difference and average difference of a segment are both at a low level, it can be determined that the brightness change in that segment is relatively gentle. When the total difference is in the middle range or the average difference is in the higher range, it can be determined that there is a certain degree of brightness fluctuation in that segment. When the total difference is significantly large or the maximum difference reaches a high level, it can be determined that there is a significant brightness change in that segment. Through this multi-indicator joint comparison method, the brightness changes of different segments can be expressed in a hierarchical manner. For example, if the total difference and the average difference are both low in a segment, it is classified as low change, while if the total difference is large and there are large single-point differences in another segment, it is classified as high change. This forms a hierarchical description of brightness changes, providing a basis for subsequent processing based on the degree of brightness change.

[0045] The total difference represents the cumulative result of all differences within a certain segment, used to reflect the overall intensity of brightness change; the average difference represents the average level of differences within the segment, used to reflect the uniformity of brightness change; the maximum difference represents the maximum change amplitude at a single location within the segment, used to reflect local abrupt changes; the first change threshold, the second change threshold, and the third change threshold are used to define the boundary standards for different change levels; low change level indicates that both the total difference and the average difference are in a low range; medium change level indicates that the total difference or the average difference is in a middle range; high change level indicates that the total difference or the maximum difference reaches a high range. These three types of change levels together constitute a hierarchical description system for the strength of brightness change.

[0046] S4. Based on the degree of brightness change, the participation ratio of the comprehensive chromaticity variable and the brightness change variable is reconstructed. The feature weight allocation in the adaptive mean drift clustering is adjusted according to the degree of brightness change, and the distance calculation is performed using the reconstructed feature set. In this embodiment, S4 specifically refers to: Based on the degree of brightness change, the participation ratio of the comprehensive chromaticity variable and the brightness change variable in the target pixel set is reconstructed. The participation ratio of the brightness change variable corresponding to the low, medium and high degree of brightness change is set as the first participation ratio, the second participation ratio and the third participation ratio, respectively. The comprehensive chromaticity variable and the brightness change variable are combined according to the corresponding participation ratio to form the reconstructed feature set. After classifying the degree of brightness variation, the corresponding degree of brightness variation can be read for each pixel in the target pixel set. Based on this classification, the participation ratio of the brightness variation variable can be set. For example, for pixels with low brightness variation, the participation ratio of the brightness variation variable is set to a small value, while the comprehensive chromaticity variable occupies a higher proportion. For pixels with medium brightness variation, the brightness variation variable and the comprehensive chromaticity variable are allocated in a moderate proportion. For pixels with high brightness variation, the participation ratio of the brightness variation variable is increased, making it dominant in subsequent calculations. After setting the ratio, the comprehensive chromaticity variable and the brightness variation variable are combined according to their corresponding proportions. That is, the two variables are weighted proportionally and rearranged to form a new feature representation. For example, if a pixel has a high degree of variation and its brightness variation variable has a high participation ratio, the combined value will highlight the brightness variation information more, thus obtaining a reconstructed feature set. This set can dynamically adjust the participation of color and brightness according to different brightness variation conditions.

[0047] The participation ratio reconstruction means redistributing the proportions of the comprehensive chromaticity variable and the luminance change variable in the overall features according to the degree of luminance change; pixels with low, medium, and high luminance change levels represent different categories of pixels divided according to the intensity of luminance change; the first participation ratio, the second participation ratio, and the third participation ratio correspond to the proportion settings of the three types of pixels in the luminance change variable; the combination processing means weighting and fusing the comprehensive chromaticity variable and the luminance change variable according to the participation ratio to form a new data representation; the reconstructed feature set represents the combined data set of the comprehensive chromaticity variable and the luminance change variable formed after the ratio reconstruction. This set has different variable proportions at different pixel positions, which is used to reflect the impact of luminance change on feature composition.

[0048] Based on the reconstruction results of the participation ratio, the feature weight allocation in the adaptive mean drift clustering is adjusted according to the degree of brightness change. The corresponding degree of brightness change is read for each pixel, and the first participation ratio, second participation ratio or third participation ratio is assigned as the weight of the brightness change variable. At the same time, the weight of the comprehensive chromaticity variable is set to a value that is complementary to the weight of the brightness change variable. The weights of the comprehensive chromaticity variable and the weights of the brightness change variable are normalized according to the pixel order so that the sum of the weights of the comprehensive chromaticity variable and the weights of the brightness change variable remains a fixed value, thus forming the feature weight allocation result. After completing the participation ratio reconstruction, the brightness change level of each pixel can be read one by one, and the corresponding participation ratio can be selected as the brightness change variable weight according to different brightness change levels. For example, when a pixel is determined to have a low change level, the first participation ratio is directly assigned as the brightness change variable weight, while the comprehensive chromaticity variable weight is taken as a ratio complementary to this value. When a pixel is determined to have a high change level, the third participation ratio is assigned as the brightness change variable weight, so that the brightness change variable occupies a higher proportion in the feature representation of this pixel. After completing the weight assignment, the comprehensive chromaticity variable weight and the brightness change variable weight corresponding to each pixel are normalized. By adjusting the two types of weights in a unified ratio, the sum of the two is kept to a fixed value, thereby ensuring that the weights between different pixels are comparable. For example, when the brightness change variable weight is large in a certain pixel, the comprehensive chromaticity variable weight is automatically reduced, but the total weight remains unchanged. This forms a feature weight allocation result suitable for adaptive mean drift clustering calculation.

[0049] Adaptive mean-shift clustering represents an iterative search clustering process based on the feature space density distribution. Feature weight allocation represents the quantitative control of the influence of different features in distance calculation; assignment represents the process of directly mapping the participation ratio to the weight value; the weight of the brightness change variable represents the proportion of brightness information in the feature; the weight of the comprehensive chromaticity variable represents the proportion of color proportion information in the feature; complementarity means that the two types of weights are mutually restrictive in value, and when one increases, the other decreases accordingly; normalization means that the weights are proportionally adjusted to ensure that the total amount is consistent; the sum of weights represents the sum of the comprehensive chromaticity variable weight and the brightness change variable weight; fixed value represents the pre-set total weight standard; the feature weight allocation result represents the combination set of comprehensive chromaticity variable weight and brightness change variable weight for each pixel, which is used for subsequent distance calculation and cluster analysis.

[0050] Distance calculation is performed using the reconstructed feature set and feature weight allocation results. The difference between the comprehensive chromaticity variable and the difference between the luminance change variable of each pair of pixels is multiplied by the corresponding weight and then accumulated. The accumulated results are recorded in the order of pixel space to obtain the distance metric results for adaptive mean drift clustering.

[0051] After completing the feature set reconstruction and feature weight allocation, pixels in the target pixel set can be compared pairwise. The comprehensive chromaticity variable and luminance variation variable corresponding to each pair of pixels are read sequentially, and the differences between the two types of variables are calculated to obtain numerical representations of color and luminance differences. Then, based on the feature weight allocation results for each pixel, the differences in the comprehensive chromaticity variable and luminance variation variable are multiplied by their respective weight values. For example, when the luminance variation variable of a pixel has a higher weight, the corresponding luminance difference accounts for a larger proportion in the calculation, while the proportion of the comprehensive chromaticity variable difference is relatively reduced. After weighting, the two weighted differences are summed to form the comprehensive distance value of the pixel pair. These distance values ​​are recorded sequentially according to the spatial order of the pixels in the image, thus forming a set of distance data that reflects the degree of difference between pixels. This data can be used to determine the similarity relationship between pixels in subsequent density-based clustering calculations.

[0052] Distance calculation represents the quantification process of the degree of difference between two pixels; the combined chromaticity variable difference and the luminance change variable difference represent the numerical values ​​of color ratio difference and luminance difference, respectively; multiplying by the corresponding weight represents weighting the difference according to the importance of different features; accumulation calculation represents combining multiple weighted differences to obtain a comprehensive difference value; the distance metric result used for adaptive mean-shift clustering represents the set of pixel distance data obtained after weighting and accumulation processing. This set is used to describe the distance relationship between samples in the feature space, thus providing a basis for density estimation and center shift in the clustering process.

[0053] S5. Perform adaptive mean-shift clustering iteration based on the distance calculation results. During the iteration process, dynamically adjust the feature weight allocation based on the clustering convergence state, and output the yarn dyeing quality evaluation results.

[0054] In this embodiment, S5 specifically refers to: Adaptive mean-shift clustering iteration is performed based on the distance calculation results. The position of each pixel in the feature space is used as the initial point. The neighborhood range is determined based on the distance calculation results. The features of the pixels in the neighborhood are weighted and summed to update the position of the current pixel in the feature space. The update is repeated for all pixels in the pixel space order to form an iterative sequence. After constructing the distance calculation results, the coordinates of each pixel in the feature space can be used as the initial position. Based on the distance calculation results, a group of neighboring pixels that are close to the pixel can be determined, for example, by sorting the distance values ​​to select a set of neighboring pixels. Then, the comprehensive chromaticity variable and brightness change variable corresponding to the neighboring pixels are weighted and summed. The feature values ​​of all pixels in the neighborhood are assigned different weights according to their distance and then accumulated to obtain a new feature position. This result is used as the updated position of the current pixel in the feature space. For example, if there are multiple pixels that are close to a certain pixel, the features of these pixels will have a greater impact on the pixel after weighting, thus causing its position to move towards the feature-dense area. After completing one update, the same update process is performed on all pixels in the spatial order of the pixels in the image, and this process is repeated many times to gradually form a stable iterative sequence, so that the pixel position gradually moves closer to the density center.

[0055] Distance calculation results represent the difference between pixels in the feature space; position in the feature space represents the multidimensional coordinates formed by the combination of chromaticity and brightness variation variables; initial point represents the feature position of each pixel at the beginning of the iteration; neighborhood range represents a set of adjacent pixels selected based on distance; weighted summation calculation represents the weighting and accumulation of features of neighboring pixels according to distance relationship; update represents replacing the weighted result with the new feature position; pixel spatial order represents processing according to the pixel arrangement order in the image; repeated update represents performing multiple rounds of position update operations on all pixels; iterative sequence represents the pixel position change trajectory formed during multiple update processes, used to gradually achieve cluster convergence.

[0056] Based on the iterative sequence, the feature weight allocation is dynamically adjusted in conjunction with the clustering convergence state. The change before and after each position update is recorded, and the clustering convergence state is determined by comparing the change with the set convergence judgment value. When the change is greater than the convergence judgment value, the feature weight allocation is adjusted proportionally. When the change is less than the convergence judgment value, the feature weight allocation remains unchanged, and the adjusted feature weight allocation is re-participated in the next iteration calculation. After completing multiple rounds of position updates to form an iterative sequence, the difference in feature positions for each pixel between two consecutive updates can be calculated. By recording the changes in position before and after the update, the convergence degree of the current iteration can be reflected. For example, when the position of a pixel in the feature space changes significantly, it indicates that the current clustering is still in the adjustment phase; when the change gradually decreases, it indicates that the clustering is becoming stable. Based on this, the change is compared with a pre-set convergence criterion value. When the change is greater than the convergence criterion value, the feature weight allocation is adjusted proportionally, for example, by appropriately increasing the weight of the comprehensive chromaticity variable or brightness change variable to change the direction of influence of subsequent position updates; when the change is less than the convergence criterion value, the current feature weight allocation remains unchanged, allowing the clustering process to gradually stabilize. The adjusted feature weights re-participate in the next round of position update calculation, thereby continuously correcting the degree of feature influence during the iteration process, enabling the clustering process to gradually approach a stable state under dynamic control.

[0057] The iterative sequence represents the trajectory of a pixel's position change during multiple updates; the clustering convergence state represents the degree to which pixel position changes tend to stabilize; the change amount represents the positional difference of the same pixel in two consecutive updates; the convergence criterion value represents the numerical limit used to determine whether the position has stabilized; the feature weight allocation represents the proportion of the combined influence of chromaticity and luminance variables in the feature space; dynamic adjustment represents adjusting the weights according to changes during the iteration process; proportional adjustment represents redistributing the weight values ​​of different features; keeping unchanged represents maintaining the current weight configuration when the convergence condition is met; re-participation represents using the adjusted weights again for subsequent position update calculations, thus forming a continuous adjustment process based on change feedback.

[0058] After completing the adaptive mean-shift clustering iteration, the pixels are assigned to clusters based on the final converged cluster centers. The comprehensive chromaticity and luminance variation variables are statistically calculated according to the pixel sets corresponding to the cluster centers. Based on the statistical results, each pixel set is classified into different levels to form the yarn dyeing quality assessment results.

[0059] After completing the adaptive mean-shift clustering iteration, all pixels can be assigned to the category corresponding to the cluster center with the smallest distance, thus forming multiple pixel sets. Then, for each pixel set, the comprehensive chromaticity variable and brightness variation variable are extracted according to the distribution order of the pixels in the set. The comprehensive chromaticity variable of all pixels in the set is statistically summarized, and the brightness variation variable is statistically analyzed, such as calculating the concentration of the comprehensive chromaticity variable and the distribution range of the brightness variation variable within the set. After completing the statistics, each pixel set is graded according to the differences in the distribution of the comprehensive chromaticity variable and the intensity of the brightness variation variable. For example, sets with stable comprehensive chromaticity variable distribution and small brightness variation are classified as high-quality regions, while sets with large brightness variation or uneven distribution are classified as low-quality regions, thus forming a complete yarn dyeing quality assessment result.

[0060] Adaptive mean-shift clustering iteration represents the process of pixels gradually clustering towards the density center in the feature space through multiple position updates; the cluster center represents the central position of a set of pixels in the feature space; the assignment partition represents the process of assigning each pixel to the corresponding cluster center; the pixel set represents a group of pixels corresponding to the same cluster center; the comprehensive chromaticity variable and brightness variation variable are used to describe the color proportion characteristics and brightness variation characteristics, respectively; statistical calculation represents the numerical analysis of the concentration and distribution of variables within the set; the grade division represents the quality classification of different pixel sets based on the statistical results; the yarn dyeing quality assessment result represents the overall dyeing quality evaluation conclusion formed based on the grade information of all pixel sets.

[0061] like Figure 2 The yarn dyeing quality assessment system based on adaptive mean drift clustering shown includes a feature decoupling module, a consistency detection module, a change modeling module, a weight reconstruction module, and a clustering control module. The feature decoupling module reconstructs the yarn image, generates a comprehensive chromaticity variable and a brightness variation variable, and uses the comprehensive chromaticity variable to construct a color consistency guiding factor, forming a feature set that is color continuous and brightness separated. The consistency detection module uses comprehensive chromaticity variables, brightness change variables, and color consistency guiding factors to perform consistency traversal, determine whether there are dyed areas in the yarn with consistent color but abrupt brightness changes, and apply constraints to the corresponding pixels to form a target pixel set when dyed areas with consistent color but abrupt brightness changes exist. The change modeling module rearranges the brightness change variables in the target pixel set to construct a brightness change mapping sequence, and determines the degree of brightness change based on the brightness change mapping sequence. The weight reconstruction module reconstructs the participation ratio of the comprehensive chromaticity variable and the luminance change variable according to the degree of luminance change, adjusts the feature weight allocation in the adaptive mean drift clustering according to the degree of luminance change, and performs distance calculation using the reconstructed feature set. The clustering control module performs adaptive mean-drift clustering iteration based on the distance calculation results. During the iteration process, it dynamically controls the feature weight allocation based on the clustering convergence state and outputs the yarn dyeing quality assessment results.

[0062] The above embodiments can be implemented, in whole or in part, by software, hardware, firmware, or any other combination thereof. When implemented using software, the above embodiments can be implemented, in whole or in part, as a computer program product. The computer program product includes one or more computer instructions or computer programs. When the computer instructions or computer programs are loaded or executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more sets of available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium. The semiconductor medium can be a solid-state drive.

[0063] It should be understood that in the various embodiments of this application, the order of the above-mentioned processes does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.

[0064] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0065] In the several embodiments provided in this application, it should be understood that the disclosed systems and methods can be implemented in other ways. For example, the embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection through some interfaces, devices, or units, and may be electrical, mechanical, or other forms.

[0066] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0067] In addition, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.

[0068] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

Claims

1. A yarn dyeing quality assessment method based on adaptive mean-shift clustering, characterized in that, Specifically, the following steps are included: S1. Reconstruct the features of the yarn image to generate a comprehensive chromaticity variable and a brightness change variable, and use the comprehensive chromaticity variable to construct a color consistency guiding factor to form a feature set with continuous color and separated brightness. S2. Using the comprehensive chromaticity variable, brightness change variable and color consistency guiding factor, perform consistency traversal to determine whether there are dyed areas in the yarn with consistent color but abrupt brightness changes. If there are dyed areas with consistent color but abrupt brightness changes, apply constraints to the corresponding pixels to form a target pixel set. S3. Rearrange the brightness change variables in the target pixel set to construct a brightness change mapping sequence, and determine the degree of brightness change based on the brightness change mapping sequence. S4. Based on the degree of brightness change, the participation ratio of the comprehensive chromaticity variable and the brightness change variable is reconstructed. The feature weight allocation in the adaptive mean drift clustering is adjusted according to the degree of brightness change, and the distance calculation is performed using the reconstructed feature set. S5. Perform adaptive mean-shift clustering iteration based on the distance calculation results. During the iteration process, dynamically adjust the feature weight allocation based on the clustering convergence state, and output the yarn dyeing quality evaluation results.

2. The yarn dyeing quality assessment method based on adaptive mean drift clustering according to claim 1, characterized in that, S1 specifically refers to: The yarn image is reconstructed by performing feature reconstruction. The normalization ratio of the color components of each pixel in the yarn image is calculated to generate a comprehensive chromaticity variable. The color components are weighted and summed to generate a brightness change variable. A one-to-one correspondence between the comprehensive chromaticity variable and the brightness change variable is established under the same pixel coordinates. Based on the comprehensive chromaticity variables, the difference between the comprehensive chromaticity variables of adjacent pixels is calculated, and a difference sequence is formed according to the pixel spatial order. The continuity of the difference sequence is determined, and the continuous intervals in which the difference changes remain monotonically changing or the change amplitude is within a preset range are identified. Pixel pairs belonging to the same continuous interval are marked as the same association category, and a color consistency guiding factor is generated based on the association category of the pixel pair. Under the constraint of the color consistency guiding factor, the comprehensive chromaticity variable and the brightness variation variable are jointly rearranged. The comprehensive chromaticity variable is arranged continuously according to the correspondence of the color consistency guiding factor, and the brightness variation variable is arranged independently according to the pixel order. The comprehensive chromaticity variable and the brightness variation variable form a corresponding distribution relationship, which constitutes a feature set with continuous color and separated brightness.

3. The yarn dyeing quality assessment method based on adaptive mean drift clustering according to claim 1, characterized in that, S2 specifically includes the following steps: S201. Perform a consistency traversal using the comprehensive chromaticity variable, brightness change variable and color consistency guide factor. Read the comprehensive chromaticity variable and brightness change variable point by point according to the pixel spatial order, and associate the pixels according to the color consistency guide factor. Pixels with the same color consistency guide factor are arranged in spatial order to form a consistency traversal sequence. S202. In the consistent traversal sequence, the difference calculation is performed on the comprehensive chromaticity variable of adjacent pixels and the difference calculation is performed on the brightness change variable of adjacent pixels. Pixel pairs with a comprehensive chromaticity variable difference less than the first threshold and a brightness change variable difference greater than the second threshold are marked as judgment pixel pairs. Based on the continuous distribution of judgment pixel pairs in the traversal sequence, it is determined whether there is a dyeing area in the yarn with consistent color but a sudden change in brightness. S203. In the case of a stained area where the color remains consistent but the brightness changes abruptly, a constraint is applied to the corresponding pixel, the brightness change variable is subjected to amplitude limiting processing while maintaining the arrangement relationship of the comprehensive chromaticity variable, and the pixels after amplitude limiting processing are divided into sets according to spatial order to form the target pixel set.

4. The yarn dyeing quality assessment method based on adaptive mean drift clustering according to claim 3, characterized in that, S202 specifically refers to: In the consistent traversal sequence, adjacent pixels are selected one by one in the pixel space order. The difference between the comprehensive chromaticity variables of the adjacent pixels is calculated and recorded. At the same time, the difference between the brightness change variables of the adjacent pixels is calculated and recorded. The difference between the comprehensive chromaticity variables and the difference between the brightness change variables corresponding to each pair of adjacent pixels are paired and stored. The difference between the overall chromaticity variable and the difference between the brightness change variable in the paired storage are compared one by one. Pixel pairs with a difference between the overall chromaticity variable and a difference between the brightness change variable and a difference between the brightness change variable and a difference between the two thresholds are marked as judgment pixel pairs. The position index of the judgment pixel pairs is recorded according to the order of arrangement in the consistent traversal sequence to form a judgment pixel pair sequence. An interval calculation is performed on the adjacent position indices in the sequence of determined pixel pairs. When the interval between adjacent position indices is less than a preset interval threshold, the corresponding determined pixel pairs are divided into the same continuous segment, and the number of determined pixel pairs in the continuous segment is counted. When the number of determined pixel pairs is greater than a preset number threshold, the pixel position of the corresponding continuous segment is determined as a stained area with consistent color but a sudden change in brightness.

5. The yarn dyeing quality assessment method based on adaptive mean drift clustering according to claim 1, characterized in that, S3 specifically includes the following steps: S301. Extract the position index of the brightness change variables in the target pixel set according to the pixel spatial order, and rearrange the brightness change variables according to the arrangement relationship of the pixels in the yarn extension direction, so as to convert the original discrete distribution of brightness change variables into a brightness change sequence arranged in an ordered manner along the spatial direction. S302. After the sequence rearrangement is completed, the difference calculation is performed on the brightness change variables of adjacent positions in the brightness change sequence, and the difference results are associated with the corresponding position indices according to the sequence order to form a brightness change mapping sequence containing position indices and difference information. S303. Based on the brightness change mapping sequence, the difference results are accumulated and segmented according to the position index order. The total difference and the difference distribution in each segment are statistically analyzed. Based on the statistical results, the brightness change variable of the target pixel set is numerically characterized to determine the corresponding brightness change degree.

6. The yarn dyeing quality assessment method based on adaptive mean drift clustering according to claim 5, characterized in that, S303 specifically refers to: Based on the brightness change mapping sequence, the difference results are read item by item according to the position index order. The difference results corresponding to consecutive position indices are accumulated and calculated. The accumulation is terminated when the position index interval is greater than the set segment interval value, and the difference results are divided into multiple segments. The difference results within each segment are statistically analyzed in order of location index. The total difference, average difference, and maximum difference within each segment are calculated. The total difference, average difference, and maximum difference are then linked and recorded with the corresponding segment location index to form a segment statistical sequence. Based on the segment statistical sequence, the total difference, the average difference, and the maximum difference are compared with the first change threshold, the second change threshold, and the third change threshold, respectively. When the total difference is less than the first change threshold and the average difference is less than the second change threshold, the brightness change of the corresponding segment is determined to be low. When the total difference is between the first change threshold and the second change threshold, or when the average difference is between the second change threshold and the third change threshold, the brightness change of the corresponding segment is determined to be medium. When the total difference is greater than the second change threshold or the maximum difference is greater than the third change threshold, the brightness change of the corresponding segment is determined to be high.

7. The yarn dyeing quality assessment method based on adaptive mean drift clustering according to claim 1, characterized in that, S4 specifically refers to: Based on the degree of brightness change, the participation ratio of the comprehensive chromaticity variable and the brightness change variable in the target pixel set is reconstructed. The participation ratio of the brightness change variable corresponding to the low, medium and high degree of brightness change is set as the first participation ratio, the second participation ratio and the third participation ratio, respectively. The comprehensive chromaticity variable and the brightness change variable are combined according to the corresponding participation ratio to form the reconstructed feature set. Based on the reconstruction results of the participation ratio, the feature weight allocation in the adaptive mean drift clustering is adjusted according to the degree of brightness change. The corresponding degree of brightness change is read for each pixel, and the first participation ratio, second participation ratio or third participation ratio is assigned as the weight of the brightness change variable. At the same time, the weight of the comprehensive chromaticity variable is set to a value that is complementary to the weight of the brightness change variable. The weights of the comprehensive chromaticity variable and the weights of the brightness change variable are normalized according to the pixel order so that the sum of the weights of the comprehensive chromaticity variable and the weights of the brightness change variable remains a fixed value, thus forming the feature weight allocation result. Distance calculation is performed using the reconstructed feature set and feature weight allocation results. The difference between the comprehensive chromaticity variable and the difference between the luminance change variable of each pair of pixels is multiplied by the corresponding weight and then accumulated. The accumulated results are recorded in the order of pixel space to obtain the distance metric results for adaptive mean drift clustering.

8. The yarn dyeing quality assessment method based on adaptive mean-shift clustering according to claim 1, characterized in that, S5 specifically refers to: Adaptive mean-shift clustering iteration is performed based on the distance calculation results. The position of each pixel in the feature space is used as the initial point. The neighborhood range is determined based on the distance calculation results. The features of the pixels in the neighborhood are weighted and summed to update the position of the current pixel in the feature space. The update is repeated for all pixels in the pixel space order to form an iterative sequence. Based on the iterative sequence, the feature weight allocation is dynamically adjusted in conjunction with the clustering convergence state. The change before and after each position update is recorded, and the clustering convergence state is determined by comparing the change with the set convergence judgment value. When the change is greater than the convergence judgment value, the feature weight allocation is adjusted proportionally. When the change is less than the convergence judgment value, the feature weight allocation remains unchanged, and the adjusted feature weight allocation is re-participated in the next iteration calculation. After completing the adaptive mean-shift clustering iteration, the pixels are assigned to clusters based on the final converged cluster centers. The comprehensive chromaticity and luminance variation variables are statistically calculated according to the pixel sets corresponding to the cluster centers. Based on the statistical results, each pixel set is classified into different levels to form the yarn dyeing quality assessment results.

9. A yarn dyeing quality assessment system based on adaptive mean-drift clustering, used to implement the yarn dyeing quality assessment method based on adaptive mean-drift clustering as described in any one of claims 1-8, characterized in that, It includes a feature decoupling module, a consistency detection module, a change modeling module, a weight reconstruction module, and a clustering regulation module; The feature decoupling module reconstructs the yarn image, generates a comprehensive chromaticity variable and a brightness variation variable, and uses the comprehensive chromaticity variable to construct a color consistency guiding factor, forming a feature set that is color continuous and brightness separated. The consistency detection module uses comprehensive chromaticity variables, brightness change variables, and color consistency guiding factors to perform consistency traversal, determine whether there are dyed areas in the yarn with consistent color but abrupt brightness changes, and apply constraints to the corresponding pixels to form a target pixel set when dyed areas with consistent color but abrupt brightness changes exist. The change modeling module rearranges the brightness change variables in the target pixel set to construct a brightness change mapping sequence, and determines the degree of brightness change based on the brightness change mapping sequence. The weight reconstruction module reconstructs the participation ratio of the comprehensive chromaticity variable and the luminance change variable according to the degree of luminance change, adjusts the feature weight allocation in the adaptive mean drift clustering according to the degree of luminance change, and performs distance calculation using the reconstructed feature set. The clustering control module performs adaptive mean-drift clustering iteration based on the distance calculation results. During the iteration process, it dynamically controls the feature weight allocation based on the clustering convergence state and outputs the yarn dyeing quality assessment results.