A method for analyzing the trash content of spinning yarn
By correcting the grayscale value of each pixel point in the cotton surface image, the contrast between the impurity area and the cotton is enhanced, and the accuracy problem of traditional algorithms when identifying the color yellow cotton as impurities is solved, achieving high-precision impurities High quality of analytical and spinning products.
Patent Information
- Application Number
- CN202411471113.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-22
- Publication Date
- 2025-02-25
- Estimated Expiration
- 2044-10-22
AI Technical Summary
When segmenting cotton surface images, the traditional Otsu threshold algorithm may mistakenly identify normal cotton with yellowish color as impurities, resulting in a decrease in the accuracy of impurities recognition.
A method for spinning miscellaneous content analysis is proposed. By obtaining the possibility that each pixel point is a pixel point in the impurity area, the grayscale value correction weight of each pixel point is calculated, and the grayscale value of each pixel point is corrected. , enhance the contrast between the impurity region and cotton, thereby improving the segmentation accuracy of the threshold segmentation algorithm.
Accurate segmentation and quantitative detection of impurity areas are achieved, the accuracy of impurity content analysis is improved, and the high quality of spinning products is ensured.
Smart Images

Figure CN119006450B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image processing, and more specifically, to a method for analyzing the trash content of spinning yarn. Background Art
[0002] In the textile industry, spinning is a key production link, and its quality directly affects the quality and market competitiveness of subsequent fabrics. The principle of spinning is to convert cotton into slender and continuous yarn through a series of mechanical operations. Therefore, in the production process of spun products, the quality of cotton raw materials is crucial and directly affects the quality of the final product. In the process of cotton collection, transportation and preliminary processing, impurities such as dead leaves will inevitably be mixed in. If these impurities are not effectively removed, the quality of spun products will be seriously affected. Therefore, the present invention detects the impurity area in the cotton to estimate the quality after the spinning. If there are more impurities in the cotton, the cotton cannot be used for spinning production.
[0003] The patent application document with the publication number CN118279339A currently discloses a corn leaf spot image segmentation method based on the improved Otsu algorithm. The method comprises the following steps: graying the image to obtain a grayscale image; performing threshold statistics on the grayscale image to obtain all threshold distributions of the grayscale image; using the Otsu algorithm to select thresholds to obtain all thresholds suitable for image segmentation; using the improved rime optimization algorithm to screen all thresholds suitable for image segmentation to obtain the optimal threshold for image segmentation; calculating the maximum inter-class variance of the optimal threshold; using the threshold of the maximum inter-class variance as the image segmentation threshold, segmenting the obtained grayscale image, and outputting the segmentation result.
[0004] The traditional Otsu threshold algorithm selects a segmentation threshold to segment the cotton surface image into two parts, the impurity area and the cotton area, based on the grayscale distribution characteristics in the cotton surface image. However, due to the quality problems of cotton itself (such as different varieties, different maturity, cotton mildew caused by humid weather, etc.), some colors may be yellowish or darker, which is similar to the color of impurities such as dead leaves. Therefore, when using the Otsu threshold algorithm to segment the cotton surface image, normal cotton with a yellowish color may be mistakenly identified as impurities, thereby reducing the accuracy of impurity identification. Summary of the invention
[0005] In order to solve the problem that when the Otsu threshold algorithm is used to segment the cotton surface image, normal cotton with a yellowish color may be mistakenly identified as impurities, thereby reducing the accuracy of impurity identification, the present invention proposes a spinning trash content analysis method, which includes the following steps:
[0006] Collect cotton surface images; obtain the gray value characteristics of each pixel in the cotton surface image; obtain the possibility that each pixel is a pixel in the impurity area:
[0007] , Represents the possibility that the i-th pixel is a pixel in the impurity area; Represents the gray value feature of the i-th pixel; Represents the number of pixels in the surrounding area of the i-th pixel; Represents the gradient direction of the kth pixel in the surrounding area of the i-th pixel; Represents the mean value of the gradient direction of all pixels in the surrounding area of the i-th pixel; norm() represents the normalization function;
[0008] Get the gray value correction weight of each pixel , Represents the gray value of the i-th pixel; represents a round-up symbol; obtaining a corrected grayscale value for each pixel, wherein the corrected grayscale value is the difference between the grayscale value of the pixel and the grayscale value correction weight; using an image composed of the corrected grayscale values of all pixels as an enhanced image; segmenting the enhanced image to obtain the number of pixels in the impurity area; obtaining the percentage of impurity content based on the number of pixels in the impurity area; and determining the quality of the cotton based on the percentage of impurity content.
[0009] The innovation of the present invention lies in obtaining a grayscale value correction weight for each pixel point according to the possibility that each pixel point is a pixel point in the impurity area, and correcting the grayscale value of each pixel point according to the grayscale value correction weight. This correction helps to enhance the contrast between the impurity area and the cotton, thereby improving the segmentation accuracy of the threshold segmentation algorithm, and can accurately segment the impurity area. Finally, combined with the quantification of the percentage of impurity content, quantitative detection of impurities is achieved, effectively solving the problem of difficulty in distinguishing from the impurity area due to quality problems of the cotton itself, improving the accuracy of impurity content analysis, and helping enterprises to better manage and optimize the cotton processing process to ensure the high quality of the final spinning products.
[0010] Preferably, the step of obtaining the grayscale value feature of each pixel in the cotton surface image includes:
[0011] ;
[0012] In the formula, Represents the gray value feature of the i-th pixel; Represents the gray value of the i-th pixel; Represents the number of pixels in the eight-neighborhood of the i-th pixel; Represents the grayscale value of the jth pixel in the eight-neighborhood of the i-th pixel; norm() represents the normalization function.
[0013] The larger the gray value feature is, the more likely it is an impurity region, which makes it easier to obtain the possibility that each pixel is an impurity region pixel based on the gray value feature.
[0014] Preferably, obtaining the surrounding area of the pixel includes:
[0015] Each pixel point in the cotton surface image and the eight neighboring pixels of each pixel point are regarded as the surrounding area of each pixel point.
[0016] Preferably, segmenting the enhanced image to obtain the number of pixels in the impurity area includes:
[0017] The enhanced image is segmented using the Otsu threshold method to obtain a segmentation threshold. The number of pixels in the enhanced image that are smaller than the segmentation threshold is recorded as the number of pixels in the impurity region.
[0018] It is convenient to obtain the impurity content percentage later.
[0019] Preferably, the obtaining of the percentage of impurity content includes:
[0020] ;
[0021] In the formula, represents the percentage of impurity content; D represents the number of pixels in the impurity area; C represents the number of pixels in the enhanced image.
[0022] This makes it easier to judge the cotton quality based on the percentage of impurity content.
[0023] Preferably, the cotton quality is determined according to the percentage of impurity content, including:
[0024] A percentage threshold W is preset. If the percentage of the impurity content is greater than the percentage threshold, the cotton contains too many impurities and cannot be used for spinning.
[0025] Improving the accuracy of the percentage of impurity content helps companies better manage and optimize the cotton processing process and ensure the high quality of the final spinning products.
[0026] Preferably, the acquisition of the gradient direction of the pixel point includes:
[0027] Use the Sobel operator to get the gradient direction of each pixel.
[0028] Preferably, collecting the cotton surface image includes:
[0029] In an environment with uniform lighting, an industrial camera is used to shoot the cotton surface to obtain an RGB image of the cotton surface. The collected RGB image of the cotton surface is gray-scaled to obtain a cotton surface image.
[0030] The present invention has the following beneficial effects: the purpose of the present invention is to obtain the grayscale value correction weight of each pixel point according to the possibility that each pixel point is a pixel point of the impurity area, and to correct the grayscale value of each pixel point according to the grayscale value correction weight. This correction helps to enhance the contrast between the impurity area and the cotton, thereby improving the segmentation accuracy of the threshold segmentation algorithm, and can accurately segment the impurity area. Finally, combined with the quantification of the percentage of the impurity content, the quantitative detection of impurities is realized, the accuracy of the impurity content analysis is improved, and the high quality of the final spinning product is ensured. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] By reading the following detailed description with reference to the accompanying drawings, the above and other objects, features and advantages of the exemplary embodiments of the present invention will become readily understood. In the accompanying drawings, several embodiments of the present invention are shown in an exemplary and non-limiting manner, and the same or corresponding reference numerals represent the same or corresponding parts, wherein:
[0032] Figure 1 The present invention is a flowchart of the steps of a spinning trash content analysis method according to an embodiment of the present invention. DETAILED DESCRIPTION
[0033] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0034] The specific embodiments of the present invention are described in detail below with reference to the accompanying drawings.
[0035] See also Figure 1 , which shows a flowchart of a method for analyzing the content of impurities in spinning provided by an embodiment of the present invention, the method comprising the following steps:
[0036] S001. Collect cotton surface images.
[0037] In an embodiment of the present invention, in an environment with uniform lighting, an industrial camera is used to shoot the cotton surface to obtain an RGB image of the cotton surface. To facilitate subsequent analysis, the collected RGB image of the cotton surface is grayed to obtain the cotton surface image.
[0038] S002. Obtain the gray value feature of each pixel in the cotton surface image, and obtain the possibility that each pixel is a pixel in the impurity area according to the gray value feature of each pixel.
[0039] It should be noted that in the production process of spinning products, the quality of cotton raw materials is crucial and directly affects the quality of the final product. In the process of cotton collection, transportation and preliminary processing, impurities such as dead leaves will inevitably be mixed in. If these impurities are not effectively removed, they will seriously affect the quality of spinning products. The traditional Otsu threshold algorithm selects a segmentation threshold to segment the cotton surface image into two parts: the target area and the background area based on the grayscale distribution characteristics in the cotton surface image. However, due to the quality problems of cotton itself (such as different varieties, different maturity, cotton mildew caused by humid weather, etc.), some colors may be yellowish or darker, which is similar to the color of impurities such as dead leaves. Therefore, when using the Otsu threshold algorithm to segment the cotton surface image, normal cotton with a yellowish color may be mistakenly identified as impurities, thereby reducing the accuracy of impurity identification.
[0040] It should be noted that due to the mechanical picking process, the surface of raw cotton is often stuck with impurities such as dead leaves and leaf residues. These impurities are often darker in color than the cotton itself. In the grayscale image, the grayscale value corresponding to the darker color area will be smaller. Therefore, the smaller the grayscale value of any pixel in the cotton surface image, the more likely this pixel is located in the darker impurity area. Impurities are often not a single pixel, but a small area. If there are similar pixels around the pixel, that is, the grayscale values of the pixel and its eight neighboring pixels are relatively small and the difference is not large, it means that the pixel is more likely to be an impurity area. Therefore, the grayscale value of each pixel is combined with the grayscale value of its eight neighboring pixels to obtain the grayscale value characteristics of each pixel in the cotton surface image.
[0041] In the embodiment of the present invention, the gray value feature of each pixel in the cotton surface image is obtained:
[0042] ;
[0043] In the formula, Represents the gray value feature of the i-th pixel; Represents the gray value of the i-th pixel; Represents the number of pixels in the eight-neighborhood of the i-th pixel; Represents the gray value of the jth pixel in the eight-neighborhood of the i-th pixel; norm() represents the normalization function; The smaller the value of is, the darker the color of the i-th pixel is, which may be the pixel in the impurity area; Represents the mean of the absolute values of the differences between the grayscale values of the ith pixel and all the pixels in its eight neighborhoods. The smaller the value, the smaller the grayscale value of the ith pixel is, the smaller the difference between the grayscale value of the ith pixel and other pixels in its eight neighborhoods. The larger the grayscale value of the ith pixel is, the darker the color of this small area is, which means that the ith pixel is more likely to be an impurity area.
[0044] It should be noted that in actual scenarios, since cotton itself may present different colors due to factors such as variety, maturity, and growth environment, such as yellow or light yellow cotton of uneven quality, the cotton collected during the process may contain such cotton, that is, there is a cotton area in the cotton surface image that has no obvious grayscale value difference from the impurity area, resulting in the impurity area being unable to be extracted based only on the grayscale value feature of each pixel point obtained; and since the texture of the impurity area is often different from that of the cotton area itself, this difference may be manifested as the roughness of the impurity surface, irregularity of shape, and changes in color depth, resulting in the grayscale value distribution of the impurity area in the cotton surface image being different from that of the cotton area, that is, the roughness and irregularity of the impurity area surface usually lead to greater grayscale changes in the impurity area, resulting in a large difference in the gradient direction between the pixels in the impurity area, while the connection between cotton fibers is usually continuous, which means that the direction of the fibers in the cotton area is relatively consistent, and the gradient direction between the pixels in the cotton area is also relatively consistent. Therefore, according to the gradient direction of the pixels in the surrounding area of each pixel point and the grayscale value feature of each pixel point, the possibility of each pixel point being a pixel point in the impurity area is obtained.
[0045] In the embodiment of the present invention, the Sobel operator is used to obtain the gradient direction of each pixel point; each pixel point in the cotton surface image and the eight neighboring pixel points of each pixel point are used as the surrounding area of each pixel point.
[0046] Get the probability that each pixel is an impurity area pixel:
[0047] ;
[0048] In the formula, Represents the possibility that the i-th pixel is a pixel in the impurity area; Represents the gray value feature of the i-th pixel; Represents the number of pixels in the surrounding area of the i-th pixel; Represents the gradient direction of the kth pixel in the surrounding area of the i-th pixel; Represents the mean value of the gradient direction of all pixels in the surrounding area of the i-th pixel; norm() represents the normalization function; The larger the value of , the larger the deviation between the gradient direction of some pixels and the mean gradient direction of all pixels in the surrounding area of the i-th pixel is, which means that the gradient direction difference of the pixels in the surrounding area of the i-th pixel is large, indicating that the i-th pixel is more likely to be a pixel in the impurity area; The larger the value of , the more likely it is that the i-th pixel is an impurity area.
[0049] S003. Correct the grayscale value of each pixel in the cotton surface image according to the possibility that each pixel is a pixel in the impurity area, obtain the corrected grayscale value of each pixel, and obtain an enhanced image according to the corrected grayscale value of each pixel.
[0050] It should be noted that due to the quality problem of cotton itself, some colors may be unevenly distributed, such as local yellowish or light yellow, which makes the grayscale value of cotton area different. The traditional Otsu algorithm selects the optimal threshold for image segmentation based on the grayscale distribution of cotton surface image. It may mistakenly identify the normal cotton area with yellowish color as impurity area due to the difference of this part of grayscale value. Therefore, before impurity detection, it is necessary to correct the grayscale value of each pixel point based on the possibility that each pixel point is the pixel point of impurity area. The grayscale value of the pixel point of impurity area is adjusted to be smaller, and the grayscale value of cotton area is adjusted to be larger. The contrast between impurity area and cotton area can be further enhanced, so as to better separate impurity area and background cotton area.
[0051] In an embodiment of the present invention, the corrected grayscale value of each pixel is obtained:
[0052] ;
[0053] In the formula, Represents the gray value of the i-th pixel; Represents the corrected gray value of the i-th pixel; Represents the possibility that the i-th pixel is a pixel in the impurity area; Represents the rounding symbol; Represents the grayscale value correction weight of the ith pixel; if the possibility that the ith pixel is a pixel in the impurity area is greater, the grayscale value correction weight of the ith pixel is positive, and the grayscale value of the pixel needs to be reduced to enhance the contrast between the impurity area and the cotton area; if the possibility that the ith pixel is a pixel in the impurity area is smaller, the grayscale value correction weight of the ith pixel is negative, and the grayscale value of the pixel needs to be increased to enhance the contrast between the impurity area and the cotton area.
[0054] The enhanced image is obtained according to the corrected gray value of each pixel.
[0055] S004. After segmenting the enhanced image, obtain the percentage of impurity content.
[0056] In the embodiment of the present invention, the enhanced image is segmented using the Otsu threshold method to obtain a segmentation threshold, and the number of pixels in the enhanced image that are smaller than the segmentation threshold is recorded as the number of pixels in the impurity region.
[0057] Get the percentage of impurity content:
[0058] ;
[0059] In the formula, represents the percentage of impurity content; D represents the number of pixels in the impurity area; C represents the number of pixels in the enhanced image.
[0060] A percentage threshold W is preset. If the percentage of the impurity content is greater than the percentage threshold, it means that the current cotton contains too many impurities and cannot be used for spinning. In an embodiment of the present invention, the preset percentage threshold W=50%. In other embodiments, the implementer can preset the value of the percentage threshold W according to the specific implementation method.
[0061] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the principles of the present invention should be included in the protection scope of the present invention.
Claims
1. A method for analyzing the content of spinning trash, characterized in that: include: Collecting cotton surface images; Get the gray value features of each pixel in the cotton surface image, including: ; Represents the gray value feature of the i-th pixel; Represents the gray value of the i-th pixel; Represents the number of pixels in the eight-neighborhood of the i-th pixel; Represents the grayscale value of the jth pixel in the eight-neighborhood of the i-th pixel; norm() represents the normalization function; obtains the possibility that each pixel is a pixel in the impurity area: , Represents the possibility that the i-th pixel is a pixel in the impurity area; Represents the number of pixels in the surrounding area of the i-th pixel; Represents the gradient direction of the kth pixel in the surrounding area of the i-th pixel; represents the mean value of the gradient direction of all pixels in the surrounding area of the i-th pixel; wherein each pixel in the cotton surface image and the eight neighboring pixels of each pixel are regarded as the surrounding area of each pixel; Get the gray value correction weight of each pixel ; represents a round-up symbol; obtaining a corrected grayscale value for each pixel, wherein the corrected grayscale value is the difference between the grayscale value of the pixel and the grayscale value correction weight; using an image composed of the corrected grayscale values of all pixels as an enhanced image; segmenting the enhanced image to obtain the number of pixels in the impurity area; obtaining the percentage of impurity content based on the number of pixels in the impurity area; and determining the quality of the cotton based on the percentage of impurity content.
2. A spinning trash content analysis method according to claim 1, characterized in that: The step of segmenting the enhanced image to obtain the number of pixels in the impurity area includes: The enhanced image is segmented using the Otsu threshold method to obtain a segmentation threshold. The number of pixels in the enhanced image that are smaller than the segmentation threshold is recorded as the number of pixels in the impurity region.
3. A spinning trash content analysis method according to claim 1, characterized in that: The obtaining of the percentage of impurity content comprises: ; In the formula, represents the percentage of impurity content; D represents the number of pixels in the impurity area; C represents the number of pixels in the enhanced image.
4. A spinning trash content analysis method according to claim 1, characterized in that: The method of determining the cotton quality according to the percentage of impurity content includes: A percentage threshold W is preset. If the percentage of the impurity content is greater than the percentage threshold, the cotton contains too many impurities and cannot be used for spinning.
5. The method for analyzing the spinning trash content according to claim 1, characterized in that: The acquisition of the gradient direction of the pixel point includes: Use the Sobel operator to get the gradient direction of each pixel.
6. A spinning trash content analysis method according to claim 1, characterized in that: The collecting of cotton surface images comprises: In an environment with uniform lighting, an industrial camera is used to shoot the cotton surface to obtain an RGB image of the cotton surface. The collected RGB image of the cotton surface is gray-scaled to obtain a cotton surface image.
Citation Information
Patent Citations
Corn leaf scab image segmentation method based on improved Otsu algorithm
CN118279339A
Geosynthetic fabric quality detection system
CN116309671A