A method and system for detecting and reporting insect pests
By constructing a pest area data set and Gaussian model, and combining the clustering evaluation function to optimize the clustering results, the problem of low accuracy in identifying new pests by the BP neural network model is solved, and efficient and accurate pest detection and identification are achieved, which is suitable for different applications. Types of crops and pests.
Patent Information
- Application Number
- CN202410756053.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-13
- Publication Date
- 2024-09-03
- Estimated Expiration
- 2044-06-13
AI Technical Summary
Among the existing pest forecasting methods, the BP neural network model is difficult to correctly identify new pest species that have not been trained, resulting in low recognition accuracy and high manpower and material resources required to update the model.
By obtaining historical crop images for annotation, a pest area data set is constructed, the pest probability matrix is calculated in real time based on the Gaussian model, and the clustering evaluation function is used to optimize the clustering results, obtain edge features and shape features, reduce model training costs, and is suitable for different types of crops and pests.
It improves the accuracy and real-time performance of pest detection, reduces the cost of model training, can identify and predict pests in a timely manner, is suitable for agricultural production, and improves crop yield and quality.
Smart Images

Figure CN118334633B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of insect pest identification, and more specifically, to an insect pest detection and forecasting method and system. Background Art
[0002] "Insect monitoring" refers to the monitoring and forecasting of crop diseases and pests. This is an important task in the agricultural field, which can help farmers take timely measures to prevent and control diseases and pests and protect the growth and yield of crops. Crops are often attacked by various pests, resulting in reduced yield and quality. Traditional agricultural management methods usually rely on manual inspections and experience judgments, which are inefficient and prone to problems such as missed inspections.
[0003] The existing Chinese patent application document with publication number CN113273555A discloses an artificial intelligence insect situation prediction system and prediction method, which is used for early warning and prediction based on the image data and GIS monitoring data, and constructs a BP neural network model by selecting various indicators such as the number of detected pests, time, longitude, latitude, temperature, humidity and atmospheric pressure as input values in the model training stage, and uses the BP neural network model to predict the development of the insect situation.
[0004] In the above method, the BP neural network is used to obtain the insect monitoring results. However, the BP neural network model mainly relies on training data. If a new type of pest that has not appeared in the training stage is encountered, the model may not be able to correctly identify and predict it, resulting in low recognition accuracy and high manpower and material resources consumed in updating the model. Summary of the invention
[0005] In order to solve the problems of low model recognition accuracy and high manpower and material resources consumed in updating the model, the present invention provides solutions in the following aspects.
[0006] In a first aspect, a method for detecting and forecasting insect pests comprises: obtaining historical crop images of an area to be detected, marking pest areas on the historical crop images, and constructing a pest area data set; constructing a Gaussian model according to the color features of the pest area data set, obtaining pixel values corresponding to the color features of the crop images in real time and inputting them into the Gaussian model to obtain a pest probability matrix; clustering the pest probability matrix to obtain multiple clustering results, obtaining edge images corresponding to each clustering cluster in each clustering result, calculating the energy value and entropy value of the edge image, and constructing a clustering evaluation function using the energy value as the edge feature and the entropy value as the shape feature. , where represents the clustering evaluation function, Indicates The vector composed of the edge features and shape features of the clusters, A vector consisting of the mean values of edge features and shape features of all clusters is represented, and in response to the clustering evaluation function being maximum, an optimal clustering result is obtained; according to the number of clusters corresponding to the optimal clustering result, multiple pest areas in the real-time crop image are obtained, and a feature vector data set of standard pests is obtained, and the distance between the feature vector of each of the pest areas and the feature vector data set of the standard pest is used as the similarity, and in response to the similarity being greater than or equal to a preset threshold, the type and quantity of each pest corresponding to the similarity are statistically analyzed.
[0007] The effect is that the accuracy of pest detection can be improved by annotating historical crop images and constructing pest area datasets, and calculating pest probability matrices for real-time crop images based on Gaussian models. The clustering accuracy is further improved by optimizing the clustering evaluation function. Real-time processing of crop images can detect and identify pests in crop images in a short time, which helps to take prevention and control measures in a timely manner. When new pests appear, only the standard pest feature vectors of the new pests need to be obtained, which reduces the cost of model training. It does not rely on the characteristics of specific crops or pests and can be applied to different types of crops and pests. This solution has high accuracy, real-time, universality and automation, and can be effectively applied to agricultural production to improve crop yield and quality.
[0008] In one embodiment, constructing a Gaussian model based on the color features of the pest area dataset includes:
[0009] The color features of the pest area are the pixel values of the RGB three channels, and the mean and variance of the pixel values of the RGB three channels of the pest area are used to construct a Gaussian model of the pest area.
[0010] The effect is that by constructing a Gaussian model based on the color features of the pest area dataset, pest detection can be effectively achieved. Due to the simplicity and computational efficiency of the Gaussian model, crop images can be processed and pests detected in real time or near real time, thereby promptly discovering and responding to pest threats.
[0011] In one embodiment, obtaining the pest probability matrix comprises the following specific steps:
[0012] Traverse each pixel point in the real-time crop image, input the pixel value of each pixel point into the Gaussian model, calculate the probability density function value of each pixel point in the Gaussian model, use the probability density function value as the probability value that the pixel point belongs to the corresponding pest area, obtain the probability values of all pixels points to construct a pest probability matrix.
[0013] The effect is that by obtaining a pest probability matrix, which represents the probability of each location in the image belonging to a pest area at the pixel level, this matrix can be used for further pest detection and location, providing a quantitative estimate of the potential pest distribution in real-time crop images, thereby ensuring crop health and yield.
[0014] In one embodiment, obtaining the optimal clustering result comprises the steps of:
[0015] Clustering the pest probability matrix based on density, presetting different clustering radii, and obtaining clustering results with different clustering radii;
[0016] Calculate the inter-class distance between each cluster in each clustering result respectively, merge two clusters whose inter-class distance is less than a preset distance, and obtain a merged clustering result under the corresponding clustering radius;
[0017] A clustering evaluation function is applied to each of the plurality of merged clustering results to obtain a clustering evaluation function value, and a clustering result of a clustering radius corresponding to a maximum clustering evaluation function value is selected as an optimal clustering result.
[0018] The effect is as follows: first, by merging clusters with similar edge features and shape features, the phenomenon of dividing the same pest cluster into multiple clusters is avoided, and the accuracy of clustering is improved. By constructing a clustering evaluation function, when the evaluation function reaches the maximum, the difference in edge features and shape features between different clusters is the largest, which means that the cluster at this time distinguishes the pest area and the background area into two categories as much as possible, thereby increasing the accuracy of classification.
[0019] In one embodiment, obtaining the edge image corresponding to the cluster comprises the steps of:
[0020] After clustering is completed, the position of the crop image where each cluster is located is obtained, the pixel value in the cluster is set to 1, and the pixel values of other positions are set to 0, to obtain a binary image of the cluster, and the product of the binary image and the real-time crop image is used as the cluster image;
[0021] Perform edge detection on the cluster image to obtain the edge image of the cluster image.
[0022] The effect is that edge images corresponding to clusters are obtained, which helps to further analyze and understand the distribution of clusters in crop images.
[0023] In one embodiment, the energy value of the edge image comprises the steps of:
[0024] According to the correlation of the pixel values of the pixel points in the edge image, the frequency of the grayscale values of the pixel pairs in the preset direction in the edge image is counted, a grayscale co-occurrence matrix is constructed, and the square of the grayscale values of the pixel pairs in the grayscale co-occurrence matrix is calculated to obtain the edge features of the edge image.
[0025] In one embodiment, the entropy value of the edge image comprises the steps of:
[0026] According to the continuity of the grayscale values of the pixels in the edge image, the run lengths and frequencies of the pixel sequences with the same grayscale values in a preset direction are counted, a grayscale run matrix is constructed, and weighted summation is performed based on the run distances and row and column element values of the grayscale run matrix to obtain the shape characteristics of the edge image.
[0027] The effect is that the edge features and shape features of the clusters are clustered using a method based on statistical laws, avoiding the accuracy of pest identification affected by shooting height, shooting angle and pest size.
[0028] In a second aspect, an insect pest monitoring system includes: a processor and a memory, wherein the memory stores computer program instructions, and when the computer program instructions are executed by the processor, the above-mentioned insect pest monitoring method is implemented.
[0029] The present invention has the following effects:
[0030] 1. The present invention clusters the pest probability matrix, and the clustering result reflects the distribution of different pests in the probability matrix. According to the energy value and entropy value of the edge image, the edge features and shape features are obtained as the basis for adjusting the optimal clustering effect, which is conducive to obtaining accurate classification results and improving the accuracy of pest identification.
[0031] 2. The present invention can compare the information of newly discovered pests by continuously updating the standard pest vector information, reduce the possibility of being unable to identify pests due to limited training data, reduce the manpower and material resources consumed in model training, and at the same time improve the accuracy of model recognition.
[0032] 3. The present invention calculates the similarity between the feature vectors of the pest areas of each cluster corresponding to the best clustering result and the vector features of the standard pests, which is beneficial to analyzing the pest information corresponding to each cluster. The statistical similarity results reflect the types and numbers of pests in the real-time crop image, thereby more accurately predicting the type and number information of pests and increasing the timeliness of the prediction results. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] 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:
[0034] Figure 1 It is a method flow chart of steps S1 to S4 in an insect monitoring method according to an embodiment of the present invention.
[0035] Figure 2 It is a method flow chart of steps S30 to S34 in an insect monitoring method according to an embodiment of the present invention. DETAILED DESCRIPTION
[0036] 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.
[0037] The specific embodiments of the present invention are described in detail below with reference to the accompanying drawings.
[0038] Reference Figure 1 A method for detecting and reporting insect pests includes steps S1 to S4, which are specifically as follows:
[0039] S1: Obtain historical crop images of the area to be detected, mark pest areas in the historical crop images, and build a pest area dataset.
[0040] To further illustrate, historical crop images of the area to be detected are collected by a CCD / CMOS camera, and those skilled in the art mark the areas of pests in the images to obtain a pest area dataset.
[0041] S2: Build a Gaussian model based on the color features of the pest area dataset, obtain the pixel values corresponding to the color features of the crop image in real time and input them into the Gaussian model to obtain the pest probability matrix.
[0042] The color features of the pest area are the pixel values of the RGB (Red, Green, Blue) three channels. The mean and variance of the pixel values of the RGB three channels of the pest area are used to construct a Gaussian model of the pest area.
[0043] Traverse each pixel point in the real-time crop image, input the pixel value of each pixel point into the Gaussian model, calculate the probability density function value of each pixel point in the Gaussian model, use the probability density function value as the probability value that the pixel point belongs to the corresponding pest area, obtain the probability values of all pixels points to construct the pest probability matrix.
[0044] To further illustrate, the input of the Gaussian model is the pixel value of the RGB three-channel of the pixel point, and the output is the probability that the pixel point belongs to a pest, which can quickly obtain the information of the pest area of the real-time crop image.
[0045] S3: Cluster the pest probability matrix to obtain multiple clustering results, obtain the edge image corresponding to each cluster in each clustering result, calculate the energy value and entropy value of the edge image, construct a clustering evaluation function using the energy value as the edge feature and the entropy value as the shape feature, and obtain the best clustering result in response to the clustering evaluation function being the largest.
[0046] Reference Figure 2 , including steps S30 to S34:
[0047] S30: clustering the pest probability matrix based on density, presetting different clustering radii, obtaining clustering results with different clustering radii, respectively calculating the inter-class distances between each clustering cluster in each clustering result, merging two clustering clusters whose inter-class distances are less than the preset distance, and obtaining the merged clustering result under the corresponding clustering radius.
[0048] In the present embodiment, the DBSCAN algorithm can be used for clustering, and different clustering radii can be adjusted according to actual conditions. For example, the clustering radius is set to 5, 6, and 7, and 3 clustering results are obtained. The number of clusters for each clustering result is 3, 4, and 5. When the clustering radius is 5, the inter-class distances of the corresponding 3 clustering clusters are calculated respectively, and the clustering clusters whose inter-class distances are less than the preset distance are merged. If the number of clustering clusters after the merger is 3, 3, and 4, it means that when the clustering radius is 3, there are 3 clustering clusters, each clustering cluster corresponds to a pest area, and each pest area is a pest species. When the clustering radius is 6, there are 4 clustering clusters, of which 2 of the 4 pest areas are of the same pest species. At the same time, when the clustering radius is 7, there are 5 clustering clusters corresponding to 5 pest areas, of which 2 of the 5 pest areas are of the same pest species.
[0049] Further explanation, in this embodiment, the preset distance is 10, which can be adjusted by those skilled in the art according to actual conditions. The smaller the inter-class distance between two clusters, the more likely the two clusters are clusters of the same category. The number of pest species is determined based on the number of merged clusters. When measuring the clustering effect, the differences in edge features and shape features between clusters are large, while the differences in edge features and shape features within clusters are small. The edge features and shape features involved in the relationships between and within clusters can be used as influencing factors for judging the clustering effect.
[0050] In another embodiment, a K-Means clustering algorithm may be used to obtain multiple clustering results by using K=2, 3, 4, 5, and the best clustering result is also selected based on edge features and shape features.
[0051] S31: Obtain the position of the crop image where each cluster in the clustering result is located, set the pixel value in the cluster to 1, and set the pixel value of the remaining position to 0, to obtain a binary image of the cluster, take the product of the binary image and the real-time crop image as the cluster image, perform edge detection on the cluster image, and obtain an edge image of the cluster image.
[0052] To further illustrate, in this embodiment, canny edge detection is used to obtain the edge image of the cluster image. In addition, the Sobel operator, Prewitt operator, and Laplacian operator can also be used to obtain the edge image of the cluster image.
[0053] S32: According to the correlation of the pixel values of the pixel points in the edge image, the frequency of the grayscale values of the pixel pairs in the preset direction in the edge image is counted, a grayscale co-occurrence matrix is constructed, and the square of the grayscale values of the pixel pairs in the grayscale co-occurrence matrix is calculated to obtain the edge features of the edge image.
[0054] Among them, the preset directions are 0 degrees, 45 degrees, 90 degrees, and 135 degrees. The pixel pair refers to all combinations of grayscale values of each pixel point. The energy value of the edge image is calculated by calculating the square of the grayscale value of the pixel pair in the grayscale co-occurrence matrix.
[0055] Specifically, the edge features satisfy the following relationship:
[0056] ,
[0057] In the formula, Represents the edge features of the edge image, Represents the gray level co-occurrence matrix Line Grayscale value of the pixel pair at column position.
[0058] Further explanation: if the grayscale values of the pixel pairs in the grayscale co-occurrence matrix are similar, then Smaller values indicate fine edge textures; if some of the values are large and others are small, In pest detection, the statistical characteristics of the edge (such as the probability of a certain pixel combination appearing) of the same pest are the same regardless of its size, and the above formula calculates the statistical characteristics of the edge, so it will not be affected by the shooting focal length and the size of the pest.
[0059] For example, count any pixel point in the directions of 0 degrees, 45 degrees, 90 degrees, and 135 degrees respectively The gray value is , according to the preset distance point The gray value is Probability, statistics The frequency of occurrence, , Represents the minimum gray value in the edge image. Indicates the maximum gray value in the edge image.
[0060] In another embodiment, due to , Traversing all the gray values in the edge map requires a lot of calculations. We can set 8 pixel levels for the gray values of the pixels to obtain the gray level co-occurrence matrix, which is helpful to reduce the number of operations.
[0061] S33: According to the continuity of the grayscale values of the pixels in the edge image, the run lengths and frequencies of the pixel sequences with the same grayscale values in a preset direction are counted, a grayscale run matrix is constructed, and weighted summation is performed based on the run distances and row and column element values of the grayscale run matrix to obtain the shape features of the edge image.
[0062] The preset directions are 0 degrees, 45 degrees, 90 degrees, and 135 degrees. For the selected direction, traverse each row (e.g., horizontal direction) or each column (e.g., vertical direction) of the image and scan pixels from left to right (or from top to bottom). The number of consecutive pixels with the same grayscale value is recorded to form a run. If the pixel values are different or reach the boundary, the current run is terminated, and the grayscale run matrix is constructed using statistical information, where each row represents a grayscale value, each column represents the run length, and the matrix elements represent the frequency of the grayscale value corresponding to the run length.
[0063] Specifically, the shape feature satisfies the following relationship:
[0064] ,
[0065] In the formula, Represents the shape characteristics of the edge image, Represents the grayscale run matrix Line The run distance corresponding to the column elements, Represents the normalized grayscale run matrix Line Grayscale values of the pixel pairs in the column.
[0066] It should be noted that in pest detection, the shape characteristics of the edge of the same pest are the same regardless of its size. Pests at different angles and sizes will cause the length of their edges in the image to be different. However, the shape characteristics calculated by the above formula will not change significantly, because the above shape characteristics are calculated based on the number of occurrences of different edge lengths. Although the edge length of the same pest may change under different shooting environments, the number of its occurrences is relatively stable, avoiding the accuracy of pest identification affected by shooting height, shooting angle and pest size.
[0067] S34: applying a clustering evaluation function to each of the plurality of merged clustering results to obtain a clustering evaluation function value, and selecting a clustering result of a clustering radius corresponding to a maximum clustering evaluation function value as the best clustering result.
[0068] It is further explained that when the clustering effect is the best, the differences in texture features and edge features between clusters are large, and the differences in texture features and edge features within a cluster are small. At the same time, after clustering the pest probability matrix, different clusters may represent different pests or the same pests. Therefore, when the feature differences between two clusters are small, the two clusters are considered to be clusters formed by the same pest and are merged. The merged edge features and shape features are the means of the edge features and shape features of each cluster before the merger.
[0069] Specifically, the clustering evaluation function satisfies the following relationship:
[0070] ,
[0071] In the formula, represents the clustering evaluation function, Indicates The vector composed of the edge features and shape features of the clusters, Represents a vector consisting of the mean edge features and shape features of all clusters.
[0072] S4: According to the number of clusters corresponding to the best clustering result, multiple pest areas in the real-time crop image are obtained, and a feature vector data set of standard pests is obtained, and the distance between the feature vectors of each of the pest areas and the feature vector data set of standard pests is calculated. When the distance is less than or equal to a preset threshold, the cluster is the type of standard pest, and the number of types is obtained according to the cluster.
[0073] The distance between the feature vector of the pest area and the feature vector of the standard pest is calculated by using the Euclidean distance. The smaller the distance, the more similar the feature vector of the pest area is to the feature vector data set of the standard pest. When the Euclidean distance meets the set threshold, the pest area is considered to be a pest category corresponding to the standard pest. The number of pest categories is determined according to the number of clusters before merging. The threshold is set to 10, which can be adjusted by personnel in this field according to specific circumstances. In addition, Manhattan distance and Minkowski distance can also be used to calculate the similarity between vectors.
[0074] It is further explained that according to the number of clusters of the best clustering result, the number of clusters represents the pest area in the real-time crop image, and the Euclidean distance is calculated between the feature vector of the pest area and the feature vector of the standard pest. The Euclidean distance exceeds the set threshold, and the type of pest is obtained. The number of clusters before merging can be used to obtain the number of pest types.
[0075] In the description of this specification, "plurality" or "several" means at least two, such as two, three or more, etc., unless otherwise clearly and specifically defined.
[0076] Although this specification has shown and described a number of embodiments of the present invention, it will be apparent to those skilled in the art that such embodiments are provided by way of example only. Those skilled in the art will conceive of many modifications, changes and alternatives without departing from the ideas and spirit of the present invention. It should be understood that in the practice of the present invention, various alternatives to the embodiments of the present invention described herein may be employed.
Claims
1. A method for detecting and reporting insect pests, It is characterized in that include: Acquire historical crop images of the area to be detected, mark pest areas on the historical crop images, and construct a pest area dataset; A Gaussian model is constructed based on the color features of the pest area dataset, and the pixel values corresponding to the color features of the crop image are obtained in real time and input into the Gaussian model to obtain the pest probability matrix; Clustering the pest probability matrix to obtain multiple clustering results, obtaining edge images corresponding to each cluster in each clustering result, calculating energy values and entropy values of the edge images, and constructing a clustering evaluation function using the energy values as edge features and the entropy values as shape features. , where represents the clustering evaluation function, Indicates The vector composed of the edge features and shape features of the clusters, The vector consisting of the mean values of edge features and shape features of all clusters is represented. When the clustering evaluation function is the largest, the best clustering result is obtained. Calculating the energy value of the edge image includes: according to the correlation of the pixel values of the pixel points in the edge image, counting the frequency of the grayscale values of the pixel pairs in the preset direction in the edge image, constructing a grayscale co-occurrence matrix, and calculating the square of the grayscale values of the pixel pairs in the grayscale co-occurrence matrix to obtain the edge features of the edge image; calculating the entropy value of the edge image includes: according to the continuity of the grayscale values of the pixel points in the edge image, counting the run length and frequency of the pixel sequence with the same grayscale value in the preset direction, constructing a grayscale run matrix, and performing weighted summation according to the run distance and row and column element values of the row and column elements in the grayscale run matrix to obtain the shape features of the edge image; According to the number of clustering clusters corresponding to the best clustering result, multiple pest areas in the real-time crop image are obtained, and a feature vector data set of standard pests is obtained, and the distance between the feature vector of each pest area and the feature vector data set of the standard pest is calculated. In response to the distance being less than or equal to a preset threshold, the cluster is the type of the standard pest, and the number of types is obtained based on the cluster.
2. A method for detecting and reporting insect pests according to claim 1, It is characterized in that The Gaussian model is constructed according to the color features of the pest area data set, including: The color features of the pest area are the pixel values of the RGB three channels, and the mean and variance of the pixel values of the RGB three channels of the pest area are used to construct a Gaussian model of the pest area.
3. The insect monitoring method according to claim 1, It is characterized in that Obtaining the pest probability matrix includes the following specific steps: Traverse each pixel point in the real-time crop image, input the pixel value of each pixel point into the Gaussian model, calculate the probability density function value of each pixel point in the Gaussian model, use the probability density function value as the probability value that the pixel point belongs to the corresponding pest area, obtain the probability values of all pixels points to construct a pest probability matrix.
4. The insect monitoring method according to claim 1, It is characterized in that Obtaining the optimal clustering result includes the following steps: Clustering the pest probability matrix based on density, presetting different clustering radii, and obtaining clustering results with different clustering radii; Calculate the inter-class distance between each cluster in each clustering result respectively, merge two clusters whose inter-class distance is less than a preset distance, and obtain a merged clustering result under the corresponding clustering radius; A clustering evaluation function is applied to each of the plurality of merged clustering results to obtain a clustering evaluation function value, and a clustering result of a clustering radius corresponding to a maximum clustering evaluation function value is selected as an optimal clustering result.
5. The insect monitoring method according to claim 1, It is characterized in that Obtaining the edge image corresponding to the cluster comprises the steps of: After clustering is completed, the position of the crop image where each cluster is located is obtained, the pixel value in the cluster is set to 1, and the pixel values of other positions are set to 0, to obtain a binary image of the cluster, and the product of the binary image and the real-time crop image is used as the cluster image; Perform edge detection on the cluster image to obtain the edge image of the cluster image.
6. A pest monitoring system, It is characterized in that include: A processor and a memory, wherein the memory stores computer program instructions, and when the computer program instructions are executed by the processor, an insect monitoring method according to any one of claims 1 to 5 is implemented.
