Method and system for detecting inclusion rate of cotton, electronic device, storage medium
By binarizing the cotton bale image and segmenting the circular region, the problem of detecting the impurity content of the cotton bale in its entirety was solved, achieving efficient and accurate detection of the impurity content of the cotton bale, and improving production efficiency and data analysis capabilities.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- CHINA RAILWAY CONSTR HEAVY IND
- Filing Date
- 2023-07-26
- Publication Date
- 2026-07-07
AI Technical Summary
Existing technologies make it difficult to accurately detect impurity content while keeping the cotton bales intact during the baling process, resulting in low production efficiency and increased labor costs.
By acquiring images of cotton bales, converting them into binary images, extracting the target region, and dividing it into annular regions layer by layer, the impurity content of each annular region is calculated using image segmentation technology, and finally the average impurity content of the cotton bales is calculated.
It enables efficient and accurate detection of impurity content while the cotton bales are intact, improving detection efficiency and providing quality analysis data support for various harvesting areas in cotton fields.
Smart Images

Figure CN117173197B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of cotton impurity detection technology, and in particular to a method and system for detecting cotton impurity, an electronic device, and a computer-readable storage medium. Background Technology
[0002] Cotton, as one of my country's major economic crops, is gradually transitioning from manual to machine harvesting. Simultaneously, the harvesting machines are shifting from box-type cotton harvesters to cotton balers, improving production efficiency. However, regardless of whether it's manual or machine harvesting, impurities such as cotton branches and boll husks will inevitably be mixed in to varying degrees. The impurity content is one of the quality evaluation indicators for cotton harvesters and an important basis for intelligent control of cotton harvesters to reduce impurity content. Furthermore, the impurity content is also an important indicator for cotton quality evaluation and a crucial basis for cotton transaction settlement. Currently, some methods exist for detecting cotton impurity content, such as image processing technology, support vector machines, and deep learning models. For example, patent CN113658143A discloses a method and system for detecting the impurity content of machine-harvested seed cotton. This method extracts the saturation channel image of the impurity-containing image of machine-harvested seed cotton, uses the Canny algorithm to detect edges, performs morphological operations, and finally outputs the impurity content and image. However, these methods study scattered cotton and are based on images taken under fixed light sources in a laboratory setting. During cotton harvesting and baling operations, if loose cotton is needed, the bales must be unpacked and repacked. Each bale weighs approximately 1.5 tons, and unpacking and repackaging reduces production efficiency and increases labor costs. Therefore, how to detect impurities in the cotton bales while maintaining their integrity has become a pressing technical problem for cotton harvesters. Summary of the Invention
[0003] This invention provides a method and system for detecting the impurity content of cotton bales, an electronic device, and a computer-readable storage medium, so as to detect the impurity content of cotton bales while keeping the cotton bales intact.
[0004] According to one aspect of the present invention, a method for detecting the impurity content of cotton is provided, comprising the following:
[0005] Acquire images of cotton bales;
[0006] Convert the cotton bale image into a binary cotton bale image;
[0007] Extract the target region from the binary image of the cotton bale;
[0008] The target region is divided into several annular regions layer by layer, and the first binary image of each annular region is obtained;
[0009] Each annular region is converted into a color image, and the annular color images are segmented to obtain a second binary image of each annular region;
[0010] The impurity content of each annular region is calculated based on the first and second binary images of each annular region, and the average impurity content of the cotton bale is calculated based on the impurity content of each annular region.
[0011] Furthermore, the process of converting the cotton bale image into a binary cotton bale image specifically involves:
[0012] Extract a single-channel image of the cotton bale.
[0013] The segmentation threshold was determined by the maximum inter-class variance method, and the binary method was used to segment the B-channel image based on the segmentation threshold to obtain the initial binary image.
[0014] Perform texture filtering on the initial binary image;
[0015] The initial binary image after texture filtering is denoised to obtain the binary image of the cotton bale.
[0016] Furthermore, the process of extracting the target region from the binary image of the cotton bale specifically involves:
[0017] The centroid position is calculated based on the coordinates of all pixels in the foreground region of the binary image of the cotton bale.
[0018] The radius is calculated based on the average distance between all pixels on the edge contour line of the foreground region from the centroid.
[0019] Draw a circle with the center of gravity as the center and the calculated radius to obtain the target area.
[0020] Furthermore, the process of dividing the target area into several annular regions layer by layer is specifically as follows:
[0021] Construct an arithmetic sequence, take the radius value of the target region as the first term of the arithmetic sequence, set the common difference to a negative integer, iteratively calculate each term of the arithmetic sequence until the value of the new term is less than the absolute value of the common difference, take the two adjacent terms in the arithmetic sequence as the two radius values of the annulus, thus dividing the target region into several annular regions.
[0022] Furthermore, the impurity content of each annular region is calculated based on the following formula:
[0023]
[0024] Where s represents the impurity rate, sn represents the total number of pixels in the first binary image, and sm represents the total number of pixels in the second binary image.
[0025] Furthermore, the average impurity content of the cotton bale is calculated based on the following formula:
[0026]
[0027] in, The s represents the average impurity content of the cotton bales, where n represents the number of terms in the arithmetic sequence. i Let a represent the impurity content of the i-th annular region. n-1 and a n Let represent two adjacent terms in the arithmetic sequence corresponding to the i-th annular region.
[0028] Furthermore, after calculating the impurity content of each annular region, the following is also included:
[0029] By correlating the impurity content of each annular region with the cotton harvester's satellite positioning and mileage, the cotton field region corresponding to each impurity content can be obtained.
[0030] In addition, the present invention also provides a detection system for the impurity content of cotton, comprising:
[0031] The image acquisition module is used to acquire images of cotton bales;
[0032] The image conversion module is used to convert cotton bale images into binary cotton bale images;
[0033] The image extraction module is used to extract the target region from the binary image of the cotton bale;
[0034] The region segmentation module is used to divide the target region into several annular regions layer by layer, and obtain the first binary image of each annular region;
[0035] The image segmentation module is used to convert each annular region into a color image and segment the annular color image to obtain a second binary image of each annular region.
[0036] The impurity content calculation module is used to calculate the impurity content of each annular region based on the first binary image and the second binary image of each annular region, and to calculate the average impurity content of the cotton bale based on the impurity content of each annular region.
[0037] In addition, the present invention also provides an electronic device, including a processor and a memory, wherein the memory stores a computer program, and the processor executes the steps of the method described above by calling the computer program stored in the memory.
[0038] In addition, the present invention provides a computer-readable storage medium for storing a computer program for detecting the impurity rate of cotton, wherein the computer program executes the steps of the method described above when running on a computer.
[0039] The present invention has the following effects:
[0040] The method for detecting impurity content in cotton bales of the present invention first converts the color image of the cotton bale into a binary image after acquiring the image to distinguish the foreground and background regions. Then, the target region, which is the cotton bale itself, is extracted from the foreground region of the binary image. This accurately segments only the background and bale regions of the image, without segmenting the cotton and impurities within the bale region. Subsequently, based on the characteristic of the cotton bale being packed from the inside out, the target region is divided into several annular regions layer by layer, obtaining a first binary image for each annular region. Each first binary image contains the cotton and impurities within each annular region. The first binary image of each annular region is then converted back into a color image. By further segmenting the annular color image, a second binary image for each annular region is obtained, where the cotton and impurities are now segmented. Finally, the proportion of impurity pixels is calculated based on the first and second binary images corresponding to each annular region to obtain the impurity content of each annular region. The average impurity content of the cotton bale can then be calculated based on the impurity content of each annular region. The method for detecting impurity content in cotton bales of the present invention can detect impurity content in machine-harvested cotton while keeping the cotton bales intact, without removing the cotton from the bales, which greatly improves detection efficiency. Furthermore, it can accurately calculate the impurity content of multiple annular areas on the cotton bales, providing data support for analyzing the quality of different harvesting areas in cotton fields.
[0041] In addition, the cotton impurity detection system of the present invention also has the above-mentioned advantages.
[0042] In addition to the objectives, features, and advantages described above, the present invention has other objectives, features, and advantages. The invention will now be described in further detail with reference to the figures. Attached Figure Description
[0043] The accompanying drawings, which form part of this application, are used to provide a further understanding of the invention. The illustrative embodiments of the invention and their descriptions are used to explain the invention and do not constitute an undue limitation of the invention. In the drawings:
[0044] Figure 1 This is a flowchart illustrating a preferred embodiment of the method for detecting the impurity rate of cotton according to the present invention.
[0045] Figure 2 This is a schematic diagram of an image of a cotton bale acquired according to a preferred embodiment of the present invention.
[0046] Figure 3 yes Figure 1 A schematic diagram of the sub-process of step S2.
[0047] Figure 4 This is a schematic diagram of the initial binary image obtained in a preferred embodiment of the present invention.
[0048] Figure 5 This is a schematic diagram of the grayscale image of the cotton bale texture obtained in a preferred embodiment of the present invention.
[0049] Figure 6 This is a schematic diagram of the internal texture image of the cotton bag obtained in a preferred embodiment of the present invention.
[0050] Figure 7 This is a schematic diagram of the binary image of the cotton bale obtained in a preferred embodiment of the present invention.
[0051] Figure 8 yes Figure 1 A schematic diagram of the sub-process of step S3.
[0052] Figure 9 This is a schematic diagram of the binary image of the target region extracted in a preferred embodiment of the present invention.
[0053] Figure 10 This is a schematic diagram of the first binary image of a circular region obtained by dividing the target region layer by layer in a preferred embodiment of the present invention.
[0054] Figure 11 This is a schematic diagram of a circular color image obtained in a preferred embodiment of the present invention.
[0055] Figure 12 This is a schematic diagram of the second binary image of the annular region obtained in a preferred embodiment of the present invention.
[0056] Figure 13 This is a schematic diagram of the module structure of a cotton impurity detection system according to another embodiment of the present invention. Detailed Implementation
[0057] The embodiments of the present invention will be described in detail below with reference to the accompanying drawings. However, the present invention can be implemented in many different ways as defined and covered below.
[0058] Understandable, such as Figure 1 As shown, a preferred embodiment of the present invention provides a method for detecting the impurity content of cotton, comprising the following:
[0059] Step S1: Acquire images of the cotton bales;
[0060] Step S2: Convert the cotton bale image into a binary cotton bale image;
[0061] Step S3: Extract the target region from the binary image of the cotton bale;
[0062] Step S4: Divide the target region into several annular regions layer by layer to obtain the first binary image of each annular region;
[0063] Step S5: Convert each annular region into a color image, and segment the annular color image to obtain a second binary image of each annular region;
[0064] Step S6: Calculate the impurity content of each annular region based on the first binary image and the second binary image of each annular region, and calculate the average impurity content of the cotton bale based on the impurity content of each annular region.
[0065] It is understood that the cotton bale impurity detection method in this embodiment first converts the color cotton bale image into a binary image after acquiring the cotton bale image to distinguish the foreground and background regions in the cotton bale image. Then, the target region is extracted from the foreground region of the cotton bale binary image, and the target region is the cotton bale itself. This accurately segments only the background region and the cotton bale region in the cotton bale image, without segmenting the cotton and impurities within the cotton bale region. Subsequently, based on the characteristic of the cotton bale being packed from the inside out, the target region is divided into several annular regions layer by layer, obtaining a first binary image for each annular region. Each first binary image contains the cotton and impurities within each annular region. The first binary image of each annular region is then converted back into a color image. By further segmenting the annular color image, a second binary image for each annular region can be obtained. At this point, the cotton and impurities are segmented in the second binary image. Finally, the proportion of impurity pixels is calculated based on the first and second binary images corresponding to each annular region to obtain the impurity content of each annular region. The average impurity content of the cotton bale can then be calculated based on the impurity content of each annular region. The method for detecting impurity content in cotton bales of the present invention can detect impurity content in machine-harvested cotton while keeping the cotton bales intact, without removing the cotton from the bales, which greatly improves detection efficiency. Furthermore, it can accurately calculate the impurity content of multiple annular areas on the cotton bales, providing data support for analyzing the quality of different harvesting areas in cotton fields.
[0066] It is understood that in step S1, after the cotton harvester finishes packing and the cotton bales are placed on the ground, an image of the cotton bales is captured using a camera. This image is a color image, such as... Figure 2 As shown. Additionally, since the lighting environment for acquiring the cotton bale image is natural lighting, there may be uneven lighting. To improve the quality of the cotton bale image, optionally, after acquiring the cotton bale image in step S1, the image is automatically corrected using a two-dimensional gamma function-based adaptive algorithm for uneven lighting. The specific two-dimensional gamma function-based adaptive algorithm for uneven lighting is existing technology and will not be described in detail here.
[0067] It can be understood that in step S2, the acquired cotton bale image mainly consists of cotton, impurities, cotton bale film, and soil. Since the color of the cotton bale film is clearly distinguishable from other components and it is located at the edge of the cotton in the cotton bale image, the cotton bale area can be marked using the cotton bale film. Converting the cotton bale image into a binary image allows for the differentiation of the background and foreground areas in the cotton bale image. Specifically, as... Figure 3 As shown, the process of converting the cotton bale image into a binary cotton bale image in step S2 is specifically as follows:
[0068] Step S21: Extract a single-channel image of the cotton bale;
[0069] Step S22: Determine the segmentation threshold using the maximum inter-class variance method, and segment the B-channel image using the binary method based on the segmentation threshold to obtain an initial binary image;
[0070] Step S23: Perform texture filtering on the initial binary image;
[0071] Step S24: Denoise the initial binary image after texture filtering to obtain the cotton bale binary image.
[0072] Specifically, in step S21, the cotton bale film used in existing cotton picking and baling machines is typically yellow. In the RGB color space, the RGB value of yellow is (255, 255, 0). Therefore, the B channel image of the cotton bale is extracted for subsequent processing to accurately segment the foreground and background regions in the cotton bale image. Of course, in other embodiments of the invention, the R channel image or the G channel image can also be extracted for subsequent processing, depending on the color of the cotton bale film. For example, when the cotton bale film is purple, the G channel image can be extracted for processing; and when the cotton bale film is cyan, the R channel image can be extracted for processing.
[0073] Then, in step S22, the maximum inter-class variance method is used to determine the segmentation threshold, wherein the formula for calculating the inter-class variance is: maximum=ω0×ω1×(μ0-μ1). 2 In the formula, maximum represents the inter-class variance, ω0 represents the ratio of the number of pixels in the foreground region to the total number of pixels in the cotton bale image, and ω1 represents the ratio of the number of pixels in the background region to the total number of pixels in the cotton bale image. N0 and N1 represent the number of pixels in the foreground and background regions, respectively; M×N represents the pixel size of the cotton bale image; μ0 represents the average gray value of the foreground region; and μ1 represents the average gray value of the background region. A segmentation threshold that maximizes the inter-class variance is obtained using an iterative method. Then, a binary method is used to segment the B-channel image based on the determined segmentation threshold, thus obtaining the initial binary image. Specifically, as shown below... Figure 4 As shown. The binary method can be expressed as: In the formula, img(i,j) represents the gray value of a pixel in the B-channel image, and threshold represents the segmentation threshold determined based on the maximum inter-class variance method.
[0074] In step S23, from Figure 4 As can be seen, in the initial binary image, white pixels represent cotton, while black pixels represent impurities, cotton bale film, soil, and other components. The foreground and background areas are chaotic, making it impossible to accurately extract the cotton bale area for impurity content calculation. However, this invention considers the consistency of texture within a region and the differences in texture between regions. Therefore, this invention extracts the internal texture of the foreground area by performing texture filtering on the initial binary image, obtaining a grayscale image of the cotton bale texture, as shown below. Figure 5 As shown, this facilitates accurate segmentation of the foreground and background regions. Then, the segmentation threshold is determined using the maximum inter-class variance method, followed by binary segmentation to extract the internal texture. The resulting image of the cotton bale's internal texture is shown below. Figure 6 As shown, finally, a mathematical morphology-based erosion algorithm removes noise points from the image, a hole-filling algorithm removes noise points from the target, and a dilation algorithm restores the eroded image edges, thus obtaining a binary image of the cotton bale, as detailed below. Figure 7 As shown, from Figure 7 It is evident that the foreground and background regions are clearly separated, with white pixels representing the foreground and black pixels representing the background. The texture filter calculates the local entropy of different regions, reflecting the amount of information contained in a particular area of the image. For any point (i,j) in the image, an m×n window can be selected, and the local entropy is defined as: In the formula, F i,j Let p represent the local entropy corresponding to point (i,j). i,j This represents the probability of a pixel at position (i,j) in the image. A 9×9 window is typically chosen. Furthermore, the specific expressions for the Otsu's method and the binary method are the same as in step S22, and will not be repeated here. The erosion algorithm, hole-filling algorithm, and dilation algorithm are existing image processing methods, and will not be elaborated upon here. For example, the definition of the erosion operation is: If sets A and B satisfy the above formula, then A is said to be dilated by B, which means that the reflection of B has been translated so that the set of points whose intersection with A is not empty; and the definition of the erosion operation is: If sets A and B satisfy the above formula, then A is said to be eroded by B, meaning that after shifting B by z, the set is the set of points contained in A; and the hole-filling formula is: Let C represent the target pixel, and C be the complement.
[0075] Understandable, such as Figure 8 As shown, in step S3, the process of extracting the target region from the binary image of the cotton bale specifically involves:
[0076] Step S31: Calculate the centroid position based on the coordinates of all pixels in the foreground region of the binary image of the cotton bale;
[0077] Step S32: Calculate the radius based on the average distance between all pixels on the edge contour line of the foreground region from the centroid;
[0078] Step S33: Draw a circle with the centroid as the center and the calculated radius to obtain the target area.
[0079] Specifically, from Figure 7 As can be seen, the white pixel area is the foreground region, and the cotton bale area is contained within the foreground region. Therefore, it is necessary to extract the target region (i.e., the cotton bale region) from the foreground region. Assuming there are n points in the foreground region of the binary image of the cotton bale, the formula for calculating the centroid (i.e., center) of the foreground region is: (x0, y0) represents the coordinates of the centroid of the foreground region, (x0, y0) i ,y i () represents the coordinates of the i-th pixel in the foreground region. Then, the radius of the cotton bale region is calculated based on the average distance between all pixels on the edge contour line of the foreground region, using the following formula: m represents the number of pixels on the edge contour line of the foreground region, (x j ,y j () represents the coordinates of the j-th pixel on the edge contour line of the foreground region. Then, by drawing a circle with the calculated centroid as the center and radius, the binary image of the cotton bale region can be accurately extracted from the binary image of the cotton bale, as shown below. Figure 9 As shown, Figure 9 The circular area in the diagram is the cotton bale area.
[0080] It is understood that in step S4, in order to obtain a more accurate impurity content, this invention, based on the characteristic of cotton bales being packaged from the inside out, divides the cotton bales into layers of regions and then calculates the impurity content of each region separately. Specifically, the process of dividing the target area layer by layer into several annular regions is as follows:
[0081] Construct an arithmetic sequence, take the radius value of the target region as the first term of the arithmetic sequence, set the common difference to a negative integer, iteratively calculate each term of the arithmetic sequence until the value of the new term is less than the absolute value of the common difference, take the two adjacent terms in the arithmetic sequence as the two radius values of the annulus, thus dividing the target region into several annular regions.
[0082] Specifically, construct an arithmetic sequence: a n=a1+(n-1)d, a n Let be the nth term of the arithmetic sequence, a1 be the first term of the arithmetic sequence, n be the number of terms in the arithmetic sequence, and d be the common difference, which is a negative integer. Using the radius of the target region calculated in step S3 as the first term of the arithmetic sequence, iteratively calculate each term of the arithmetic sequence until the value of the new term is less than the absolute value of the common difference, thus satisfying condition a1. n When -|d|≤0, a n =0. By using adjacent terms in the arithmetic sequence as the inner and outer radii of the annulus, the target region can be divided into several annular regions layer by layer. When one of the adjacent terms is 0, i.e., one radius of the annulus is zero, the smallest annulus obtained is a circle. Furthermore, for each annular region, the following condition must be satisfied: In the formula, That is, only pixels within the current annular region have a grayscale value of 255, otherwise it is 0. This allows us to obtain the first binary image of several annular regions. The first binary image of one annular region is as follows: Figure 10 As shown, Figure 10 The white area in the image is the circular area.
[0083] It can be understood that in step S5, the first binary image of each annular region is multiplied by the channel images of the colored cotton bag image, thereby converting it back into an annular color image, as shown below. Figure 11 As shown. Then, the annular color image is segmented again. First, the segmentation threshold is determined by the Otsu's method, and then the binary method is used for segmentation, thus obtaining a second binary image of each annular region, as shown. Figure 12 As shown.
[0084] It is understandable that in step S6, the first binary image of each annular region is extracted and segmented based on the binary image of the cotton bale. The binary image of the cotton bale has undergone image segmentation, texture filtering, and morphological denoising processing. Although image segmentation can separate the cotton and impurities, it cannot accurately separate the foreground and background regions. Therefore, subsequent texture filtering and morphological denoising processes achieve accurate segmentation of the foreground and background regions. However, this also mixes the cotton and impurities in the cotton bale region, making it impossible to separate them. Therefore, the first binary image of each annular region contains both cotton and impurities. Figure 10 The white area pixels in the image include both cotton and impurity pixels. By converting the first binary image of each annular region back into a color annular image, and then performing image segmentation processing on the color annular image again, the cotton and impurities can be accurately separated. Figure 12 The white pixels in the image are all cotton-like pixels. Therefore, the impurity content of each annular region can be calculated based on the following formula:
[0085]
[0086] Where s represents the impurity rate, and sn represents the total number of pixels in the first binary image, i.e. Figure 10 The total number of white pixels, where sm represents the total number of pixels in the second binary image, i.e. Figure 12 The total number of white pixels.
[0087] Then, using the area of each ring as a weighting factor, the average impurity content of the cotton bale is calculated based on the following formula:
[0088]
[0089] in, The s represents the average impurity content of the cotton bales, where n represents the number of terms in the arithmetic sequence. i Let a represent the impurity content of the i-th annular region. n-1 and a n Let represent two adjacent terms in the arithmetic sequence corresponding to the i-th annular region.
[0090] Optionally, step S6, after calculating the impurity content of each annular region, further includes the following:
[0091] By correlating the impurity content of each annular region with the satellite positioning and mileage of the cotton harvester, the cotton field region corresponding to each impurity content is obtained, thereby analyzing the cotton quality of each harvesting region in the cotton field.
[0092] In addition, step S6, after calculating the impurity content of each annular region, may also include the following:
[0093] The impurity content of each annular region is correlated with the cotton harvester's operating data to facilitate the analysis of factors affecting the impurity content, providing data support for optimizing the cotton harvester's performance.
[0094] In addition, such as Figure 13 As shown, another embodiment of the present invention also provides a detection system for the impurity content of cotton, preferably employing the detection method described above, which includes:
[0095] The image acquisition module is used to acquire images of cotton bales;
[0096] The image conversion module is used to convert cotton bale images into binary cotton bale images;
[0097] The image extraction module is used to extract the target region from the binary image of the cotton bale;
[0098] The region segmentation module is used to divide the target region into several annular regions layer by layer, and obtain the first binary image of each annular region;
[0099] The image segmentation module is used to convert each annular region into a color image and segment the annular color image to obtain a second binary image of each annular region.
[0100] The impurity content calculation module is used to calculate the impurity content of each annular region based on the first binary image and the second binary image of each annular region, and to calculate the average impurity content of the cotton bale based on the impurity content of each annular region.
[0101] It is understood that the cotton bale impurity detection system in this embodiment first converts the color cotton bale image into a binary image after acquiring the cotton bale image to distinguish the foreground and background regions in the cotton bale image. Then, it extracts the target region from the foreground region of the cotton bale binary image; the target region is the cotton bale itself. This accurately segments only the background region and the cotton bale region in the cotton bale image, without segmenting the cotton and impurities within the cotton bale region. Subsequently, based on the characteristic of the cotton bale being packed from the inside out, the target region is divided into several annular regions layer by layer, obtaining a first binary image for each annular region. Each first binary image contains the cotton and impurities within each annular region. The first binary image of each annular region is then converted back into a color image. By further segmenting the annular color image, a second binary image for each annular region can be obtained. At this point, the cotton and impurities are segmented in the second binary image. Finally, based on the first and second binary images corresponding to each annular region, the proportion of impurity pixels is calculated to obtain the impurity content of each annular region. Based on the impurity content of each annular region, the average impurity content of the cotton bale can be calculated. The cotton impurity detection system of the present invention can detect the impurity content of machine-harvested cotton while keeping the cotton bales intact, without removing the cotton from the bales, which greatly improves the detection efficiency. It can also accurately calculate the impurity content of multiple annular areas on the cotton bales, providing data support for analyzing the quality of different harvesting areas in cotton fields.
[0102] In addition, another embodiment of the present invention provides an electronic device including a processor and a memory, wherein the memory stores a computer program, and the processor executes the steps of the method described above by calling the computer program stored in the memory.
[0103] In addition, another embodiment of the present invention provides a computer-readable storage medium for storing a computer program for detecting the impurity rate of cotton, wherein the computer program performs the steps of the method described above when run on a computer.
[0104] Common computer-readable storage media include: floppy disks, flexible disks, hard disks, magnetic tapes, any other magnetic media, CD-ROMs, any other optical media, punch cards, paper tape, any other physical media with perforated patterns, random access memory (RAM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), flash erasable programmable read-only memory (FLASH-EPROM), any other memory chips or cartridges, or any other media readable by a computer. Instructions may further be transmitted or received by a transmission medium. The term transmission medium can include any tangible or intangible medium used to store, encode, or carry instructions for machine execution, and includes digital or analog communication signals or intangible media that facilitate communication of such instructions. Transmission media include coaxial cables, copper wires, and optical fibers, which contain conductors for transmitting a bus of computer data signals.
[0105] The above description is merely a preferred embodiment of the present invention and is not intended to limit the invention. Various modifications and variations can be made to the present invention by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
[0106] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code. The solutions in the embodiments of this application can be implemented in various computer languages, such as the object-oriented programming language Java and the interpreted scripting language JavaScript.
[0107] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0108] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0109] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0110] Although preferred embodiments of this application have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of this application.
[0111] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the spirit and scope of this application. Therefore, if such modifications and variations fall within the scope of the claims of this application and their equivalents, this application also intends to include such modifications and variations.
Claims
1. A method for detecting the impurity content of cotton, characterized in that, Includes the following: Acquire images of cotton bales; Convert the cotton bale image into a binary cotton bale image; Extract the target region from the binary image of the cotton bale; The target region is divided into several annular regions layer by layer, and the first binary image of each annular region is obtained; Each annular region is converted into a color image, and the annular color images are segmented to obtain a second binary image of each annular region; The impurity content of each annular region is calculated based on the first and second binary images of each annular region, and the average impurity content of the cotton bale is calculated based on the impurity content of each annular region. The process of extracting the target region from the binary image of the cotton bale is as follows: The centroid position is calculated based on the coordinates of all pixels in the foreground region of the binary image of the cotton bale. The radius is calculated based on the average distance between all pixels on the edge contour line of the foreground region from the centroid. Draw a circle with the center of gravity as the center and the calculated radius to obtain the target area; The process of dividing the target area into several annular regions layer by layer is specifically as follows: Construct an arithmetic sequence, take the radius value of the target region as the first term of the arithmetic sequence, set the common difference to a negative integer, iteratively calculate each term of the arithmetic sequence until the value of the new term is less than the absolute value of the common difference, take the two adjacent terms in the arithmetic sequence as the two radius values of the annulus, thereby dividing the target region into several annular regions; The impurity content of each annular region is calculated based on the following formula: ; Where s represents the impurity rate, sn represents the total number of pixels in the first binary image, and sm represents the total number of pixels in the second binary image; The average impurity content of cotton bales is calculated based on the following formula: ; in, This represents the average impurity content of the cotton bales, where n represents the number of terms in the arithmetic sequence. This represents the impurity content of the i-th annular region. and Let represent two adjacent terms in the arithmetic sequence corresponding to the i-th annular region.
2. The method for detecting impurity content in cotton as described in claim 1, characterized in that, The process of converting the cotton bale image into a binary cotton bale image is as follows: Extract a single-channel image of the cotton bale. The segmentation threshold was determined by the maximum inter-class variance method, and the binary method was used to segment the B-channel image based on the segmentation threshold to obtain the initial binary image. Perform texture filtering on the initial binary image; The initial binary image after texture filtering is denoised to obtain the binary image of the cotton bale.
3. The method for detecting the impurity content of cotton as described in claim 1, characterized in that, After calculating the impurity content of each annular region, the following is also included: By correlating the impurity content of each annular region with the cotton harvester's satellite positioning and mileage, the cotton field region corresponding to each impurity content can be obtained.
4. A cotton impurity content detection system, employing the cotton impurity content detection method as described in any one of claims 1 to 3, characterized in that, include: The image acquisition module is used to acquire images of cotton bales; The image conversion module is used to convert cotton bale images into binary cotton bale images; The image extraction module is used to extract the target region from the binary image of the cotton bale; The region segmentation module is used to divide the target region into several annular regions layer by layer, and obtain the first binary image of each annular region; The image segmentation module is used to convert each annular region into a color image and segment the annular color image to obtain a second binary image of each annular region. The impurity content calculation module is used to calculate the impurity content of each annular region based on the first binary image and the second binary image of each annular region, and to calculate the average impurity content of the cotton bale based on the impurity content of each annular region.
5. An electronic device, characterized in that, The method includes a processor and a memory, wherein the memory stores a computer program, and the processor executes the steps of the method as described in any one of claims 1 to 3 by calling the computer program stored in the memory.
6. A computer-readable storage medium for storing a computer program for detecting impurity content in cotton, characterized in that, The computer program, when run on a computer, performs the steps of the method as described in any one of claims 1 to 3.