Pest and disease classification and recognition method based on image enhancement
Through image enhancement technology, multi-label classification network and gamma correction algorithm are used to solve the problem of unclear feature differences in pest and disease identification, achieve accurate identification of pest and disease categories, and improve the accuracy of identification results.
Patent Information
- Application Number
- CN202410728103.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-06
- Publication Date
- 2024-10-11
- Estimated Expiration
- 2044-06-06
AI Technical Summary
In the existing technology, due to the numerous categories of pests and diseases, the differences in color features and texture features are not obvious, resulting in the inability to obtain accurate identification results of pests and diseases.
The pest classification and identification method based on image enhancement is used to obtain preliminary identification results through a multi-label classification network, construct an initial gamma vector to perform gamma correction on the image area, calculate inter-class distance and intra-class distance, and use the target gamma vector to further enhance the image , input multi-label classification network to obtain accurate recognition results.
It improves the accuracy of identification of pests and diseases, can effectively distinguish suspected categories, and ensures the accuracy and reliability of identification results.
Smart Images

Figure CN118314605B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing technology, and in particular to a method for classifying and identifying pests and diseases based on image enhancement. Background Art
[0002] With the rapid development of artificial intelligence technology and the rapid growth of population, agriculture as a key industry has also developed rapidly, and artificial intelligence technologies such as image processing and neural networks have gradually been applied to the agricultural field. In the agricultural field, pests and diseases have always been a matter of great concern. Correctly and efficiently identifying the types of crop diseases can enable crops to receive timely treatment, thereby reducing unnecessary losses and increasing crop yields.
[0003] At present, a patent application document with publication number CN109308697A discloses a leaf disease identification method based on a machine learning algorithm, the method comprising: collecting leaf crop sample images and preprocessing the images; segmenting the preprocessed crop sample images using an adaptive threshold segmentation method to highlight the texture features of the crop sample images; extracting the color features of the crop sample images and the texture features of the segmented images based on the RGB color space; extracting the features of all crop sample images, setting them as a sample feature set m, and constructing an SVM classification model using a cross-validation method; using a grid optimization method to find the optimal parameters to obtain the optimal SVM classification model, and inputting the test crop sample images into the trained SVM classification model to obtain the recognition results.
[0004] However, the above method obtains pest and disease identification results based on the color features and texture features of crop sample images, but there are many categories of pests and diseases, and the differences in color features and texture features in crop sample images of different pest and disease categories are not obvious, resulting in the inability to accurately obtain pest and disease identification results. Summary of the invention
[0005] In order to solve the technical problem of being unable to accurately obtain pest and disease identification results, the present application provides a pest and disease classification and identification method based on image enhancement, which can accurately obtain pest and disease identification results.
[0006] The present application provides a method for classifying and identifying pests and diseases based on image enhancement, the identification method comprising inputting a crop image into a multi-label classification network to obtain a first identification result, the first identification result comprising a suspected category and a determined category; constructing an initial gamma vector, the initial gamma vector comprising gamma parameters of various image regions; performing gamma correction on various image regions in a crop sample image of the suspected category according to the initial gamma vector to obtain an enhanced sample image, calculating the inter-class distance and intra-class distance of the suspected category in the enhanced sample image, taking the ratio of the inter-class distance to the intra-class distance as an objective function, and taking the initial gamma vector corresponding to the maximum value of the objective function as a target gamma vector; performing gamma correction on various image regions in the crop image according to the target gamma vector to obtain an enhanced crop image, and inputting the enhanced crop image into a multi-label classification network to obtain a second identification result; taking the second identification result and the determined category as a pest and disease identification result.
[0007] The beneficial effects are as follows: firstly, the suspected categories among all the pest and disease categories are determined; since the image features in various image regions have different effects on distinguishing the suspected categories in the crop images, different gamma parameters are configured for various image regions to obtain initial gamma vectors, and the image enhancement with different effects can be performed on various image regions according to the initial gamma vectors; further, the gamma parameters in the initial gamma vectors are continuously updated on the crop sample images, and the initial gamma vectors when the inter-class distance between the suspected categories is the largest and the intra-class distance is the smallest (that is, when the objective function is the largest) are used as the target gamma vectors, and then the target gamma vectors are used to perform gamma correction on the crop images, so that the enhanced crop images can effectively distinguish the suspected categories and obtain accurate pest and disease recognition results.
[0008] In some embodiments, the multi-label classification network includes a feature extraction subnetwork, a feature mapping subnetwork and a multi-classification subnetwork; the feature extraction subnetwork is used to extract features of the crop image to obtain image features; the feature mapping subnetwork is used to perform dimensionality transformation on the image features to obtain category feature values of each pest and disease category; the multi-classification subnetwork is used to map the category feature values into probability values corresponding to the pest and disease category, and the multi-classification subnetwork includes multiple logistic regression functions, and the logistic regression functions correspond one-to-one to the pest and disease categories.
[0009] The beneficial effect is that the multi-label classification network can output the probability value of each pest and disease category in the crop image, and can identify multiple pest and disease categories that exist in the crop at the same time.
[0010] In some embodiments, the training method of the multi-label classification network includes: collecting training crop images and obtaining category labels of the training crop images, wherein the category labels include label values for each pest and disease category, and the label values are 0 or 1; inputting the training crop images into the multi-label classification network to obtain predicted probability values for each pest and disease category; for a pest and disease category, calculating the cross entropy loss of the predicted probability value and the label value, and taking the sum of the cross entropy losses of each pest and disease category as the multi-label loss; performing back propagation based on the multi-label loss to train the multi-label classification network; and iteratively training the multi-label classification network until a preset condition is met and stopping.
[0011] In some embodiments, inputting the crop image into a multi-label classification network to obtain a first recognition result includes: inputting the crop image into a multi-label classification network to obtain a predicted probability value for each pest and disease category; in response to the predicted probability value being greater than a first probability threshold, marking the pest and disease category corresponding to the predicted probability value as an existing pest category; in response to the predicted probability value being less than a second probability threshold, marking the pest and disease category corresponding to the predicted probability value as a non-pest category; in response to the predicted probability value being less than or equal to the first probability threshold and greater than or equal to the second probability threshold, marking the pest and disease category corresponding to the predicted probability value as a suspected category; wherein the first probability threshold is greater than the second probability threshold; the existing pest category and the non-pest category correspond to the determined category.
[0012] The beneficial effect is that according to the predicted probability value of each pest and disease category output by the multi-label classification network, each pest and disease category is divided into existing pest category, non-pest category and suspected category. In the subsequent image enhancement process, only the inter-class distance and intra-class distance between suspected categories need to be considered, which reduces the difficulty of image enhancement, ensures the effect of image enhancement, and thus improves the accuracy of pest and disease recognition results.
[0013] In some embodiments, the method for acquiring the crop sample image of the suspected category includes: in response to any historical crop image belonging to the suspected category and not belonging to other pest and disease categories outside the suspected category, using the historical crop image as the crop sample image of the suspected category.
[0014] In some embodiments, inputting the enhanced crop image into a multi-label classification network to obtain a second recognition result includes: inputting the enhanced crop image into the multi-label classification network to obtain a second predicted probability value for each pest and disease category; in response to the second predicted probability value being greater than a third probability threshold, marking the pest and disease category corresponding to the second predicted probability value as a pest category, otherwise, marking the pest and disease category corresponding to the second predicted probability value as a non-pest category.
[0015] In some embodiments, before calculating the inter-class distance and intra-class distance of the suspected categories in the enhanced sample image, the recognition method also includes: inputting the crop image into a semantic segmentation network to obtain various image regions of the crop image, the image regions including leaf regions, fruit regions, and branch regions; and using a gradient weighted class activation mapping algorithm to obtain the classification contribution of each image region in the crop image to each suspected category.
[0016] The beneficial effects are as follows: in the multi-label classification network, the probability values of each pest and disease category are obtained based on the image features output by the feature extraction subnetwork; for each pest and disease category, when the multi-label classification network obtains its probability value, it pays different attention to each type of image area in the crop image, that is, each type of image area has a different contribution to the classification of the suspected category; therefore, the accurate measurement of the contribution of each type of image area to the classification of the suspected category is achieved through the gradient weighted class activation mapping algorithm, which can accurately reflect the importance of each type of image area in distinguishing the suspected category, and thus enable the objective function to accurately characterize the effectiveness of the enhanced sample image in distinguishing the suspected category.
[0017] In some embodiments, the classification contribution of each image area in the crop image to each suspected category is obtained using a gradient weighted class activation mapping algorithm, including: for any suspected category, obtaining a class activation map of the suspected category using a gradient weighted class activation mapping algorithm, the class activation map including the contribution value of each position point in the crop image to the suspected category; for any type of image area, calculating the sum of the average contribution values of the image area in the class activation map of each suspected category to obtain the classification contribution of the image area to each suspected category.
[0018] In some embodiments, calculating the inter-class distance and intra-class distance of suspected categories in the enhanced sample image includes: respectively multiplying the enhanced sample image with the mask map of each type of image area to obtain a regional enhancement map of each type of image area, wherein in the mask map of the image area, the value of the position point in the image area is 1, and the value of the position point outside the image area is 0; respectively inputting the regional enhancement map of each type of image area into the multi-label classification network to obtain image features of each type of image area, and performing weighted summation of the image features according to the classification contribution of each type of image area to obtain classification reference features; the inter-class distance corresponds to the Euclidean distance of the classification reference features between each suspected category; and the intra-class distance corresponds to the Euclidean distance of the classification reference features within each suspected category.
[0019] The beneficial effect is that the classification reference feature comprehensively considers the image features of various image areas and the classification contribution to the suspected category, and calculates the inter-class distance and intra-class distance of the suspected category through the classification reference feature, so that the inter-class distance and intra-class distance can accurately characterize the effectiveness of the enhanced sample image in distinguishing the suspected category. The larger the inter-class distance and the smaller the intra-class distance, the easier it is to accurately distinguish the suspected category of the enhanced crop sample image.
[0020] The technical solution of this application has the following beneficial technical effects:
[0021] The above-mentioned pest and disease classification and identification method based on image enhancement provided in the embodiment of the present application first determines the suspected categories among all pest and disease categories; performs image enhancement of different effects on various image areas in the crop sample image through the gamma parameters in the initial gamma vector to obtain an enhanced sample image, and calculates the inter-class distance and intra-class distance of the suspected category in the enhanced sample image. The inter-class distance and intra-class distance can accurately characterize the effectiveness of the enhanced sample image in distinguishing the suspected categories. The larger the inter-class distance and the smaller the intra-class distance (that is, the larger the objective function), the easier it is for the enhanced crop sample image to accurately distinguish the suspected categories; further, the initial gamma vector corresponding to the maximum value of the objective function is determined by an optimization algorithm to obtain a target gamma vector, and the target gamma vector is used to perform gamma correction on the crop image, so that the enhanced crop image can effectively distinguish the suspected categories, thereby obtaining an accurate pest and disease identification result. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] By reading the detailed description below with reference to the accompanying drawings, the above and other purposes, features and advantages of the exemplary embodiments of the present application will become easy to understand. In the accompanying drawings, several embodiments of the present application are shown in an exemplary and non-limiting manner, and the same or corresponding reference numerals represent the same or corresponding parts, wherein:
[0023] Figure 1 is a flow chart of a method for classifying and identifying pests and diseases based on image enhancement according to an embodiment of the present application;
[0024] Figure 2 It is a structural diagram of a multi-label classification network according to an embodiment of the present application. DETAILED DESCRIPTION
[0025] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present application.
[0026] It should be understood that when the application uses the terms "first", "second", etc., they are only used to distinguish different objects, rather than to describe a specific order. The terms "include" and "comprise" used in the application indicate the presence of the described features, wholes, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or their collections.
[0027] This application provides a method for classifying and identifying pests and diseases based on image enhancement. Figure 1 FIG. 1 is a flowchart of a method for classifying and identifying pests and diseases based on image enhancement according to an embodiment of the present application. According to different requirements, the order of the steps in the flowchart can be changed, and some steps can be omitted.
[0028] S11, inputting the crop image into a multi-label classification network to obtain a first recognition result, wherein the first recognition result includes a suspected category and a confirmed category.
[0029] In one embodiment, since crops may have multiple pests and diseases at the same time, pest and disease classification and identification can be regarded as a multi-label classification task, which can determine all the types of pests and diseases existing in the crop based on the crop image.
[0030] See also Figure 2 , is a schematic diagram of the structure of a multi-label classification network according to an embodiment of the present application. The multi-label classification network includes a feature extraction subnetwork 21, a feature mapping subnetwork 22 and a multi-classification subnetwork 23; the feature extraction subnetwork 21 is used to extract features from the crop image to obtain image features; the feature mapping subnetwork 22 is used to perform dimensional transformation on the image features to obtain category feature values of each pest category; the multi-classification subnetwork 23 is used to map the category feature values to probability values of corresponding pest categories, and the multi-classification subnetwork 23 includes multiple logistic regression functions, which correspond to pest categories one by one, and the logistic regression function is used to map the category feature values of the corresponding pest categories to probability values. The probability value ranges from 0 to 1.
[0031] The feature extraction subnetwork 21 uses a convolutional neural network, specifically, an existing convolutional neural network such as VGGNet, ResNet or DenseNet; the feature mapping subnetwork 22 uses a fully connected neural network. The logistic regression function is a well-known technology for those skilled in the art and will not be described in detail here.
[0032] For example, if there are 8 categories of pests and diseases, including rice planthoppers, powdery mildew, corn borers, cotton bollworms, wheat rust, cotton aphids, rice sheath blight, and locusts, the size of the category feature vector is 8 rows and 1 column, including a total of 8 category feature values; at the same time, the multi-classification subnetwork 23 can output probability values of the 8 categories of pests and diseases.
[0033] In one embodiment, in order to enable the multi-label classification network to learn the mapping relationship between the input image and the pest and disease identification result, the multi-label classification network needs to be trained. Specifically, the training method of the multi-label classification network includes: collecting training crop images and obtaining the category labels of the training crop images, the category labels include label values of each pest and disease category, and the label values are 0 or 1; inputting the training crop images into the multi-label classification network to obtain the predicted probability value of each pest and disease category; for a pest and disease category, calculating the cross entropy loss of the predicted probability value and the label value, and taking the sum of the cross entropy losses of each pest and disease category as the multi-label loss; performing back propagation based on the multi-label loss to train the multi-label classification network; iteratively training the multi-label classification network until the preset conditions are met and stopping.
[0034] The training crop image is a crop image used to train a multi-label classification network; the multi-label loss satisfies the relationship:
[0035] ;in, represents the number of all pests and diseases categories, For the The predicted probability value of each pest category, For the The label value of the pest category, Indicates The cross entropy loss of the pest categories, is the value of the multi-label loss; the preset condition is that the value of the multi-label loss is less than the set value or the number of iterations is greater than the set number. When the preset condition is met, it means that the trained multi-label classification network is obtained and the training is stopped.
[0036] Among them, the set value is 0.001, and the set number of times is 500.
[0037] Exemplarily, the process of "obtaining the category label of the training crop image" is set manually; for a total of 8 categories of pests and diseases, including rice planthoppers, powdery mildew, corn borer, cotton bollworm, wheat rust, cotton aphids, rice sheath blight and locusts, if crops have both rice planthoppers and corn borers as pests and diseases, then in the training crop image corresponding to the crop, the label values corresponding to rice planthoppers and corn borer are 1, and the label values corresponding to powdery mildew, cotton bollworm, wheat rust, cotton aphids, rice sheath blight and locusts are 0.
[0038] In one embodiment, inputting the crop image into a multi-label classification network to obtain a first recognition result includes: inputting the crop image into the multi-label classification network to obtain a first predicted probability value for each pest category; in response to the first predicted probability value being greater than a first probability threshold, marking the pest category corresponding to the first predicted probability value as an existing pest category; in response to the first predicted probability value being less than a second probability threshold, marking the pest category corresponding to the first predicted probability value as a non-pest category; in response to the first predicted probability value being less than or equal to the first probability threshold and greater than or equal to the second probability threshold, marking the pest category corresponding to the first predicted probability value as a suspected category; wherein the first probability threshold is greater than the second probability threshold; the existing pest category and the non-pest category correspond to the determined category.
[0039] The value of the first probability threshold is 0.7, and the value of the second probability threshold is 0.3.
[0040] In this way, the suspected categories and confirmed categories of the crop images are obtained based on the multi-label classification network, and the union of the suspected categories and the confirmed categories covers all pest and disease categories.
[0041] S12, constructing an initial gamma vector, where the initial gamma vector includes gamma parameters of various image regions.
[0042] In one embodiment, in response to the number of suspected categories being equal to 0, the presence of pest categories and non-pest categories in the crop image can be accurately determined, and the pest identification result can be directly obtained; in response to the number of suspected categories being greater than 0, steps S12 to S15 are continued.
[0043] In one embodiment, in order to accurately distinguish each suspected category, it is necessary to perform gamma correction on each image region in the crop image to increase the inter-class difference of the suspected categories in the crop image.
[0044] In this application, gamma correction is used to enhance various image areas in crop images. The gamma correction satisfies the relationship: ;in, is the image before enhancement, is the gamma parameter, represents the enhanced image. When , the contrast of low gray value areas is enhanced, the contrast of high gray value areas is reduced, and the detail features of low gray value areas are enhanced; when When , the contrast of low gray value areas decreases, the contrast of high gray value areas increases, and the detail features of high gray value areas are enhanced; when When , the image before enhancement is the same as the image after enhancement; therefore, different gamma parameters correspond to different image enhancement effects. Therefore, it is necessary to accurately determine the gamma parameters of various image areas in the crop image.
[0045] Among them, various image regions include leaf regions, fruit regions and branch regions, and different gamma parameters are used for gamma correction of different types of image regions, so that the enhanced image can distinguish the suspected categories. Specifically, the initial gamma vector includes gamma parameters of various image regions, and illustratively, the gamma parameters of various image regions in the initial gamma vector are all 1.
[0046] S13, performing gamma correction on various image areas in the crop sample image of the suspected category according to the initial gamma vector, obtaining an enhanced sample image, calculating the inter-class distance and intra-class distance of the suspected category in the enhanced sample image, taking the ratio of the inter-class distance to the intra-class distance as the objective function, and taking the initial gamma vector corresponding to the maximum value of the objective function as the target gamma vector.
[0047] In one embodiment, it is necessary to first obtain sample images of crops of suspected categories, and then calculate the inter-class distance and intra-class distance of each suspected category on the sample images of suspected categories. Specifically, the method for obtaining sample images of crops of suspected categories includes: in response to any historical crop image belonging to the suspected category and not belonging to other pest and disease categories outside the suspected category, taking the historical crop image as the sample image of crops of the suspected category.
[0048] Since a historical crop image may contain multiple pests and diseases, taking the suspected category of "cotton bollworm" as an example, if a historical crop image only contains cotton bollworm and no other pests and diseases except cotton bollworm, then the historical crop image is used as a crop sample image of the suspected category "cotton bollworm". One suspected category corresponds to multiple crop sample images.
[0049] It should be noted that the historical crop image may also be the training crop image in step S11.
[0050] It can be understood that, since the number of suspected categories is one or more, each suspected category corresponds to a plurality of crop sample images.
[0051] In one embodiment, after obtaining a crop sample image of a suspected category, the crop sample image is labeled to obtain various image regions in the crop sample image, that is, to obtain a leaf region, a fruit region, and a branch region in each crop sample image, wherein the labeling process may be manually labeled. Gamma correction is performed on various image regions in the crop sample image according to the gamma parameters in the initial gamma vector to obtain an enhanced sample image. Specifically, for any type of image region, the gamma parameters of the image region in the initial gamma vector are used to perform gamma correction on the image region in the crop sample image; after gamma correction is performed on various image regions in the crop sample image, an enhanced sample image is obtained.
[0052] It can be understood that in the enhanced sample image obtained according to the initial gamma vector, the enhancement effects of various image areas are different. In order to measure the effectiveness of the enhanced sample image in distinguishing suspected categories, the inter-class distance and intra-class distance of the suspected categories in the enhanced sample image are calculated, and the ratio of the inter-class distance to the intra-class distance is used as the objective function. The objective function can characterize the effectiveness of the enhanced sample image in distinguishing suspected categories.
[0053] In an optional embodiment, for a suspected category, the average value of all enhanced sample images is calculated to obtain the average image of the suspected category; the Euclidean distance between the average images of different suspected categories is used as the inter-class distance; within the same suspected category, the Euclidean distance between each enhanced sample image and the average image is calculated, and the sum of all Euclidean distances is used as the intra-class distance of the suspected category.
[0054] In another embodiment, in the multi-label classification network, the feature mapping subnetwork 22 and the multi-classification subnetwork 23 obtain the probability values of each pest and disease category based on the image features output by the feature extraction subnetwork 21, and when the feature mapping subnetwork 21 extracts features from the crop image, it pays different attention to various image areas in the crop image, that is, the classification contribution of each image area to the suspected category.
[0055] In order to make the objective function more accurately characterize the effectiveness of the enhanced sample image in distinguishing suspected categories, when calculating the inter-class distance and intra-class distance of the suspected categories in the enhanced sample image, the recognition method also includes: inputting the crop image into a semantic segmentation network to obtain various image regions of the crop image, the image regions including leaf regions, fruit regions and branch regions; and using a gradient weighted class activation mapping algorithm to obtain the classification contribution of each image region in the crop image to each suspected category.
[0056] The input of the semantic segmentation network is any crop image, and the output is the leaf region, fruit region and branch region in the crop image. The semantic segmentation network can adopt an existing semantic segmentation network such as FCN or UNet. It is a well-known technology for those skilled in the art to obtain the leaf region, fruit region and branch region in the crop image using the semantic segmentation network, and will not be described in detail here.
[0057] Furthermore, the Grad-CAM algorithm (gradient weighted class activation mapping algorithm) is used to determine the classification contribution of each image region to each suspected category. Among them, the Grad-CAM algorithm can output the activation heat map of each suspected category.
[0058] Specifically, using the gradient weighted class activation mapping algorithm to obtain the classification contribution of each image region in the crop image to each suspected category includes: for any suspected category, using the gradient weighted class activation mapping algorithm to obtain the class activation map of the suspected category, the class activation map includes the contribution value of each position point in the crop image to the suspected category; for any type of image region, calculating the sum of the average contribution values of the image region in the class activation map of each suspected category, and obtaining the classification contribution of the image region to each suspected category. Wherein, the activation heat map is equal to the size of the crop image, and for the activation heat map of a suspected category, the contribution value of a position point is used to reflect the degree of attention paid to the position point in the crop image when obtaining the predicted probability value of the suspected category.
[0059] Furthermore, after obtaining the classification contribution of each image area in the crop image to each suspected category, the inter-class distance and intra-class distance of the suspected category in the enhanced sample image are calculated, specifically including: multiplying the enhanced sample image with the mask map of each type of image area respectively to obtain the regional enhancement map of each type of image area, wherein in the mask map of the image area, the value of the position point in the image area is 1, and the value of the position point outside the image area is 0; inputting the regional enhancement map of each type of image area into the multi-label classification network respectively to obtain the image features of each type of image area, and performing weighted summation on the image features according to the classification contribution of each type of image area to obtain the classification reference features; the inter-class distance corresponds to the Euclidean distance of the classification reference features between each suspected category; and the intra-class distance corresponds to the Euclidean distance of the classification reference features within each suspected category.
[0060] Exemplarily, for an enhanced sample image, the values of the position points in the leaf area of the enhanced sample image are set to 1, and the values of the position points outside the leaf area are set to 0 to obtain a mask map of the leaf area. The mask map of the leaf area is multiplied by the enhanced sample image to obtain a regional enhancement map of the leaf area. The regional enhancement map of the leaf area is input into the multi-label classification network to obtain the image features output by the feature extraction subnetwork 21 in the multi-label classification network as the image features of the leaf area. The regional enhancement maps of various image areas are obtained in the same way. The regional enhancement maps of various image areas are weighted and summed according to the classification contribution of each image area to obtain a classification reference feature. The classification reference feature satisfies the relationship:
[0061] ;in, , and are the classification contributions of the leaf area, fruit area, and branch area, respectively. For the The classification contribution of the image region, For the The image features of the image region, is the classification reference feature. For example, when hour, is the image feature of the leaf area, when hour, is the image feature of the fruit area, when hour, is the image feature of the branch area.
[0062] In one embodiment, the objective function satisfies the relationship:
[0063] ;in, is the number of all enhanced sample images, For the The classification reference features of the enhanced sample image, For the The classification reference average feature of the suspected category to which the enhanced sample image belongs, is the number of each suspected category, For the The enhanced sample image belongs to a category other than the suspected category. The average characteristics of the classification references of other suspected categories, is the value of the objective function; The suspected category to which the enhanced sample image belongs is calculated, and the average value of the classification reference features of all corresponding enhanced sample images is obtained to obtain the classification reference average feature .
[0064] Similarly, calculate the The average classification reference features of all enhanced sample images corresponding to other suspected categories are obtained .
[0065] Understandably, is the number of all other suspected categories, Representation calculation The Euclidean distance of the reference features of the classification in each suspected category can be used as the first The intra-class difference of the enhanced sample images; Representation calculation The Euclidean distance of the reference features between the suspected categories can be used as the first The enhanced sample image and The inter-class difference between other suspected categories, the smaller the intra-class difference, the greater the inter-class difference, the objective function The larger the value of The more enhanced sample images are, the easier it is to be correctly classified. After the enhanced sample image is gamma corrected, the category features in the enhanced sample image are more obvious.
[0066] It should be noted that when the number of suspected categories is 1, the number of all other suspected categories The value of is 0, then The enhanced sample image and The inter-class differences between other suspected classes are set to 0.
[0067] In another embodiment, after obtaining the classification reference features corresponding to the enhanced sample images of each suspected category, the intra-class distance can be calculated based on the similarity between the classification reference features within each suspected category, and the inter-class distance can be calculated based on the similarity between the classification reference features between each suspected category; or other existing methods for calculating the intra-class distance and the inter-class distance can be used, which will not be repeated here.
[0068] In one embodiment, the gamma parameters in the initial gamma vector are continuously adjusted using an optimization algorithm, and the initial gamma vector corresponding to the maximum value of the objective function is used as the target gamma vector. The target gamma vector includes target gamma parameters of various image regions.
[0069] The optimization algorithm may be an existing optimization algorithm such as a genetic algorithm, a hill climbing algorithm or a particle swarm algorithm.
[0070] In this way, gamma correction is performed on the crop sample images of each suspected category according to the initial gamma vector, and then an objective function is constructed. The objective function can characterize the effectiveness of the enhanced sample image in distinguishing the suspected categories. The larger the objective function, the easier it is to accurately distinguish the suspected categories with the enhanced crop sample image. In other words, the more obvious the category features related to the suspected categories in the enhanced sample image, the more effective the enhanced sample image is in distinguishing the suspected categories.
[0071] S14, performing gamma correction on various image regions in the crop image according to the target gamma vector to obtain an enhanced crop image, and inputting the enhanced crop image into a multi-label classification network to obtain a second recognition result.
[0072] In one embodiment, the target gamma vector includes target gamma parameters of various image areas, and the process of obtaining an enhanced crop image includes: performing gamma correction on corresponding image areas in the crop image according to the target gamma parameters; and obtaining an enhanced crop image after performing gamma correction on various image areas in the crop image.
[0073] In this way, different gamma parameters are used to perform gamma correction on different image regions in the crop image to obtain an enhanced crop image. The enhanced crop image includes category features related to the suspected category and can effectively distinguish the suspected category.
[0074] In one embodiment, inputting the enhanced crop image into the multi-label classification network to obtain the second recognition result includes: inputting the enhanced crop image into the multi-label classification network to obtain a second predicted probability value for each pest category; in response to the second predicted probability value being greater than a third probability threshold, marking the pest category corresponding to the second predicted probability value as a pest category, and conversely, marking the pest category corresponding to the second predicted probability value as a non-pest category. The value of the third probability threshold is 0.7.
[0075] It can be understood that since the suspected categories and confirmed categories have been clearly identified in the first recognition result, and the subsequent image enhancement process is performed on each suspected category, inputting the enhanced crop image into the multi-label classification network can accurately determine which of the suspected categories are pest categories and which are non-pest categories.
[0076] S15, using the second identification result and the determined category as a disease and insect pest identification result.
[0077] Specifically, the second recognition result and the existing pest category in the category determined in step S11 are used as the pest recognition result.
[0078] The above-mentioned pest and disease classification and identification method based on image enhancement provided in the embodiment of the present application first determines the suspected categories among all pest and disease categories; performs image enhancement of different effects on various image areas in the crop sample image through the gamma parameters in the initial gamma vector to obtain an enhanced sample image, and calculates the inter-class distance and intra-class distance of the suspected category in the enhanced sample image. The inter-class distance and intra-class distance can accurately characterize the effectiveness of the enhanced sample image in distinguishing the suspected categories. The larger the inter-class distance and the smaller the intra-class distance (that is, the larger the objective function), the easier it is for the enhanced crop sample image to accurately distinguish the suspected categories; further, the initial gamma vector corresponding to the maximum value of the objective function is determined by an optimization algorithm to obtain a target gamma vector, and the target gamma vector is used to perform gamma correction on the crop image, so that the enhanced crop image can effectively distinguish the suspected categories, thereby obtaining an accurate pest and disease identification result.
[0079] The technical features of the above-described embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above-described embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0080] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the patent application. It should be pointed out that, for ordinary technicians in this field, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application.
Claims
1. A pest and disease classification and identification method based on image enhancement, characterized in that: The identification method comprises: Inputting the crop image into a multi-label classification network to obtain a first recognition result, wherein the first recognition result includes a suspected category and a confirmed category; Constructing an initial gamma vector, wherein the initial gamma vector includes gamma parameters of various image regions; gamma correction is performed on various image regions in the sample image of the crop of the suspected category according to the initial gamma vector to obtain an enhanced sample image, a target function is constructed, and the initial gamma vector corresponding to the maximum value of the target function is used as a target gamma vector; performing gamma correction on various image regions in the crop image according to the target gamma vector to obtain an enhanced crop image, and inputting the enhanced crop image into a multi-label classification network to obtain a second recognition result; Using the second identification result and the determined category as a pest identification result; The method for acquiring the crop sample image of the suspected category includes: In response to any historical crop image belonging to the suspected category and not belonging to other pest and disease categories outside the suspected category, taking the historical crop image as a crop sample image of the suspected category; The objective function for: ;in, is the number of all enhanced sample images, For the The classification reference features of the enhanced sample image, For the The classification reference average features of all enhanced sample images in the suspected category to which the enhanced sample image belongs, is the number of suspected categories, For the The enhanced sample image belongs to a category other than the suspected category. The classification reference average features of all enhanced sample images in other suspected categories; ;in, , and are the classification contributions of the leaf area, fruit area, and branch area, respectively. , , are the image features of the leaf area, fruit area and branch area respectively, is a classification reference feature; the classification contribution is obtained through a gradient weighted class activation mapping algorithm.
2. The method for classifying and identifying pests and diseases based on image enhancement according to claim 1, characterized in that: The multi-label classification network includes a feature extraction subnetwork, a feature mapping subnetwork and a multi-classification subnetwork; The feature extraction subnetwork is used to extract features from the crop images to obtain image features; the feature mapping subnetwork is used to perform dimensional transformation on the image features to obtain category feature values of each pest and disease category; the multi-classification subnetwork is used to map the category feature values into probability values corresponding to the pest and disease category, and the multi-classification subnetwork includes multiple logistic regression functions, and the logistic regression functions correspond one-to-one to the pest and disease categories.
3. The method for classifying and identifying pests and diseases based on image enhancement according to claim 2, characterized in that: The training method of the multi-label classification network includes: Collecting training crop images and obtaining category labels of the training crop images, wherein the category labels include label values of various pest and disease categories, and the label values are 0 or 1; Inputting the training crop image into the multi-label classification network to obtain the predicted probability value of each pest and disease category; For a pest and disease category, the cross entropy loss of the predicted probability value and the label value is calculated, and the sum of the cross entropy losses of each pest and disease category is used as the multi-label loss; Performing back propagation according to the multi-label loss to train the multi-label classification network; The multi-label classification network is trained iteratively until a preset condition is met.
4. The method for classifying and identifying pests and diseases based on image enhancement according to claim 2, characterized in that: The step of inputting the crop image into the multi-label classification network to obtain a first recognition result includes: Input the crop image into a multi-label classification network to obtain a first predicted probability value for each pest category; in response to the first predicted probability value being greater than a first probability threshold, mark the pest category corresponding to the first predicted probability value as an existing pest category; in response to the first predicted probability value being less than a second probability threshold, mark the pest category corresponding to the first predicted probability value as a non-pest category; in response to the first predicted probability value being less than or equal to the first probability threshold and greater than or equal to the second probability threshold, mark the pest category corresponding to the first predicted probability value as a suspected category; The first probability threshold is greater than the second probability threshold; the pest-existing category and the non-pest-existing category correspond to the determined category.
5. The method for classifying and identifying pests and diseases based on image enhancement according to claim 1, characterized in that: Inputting the enhanced crop image into a multi-label classification network to obtain a second recognition result includes: The enhanced crop images are input into the multi-label classification network to obtain the second predicted probability value of each pest and disease category; In response to the second predicted probability value being greater than the third probability threshold, the pest category corresponding to the second predicted probability value is marked as a pest-existing category; otherwise, the pest category corresponding to the second predicted probability value is marked as a non-pest category.
