Cotton boll detection method and system in complex natural scenes
Through HSV color space image processing, clustering and Hough transformation technology, the robustness and accuracy of cotton boll detection in complex natural environments are solved, and the accurate detection of the position of cotton bolls is achieved.
Patent Information
- Application Number
- CN202210086584.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-25
- Publication Date
- 2024-12-06
- Estimated Expiration
- 2042-01-25
AI Technical Summary
The robustness and accuracy of cotton boll detection in complex natural environments are greatly affected by factors such as plant occlusion, light interference, and leaf reflection, and the existing technology is difficult to effectively solve.
The HSV color space image is used for histogram equalization, noise is removed, the boll and background are segmented by fuzzy C-mean clustering, edge information is extracted using the Sobel operator, and the boll profile is detected by setting thresholds through the Hoff transform.
Effectively overcome light changes and noise interference, improve the robustness and accuracy of boll detection, and can detect the position of bolls at different periods and sizes.
Smart Images

Figure CN114581661B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of image processing, and in particular relates to a cotton boll detection method and system in complex natural scenes. Background Art
[0002] The statements in this section merely provide background information related to the present invention and do not necessarily constitute prior art.
[0003] Cotton growth stage monitoring mainly relies on manual records, which requires frequent observation and professional knowledge. The detection of early cotton bolls assisted by computer vision technology can improve efficiency and reduce manual errors. It can also be used for subsequent crop disease detection and yield prediction. Extracting crops from crop images collected in the field is a difficult task. The inventors found that the robustness and accuracy of current cotton boll detection are reduced due to the presence of plant occlusion, light interference, leaf reflection and other factors in complex natural environments. Summary of the invention
[0004] In order to solve the technical problems existing in the above-mentioned background technology, the present invention provides a cotton boll detection method and system in complex natural scenes, which is suitable for cotton boll detection in natural scenes and has high robustness and accuracy.
[0005] In order to achieve the above object, the present invention adopts the following technical solution:
[0006] A first aspect of the present invention provides a cotton boll detection method in a complex natural scene, comprising:
[0007] Get RGB images of cotton in natural environment;
[0008] The cotton RGB image is converted into an HSV color space image, the S channel and the V channel are respectively subjected to histogram equalization processing, and then the S channel and the V channel are merged and converted into an RGB color space image;
[0009] Remove noise from RGB color space images converted from HSV color space images;
[0010] Clustering the filtered image to segment the cotton bolls and background in the image;
[0011] Perform edge detection on the clustered image to extract the outline of the cotton boll;
[0012] Different thresholds are set by Hough transform to detect the edge information of cotton boll contour and the positions of cotton bolls of different periods or sizes.
[0013] A second aspect of the present invention provides a cotton boll detection system in a complex natural scene, comprising:
[0014] An RGB image acquisition module is used to acquire RGB images of cotton in a natural environment;
[0015] A histogram equalization processing module is used to convert the cotton RGB image into an HSV color space image, perform histogram equalization processing on the S channel and the V channel respectively, and then merge the S channel and the V channel to convert into an RGB color space image;
[0016] An image filtering module, which is used to remove noise from an RGB color space image converted from an HSV color space image;
[0017] An image clustering module, which is used to cluster the filtered image to segment the cotton bolls and the background in the image;
[0018] A contour extraction module is used to perform edge detection on the clustered image and extract the contour of the cotton boll;
[0019] The cotton boll detection module is used to set different thresholds through Hough transform, detect the edge information of the cotton boll contour, and detect the positions of cotton bolls of different periods or different sizes.
[0020] A third aspect of the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the cotton boll detection method in a complex natural scene as described above.
[0021] A fourth aspect of the present invention provides a computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the steps in the cotton boll detection method in complex natural scenes as described above are implemented.
[0022] Compared with the prior art, the present invention has the following beneficial effects:
[0023] The present invention can effectively solve the problem of brightness variation of illumination by converting the image of cotton crops collected in the wild into HSV color space for histogram equalization processing; the use of guided filtering for preprocessing can effectively remove noise, smooth the image while retaining the edge information of cotton bolls, leaves, etc., and also enhance the contrast of the image; the fuzzy C-means clustering algorithm can further segment the cotton bolls and the background; the Sobel operator extracts the edge information of the clustered image, and then performs a sharpening operation to make the edge more prominent; by setting different thresholds, the Hough transform can effectively detect the number and position of cotton bolls of different periods and sizes.
[0024] The cotton boll detection method in complex natural scenes of the present invention is suitable for cotton boll images in complex natural environments, effectively overcomes the influence of multiple factors such as plant occlusion, light interference, leaf reflection, etc., and improves the robustness and accuracy of accurately detecting cotton bolls in different periods.
[0025] Advantages of additional aspects of the present invention will be given in part in the following description, and in part will become obvious from the following description, or will be learned through practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] The accompanying drawings in the specification, which constitute a part of the present invention, are used to provide a further understanding of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute improper limitations on the present invention.
[0027] Figure 1 is a flow chart of a cotton boll detection method in a complex natural scene according to an embodiment of the present invention;
[0028] Figure 2 It is a schematic diagram of the structure of a cotton boll detection system in a complex natural scene according to an embodiment of the present invention. DETAILED DESCRIPTION
[0029] The present invention will be further described below in conjunction with the accompanying drawings and embodiments.
[0030] It should be noted that the following detailed descriptions are all illustrative and intended to provide further explanation of the present invention. Unless otherwise specified, all technical and scientific terms used herein have the same meanings as those commonly understood by those skilled in the art to which the present invention belongs.
[0031] It should be noted that the terms used herein are only for describing specific embodiments and are not intended to limit exemplary embodiments according to the present invention. As used herein, unless the context clearly indicates otherwise, the singular form is also intended to include the plural form. In addition, it should be understood that when the terms "comprising" and / or "including" are used in this specification, it indicates the presence of features, steps, operations, devices, components and / or combinations thereof.
[0032] Embodiment 1
[0033] like Figure 1 As shown, this embodiment provides a cotton boll detection method in a complex natural scene, which includes the following steps:
[0034] S101: Acquire an RGB image of cotton in a natural environment.
[0035] S102: converting the cotton RGB image into an HSV color space image, performing histogram equalization processing on the S channel and the V channel respectively, and then merging the S channel and the V channel to convert the image into an RGB color space image.
[0036] The collection of cotton images in the natural environment is usually affected by various factors such as weather (sunny, cloudy, overcast, etc.), light exposure, etc., resulting in uneven brightness distribution of the acquired images, making it difficult to observe very bright or dark details, so data preprocessing is required before cotton boll detection. Since the three channels of the RGB color space model are highly correlated and very sensitive to changes in brightness, it will lead to uncertainty in image information and ultimately reduce the accuracy of cotton boll detection. The HSV color space model is represented by hue, saturation, and brightness. Under different lighting conditions, the H component is not obvious, objects of different colors can be identified, and the intuitive features of colors in the image can be better portrayed, so it is more suitable for processing images that are sensitive to lighting changes.
[0037] The histogram equalization operation of this embodiment enhances the contrast of the image and alleviates the problem of brightness changes such as sunlight and shadows. Compared with directly equalizing the RGB image or HSV image, this method can more effectively enhance the contrast between the cotton boll area and the background area, while solving the interference caused by light changes and highlighting the details of the dark and overly bright parts.
[0038] S103: removing noise from the RGB color space image converted from the HSV color space image.
[0039] In step S103, the noise of the RGB color space image converted from the HSV color space image is removed by guided filtering.
[0040] Commonly used image denoising methods such as Gaussian filtering, median filtering, and mean filtering will smooth the edge information of cotton bolls. The colors of early cotton bolls and leaves are very similar, and the effect of using color features to detect cotton bolls will be very poor. An important morphological feature of cotton bolls is that the edges are round. After the edges are smoothed, it is difficult to use other morphological features to detect whether the image contains cotton bolls and their specific locations. This embodiment mainly uses the morphological feature of the cotton boll edge for detection, so the guided filter has the characteristic of maintaining the edge of the object to process image noise.
[0041] The image obtained in the natural scene of this embodiment usually contains noise, which requires preprocessing of the image. The low-pass filter only allows the low-frequency components represented by the frequency domain of the image to pass through, and blocks all high frequencies that exceed the cutoff value. Since the high-frequency components correspond to edges, details, noise, etc., the low-pass filter tends to filter them out. However, common low-pass filters such as mean filtering, median filtering, and Gaussian filtering destroy the details of the image, especially the edges, while smoothing the image for denoising, making the image blurred, and subsequent detection of cotton bolls becomes difficult.
[0042] The use of guided filtering can not only achieve the edge smoothing of bilateral filtering, but also has a good performance near the edge detection, removes noise and also realizes the function of image contrast enhancement. The implementation principle of guided filtering is as follows:
[0043] For a common linear transformation filter, the input image is I, the output image is S, the guiding function image is T, and the filtering result defined by the guided filter at the pixel point j can be expressed as follows:
[0044] S j =∑ i W ij (T)I j (1)
[0045] Where i and j are the subscripts of pixels, and the filter kernel function W ij is the weighted coefficient of the image, and the classic bilateral filter kernel is given as follows:
[0046]
[0047] where x is the pixel coordinate, K i is a normalization parameter, Parameter σ s With σ r Represents the sensitivity of spatial similarity and color range similarity. Assume that the guided filter has a linear model as follows:
[0048] S i =a k i+b k i∈W k (3)
[0049] The window function W k is the linear transformation of S at pixel k with I as the center, and the coefficient a k and b k Satisfy the same linear coefficient. To determine the linear coefficient, the output response q should satisfy the following formula:
[0050] q i =I I -ni (4)
[0051] Where n i Represents noise, and the local linear model determines the edge corresponding to the input and output, which can minimize the difference between q and I while maintaining the original linear transformation. Minimize the window function W k :
[0052]
[0053] Where Ψ is a regularization parameter, and the coefficient a is obtained according to the linear transformation k and b k :
[0054]
[0055]
[0056] where u k With σ k is the window function w of the guiding function I k The mean and variance of |w| is the total number of pixels,
[0057] The steps to implement guided filtering are as follows:
[0058] (1) The boxFilter filter is used to complete the mean calculation, where the mean includes the guided mean, the original mean, the cross-correlation mean and the autocorrelation mean.
[0059] (2) Calculate the correlation coefficient parameters based on the mean, including the autocorrelation and cross-correlation variances.
[0060] (3) Calculate the window linear transformation parameter coefficients a and b.
[0061] (4) Calculate the mean of parameters a and b according to the formula.
[0062] (5) The guided filter output matrix S is obtained using the parameters.
[0063] S104: Clustering the filtered image to segment the cotton bolls and the background in the image.
[0064] In step S104, the filtered image is clustered using a fuzzy C-means clustering algorithm.
[0065] The data preprocessing part enhances the contrast of the image, and the background and cotton bolls in the image can be further segmented through image clustering to increase the accuracy of segmentation.
[0066] Fuzzy C-means clustering algorithm (FCM) is a partition-based algorithm that uses the concept of determining the geometric proximity of data points in Euclidean space to assign data to different clusters and then determine the distance between these clusters. The basic idea is to maximize the similarity between objects classified into the same cluster, while minimizing the similarity between different clusters. For example: set the number of clusters to 5 and the parameter m to 2 for clustering. The final clustering result can distinguish cotton bolls from the background very well, removing many interference factors such as illumination, occlusion, and shadow that affect detection, which is conducive to the detection of cotton bolls.
[0067] S105: Perform edge detection on the clustered image to extract the outline of the cotton boll.
[0068] In step S105, edge detection is performed on the clustered image using the Sobel operator to extract the outline of the cotton boll.
[0069] The Sobel operator is used to perform edge detection on the clustered image to extract the rough outline of the cotton boll. Image clustering will also cause the extracted outline of the cotton boll to be incomplete, mainly manifested in edge blur and discontinuity. In order to improve the accuracy of detection, it is necessary to perform a sharpening operation on the extracted outline to enhance the edge information. Here, the sharpening kernel [[0,-1,0],[-1,5,-1],[0,-1,0]] is used. The purpose of sharpening is to highlight the details in the image or enhance the blurred details, making the edges of the extracted cotton bolls more prominent.
[0070] S106: Setting different thresholds through Hough transformation to detect edge information of the cotton boll contour and to detect the positions of cotton bolls of different periods or different sizes.
[0071] Among them, Hough transform is one of the basic processing methods for identifying geometric shapes from images. The basic principle is to use the duality of points and lines to transform a given curve in the original image space into a point in the parameter space through a curve expression, thus transforming the detection problem of a given curve in the original image into the problem of finding a peak in the parameter space. The more edge point sets that intersect with a point in a three-dimensional space curve, the more pixels on the common circle they pass through. Setting a threshold can be used to determine whether a circle is detected.
[0072] Cotton bolls are generally round or elliptical in shape, and the sizes of cotton bolls at different stages are different. By setting different thresholds through Hough transform and detecting the edge information extracted in the previous step, the positions of cotton bolls at different stages or of different sizes can be detected.
[0073] In other embodiments, different thresholds are set through Hough transformation to detect edge information of the cotton boll outline and also detect the number of cotton bolls contained in an image.
[0074] Embodiment 2
[0075] like Figure 2 As shown, this embodiment provides a cotton boll detection system in a complex natural scene, which includes the following modules:
[0076] (1) An RGB image acquisition module is used to acquire RGB images of cotton in a natural environment.
[0077] (2) A histogram equalization processing module, which is used to convert the cotton RGB image into an HSV color space image, perform histogram equalization processing on the S channel and the V channel respectively, and then merge the S channel and the V channel and convert them into an RGB color space image.
[0078] (3) An image filtering module, which is used to remove noise from the RGB color space image converted from the HSV color space image.
[0079] Specifically, in the image filtering module, the noise of the RGB color space image converted from the HSV color space image is removed by guided filtering.
[0080] (4) An image clustering module is used to cluster the filtered image to segment the cotton bolls and the background in the image.
[0081] Specifically, in the image clustering module, the filtered image is clustered using a fuzzy C-means clustering algorithm.
[0082] (5) A contour extraction module is used to perform edge detection on the clustered image and extract the contour of the cotton boll.
[0083] Specifically, in the contour extraction module, the Sobel operator is used to perform edge detection on the clustered image to extract the contour of the cotton boll.
[0084] (6) A cotton boll detection module is used to set different thresholds through Hough transform, detect the edge information of the cotton boll contour, and detect the positions of cotton bolls of different periods or different sizes.
[0085] It should be noted here that each module in this embodiment corresponds to each step in Example 1 one by one, and the specific implementation process is the same, which will not be repeated here.
[0086] Embodiment 3
[0087] This embodiment provides a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, the steps in the cotton boll detection method in a complex natural scene as described above are implemented.
[0088] Embodiment 4
[0089] This embodiment provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, the steps in the cotton boll detection method in complex natural scenes as described above are implemented.
[0090] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems) and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram and the combination of processes and / or blocks in the flowchart and / or block diagram can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the process in the flowchart. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0091] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A cotton boll detection method in complex natural scenes, It is characterized in that include: Get RGB images of cotton in natural environment; The cotton RGB image is converted into an HSV color space image, the S channel and the V channel are respectively subjected to histogram equalization processing, and then the S channel and the V channel are merged and converted into an RGB color space image; Remove noise from RGB color space images converted from HSV color space images; Remove noise from the RGB color space image converted from the HSV color space image by guided filtering; The implementation principle of guided filtering is as follows: For ordinary linear transformation filters, the filtering result of guided filtering defined at pixel point j can be expressed as follows: S j =∑ i W ij (T)I j The input image is I, the output image is S, the guidance function image is T, i and j are the subscripts of the pixels, and the filter kernel function is W. ij is the weighted coefficient of the image, and the classic bilateral filter kernel is given as follows: where x is the pixel coordinate, K i is a normalization parameter, Parameter σ s With σ r Represents the sensitivity of spatial similarity and color range similarity; the linear model of the guided filter is as follows: S i =a k i+b k i∈W k The window function W k is the linear transformation of S at pixel k with I as the center, and the coefficient a k and b k Satisfy the same linear coefficient; determine the linear coefficient, and determine that the output response q satisfies the following formula: q i =I I -n i where n i Indicates noise; Minimize window function W k : Where Ψ is a regularization parameter, and the coefficient a is obtained according to the linear transformation k and b k : where u k With σ k is the window function w of the guiding function I k The mean and variance of |w| is the total number of pixels, Clustering the filtered image to segment the cotton bolls and background in the image; The filtered image is clustered using the fuzzy C-means clustering algorithm; Perform edge detection on the clustered image to extract the outline of the cotton boll; Different thresholds are set by Hough transform to detect the edge information of cotton boll contour and the positions of cotton bolls of different periods or sizes.
2. The cotton boll detection method in complex natural scenes as claimed in claim 1, It is characterized in that The Sobel operator is used to perform edge detection on the clustered image and extract the outline of the cotton boll.
3. The cotton boll detection method in complex natural scenes as claimed in claim 1, It is characterized in that Different thresholds are set by Hough transform to detect the edge information of cotton boll contour and the number of cotton bolls.
4. A cotton boll detection system in complex natural scenes, It is characterized in that include: An RGB image acquisition module is used to acquire RGB images of cotton in a natural environment; A histogram equalization processing module is used to convert the cotton RGB image into an HSV color space image, perform histogram equalization processing on the S channel and the V channel respectively, and then merge the S channel and the V channel to convert into an RGB color space image; An image filtering module, which is used to remove noise from an RGB color space image converted from an HSV color space image; Remove noise from the RGB color space image converted from the HSV color space image by guided filtering; The implementation principle of guided filtering is as follows: For ordinary linear transformation filters, the filtering result of guided filtering defined at pixel point j can be expressed as follows: S j =∑ i W ij (T)I j The input image is I, the output image is S, the guidance function image is T, i and j are the subscripts of the pixels, and the filter kernel function is W. ij is the weighted coefficient of the image, and the classic bilateral filter kernel is given as follows: where x is the pixel coordinate, K i is a normalization parameter, Parameter σ s With σ r Represents the sensitivity of spatial similarity and color range similarity; the linear model of the guided filter is as follows: S i =a k i+b k i∈W k The window function W k is the linear transformation of S at pixel k with I as the center, and the coefficient a k and b k Satisfy the same linear coefficient; determine the linear coefficient, and determine that the output response q satisfies the following formula: q i =I I -n i where n i Indicates noise; Minimize window function W k : Where Ψ is a regularization parameter, and the coefficient a is obtained according to the linear transformation k and b k : where u k With σ k is the window function w of the guiding function I k The mean and variance of |w| is the total number of pixels, An image clustering module, which is used to cluster the filtered image to segment the cotton bolls and the background in the image; The filtered image is clustered using the fuzzy C-means clustering algorithm; A contour extraction module is used to perform edge detection on the clustered image and extract the contour of the cotton boll; The cotton boll detection module is used to set different thresholds through Hough transform, detect the edge information of the cotton boll contour, and detect the positions of cotton bolls of different periods or different sizes.
5. The cotton boll detection system in complex natural scenes as claimed in claim 4, It is characterized in that In the image filtering module, the noise of the RGB color space image converted from the HSV color space image is removed by guided filtering.
6. The cotton boll detection system in complex natural scenes as claimed in claim 4, It is characterized in that In the image clustering module, clustering is performed on the filtered image using a fuzzy C-means clustering algorithm; Or in the contour extraction module, the Sobel operator is used to perform edge detection on the clustered image to extract the contour of the cotton boll.
7. A computer-readable storage medium having a computer program stored thereon, It is characterized in that When the program is executed by a processor, the steps of the cotton boll detection method in a complex natural scene as described in any one of claims 1 to 3 are implemented.
8. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, It is characterized in that When the processor executes the program, the steps of the cotton boll detection method in a complex natural scene according to any one of claims 1 to 3 are implemented.
Citation Information
Patent Citations
Tomato identification positioning method and system
CN110599507A
