A traditional Chinese medicine dyeing color uniformity detection method and system
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- HANGZHOU YINAIJIE TEXTILE CO LTD
- Filing Date
- 2026-04-28
- Publication Date
- 2026-05-29
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Existing machine vision-based textile uniformity detection methods suffer from problems such as low signal-to-noise ratio, severe texture interference, and difficulty in eliminating interference from lighting and fabric deformation in traditional Chinese medicine-dyed textiles, leading to distorted detection results.
Images were acquired under controlled lighting conditions, and color correction and lighting compensation were performed. Prior information on the energy distribution of fabric texture was extracted, and a multi-spatial-level image sequence was constructed. A texture-color decoupled neural network model was used to output color purity feature images for spatial statistical analysis and defect localization.
It significantly suppresses texture interference, highlights the differences in the adhesion and distribution of Chinese herbal dyes, improves the stability and accuracy of detection results, and achieves high-precision uniformity detection of Chinese herbal dyed textiles.
Smart Images

Figure CN122115443A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of intelligent detection technology, and in particular to a method and system for detecting the uniformity of color in traditional Chinese medicine staining. Background Technology
[0002] Traditional Chinese medicine dyeing is an environmentally friendly and healthy dyeing process. Thanks to the advantages of its natural, non-toxic dyes and good biocompatibility, it is widely used in textile processing. However, the traditional Chinese medicine dyeing process itself has inherent limitations: low dye uptake, pale colors, and uneven penetration make it extremely difficult to control the color uniformity of textiles.
[0003] Existing machine vision-based methods for textile uniformity detection are primarily designed for chemically dyed products. However, they face numerous technical challenges when applied to textiles dyed with traditional Chinese medicine. The weak color signals from the traditional Chinese medicine dyes are easily obscured by the inherent weave texture (such as plain or twill weave), yarn knots, and weave shadows, resulting in an extremely low signal-to-noise ratio and difficulty in distinguishing between genuine dyeing differences and texture interference. Traditional methods extract features using fixed color spaces and filtering parameters, failing to consider the modulation effect of dye penetration on texture visibility or the fundamental frequency characteristics of the texture corresponding to the fabric's warp and weft yarn densities. This makes it impossible to effectively separate texture and color information, easily misjudging texture as color difference and leading to distorted detection results. Furthermore, fluctuations in lighting conditions and non-uniform shadows caused by physical deformation of the fabric surface further interfere with the accurate acquisition of color information. Existing preprocessing methods can only perform simple color correction or lighting compensation, failing to specifically eliminate these interferences.
[0004] Therefore, there is an urgent need for a method and system for detecting the uniformity of color in traditional Chinese medicine staining to solve the above problems. Summary of the Invention
[0005] The purpose of this invention is to provide a method for detecting the uniformity of color staining in traditional Chinese medicine, comprising the following steps: Under controlled lighting conditions, the original RGB image of the dyed textile product made from Chinese herbal medicine was acquired, and the effective fabric area image was obtained based on the original RGB image. The effective fabric region image is subjected to frequency domain transformation to separate and extract prior information on texture energy distribution that characterizes the inherent weave structure of the fabric. A multi-spatial-level image sequence is constructed and, together with the prior information of the texture energy distribution, is input into a pre-trained texture-color decoupling neural network model. The neural network model is used to output a color purity feature image that suppresses texture interference. Spatial statistical analysis is performed on the color purity feature image to calculate the overall uniformity quantification index, and a local non-uniformity heat map is generated to form a defect list in order to locate the defect area. By combining the overall uniformity quantification index and defect area location information, the detection results, including uniformity level determination and visual defect report, are generated and output.
[0006] Furthermore, the step of acquiring an image of the effective fabric area includes: Obtain the original RGB image of the fabric to be tested; The original RGB image is subjected to color correction and illumination compensation to obtain a preprocessed image; The preprocessed image is analyzed to identify non-uniform shadow areas caused by physical deformation of the fabric surface, and the intensity of its morphological shadow interference is estimated. Based on the intensity of the morphological shadow interference, an adaptive surface morphology compensation coefficient map is generated. The surface morphology compensation coefficient map is used to enhance and suppress the preprocessed image to compensate for the influence of physical deformation on color perception and generate an optimized image. The continuous effective regions, excluding areas with high topographic interference, are automatically selected as the effective fabric region image.
[0007] Furthermore, the step of separating and extracting prior information on the texture energy distribution characterizing the inherent weave structure of the fabric includes: The effective fabric region image is converted to a specific color space channel that is sensitive to the physical structure of the fabric, and an initial texture feature image is generated. The color distribution characteristics of the effective fabric area image are analyzed, and the dye penetration uniformity index is calculated. The dye penetration uniformity index is used to quantify the degree to which the dyeing process modulates the visibility of the original fabric texture. The power spectrum is obtained by performing frequency domain transformation on the initial texture feature image. Based on the theoretical texture fundamental frequency determined by the known warp and weft yarn density of the fabric and the dye penetration uniformity index, the parameters of the bandpass filter are dynamically set together to filter the power spectrum, so as to suppress color interference and enhance the texture signal. The filtered spectrum is inversely transformed to obtain the spatial domain texture response map; The texture response map is adaptively normalized by combining the dye penetration uniformity index to generate a texture energy prior image, and the texture energy prior image is used as the prior information of texture energy distribution.
[0008] Furthermore, the step of outputting a color purity feature image that suppresses texture interference includes: Based on the image of the effective fabric region, a multi-spatial-level image sequence is constructed by downsampling; The images at each scale in the multi-spatial-level image sequence are fused with the texture energy prior image to form fused input features; The fused input features are then fed into a pre-trained neural network model based on an encoder-decoder architecture. Obtain the color purity feature image output by the neural network model, which has the same size as the input image.
[0009] Furthermore, the step of generating a local non-uniformity heatmap and forming a defect list includes: Calculate the standard deviation of dye distribution and the average gradient magnitude of the color purity feature image as the overall uniformity quantification index; The local variance of the color purity feature image is calculated using the sliding window method, and a local non-uniformity heatmap is generated by mapping. The local non-uniformity heatmap is subjected to image segmentation and connected component analysis to extract the contour and attribute information of the defect region and form a defect list.
[0010] Furthermore, the step of generating a local non-uniformity thermal map and forming a defect list includes: The uniformity level is determined by comparing the standard deviation and average gradient amplitude of the dye distribution with a preset threshold. A composite visual defect report is generated, which integrates the effective fabric area image, color purity feature image, local non-uniformity heat map, and overlaid defect outline; The uniformity level, overall uniformity quantification index, defect list, and visual defect report are displayed and output in a structured manner.
[0011] Furthermore, this application also discloses a system for detecting the uniformity of color in traditional Chinese medicine staining, comprising: The acquisition module is used to acquire the original RGB image of the dyed textile of Chinese medicine to be tested under controlled lighting conditions, and to acquire the effective fabric area image based on the original RGB image. The extraction module is used to perform frequency domain transformation on the effective fabric region image, and separate and extract prior information on texture energy distribution that characterizes the inherent weave structure of the fabric. The construction module is used to construct a multi-spatial-level image sequence, and together with the prior information of the texture energy distribution, input it into a pre-trained texture-color decoupling neural network model. The neural network model is used to output a color purity feature image that suppresses texture interference. The calculation module is used to perform spatial statistical analysis on the color purity feature image, calculate the overall uniformity quantification index, generate a local non-uniformity heat map and form a defect list to locate defect areas. The output module is used to integrate the overall uniformity quantification index and defect area location information to generate and output the detection results, which include uniformity level judgment and visual defect report.
[0012] Furthermore, the extraction module includes: The conversion unit is used to convert the effective fabric region image to a specific color space channel that is sensitive to the physical structure of the fabric, and generate an initial texture feature image. The analysis unit is used to analyze the color distribution characteristics of the effective fabric area image and calculate the dye penetration uniformity index, which is used to quantify the degree of modulation of the original fabric texture visibility by the dyeing process. The first transformation unit is used to perform frequency domain transformation on the initial texture feature image to obtain the power spectrum. Based on the theoretical texture fundamental frequency determined by the known warp and weft yarn density of the fabric and the dye penetration uniformity index, the parameters of the bandpass filter are dynamically set together to filter the power spectrum in order to suppress color interference and enhance the texture signal. The second transformation unit is used to perform inverse transformation on the filtered spectrum to obtain the spatial domain texture response map. The generation unit is used to perform adaptive normalization processing on the texture response map by combining the dye penetration uniformity index, generate a texture energy prior image, and use the texture energy prior image as prior information on texture energy distribution.
[0013] This application also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps of the above-described method for detecting the uniformity of coloring in traditional Chinese medicine.
[0014] This application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the above-described method for detecting the uniformity of coloring in traditional Chinese medicine.
[0015] The beneficial effects of this application are as follows: Firstly, this invention extracts prior information about fabric texture energy through frequency domain transformation and combines it with a multi-spatial-level image sequence and a texture-color decoupling neural network to construct a texture-insensitive color purity feature space, thus fundamentally solving the problem of texture-color coupling interference. The network, trained with a composite loss function, significantly suppresses interference from fabric weaving textures and yarn knots, highlighting subtle differences in the distribution of traditional Chinese medicine dyes, greatly improving the signal-to-noise ratio of color feature extraction, and avoiding misjudging texture as color difference.
[0016] Secondly, the present invention can deeply decouple the network to learn and amplify the subtle color differences unique to traditional Chinese medicine dyeing, so that uneven defects such as color spots and blemishes that were originally covered by texture can be clearly highlighted in the color purity feature image. This effectively overcomes the shortcomings of traditional methods that are not sensitive to light colors and accurately matches the process characteristics of low dyeing rate and light color of traditional Chinese medicine dyes.
[0017] Thirdly, this invention effectively eliminates the interference of non-uniform shadows caused by light fluctuations and physical deformation of fabrics through the construction of a standard light source environment, color correction, illumination compensation, and adaptive compensation of surface morphology. It automatically selects effective fabric area images that exclude highly interfered areas, providing a clean and reliable data foundation for subsequent detection and further improving the stability and accuracy of the detection results. Attached Figure Description
[0018] Figure 1 This is a schematic diagram of a method flow proposed in an embodiment of this application.
[0019] Figure 2 This is a schematic diagram of the system structure proposed in an embodiment of the present invention.
[0020] The realization of the purpose, functional features and advantages of this application will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation
[0021] It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
[0022] like Figure 1 As shown, this application provides a method for detecting the uniformity of color in traditional Chinese medicine staining, comprising the following steps: S1. Under controlled lighting conditions, acquire the original RGB image of the dyed textile of the Chinese herbal medicine to be tested, and acquire the effective fabric area image based on the original RGB image; S2. Perform frequency domain transformation on the image of the effective fabric region to separate and extract prior information on texture energy distribution that characterizes the inherent weaving structure of the fabric. S3. Construct a multi-spatial-level image sequence, and input it along with the prior information of the texture energy distribution into a pre-trained texture-color decoupling neural network model. This neural network model is used to output a color purity feature image that suppresses texture interference. S4. Perform spatial statistical analysis on the color purity feature image, calculate the overall uniformity quantification index, and generate a local non-uniformity heat map to locate the defect area. S5. Based on the overall uniformity quantification index and defect area location information, generate and output the detection results, which include uniformity level determination and visual defect report.
[0023] As described in steps S1-S5 above, the dyeing process of traditional Chinese medicine is characterized by low dye uptake, light color, and uneven penetration. Textiles themselves have inherent textures formed by their weaving structure, which can mask subtle color differences, resulting in an extremely low signal-to-noise ratio for color uniformity detection. At the same time, changes in lighting in the detection environment and shadows caused by physical deformation of the fabric surface can further interfere with the accurate acquisition of color information. Therefore, a detection method is needed that can eliminate environmental interference, separate texture and color information, and accurately extract dyeing uniformity features to solve the core technical problems of weak signal and strong interference in the uniformity detection of traditional Chinese medicine dyed textiles.
[0024] Existing machine vision-based uniformity detection methods are mostly designed for chemically dyed textiles, relying on simple color difference calculations or fixed texture filtering. These methods cannot adapt to the light colors of traditional Chinese medicine dyes and cannot effectively separate fabric texture from dye color information, easily misjudging texture as color difference. Furthermore, they do not consider the interference caused by light fluctuations and fabric surface deformation, resulting in low detection accuracy and high misjudgment rate, making it difficult to meet the detection requirements of traditional Chinese medicine dyed textiles. This invention addresses these problems through a collaborative design of standardized lighting environment construction, frequency domain prior extraction, multi-scale decoupling network, and precise quantitative evaluation.
[0025] By employing a coherent process of image acquisition and standard light source environment construction, fabric texture frequency domain prior extraction, multi-scale texture-color feature decoupling, feature map-based uniformity quantification evaluation, and generation and output of detection results, high-precision automatic detection of color uniformity in Chinese herbal dyed textiles is achieved. This process accurately suppresses fabric texture interference, highlights subtle dyeing differences, and completes uniformity level determination and defect location.
[0026] It is important to note that the core logic of this solution addresses the critical pain points of traditional Chinese medicine-dyed textiles, such as light color, low dye uptake, and the tendency for the inherent weave texture to obscure the dyeing color signal. Through a closed-loop process involving standardized acquisition and interference removal, texture prior extraction, multi-scale feature decoupling, precise quantitative evaluation, and structured result output, a texture-insensitive color purity feature space is constructed to achieve high-precision uniformity detection. The principle is as follows: First, original RGB images are acquired under D65 standard controlled lighting conditions. Through color correction, illumination compensation, surface morphology interference compensation, and effective region selection, effective fabric region images free from environmental interference and deformation effects are obtained. Next, frequency domain transformation is performed on the effective fabric region images to separate and extract prior information on texture energy distribution, characterizing the inherent weave structure of the fabric. This clarifies the distribution pattern and energy characteristics of texture in the image, providing clear guidance for the separation of texture and color. Subsequently, a multi-spatial-level image sequence is constructed to capture multi-level information from local texture details to global color distribution, which is then combined with the texture energy distribution prior information. Multimodal input features are formed by fusing line features and fed into a pre-trained encoder-decoder architecture texture-color decoupled neural network. Through the network's ability to suppress texture features and highlight color features, the output color purity feature image is characterized by significantly suppressed texture interference and amplified differences in the distribution of Chinese medicine dyes. Spatial statistical analysis is then performed on this feature image to calculate the standard deviation of dye distribution and the average gradient magnitude as quantitative indicators of overall uniformity. At the same time, a sliding window method is used to generate a local non-uniformity heatmap. Defect regions are located through image segmentation and connected component analysis, achieving a two-dimensional uniformity assessment of both the overall and local dimensions. Finally, the uniformity level is determined by combining the overall quantitative indicators and defect location information, and a visual report integrating the original image, processing process, and quantitative results is generated. The report is also output in a standardized data format for use by production management or quality traceability systems. The entire solution solves the texture-color coupling interference problem at its root through the synergistic effect of frequency domain prior and deep learning decoupling, achieving objective, accurate, and automated detection of the uniformity of Chinese medicine dyeing.
[0027] In one embodiment, the step of acquiring an image of the effective fabric area includes: S11. Under the D65 standard light source, acquire the original RGB image of the fabric to be tested; S12. Perform color correction and illumination compensation on the original RGB image to obtain a preprocessed image; S13. Analyze the preprocessed image, identify the non-uniform shadow areas caused by physical deformation of the fabric surface, and estimate the intensity of its morphological shadow interference. S14. Based on the intensity of the morphological shadow interference, generate an adaptive surface morphological compensation coefficient map, and use the surface morphological compensation coefficient map to enhance and suppress the preprocessed image in order to compensate for the influence of physical deformation on color perception and generate an optimized image. S15. Based on the optimized image, automatically select a continuous effective region excluding areas with high morphological interference as the effective fabric region image.
[0028] As described in steps S11-S15 above, through a series of steps including image acquisition under a D65 standard light source, color correction and illumination compensation, identification of non-uniform shadow areas and estimation of interference intensity, adaptive surface morphology compensation, and selection of effective areas, an effective fabric area image is obtained to eliminate interference from illumination fluctuations and surface deformation. This provides a clean and reliable detection object for subsequent texture frequency domain prior extraction and texture-color feature decoupling. The colors of traditional Chinese medicine dyed textiles are light and the signals are weak. During the detection process, unstable lighting conditions can lead to image color distortion. Non-uniform shadows caused by physical deformations such as folding and uneven weaving tightness on the fabric surface can further obscure the true dyeing color information. These interferences directly affect the subsequent separation of texture and color, reducing the accuracy of uniformity detection. Therefore, it is necessary to standardize the lighting environment and eliminate various interferences to obtain an effective fabric area image that truly reflects the dyeing situation, providing a high-quality data foundation for the entire detection process.
[0029] In existing technologies, image preprocessing simply performs color correction or fixed-parameter illumination compensation without considering the non-uniform shadow interference caused by the physical deformation of the fabric surface, nor does it perform targeted compensation for shadow areas. As a result, the preprocessed image still contains a lot of interference, and the selection of effective areas depends on manual or simple threshold segmentation, which cannot accurately exclude highly interference areas. This makes subsequent processing based on image data containing interference, ultimately affecting the detection accuracy. This invention systematically solves the above interference problems through standardized light source acquisition, multi-dimensional compensation, and intelligent effective area selection.
[0030] Under controlled lighting conditions created by the D65 standard light source, a CCD camera was used to vertically photograph the dyed textiles of traditional Chinese medicine under test to obtain original RGB images. The spectrum of the D65 standard light source is close to that of natural sunlight, which can ensure the authenticity and stability of the color information in the image. The vertical shooting method can reduce the uneven lighting caused by the shooting angle. The image acquisition of the CCD camera can ensure that the subtle texture and slight dyeing differences of the fabric can be captured, providing high-quality raw data for subsequent processing.
[0031] Color correction and illumination compensation are performed on the original RGB image. Color correction eliminates color shifts caused by spectral deviations of the light source through white balance adjustment, ensuring that the image color matches the actual dyed color of the fabric. Illumination compensation uses a homomorphic filtering algorithm to separate the illuminance and reflectance components of the image, suppressing grayscale differences caused by non-uniform illumination and enhancing the uniformity of the overall brightness of the image. These two steps result in a pre-processed image that effectively reduces the interference of illumination fluctuations on color information.
[0032] The grayscale distribution characteristics of the preprocessed image are analyzed to identify non-uniform shadow regions caused by physical deformation of the fabric surface. By calculating the grayscale mean and variance of local regions of the image, when the grayscale mean of a local region is lower than 70% of the global grayscale mean and the variance is less than 30% of the global variance, the region is determined to be a non-uniform shadow region. Based on the grayscale difference between the shadow region and the normal region, and the area of the shadow region, the intensity of the morphological shadow interference is estimated. The interference intensity value ranges from 0 to 1, with a larger value indicating a more severe interference of the shadow on color perception.
[0033] An adaptive surface topography compensation coefficient map is generated based on the intensity of morphological shadow interference. For areas with high interference intensity, the compensation coefficient is set to 1.2 to 1.5, and pixel-level enhancement is performed on these areas. For areas with low interference intensity, the compensation coefficient is set to 0.9 to 1.1, with slight adjustments. For areas without interference, the compensation coefficient is set to 1.0, keeping the pixel values unchanged. This compensation coefficient map is then used to perform pixel-by-pixel multiplication operations on the preprocessed image to achieve targeted compensation for shadow interference caused by physical deformation, correct color perception deviations caused by shadows, and generate an optimized image that makes the color information in the optimized image closer to the actual dyeing condition of the fabric.
[0034] Effective fabric regions are selected based on the optimized image. A connected component analysis algorithm is used to traverse the optimized image, filtering out continuous regions with an area greater than a preset threshold (30% of the total image area) and uniform grayscale distribution (grayscale variance within the region is less than 50% of the global grayscale variance). Regions with high morphological interference (interference intensity values greater than 0.7) are excluded. The largest continuous region meeting these criteria is then identified as the effective fabric region image. This effective fabric region image eliminates various interferences such as illumination fluctuations and surface deformation shadows, ensuring accurate separation of texture and color information in subsequent processing.
[0035] In one embodiment, the step of separating and extracting prior information on texture energy distribution characterizing the inherent weave structure of the fabric includes: S21. Convert the image of the effective fabric area to a specific color space channel (such as the S or V channel of the HSV space) that is sensitive to the physical structure of the fabric, and generate an initial texture feature image. S22. Analyze the color distribution characteristics of the effective fabric area image and calculate the dye penetration uniformity index, which is used to quantify the degree of modulation of the original fabric texture visibility by the dyeing process. S23. The power spectrum is obtained by frequency domain transformation of the initial texture feature image. Based on the theoretical texture fundamental frequency determined by the known warp and weft yarn density of the fabric and the dye penetration uniformity index, the parameters of the bandpass filter are dynamically set together to filter the power spectrum in order to suppress color interference and enhance the texture signal. S24. Perform an inverse transform on the filtered spectrum to obtain the spatial domain texture response map; S25. Based on the dye penetration uniformity index, the texture response map is adaptively normalized to finally generate the texture energy prior image.
[0036] As described in steps S21-S25 above, through a series of steps including specific color space conversion, dye penetration uniformity index calculation, frequency domain transformation and dynamic filtering, inverse transformation and adaptive normalization, the prior information of texture energy distribution characterizing the inherent weaving structure of the fabric is accurately separated and extracted.
[0037] In the process of dyeing traditional Chinese medicine, differences in dye penetration can modulate the visibility of the original texture of the fabric. At the same time, the warp and weft yarn densities of different fabrics determine the inherent differences in their texture fundamental frequencies. The accuracy of the prior information of texture energy distribution directly affects the subsequent decoupling effect between texture and color. If the extracted texture information contains too much color interference or fails to conform to the inherent structure of the fabric, the decoupling network will be unable to accurately distinguish the differences between texture and dyeing, thus affecting the uniformity detection accuracy. Therefore, it is necessary to extract prior information of texture energy distribution that can truly reflect the inherent weaving structure of the fabric and is not affected by dyeing, so as to provide accurate guidance for the decoupling process.
[0038] The effective fabric area image is converted to the S channel of HSV space to generate an initial texture feature image. The S channel of HSV space is more sensitive to the light and dark contrast of the fabric's physical structure, which can highlight the texture details formed by the interlacing of the warp and weft yarns and weaken the influence of color itself, laying the foundation for subsequent texture extraction. Taking the plain weave cotton fabric dyed with the Chinese herbal medicine gardenia as an example, after conversion to the S channel, the plain weave texture lines formed by the interlacing of the warp and weft yarns will be clearer, which is convenient for subsequent separation of texture and dyeing information.
[0039] It should be noted that the HSV color space is a color space based on human visual perception of color. H represents hue, corresponding to the type of color (such as red, yellow, etc.), with a value range of 0° to 360°. S represents saturation, characterizing the purity of the color, with a value range of 0 to 1 (or 0% to 100%). Higher saturation results in a more vibrant color, while lower saturation makes the color closer to grayscale. V represents lightness, reflecting the brightness of the color, with a value range of 0 to 1 (or 0% to 100%). Higher lightness results in a brighter color. For texture extraction from textiles dyed with traditional Chinese medicine, the core advantage of the S channel lies in its higher sensitivity to the contrast between light and dark areas created by the fabric's physical structure. It effectively highlights the texture details formed by the interweaving of warp and weft yarns, while weakening the absolute intensity differences of the color itself, avoiding interference from the pale and uneven colors of the traditional Chinese medicine dyeing on texture recognition.
[0040] The specific steps to convert the RGB image of the effective fabric area to the S channel (i.e., saturation channel) of the HSV space are as follows: First, normalize the RGB components of each pixel in the effective fabric area image, that is, divide the R, G, and B values of each pixel (original value range 0 to 255) by 255 respectively, and convert them into normalized values between 0 and 1. Then, calculate each component of the HSV space using the following formula, and finally extract the S channel as the basis for the initial texture feature image.
[0041] Analyze the color distribution characteristics of the effective fabric area image and calculate the dye penetration uniformity index. By statistically analyzing the color mean and standard deviation of the dyed area in the effective fabric area image, and combining this with the color reference value of the same type of undyed white fabric (the white fabric color reference value is obtained by statistically analyzing images of the same type of white fabric), the dye penetration uniformity index is calculated using the following formula: ; Among them, the Indicates the dye penetration uniformity index. Indicates the standard deviation of color in the stained area. This represents the standard deviation of the white fabric color. Specifically, the standard deviation of the dyed area color is calculated based on the HSV space V channel of the effective fabric area image, specifically the standard deviation of the grayscale values of all pixels in that channel, reflecting the dispersion of the color distribution in the dyed area. The standard deviation of the white fabric color is the color standard deviation of the same type of undyed white fabric. It is calculated by collecting RGB images of at least 30 white fabric samples of the same batch and specification, converting them to the HSV space V channel, calculating the standard deviation of each sample, and taking the arithmetic mean as the final standard deviation of the white fabric color. This represents the average deviation of dye uptake rate, used to reflect the uniformity of actual dye adhesion. This indicates the maximum allowable deviation in dyeing rate, which can be taken as 20% to align with the limits of traditional Chinese medicine dyeing processes. A deviation exceeding 20% can be considered a complete failure of penetration. and Denotes the weight coefficients, and satisfies + =1, in this embodiment The value is =0.45 (surface color uniformity weight), The value is =0.55 (weight for actual adhesion uniformity). In traditional Chinese medicine dyeing, greater emphasis is placed on the actual uniformity of dye adhesion; therefore, the weight for dyeing rate deviation is slightly higher. The above weights... and The value of is not subjectively set, but obtained through comparative experiments and statistical verification of multiple groups of standard samples of Chinese herbal medicine staining. This is achieved through the calculation formula described above. The value constraint function ensures that the calculation result is forced to be 0 when it is negative, so as to avoid calculation results without physical meaning. The dye penetration uniformity index ranges from 0 to 1. The closer the value is to 1, the more uniform the dye penetration is and the less it modulates the visibility of the original fabric texture. The closer the value is to 0, the more uneven the dye penetration is and the greater the modulation of the texture visibility. It quantifies the influence of the dyeing process on the original fabric texture, retains the intuitive judgment of the surface color, and supplements the physical essence of the actual adhesion amount. It can match the dual detection needs of surface uniformity and internal penetration of traditional Chinese medicine dyeing.
[0042] The formula for calculating the average deviation of the dye uptake rate is as follows: ; In the above calculation formula, n represents the number of sub-regions, and n≥20 to ensure statistical reliability. The term represents the dyeing rate of the i-th sub-region. The average dye uptake rate is represented by the method of dividing the number of sub-regions n into several sub-regions with a size of "10mm × 10mm" by dividing the effective fabric area (the pure detection area excluding edges, shadows, and impurities). The dye uptake rate of the i-th sub-region is... The average dyeing rate is measured directly using the weight difference method, a common method in the textile dyeing industry for quantifying dyeing rate, which will not be elaborated upon here. The staining rate of n (n≥20) sub-regions ( to After summing, divide by the number of subregions n to get the result.
[0043] A Fast Fourier Transform (FFT) is performed on the initial texture feature image to convert the spatial domain signal into a frequency domain power spectrum. The theoretical texture fundamental frequency is calculated based on the known warp and weft yarn densities of the fabric. For example, for a plain weave fabric with a warp and weft yarn density of 100 yarns / inch, the theoretical texture fundamental frequency can be derived through the correspondence between density and image resolution. The parameters of the Butterworth bandpass filter are dynamically set in conjunction with the dye penetration uniformity index. When the dye penetration uniformity index is low (less than 0.3), indicating severe dye modulation of the texture, the passband width of the bandpass filter is reduced to ±5% of the theoretical texture fundamental frequency, and the center frequency is fine-tuned to 1.02 times the theoretical texture fundamental frequency to accurately extract the texture signal. When the dye penetration uniformity index is high (greater than 0.7), the passband width is expanded to ±10% of the theoretical texture fundamental frequency to ensure complete texture signal extraction. This dynamically parameterized bandpass filter filters the power spectrum, effectively suppressing low-frequency components corresponding to color interference and extremely high-frequency components corresponding to noise, while enhancing the mid-to-high-frequency components corresponding to the texture.
[0044] An inverse fast Fourier transform is performed on the filtered frequency domain spectrum to restore the frequency domain signal to a spatial domain texture response map. This step can restore the distribution pattern of the texture in the spatial domain. At this point, the texture response map has significantly reduced the effects of color interference and noise, and the texture features of the inherent weave structure of the fabric are more prominent, providing high-quality texture data for subsequent normalization processing.
[0045] Adaptive normalization of the texture response map is performed using the dye penetration uniformity index. When the dye penetration uniformity index is less than 0.3, a normalization coefficient of 0.8 is used to avoid over-normalization caused by severe texture modulation. When the dye penetration uniformity index is between 0.3 and 0.7, a normalization coefficient of 1.0 is used. When the dye penetration uniformity index is greater than 0.7, a normalization coefficient of 1.2 is used to enhance the contrast of the texture response. Through this adaptive normalization process, a texture energy prior image is finally generated. This texture energy prior image can accurately represent the energy distribution of the inherent weave structure of the fabric, clearly identify the regions in the image that belong to the texture, and ensure that the decoupled network can specifically suppress texture interference.
[0046] In one embodiment, the step of outputting a color purity feature image that suppresses texture interference includes: S31. Based on the effective fabric area image, a multi-scale image sequence containing multiple different scales is generated by using the Gaussian pyramid downsampling method to capture multi-level information from local texture details to global color distribution. S32. The images at each scale in the multi-spatial-level image sequence are fused with the texture energy prior image to generate multimodal input features, and the multimodal input features are used as input data for the neural network model. S33. Input the multimodal input features into a pre-trained texture-color decoupled neural network model. The model is based on an encoder-decoder architecture. The encoder part extracts multi-scale depth features through convolutional layers, and the decoder part gradually restores spatial resolution through upsampling and convolutional layers. S34. The output of the texture-color decoupling neural network model is a color purity feature image with the same spatial size as the original RGB image. In this color purity feature image, the weaving texture and yarn knot information of the fabric itself are significantly suppressed, while the differences in the attachment and distribution of Chinese herbal dyes are highlighted, which are manifested as spatial changes in feature values.
[0047] As described in steps S31-S34 above, through a series of steps including multi-spatial hierarchical image sequence construction, multi-modal input feature fusion, texture-color decoupled neural network forward inference, and color purity feature image generation, the interference of fabric weaving texture and yarn knots is accurately suppressed, the slight differences in the adhesion and distribution of traditional Chinese medicine dyes are highlighted, and a color purity feature image that can truly reflect the uniformity of dyeing is output.
[0048] The color signals of textiles dyed with Chinese herbs are inherently faint and weak. The weaving texture of the fabric has multi-layered characteristics of local details and global distribution. It is difficult to fully capture the texture information at a single scale, resulting in incomplete decoupling of texture and color. If the decoupling process lacks clear texture prior guidance, the network cannot accurately distinguish the differences between texture and dyeing, which will directly affect the accuracy of subsequent uniformity assessment. Therefore, it is necessary to construct multi-spatial-level image sequences to cover different levels of features and integrate texture prior information. A dedicated decoupling network can be used to achieve efficient separation of texture and color.
[0049] Based on the effective fabric region image, a multi-spatial-level image sequence is generated using the Gaussian pyramid downsampling method. Specifically, the effective fabric region image is processed with Gaussian filtering (Gaussian kernel size 5×5, standard deviation 1.0), and then pixels are removed from every row and column to achieve downsampling, generating image sequences at three scales: 1:1 (original image), 1:2 (half the original image size), and 1:4 (one-quarter of the original image size). This multi-spatial-level image sequence can simultaneously capture the local texture details of the fabric (small-scale image) and the global color distribution (large-scale image), providing the network with more comprehensive feature information and avoiding the loss of perception of local texture or global color at a single scale. Taking cotton plain weave fabric dyed with the traditional Chinese medicine gardenia as an example, the 1:1 scale image retains fine textures such as yarn knots, while the 1:4 scale image more clearly presents the overall color distribution trend of the dyeing.
[0050] Input preparation for the texture-color decoupling neural network model: Each scale image in the multi-spatial-level image sequence is concatenated with the texture energy prior image to achieve feature fusion. Specifically, the RGB image (3 channels) at each scale is concatenated with the texture energy prior image (1 channel) to form a 4-channel feature map, resulting in a total of 12 channels of multimodal input features across the three scales. This fusion method allows the neural network to obtain clear texture distribution guidance while receiving image color information, identifying which areas require focused texture suppression, providing data support for accurate decoupling, and improving the network's ability to distinguish between texture and color.
[0051] The texture-color decoupled neural network performs forward inference. This neural network is based on an encoder-decoder architecture. The encoder consists of four convolutional layers, each using a 3×3 kernel with a stride of 2 and ReLU activation. By progressively reducing the feature map size, it extracts multi-scale depth features. The first convolutional layer outputs a 64-channel feature map, with the number of channels doubling in subsequent layers, reaching a 512-channel feature map in the fourth layer. The decoder consists of four upsampling layers and four convolutional layers. The upsampling layers use transposed convolutions (3×3 kernel, stride 2), and the convolutional layers also use 3×3 kernels and ReLU activation. By progressively increasing the feature map size, it restores spatial resolution, ultimately outputting a feature map with the same spatial dimensions as the original RGB image. During the network training phase, a training dataset was constructed containing images of pure textured white fabric, simulated uniformly stained traditional Chinese medicine images, and simulated non-uniformly stained traditional Chinese medicine images. A composite loss function was used for training, where the reconstruction loss ensured that the network output matched the overall information of the input image, and the decoupling loss constrained the network to output a uniform grayscale image for pure texture input, forcing the network to learn to remove texture patterns. Multimodal input features were fed into the pre-trained network, and through feature extraction and transformation at each layer, accurate separation of texture and color was achieved.
[0052] A color purity feature image is generated and output. The final output of the decoder of the trained neural network is the color purity feature image, which has the same spatial dimensions as the original RGB image. In this feature image, the weave texture and yarn knot information of the fabric itself are significantly weakened due to the suppression effect of the decoupled network, while the subtle differences in the distribution of the herbal dye are magnified and highlighted, manifested as spatial variations in feature values. Uniform color areas show a smooth feature value distribution, while non-uniform areas such as color spots and patches show abrupt peaks and valleys in feature values, providing a high signal-to-noise ratio feature basis for subsequent uniformity quantification evaluation.
[0053] In one embodiment, the step of generating a local non-uniformity heatmap includes: S41. For the color purity feature image obtained above, calculate its global statistical features as a quantitative evaluation index of overall uniformity. The global statistical features include the standard deviation of dye distribution and the average gradient magnitude. The calculation process of the standard deviation of dye distribution is as follows: First, calculate the average value of all pixel feature values in the feature image. Then, calculate the square of the difference between each pixel feature value and the average value. Then, sum the squares of all differences and divide by the total number of pixels. Finally, take the square root of the quotient as the standard deviation of dye distribution. The calculation process of the average gradient magnitude is as follows: First, use the gradient operator to calculate the gradient component of each pixel in the feature image. Then, calculate the gradient magnitude of each pixel. Finally, take the arithmetic mean of the gradient magnitudes of all pixels. S42. Use the sliding window method to traverse the color purity feature image. For the local area covered by each window, calculate the variance of the pixel feature values in that area as the local non-uniformity measure of the central pixel position of the window. After traversal, map the local non-uniformity measure values corresponding to all pixel positions into a new image, namely the local non-uniformity heatmap. The areas with higher values in the heatmap correspond to the potential color non-uniformity defect positions. S43. Apply image segmentation technology to the local non-uniformity heatmap to automatically identify and mark significant defect areas. First, the heatmap is binarized to obtain an initial defect mask. Then, morphological operations are performed on the initial defect mask to eliminate noise and connect adjacent areas. Finally, through connected component analysis, the contour, area, and center location information of each independent defect area are identified to form a list of defect attributes.
[0054] As described in steps S41-S43 above, through the sequential steps of calculating the overall uniformity quantification index, generating the local non-uniformity heat map, and automatically segmenting and locating the defect area, a comprehensive analysis of the color purity feature image is achieved. This not only completes the quantitative assessment of the fabric dyeing uniformity but also accurately locates local color non-uniformity defects, providing data support for the final detection result output.
[0055] Color purity feature images have effectively suppressed texture interference and highlighted the differences in the distribution of traditional Chinese medicine dyes. However, to comprehensively evaluate dyeing uniformity, analysis needs to be conducted from both overall and local dimensions. Overall uniformity determines the overall grade of fabric dyeing quality, while local defects directly affect product qualification. If only a single-dimensional analysis is performed, the evaluation will be incomplete and unable to meet the needs of production quality control. Therefore, it is necessary to establish a quantitative index system and achieve precise defect location to ensure the objectivity and practicality of the test results. In existing technologies, uniformity evaluation mostly relies on a single global color difference index, which cannot reflect local color unevenness. Moreover, defect location often adopts manual annotation, which is inefficient and highly subjective. Some automatic location methods have fixed thresholds, which are difficult to adapt to the defect characteristics of different dyeing scenarios, resulting in low location accuracy and high false negative rate. This invention solves the above problems through dual-dimensional quantitative indicators, dynamic threshold segmentation, and morphological optimization.
[0056] The standard deviation of dye distribution and the average gradient magnitude are calculated as quantitative indicators of overall uniformity for the color purity feature image. The calculation of the standard deviation of dye distribution first involves statistically analyzing the feature values of all pixels in the color purity feature image, calculating their arithmetic mean, then calculating the difference between each pixel's feature value and the mean value, squaring the difference, summing all the squared differences, dividing by the total number of pixels, and finally taking the square root of the result.
[0057] The specific formula for calculating the standard deviation of the dye distribution is as follows: ; Among them, the This represents the standard deviation of dye distribution, which reflects the overall dispersion of color distribution. A larger value indicates a worse overall uniformity. This represents the feature value of the i-th pixel in the color purity feature image. The color purity feature image is output by a texture-color decoupling neural network and is a color distribution feature map after suppressing texture interference. This represents the arithmetic mean of all pixel feature values in the color purity feature image. It is calculated by summing all pixel feature values in the feature image and then dividing by the total number of pixels. The total number of pixels in the color purity feature image is determined by the image resolution. Taking a plain-weave cotton fabric dyed with the traditional Chinese medicine gardenia as an example, if the total number of pixels in the color purity feature image is 1,000,000, the average value of all pixel feature values is 50, and the sum of squared differences is 8,500,000, then the standard deviation of the dye distribution is... ≈2.915. The average gradient magnitude is calculated using the Sobel gradient operator, calculating the gradient components of each pixel in the horizontal and vertical directions. The horizontal gradient operator is [[1,0,-1],[2,0,-2],[1,0,-1]], and the vertical gradient operator is [[1,2,1],[0,0,0],[-1,-2,-1]]. After obtaining the gradient components in each direction through convolution, the gradient magnitude of each pixel is calculated (the gradient magnitude is calculated by taking the square root of the sum of the squares of the horizontal and vertical gradient components). Finally, the arithmetic mean of the gradient magnitudes of all pixels is taken. The standard deviation of dye distribution reflects the dispersion of color distribution; a larger value indicates poorer overall uniformity. The average gradient magnitude reflects the severity of color changes; a larger value indicates less stable color transitions on the fabric surface. Combining the two can comprehensively quantify the overall uniformity.
[0058] A sliding window method is used to traverse the color purity feature image to generate a local non-uniformity heatmap. The sliding window size is set to 15x15, and the window traverses the entire feature image pixel by pixel with a step size of 1. For each local area covered by the window, the variance of all pixel feature values within that area is calculated, and this variance value is used as the local non-uniformity measure of the central pixel of the window. After traversal, the local non-uniformity measures of all pixels are mapped to an image according to grayscale, i.e., the local non-uniformity heatmap. The higher the measure value, the brighter the corresponding grayscale level, corresponding to the location of potential color non-uniformity defects. Taking the dyed fabric of gardenia (a traditional Chinese medicine) as an example, the local variance of the stained area is significantly higher than that of the surrounding uniform area, appearing as bright spots in the heatmap, intuitively indicating the range of defects. This method can accurately capture subtle local color differences, avoiding the omission of small-area stained defects.
[0059] Automatic segmentation and localization of defect regions are performed on heatmaps with localized non-uniformity. First, the Otsu threshold segmentation algorithm is used to binarize the heatmap. This algorithm automatically calculates the optimal threshold, dividing the heatmap into foreground (defect region) and background (uniform region), resulting in an initial defect mask. Morphological operations are then performed on the initial defect mask: a dilation operation (using a 3x3 rectangle as the structuring element) connects adjacent small defect regions, followed by an erosion operation to eliminate noise points and small false defects, resulting in an optimized defect mask. Connected component analysis is then used to process the optimized defect mask, marking the contour of each independent connected component and calculating the area (number of pixels) and center coordinates of each component (the x-axis is the average of the x-coordinates of all pixels in the connected component, and the y-axis is the average of the y-coordinates of all pixels in the connected component), forming a defect attribute list. This step achieves automatic identification and precise localization of defect regions without manual intervention and accurately obtains key defect attributes, providing a concrete basis for quality assessment and process adjustment.
[0060] In one embodiment, the step of generating and outputting the detection results, which include uniformity level determination and a visual defect report, includes: S51. Establish a uniformity level judgment rule based on the overall quantitative index, and compare the dye distribution standard deviation and average gradient amplitude with the preset multi-level threshold range. The judgment rule is as follows: when the dye distribution standard deviation and average gradient amplitude do not exceed the first level threshold, the uniformity level is judged as excellent; when either or both exceed the first level threshold but do not exceed the second level threshold, the uniformity level is judged as good; when either exceeds the second level threshold, the uniformity level is judged as unqualified. S52. Generate a visual inspection report that integrates the original image, processing process and quantification results. The report includes: the original image of the fabric to be tested, the color purity feature image, the local non-uniformity heat map, and the outline of the defect area located above, which is superimposed on the original image. At the same time, the report lists the specific values of the overall uniformity level, dye distribution standard deviation and average gradient amplitude in text form, as well as the attribute information of each defect area. S53. The judgment results and the visual inspection report are displayed through the system interface. At the same time, the structured inspection result data, including uniformity level, quantitative index value and defect attribute list, are output through the application programming interface in a preset data format for the production management system or quality traceability system to call.
[0061] As described in steps S51-S53 above, through the continuous steps of comprehensive uniformity level determination, visualization report synthesis, result output and system integration, the overall uniformity quantitative index and defect area location information are transformed into intuitive and standardized test results. This not only achieves accurate grading of dyeing uniformity, but also provides directly applicable data support and visualization basis for production quality control and process adjustment.
[0062] The quality assessment of Chinese herbal dyed textiles needs to take into account both qualitative grading and quantitative data support. At the same time, it needs to meet the dual requirements of intuitive viewing by on-site staff and data integration with the production management system. If the test results only output a single data or simple judgment, it will be difficult for staff to quickly understand the problem and will not be able to be effectively integrated with the existing production management system, affecting the practicality and implementation of the test results. Therefore, it is necessary to establish a systematic result generation and output process to achieve the delivery of test results with clear grades, comprehensive information, and compatible interfaces.
[0063] A uniformity rating system based on overall quantitative indicators was established, with two preset threshold levels. The first threshold level has a dye distribution standard deviation of 5.0 and an average gradient amplitude of 3.0, while the second threshold level has a dye distribution standard deviation of 8.0 and an average gradient amplitude of 5.0. These two threshold levels were determined through statistical analysis of a large amount of test data collected from various types of Chinese herbal dyed textiles (including cotton, linen, silk, and dyes from herbs such as gardenia and isatis root). This system can cover most uniformity scenarios in Chinese herbal dyeing. The calculated dye distribution standard deviation and average gradient amplitude were compared with the preset threshold ranges, and the following rating rules were applied: when both do not exceed the first threshold level, the uniformity rating is excellent; when any one or both exceed the first threshold level but do not exceed the second threshold level, the uniformity rating is good; and when any one exceeds the second threshold level, the uniformity rating is unacceptable. Taking cotton plain weave fabric dyed with the traditional Chinese medicine gardenia as an example, if the standard deviation of the dye distribution is 8.5 and the average gradient amplitude is 4.0, the uniformity level is judged as unqualified because the standard deviation of the dye distribution exceeds the second-level threshold. If the standard deviation of the dye distribution is 6.0 and the average gradient amplitude is 2.5, it does not exceed the second-level threshold but exceeds the first level, and is judged as good. If both are 4.0 and 2.0 respectively, neither exceeds the first level, and is judged as excellent. Through clear quantitative thresholds and judgment logic, the objectivity and consistency of uniformity level judgment are ensured, avoiding errors caused by subjective evaluation.
[0064] This report presents a comprehensive and visually integrated inspection report that combines the original image, processing details, and quantification results. It includes the original image of the fabric under test, a color purity feature image, a local non-uniformity heatmap, and the outlines of the located defect areas superimposed on the original image. The text section lists the overall uniformity level, the standard deviation of dye distribution, and the average gradient amplitude, as well as the attribute information of each defect area, including the defect outline coordinates, area (in pixels), and center coordinates. For the above-mentioned unqualified cotton plain weave fabric dyed with gardenia fruit, the report clearly presents the three color spot defect boxes superimposed on the original image, the abrupt changes in the feature values of the color spot areas in the color purity feature image, the corresponding bright spot areas in the local non-uniformity heatmap, and the text label indicating an unqualified level, a dye distribution standard deviation of 8.5, an average gradient amplitude of 4.0, and the specific area and center coordinates of each color spot. This report intuitively integrates key information from the entire inspection process, facilitating staff to quickly locate the specific location and severity of dyeing non-uniformity issues.
[0065] The system integrates and outputs results. The judgment results and visual inspection reports are displayed intuitively through the system interface for on-site staff to view immediately. Simultaneously, structured inspection result data is output in JSON format via an application programming interface (API). This structured data includes uniformity level, dye distribution standard deviation, average gradient amplitude, number of defects, and attribute information for each defect area (outline coordinate array, area value, center coordinate value). This application adopts a standardized JSON format design, ensuring that the production management system or quality traceability system can directly parse and access the data, achieving seamless integration of inspection results with the production process and quality traceability system. For example, the quality traceability system can obtain data through the interface, associating and storing the inspection results with the fabric's production batch and dyeing process parameters. When subsequent quality problems occur, the cause can be quickly traced. The production management system can automatically trigger process adjustment prompts based on the uniformity level and defect information, guiding staff to optimize dyeing parameters and improve production quality.
[0066] like Figure 2 As shown, the present invention also discloses a system for detecting the uniformity of color staining in traditional Chinese medicine, comprising: The acquisition module 1 is used to acquire the original RGB image of the dyed textile of the Chinese herbal medicine to be tested under controlled lighting conditions, and to acquire the effective fabric area image based on the original RGB image. Extraction module 2 is used to perform frequency domain transformation on the effective fabric region image, and separate and extract prior information of texture energy distribution that characterizes the inherent weave structure of the fabric; Module 3 is used to construct a multi-spatial-level image sequence and, together with the prior information of the texture energy distribution, input it into a pre-trained texture-color decoupling neural network model. The neural network model is used to output a color purity feature image that suppresses texture interference. The calculation module 4 is used to perform spatial statistical analysis on the color purity feature image, calculate the overall uniformity quantification index, generate a local non-uniformity heat map and form a defect list to locate the defect area. Output module 5 is used to integrate the overall uniformity quantification index and defect area location information to generate and output detection results including uniformity level judgment and visual defect report.
[0067] In one embodiment, the extraction module includes: The conversion unit is used to convert the effective fabric region image to a specific color space channel that is sensitive to the physical structure of the fabric, and generate an initial texture feature image. The analysis unit is used to analyze the color distribution characteristics of the effective fabric area image and calculate the dye penetration uniformity index, which is used to quantify the degree of modulation of the original fabric texture visibility by the dyeing process. The first transformation unit is used to perform frequency domain transformation on the initial texture feature image to obtain the power spectrum. Based on the theoretical texture fundamental frequency determined by the known warp and weft yarn density of the fabric and the dye penetration uniformity index, the parameters of the bandpass filter are dynamically set together to filter the power spectrum in order to suppress color interference and enhance the texture signal. The second transformation unit is used to perform inverse transformation on the filtered spectrum to obtain the spatial domain texture response map. The generation unit is used to perform adaptive normalization processing on the texture response map by combining the dye penetration uniformity index, generate a texture energy prior image, and use the texture energy prior image as prior information on texture energy distribution.
[0068] This application also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps of the above-described method for detecting the uniformity of coloring in traditional Chinese medicine.
[0069] This application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the above-described method for detecting the uniformity of coloring in traditional Chinese medicine.
[0070] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments of the above methods. Any references to memory, storage, databases, or other media used in this application and in the embodiments can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual-speed SDRAM (SSRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), RAMbus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0071] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, apparatus, article, or method that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, apparatus, article, or method. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, apparatus, article, or method that includes that element.
[0072] The above description is merely a preferred embodiment of the present invention and does not limit the scope of this application. Any equivalent results or equivalent process transformations made based on the content of the present invention's specification and drawings, or direct or indirect applications in other related technical fields, are similarly included within the scope of protection of this application.
Claims
1. A method for detecting the uniformity of color in traditional Chinese medicine staining, characterized in that, Includes the following steps: Under controlled lighting conditions, the original RGB image of the dyed textile product made from Chinese herbal medicine was acquired, and the effective fabric area image was obtained based on the original RGB image. The effective fabric region image is subjected to frequency domain transformation to separate and extract prior information on texture energy distribution that characterizes the inherent weave structure of the fabric. A multi-spatial-level image sequence is constructed and, together with the prior information of the texture energy distribution, is input into a pre-trained texture-color decoupling neural network model. The neural network model is used to output a color purity feature image that suppresses texture interference. Spatial statistical analysis is performed on the color purity feature image to calculate the overall uniformity quantification index, and a local non-uniformity heat map is generated to form a defect list in order to locate the defect area. By combining the overall uniformity quantification index and defect area location information, the detection results, including uniformity level determination and visual defect report, are generated and output.
2. The method for detecting the uniformity of traditional Chinese medicine staining according to claim 1, characterized in that, The step of acquiring an image of the effective fabric region includes: Obtain the original RGB image of the fabric to be tested; The original RGB image is subjected to color correction and illumination compensation to obtain a preprocessed image; The preprocessed image is analyzed to identify non-uniform shadow areas caused by physical deformation of the fabric surface, and the intensity of its morphological shadow interference is estimated. Based on the intensity of the morphological shadow interference, an adaptive surface morphology compensation coefficient map is generated. The surface morphology compensation coefficient map is used to enhance and suppress the preprocessed image to compensate for the influence of physical deformation on color perception and generate an optimized image. The continuous effective regions, excluding areas with high topographic interference, are automatically selected as the effective fabric region image.
3. The method for detecting the uniformity of traditional Chinese medicine staining according to claim 1, characterized in that, The step of separating and extracting prior information on texture energy distribution characterizing the inherent weave structure of the fabric includes: The effective fabric region image is converted to a specific color space channel that is sensitive to the physical structure of the fabric, and an initial texture feature image is generated. The color distribution characteristics of the effective fabric area image are analyzed, and the dye penetration uniformity index is calculated. The dye penetration uniformity index is used to quantify the degree to which the dyeing process modulates the visibility of the original fabric texture. The power spectrum is obtained by performing frequency domain transformation on the initial texture feature image. Based on the theoretical texture fundamental frequency determined by the known warp and weft yarn density of the fabric and the dye penetration uniformity index, the parameters of the bandpass filter are dynamically set together to filter the power spectrum, so as to suppress color interference and enhance the texture signal. The filtered spectrum is inversely transformed to obtain the spatial domain texture response map; The texture response map is adaptively normalized by combining the dye penetration uniformity index to generate a texture energy prior image, and the texture energy prior image is used as the prior information of texture energy distribution.
4. The method for detecting the uniformity of traditional Chinese medicine staining according to claim 3, characterized in that, The step of outputting a color purity feature image that suppresses texture interference includes: Based on the image of the effective fabric region, a multi-spatial-level image sequence is constructed by downsampling; The images at each scale in the multi-spatial-level image sequence are fused with the texture energy prior image to form fused input features; The fused input features are then fed into a pre-trained neural network model based on an encoder-decoder architecture. Obtain the color purity feature image output by the neural network model, which has the same size as the input image.
5. The method for detecting the uniformity of traditional Chinese medicine staining according to claim 1, characterized in that, The steps of generating a local non-uniformity thermal map and forming a defect list include: Calculate the standard deviation of dye distribution and the average gradient magnitude of the color purity feature image as the overall uniformity quantification index; The local variance of the color purity feature image is calculated using the sliding window method, and a local non-uniformity heatmap is generated by mapping. The local non-uniformity heatmap is subjected to image segmentation and connected component analysis to extract the contour and attribute information of the defect region and form a defect list.
6. The method for detecting the uniformity of traditional Chinese medicine staining according to claim 5, characterized in that, The steps of generating a local non-uniformity thermal map and forming a defect list include: The uniformity level is determined by comparing the standard deviation and average gradient amplitude of the dye distribution with a preset threshold. A composite visual defect report is generated, which integrates the effective fabric area image, color purity feature image, local non-uniformity heat map, and overlaid defect outline; The uniformity level, overall uniformity quantification index, defect list, and visual defect report are displayed and output in a structured manner.
7. A system for detecting the uniformity of color staining in traditional Chinese medicine, characterized in that, include: The acquisition module is used to acquire the original RGB image of the dyed textile of Chinese medicine to be tested under controlled lighting conditions, and to acquire the effective fabric area image based on the original RGB image. The extraction module is used to perform frequency domain transformation on the effective fabric region image, and separate and extract prior information on texture energy distribution that characterizes the inherent weave structure of the fabric. The construction module is used to construct a multi-spatial-level image sequence, and together with the prior information of the texture energy distribution, input it into a pre-trained texture-color decoupling neural network model. The neural network model is used to output a color purity feature image that suppresses texture interference. The calculation module is used to perform spatial statistical analysis on the color purity feature image, calculate the overall uniformity quantification index, generate a local non-uniformity heat map and form a defect list to locate defect areas. The output module is used to integrate the overall uniformity quantification index and defect area location information to generate and output the detection results, which include uniformity level judgment and visual defect report.
8. The traditional Chinese medicine staining uniformity detection system according to claim 7, characterized in that, The extraction module includes: The conversion unit is used to convert the effective fabric region image to a specific color space channel that is sensitive to the physical structure of the fabric, and generate an initial texture feature image. The analysis unit is used to analyze the color distribution characteristics of the effective fabric area image and calculate the dye penetration uniformity index, which is used to quantify the degree of modulation of the original fabric texture visibility by the dyeing process. The first transformation unit is used to perform frequency domain transformation on the initial texture feature image to obtain the power spectrum. Based on the theoretical texture fundamental frequency determined by the known warp and weft yarn density of the fabric and the dye penetration uniformity index, the parameters of the bandpass filter are dynamically set together to filter the power spectrum in order to suppress color interference and enhance the texture signal. The second transformation unit is used to perform inverse transformation on the filtered spectrum to obtain the spatial domain texture response map. The generation unit is used to perform adaptive normalization processing on the texture response map by combining the dye penetration uniformity index, generate a texture energy prior image, and use the texture energy prior image as prior information on texture energy distribution.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 6.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6.