Pepper disease and pest detection method and system based on improved YOLOv11n and storage medium
By collecting unobstructed lesion samples, extracting the lesion center point, region radius, hue mean, and texture entropy value, and combining contour completion model and texture feature fusion technology, the problem of insufficient detection accuracy in lesion occlusion scenarios within seedling trays was solved, achieving accurate detection of pepper diseases and pests.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-24
- Publication Date
- 2026-04-07
AI Technical Summary
Existing technologies struggle to accurately locate and classify lesions in situations where overlapping leaves obscure lesions within chili seedling trays, and lack effective pixel completion and fusion methods, resulting in insufficient detection accuracy.
By collecting unobstructed lesion samples, the center point, region radius, mean hue, and texture entropy of the lesions are extracted. Combined with contour completion model and texture feature fusion technology, the complete contour of the lesions is reconstructed and the pixel information of the occluded region is completed. The results are then input into the improved YOLOv11n for detection.
It achieves quantitative determination of lesion type and stage division in occluded scenes, accurately defines the range of occluded areas, improves detection accuracy, and avoids texture discontinuity and color deviation between the completed area and the visible area.
Smart Images

Figure CN121414734B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of pepper pest and disease detection technology, specifically to a pepper pest and disease detection method, system, and storage medium based on an improved YOLOv11n. Background Technology
[0002] As a widely cultivated economic crop globally, the control of pests and diseases during the seedling stage directly determines the subsequent yield and quality of chili peppers. Due to the dense spacing of seedlings in seedling trays, leaves and stems easily overlap, often obscuring lesions (such as those caused by the green peach aphid and anthracnose) on the stem base and the underside of leaves. This obscuring rate can reach 20%-60%, posing a significant challenge to accurate pest and disease detection. Traditional manual detection methods are inefficient and highly subjective, failing to meet the rapid detection needs of large-scale seedling farms. Therefore, automated detection technologies based on computer vision and deep learning have become a research hotspot.
[0003] In recent years, the YOLO series of object detection algorithms have been widely used in the field of plant disease and pest detection due to their good balance between detection speed and accuracy. However, there are still some shortcomings. For scenarios where lesions are obscured by overlapping leaves in pepper seedling trays, existing technologies can only perform direct inference based on the visible area of the incomplete lesions. Due to the lack of effective texture and shape features, it is difficult to achieve accurate localization and classification of lesions. At the same time, there is a lack of pixel completion and fusion methods based on the texture features of the visible area of the leaves, resulting in abrupt transitions between the completed area and the visible area, obvious texture breaks, and reduced accuracy of pepper disease and pest detection.
[0004] The information disclosed in the background section is only intended to enhance the understanding of the background of this disclosure, and therefore may include information that does not constitute prior art known to those skilled in the art. Summary of the Invention
[0005] The purpose of this invention is to provide a method, system, and storage medium for detecting diseases and pests in chili peppers based on an improved YOLOv11n, in order to solve the problems mentioned in the background art.
[0006] To achieve the above objectives, the present invention provides the following technical solution:
[0007] A method for detecting diseases and pests in chili peppers based on an improved YOLOv11n, comprising the following steps:
[0008] S1. Collect unobstructed images of pepper leaf samples with known lesion types, extract the lesion areas from all sample images and determine the center point, and use the maximum pixel distance from the edge of the lesion area to the center point as the radius of the lesion area.
[0009] S2. Obtain an image of the visible area of the pepper leaf to be identified, and extract the visible lesion area from it;
[0010] S3. Based on the radius of the lesion area, determine the preliminary lesion type of the visible lesion area, combine its hue mean and texture entropy value to determine the lesion development stage, and determine the reference radius of the visible lesion area according to the lesion development stage;
[0011] S4. Obtain the outline and circumference of the visible lesion area. Input the outline, circumference, and reference radius of the visible lesion area into the outline completion model and output the complete outline of the lesion.
[0012] S5. Collect the baseline texture features of the preliminary lesion type, complete the pixel information of the occluded area within the complete outline of the lesion, merge them into the complete lesion area, and reconstruct it into a complete leaf image. Input the improved YOLOv11n trained based on the sample images of pepper leaves, and select the result with the highest confidence as the final lesion type of pepper leaf.
[0013] Furthermore, the types of lesions include green peach aphid, silver leaf whitefly, thrips, cotton bollworm, and anthracnose.
[0014] Furthermore, the center point of each lesion region in the sample image is determined, and the specific logic is as follows:
[0015] For each lesion area, it is binarized, where the pixels in the lesion area are 1 and the background pixels are 0.
[0016] Collect the coordinates of all pixels within the lesion area to form a set of pixel coordinates;
[0017] Calculate the arithmetic mean of the x and y coordinates of all pixels in the pixel coordinate set, and use it as the x and y coordinates of the center point;
[0018] Combine the x and y coordinates of the center point to obtain the coordinates of the center point of the lesion area.
[0019] Furthermore, taking the center point of the lesion region as the center and the maximum pixel distance from the edge of the lesion region to the center point as the radius of the lesion region, the specific logic is as follows:
[0020] Based on the coordinates of the center point of the lesion region, all edge pixels with a pixel value of 1 in the binarized image of the lesion region are extracted to form a set of edge pixel coordinates.
[0021] Calculate the pixel distance from each edge pixel in the set of edge pixel coordinates to the center point;
[0022] From all pixel distances, select the distance value with the largest value and use that distance value as the radius of the lesion area.
[0023] Furthermore, based on the radius of the lesion area, the preliminary lesion type of the visible lesion area is determined, and the specific logic is as follows:
[0024] Take the intersection of the diagonals of the visible lesion bounding box as the center point, and calculate the maximum pixel distance from the edge of the lesion region to the center point as the radius of the visible lesion region;
[0025] Statistically analyze the radius range of all lesion types at all stages. If the radius of the visible lesion area falls only within the range of a single lesion type, the lesion type is directly determined to be a preliminary lesion type.
[0026] If the radius of the visible lesion area falls within the radius range of multiple lesion types, calculate the absolute value of the difference between the radius of the visible lesion area and the average radius of the multiple lesion types, and select the lesion type with the smallest absolute value of the difference as the preliminary lesion type.
[0027] Among them, the average radius of lesion type refers to the arithmetic mean of the radius of the lesion area of the corresponding lesion type in the pepper leaf sample.
[0028] Furthermore, the lesion development stage is determined by combining its hue mean and texture entropy value. Based on the lesion development stage, the reference radius of the visible lesion area is determined. The specific logic is as follows:
[0029] For the preliminarily identified lesion types, the mean range of hue and the range of texture entropy values were statistically analyzed in the three development stages of the initial stage, the peak stage and the decline stage, and a one-to-one correspondence model was established.
[0030] The extracted mean hue and texture entropy values of the visible lesion area are substituted into the association model corresponding to the preliminary lesion type. If the mean hue and texture entropy values fall within the feature interval of any of the above development stages, the visible lesion is determined to be in that development stage.
[0031] Retrieve the radii of all samples corresponding to the initial lesion type at this development stage, calculate the mean radius of this development stage, and use this mean radius as the reference radius of the visible lesion area.
[0032] Furthermore, the baseline texture features of the preliminary lesion type are collected, the pixel information of the occluded area within the complete outline of the lesion is completed, fused into the complete lesion area, and reconstructed into a complete leaf image. The specific logic is as follows:
[0033] Collect baseline texture features for preliminary lesion types. The baseline texture features include energy, entropy, and contrast.
[0034] Pixel information consistent with the baseline texture features is generated using texture interpolation. The generated pixel information is then filled into the pixel space of the occluded area to complete the pixel filling of the occluded area.
[0035] The filled occluded area is merged with the visible lesion area. A fusion zone is defined at the boundary between the two areas. Pixels closer to the visible lesion area within the fusion zone are referenced to the pixel values of the visible lesion area, and pixels closer to the filled area are referenced to the pixel values of the filled area. The final brightness and darkness values of each pixel within the fusion zone are obtained through weighted calculation to form the complete lesion area.
[0036] Using the original image of the pepper leaf to be identified as a base, the coordinates of the center of the complete lesion area are read to locate the position and range of the lesion in the original image. Based on the center, the fused complete lesion area is mapped to the corresponding position according to the size ratio of the original image, replacing the pixels of the lesion part in the original image, and retaining the pixels of the non-lesion part to obtain the complete leaf image.
[0037] To achieve the above objectives, the present invention also provides the following technical solution:
[0038] A pepper pest and disease detection system based on an improved YOLOv11n, the system being used to execute any of the above-described pepper pest and disease detection methods based on an improved YOLOv11n, comprising:
[0039] The first region extraction module is used to collect unobstructed chili leaf sample images with known lesion types, extract lesion regions from all sample images and determine the center point, and use the maximum pixel distance from the edge of the lesion region to the center point as the radius of the lesion region.
[0040] The second region extraction module is used to acquire the visible region image of the pepper leaf to be identified, and to extract the visible lesion region from it;
[0041] The data processing module is used to determine the preliminary lesion type of the visible lesion area, determine the lesion development stage by combining its hue mean and texture entropy value, and determine the reference radius of the visible lesion area based on the lesion development stage.
[0042] The contour completion module is used to obtain the contour and circumference of the visible lesion area. The contour, circumference and reference radius of the visible lesion area are input into the contour completion model, and the complete contour of the lesion is output.
[0043] The image reconstruction module is used to collect the baseline texture features of the preliminary lesion type, complete the pixel information of the occluded area within the complete outline of the lesion, fuse them into the complete lesion area, and reconstruct the complete leaf image. The improved YOLOv11n trained based on sample images of pepper leaves is input, and the result with the highest confidence is selected as the final lesion type of pepper leaf.
[0044] A storage medium for storing a computer program, which, when executed by a processor, implements any of the above-described methods for detecting pests and diseases in chili peppers based on an improved YOLOv11n.
[0045] Compared with the prior art, the beneficial effects of the present invention are:
[0046] This invention collects unobstructed lesion samples, extracts and associates the lesion center point, lesion region radius, hue mean, and texture entropy value, providing a quantitative basis for lesion type determination and stage division in occluded scenes, effectively avoiding matching errors caused by existing technologies that rely on experience judgment or scattered features;
[0047] This invention uses radius matching to identify the initial lesion type, combines the mean hue and texture entropy value to determine the development stage and obtain the reference radius, and integrates the outline and circumference of visible lesions to achieve complete outline reconstruction, accurately defining the range of the occluded area. It fundamentally makes up for the feature loss problem caused by existing technologies that rely solely on inference from incomplete visible areas, and breaks through the detection limitations in occluded scenarios.
[0048] This invention performs pixel completion of occluded areas based on the baseline texture features of preliminary lesion types, ensuring consistency in texture and tone between the completed and visible areas. At the same time, it eliminates splicing artifacts through feature fusion technology, so that the reconstructed complete leaf image retains the real lesion morphology and texture details, providing high-quality input images for improving YOLOv11n, and effectively avoiding the problems of insufficient detection accuracy caused by abrupt transitions and texture breaks in the completed areas in the prior art. Attached Figure Description
[0049] Figure 1 This is a schematic diagram of the overall method flow of the present invention;
[0050] Figure 2 This is a block diagram of the module composition of the present invention. Detailed Implementation
[0051] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to specific embodiments.
[0052] It should be noted that, unless otherwise defined, the technical or scientific terms used in this invention should have the ordinary meaning understood by one of ordinary skill in the art to which this invention pertains. The terms "first," "second," and similar terms used in this invention do not indicate any order, quantity, or importance, but are merely used to distinguish different components. Terms such as "comprising" or "including" mean that the element or object preceding the word encompasses the elements or objects listed following the word and their equivalents, without excluding other elements or objects. Terms such as "connected" or "linked" are not limited to physical or mechanical connections, but can include electrical connections, whether direct or indirect. Terms such as "upper," "lower," "left," and "right" are used only to indicate relative positional relationships; when the absolute position of the described object changes, the relative positional relationship may also change accordingly.
[0053] Example:
[0054] Please see Figure 1 The present invention provides a technical solution:
[0055] A method for detecting diseases and pests in chili peppers based on an improved YOLOv11n, comprising the following steps:
[0056] S1. Collect unobstructed images of pepper leaf samples with known lesion types, extract lesion areas from all sample images and determine the center point, and use the maximum pixel distance from the edge of the lesion area to the center point as the radius of the lesion area to provide basic data support for subsequent pepper disease and pest detection.
[0057] Based on the above embodiments, the sample images include pepper leaf images of all lesion types, including those of green peach aphid, silver leaf whitefly, thrips, cotton bollworm, and anthracnose.
[0058] Based on the above embodiments, lesion regions are extracted from all sample images, and the specific logic is as follows:
[0059] The sample image is converted from RGB to HSV color space. The brightness channel is denoised using a 5×5 Gaussian filter, and then histogram equalization is used to enhance the contrast between lesions and healthy areas. Based on the threshold segmentation of the hue and saturation channels corresponding to the lesion type, a binary image of the lesion is obtained. The 3×3 structuring element "dilation-erosion" is used to fill holes and remove noise, generating a mask of suspected lesions. The Canny algorithm is used to extract the contour of connected regions with an area > 50 square pixels in the mask. The contour morphology features are compared with the baseline features. The region that matches successfully is the target lesion region, and its coordinates and pixel set are output.
[0060] Based on the above embodiments, the center point of the lesion region in the sample image is determined using the following logic:
[0061] For each lesion area, it is binarized, where the pixels in the lesion area are 1 and the background pixels are 0.
[0062] Collect the coordinates of all pixels within the lesion area to form a set of pixel coordinates;
[0063] Calculate the arithmetic mean of the x and y coordinates of all pixels in the pixel coordinate set, and use it as the x and y coordinates of the center point;
[0064] Combine the x and y coordinates of the center point to obtain the coordinates of the center point of the lesion area.
[0065] Based on the above embodiments, the radius of the lesion region is defined by taking the center point of the lesion region as the center and the maximum pixel distance from the edge of the lesion region to the center point as the radius of the lesion region. The specific logic is as follows:
[0066] Based on the coordinates of the center point of the lesion region, all edge pixels with a pixel value of 1 in the binarized image of the lesion region are extracted to form a set of edge pixel coordinates.
[0067] Calculate the pixel distance from each edge pixel in the set of edge pixel coordinates to the center point;
[0068] From all pixel distances, select the distance value with the largest value and use that distance value as the radius of the lesion area.
[0069] S2. Obtain the visible area image of the chili leaf to be identified, convert the visible area image to the HSV color space, and perform multi-channel joint threshold segmentation based on the hue and saturation reference ranges of various lesions determined by the above method to generate a binary image of suspected lesions; use 3×3 structuring elements to sequentially perform dilation and erosion morphological operations on the binary image to fill the lesion holes and eliminate edge noise; finally, select the connected regions whose area and circumference match the lesion morphological characteristics, which are the visible lesion regions.
[0070] Based on the above, it should be noted that:
[0071] By collecting unobstructed lesion samples, extracting and associating lesion center point, lesion region radius, hue mean, and texture entropy value, we can provide a quantitative basis for lesion type determination and stage division in occluded scenarios, effectively avoiding matching errors caused by existing technologies that rely on experience-based judgment or scattered features.
[0072] S3. Based on the radius of the lesion area, determine the preliminary lesion type of the visible lesion area, combine its hue mean and texture entropy value to determine the lesion development stage, and determine the reference radius of the visible lesion area according to the lesion development stage;
[0073] Based on the above embodiments, the preliminary lesion type of the visible lesion area is determined according to the radius of the lesion area. The specific logic is as follows:
[0074] Take the intersection of the diagonals of the visible lesion bounding box as the center point, and calculate the maximum pixel distance from the edge of the lesion region to the center point as the radius of the visible lesion region;
[0075] Statistically analyze the radius range of all lesion types at all stages. If the radius of the visible lesion area falls only within the range of a single lesion type, the lesion type is directly determined to be a preliminary lesion type.
[0076] If the radius of the visible lesion area falls within the radius range of multiple lesion types, calculate the absolute value of the difference between the radius of the visible lesion area and the average radius of the multiple lesion types, and select the lesion type with the smallest absolute value of the difference as the preliminary lesion type.
[0077] Among them, the average radius of lesion type refers to the arithmetic mean of the radius of the lesion area of the corresponding lesion type in the pepper leaf sample.
[0078] Based on the above embodiments, the lesion development stage is determined by combining its hue mean and texture entropy value. The specific logic based on the lesion development stage is as follows:
[0079] For each type of preliminary lesion that has been identified, collect images of pepper leaf samples at three typical development stages: the initial stage, the peak stage, and the decline stage, with no fewer than 50 samples at each stage.
[0080] The sample images for each stage are processed as follows:
[0081] Hue mean extraction: Convert the image of the visible lesion area from RGB color space to HSV color space, and extract only the hue channel data, because the hue is more sensitive to the color change of the lesion than the RGB channel. Calculate the hue mean of all pixels in the area.
[0082] Texture entropy extraction: Based on the gray-level co-occurrence matrix of the lesion region, the texture entropy value is calculated. The larger the texture entropy value, the more complex and uneven the lesion texture. The range of the mean hue and texture entropy value of each lesion type under the three development stages is statistically analyzed to form a one-to-one correspondence between the stage, the mean hue interval, and the texture entropy value interval, and to establish an association model.
[0083] For the pepper leaves to be tested that have completed the type determination, crop the image of the visible lesion area, convert the HSV color space according to the same method as above, and calculate the actual hue mean and actual entropy value of the visible lesion area.
[0084] Substitute the actual hue mean and actual entropy value into the association model corresponding to the preliminary lesion type, and perform two-parameter interval matching:
[0085] If the actual hue mean falls within the hue mean range of a certain development stage, and the actual entropy value also falls within the entropy value range of that stage, then the visible lesion is determined to be in that development stage.
[0086] If only a single parameter falls within the range, or if two parameters belong to different stages, the feature data of the lesion area is extracted again and matched again; if a match still cannot be found, it is determined to be a "transitional stage", and the average of the parameters of the two adjacent stages is used for subsequent calculations.
[0087] The reference radius for determining the visible lesion area is as follows:
[0088] Based on the identified lesion type and development stage, all lesion samples of the same type and stage are screened from the sample library, and the actual pixel area of the lesions in these samples is retrieved. Since the lesion shapes of different samples vary, the lesion area of each sample is approximated as the area of a standard circle. The corresponding radius, i.e., the equivalent radius of the sample, is calculated by using the formula for the area of a circle. This achieves scale uniformity for lesions of different shapes. The total number of matching samples is counted, and the arithmetic mean of the equivalent radii of all samples is calculated. This average value is the reference radius of the lesion to be detected. It avoids the differences of a single sample and can accurately reflect the typical size of the lesion type at the current stage, providing a scale benchmark for subsequent contour completion.
[0089] Based on the above, it should be noted that:
[0090] By outputting three core parameters—preliminary lesion type, development stage, and reference radius—through a coherent logical output, key data support is provided for subsequent contour completion, pixel completion, and final model detection. This effectively solves the problems of completion distortion and inaccurate detection caused by fuzzy basic parameters in existing technologies, laying a solid foundation for accurate detection of pepper pests and diseases in occluded scenarios.
[0091] S4. Obtain the outline and circumference of the visible lesion area. Input the outline, circumference, and reference radius of the visible lesion area into the outline completion model and output the complete outline of the lesion.
[0092] Based on the above embodiments, the method for obtaining the outline and circumference of the lesion area is shown in the following steps:
[0093] From the visible area image of the pepper leaf to be identified, based on the determined boundary coordinates of the visible lesion area, an independent image of the visible lesion is cropped out; the image is converted from RGB color space to Lab color space, and the red-green color difference channel that is sensitive to color difference is selected to highlight the color boundary between the lesion and healthy tissue;
[0094] An adaptive threshold segmentation algorithm is used for binarization processing. The segmentation threshold is automatically determined, and the lesion area is marked as white (pixel value 255) and the background area is marked as black (pixel value 0) to obtain the lesion binarized image.
[0095] The contours of all connected regions are extracted based on the binarized image; by filtering the contour area, tiny noise contours with an area of less than 50 pixels are removed, and the contour with the largest area is retained as the contour of the visible lesion area.
[0096] The outline of the extracted visible lesion area is output as a set of pixel coordinates.
[0097] Based on the extracted contours of the visible lesion regions, the area of the pixel region enclosed by the lesion contour and the pixel length around the edge of the lesion contour are obtained, and the classic formula for calculating pi is used. ,in, For circumference, The area of the pixel region enclosed by the lesion outline. The pixel length around the edge of the lesion outline;
[0098] The value of circumference ranges from 0 to 1. The closer the value is to 1, the closer the lesion outline is to a standard circle; the closer the value is to 0, the more irregular the lesion outline is.
[0099] Based on the above, it should be noted that:
[0100] The function of the contour completion model is to infer the occluded edge based on the visible edge. The contour of the visible lesion area is the direct data source for the contour completion model to identify the edge direction and judge the contour trend. If the complete contour of the visible lesion area is missing, the contour completion model will not be able to establish the basic morphological framework of the lesion, and the completion result is prone to "morphological distortion".
[0101] Pi quantifies the similarity between lesions and standard circles through the "perimeter-area" relationship, providing morphological constraints for the model. For example, during the peak period of anthrax, the pi of lesions is mostly between 0.8 and 0.9 (nearly circular). The contour completion model can use this index to avoid completing them as elongated shapes with a pi of less than 0.3. At the same time, the correction value of pi can reflect the influence of slight occlusion on the shape, helping the contour completion model to distinguish between "original irregular contours" and "contour defects caused by occlusion", reducing completion errors.
[0102] The reference radius obtained above only provides the "typical scale" of the lesion, while the contour and circumference provide the "actual shape" of the lesion. The combination of the two forms a dual constraint, which accurately defines the range of the occluded area: the contour completion model needs to complete the contour within the "scale range limited by the reference radius" based on the "edge direction of the visible lesion area contour" and the "morphological features reflected by the circumference". This ensures that the completed visible lesion not only conforms to the size pattern of the current stage, but also matches its own morphological characteristics. This fundamentally makes up for the feature loss problem caused by the existing technology relying only on inference of the incomplete visible area, breaks through the detection limitations in occluded scenarios, and avoids the problem of "correct scale but incorrect shape".
[0103] Different pests and diseases have inherent differences in the morphology of lesions. For example, thrips lesions have a circumference of <0.5 and are serrated; anthracnose lesions have a circumference of >0.7 and are nearly circular. The complete outline and corresponding circumference can be cross-checked with the initially determined lesion type. If the morphological features do not match the lesion type, the features are re-compared to improve the reliability of the final identification result.
[0104] The contour completion model is constructed using a deep learning network based on a multilayer perceptron. The deep neural network of the multilayer perceptron includes an input layer, a first hidden layer, a second hidden layer, a third hidden layer, and an output layer. The first hidden layer, the second hidden layer, and the third hidden layer each have at least two neurons and all use ReLU (Rectified Linear Unit) as the activation function.
[0105] Multiple sets of historical sample data were collected. Each set of data included the outline, circumference, reference radius and corresponding complete outline of the visible lesion area. All samples were divided into training set, validation set and test set in a ratio of 7:2:1.
[0106] The training set is used to learn the model parameters; the validation set is used to adjust hyperparameters during training to prevent overfitting; and the test set is used to evaluate the generalization ability of the model after training.
[0107] The structure of a deep learning network with a multilayer perceptron is as follows:
[0108] Input layer: Used to receive the outline, circumference, and reference radius of the visible lesion area;
[0109] The first hidden layer has 128 neurons and uses ReLU as the activation function.
[0110] The second hidden layer has 64 neurons and also uses the ReLU activation function;
[0111] The third hidden layer has 32 neurons and uses the ReLU activation function;
[0112] Output layer: It has 1 neuron, which is used to output the coordinate sequence of the reconstructed complete lesion contour, that is, the complete lesion contour.
[0113] The process of training the contour completion model is as follows:
[0114] Using the contours, circumference, and reference radius of multiple previously visible lesion regions as input, and the corresponding complete lesion contours as labeled output, a contour completion model is trained. Mean squared error is used as the loss function. When the mean squared error is within a certain range... If the loss value does not decrease significantly within the specified range for 10 consecutive training rounds, training of the contour completion model should be stopped.
[0115] Based on the above, it should be noted that:
[0116] Mean squared error can accurately measure the coordinate deviation between the predicted contour and the true contour, and is suitable for numerical regression tasks of geometric contour completion.
[0117] Before training, the circumference and reference radius need to be standardized from 0 to 1, and the contour features need to be converted into Fourier descriptor vectors with fixed dimensions to ensure that the input feature dimensions are uniform.
[0118] S5. Collect the baseline texture features of the preliminary lesion type, complete the pixel information of the occluded area within the complete outline of the lesion, merge them into the complete lesion area, and reconstruct it into a complete leaf image. Input the improved YOLOv11n trained based on the sample images of pepper leaves, and select the result with the highest confidence as the final lesion type of pepper leaf.
[0119] Based on the above embodiments, the baseline texture features of the preliminary lesion type are collected, the pixel information of the occluded area within the complete outline of the lesion is completed, fused into the complete lesion area, and reconstructed into a complete leaf image. The specific logic is as follows:
[0120] Collect baseline texture features for preliminary lesion types. The baseline texture features include energy, entropy, and contrast.
[0121] Wherein, the energy is the sum of the squares of all elements in the gray-level co-occurrence matrix (GLCM) of the lesion texture. A 16×16 pixel texture sub-image is cropped from the normalized image of the lesion, and a GLCM with a distance of 1 and angles of 0° / 45° / 90° / 135° is constructed. The energy values of the four types of GLCM are calculated and the average value is taken as the lesion energy.
[0122] Entropy is the information entropy of the gray-level co-occurrence matrix (GLCM) of the lesion texture, which characterizes the complexity of the texture; the entropy value is calculated based on the GLCM of the lesion texture.
[0123] Contrast is the sum of squares of the differences in pixel gray values in the gray-level co-occurrence matrix (GLCM) of lesion texture, reflecting the magnitude of gray-level variation within the lesion. For example, the contrast between silver leaf whitefly lesions and healthy tissue is high, while the contrast between cotton bollworm lesions is low. Contrast is calculated based on the gray-level co-occurrence matrix (GLCM) of lesion texture.
[0124] The calculation of energy, entropy, and contrast based on the gray-level co-occurrence matrix (GLCM) of lesion texture is an existing technique and will not be elaborated further here.
[0125] Based on the above, it should be noted that:
[0126] Energy reflects texture uniformity through the sum of squares of gray-level co-occurrence matrix elements, which can quickly distinguish between diseases such as anthracnose and thrips, because anthracnose has regular and uniform textures with high energy values, while thrips has messy textures with low energy values; entropy is calculated based on the probability distribution of GLCM and characterizes the richness of texture information, which can accurately identify the development stage of lesions—during the peak period, lesions have increased texture complexity due to intensified tissue necrosis, and the entropy value is significantly higher than that in the initial stage; contrast reflects the fluctuations in brightness and darkness through the sum of squares of gray-level differences in GLCM, which is the core distinguishing feature between silver leaf whitefly and cotton bollworm. The three factors work together to completely capture the essence of lesion texture.
[0127] Based on the above embodiments, a texture interpolation method is used to generate pixel information consistent with the reference texture features, and the generated pixel information is filled into the pixel space of the occluded area to complete the pixel completion of the occluded area.
[0128] The filled occluded area is merged with the visible lesion area. A fusion zone is defined at the boundary between the two areas. Pixels closer to the visible lesion area within the fusion zone are referenced to the pixel values of the visible lesion area, and pixels closer to the filled area are referenced to the pixel values of the filled area. The final brightness and darkness values of each pixel within the fusion zone are obtained through weighted calculation to form the complete lesion area.
[0129] Using the original image of the pepper leaf to be identified as a base, the coordinates of the center of the complete lesion area are read to locate the position and range of the lesion in the original image. Based on the center, the fused complete lesion area is mapped to the corresponding position according to the size ratio of the original image, replacing the pixels of the lesion part in the original image, and retaining the pixels of the non-lesion part to obtain the complete leaf image.
[0130] Based on the above, it should be noted that:
[0131] The center coordinates of the complete lesion area are directly taken from the "intersection of the diagonals of the visible lesion bounding box" determined when calculating the radius of the visible lesion area in step S3. This is because the subsequent contour completion is based on the collaborative reconstruction of the visible lesion contour, circumference and reference radius. The center of the complete contour coincides with the center point of the original visible lesion area, so there is no need to recalculate. Only the pixel coordinates of the center point need to be retrieved directly.
[0132] Based on the above, it should be noted that:
[0133] From the acquisition of the original image (S2) and extraction of the visible lesion region to contour completion and pixel completion, no image scaling was performed; all operations were based on the pixel scale of the original image. Therefore, the pixel scale of the fused complete lesion region is completely consistent with that of the original image, so the size ratio of the original image is 1:1, that is, one pixel of the complete lesion region corresponds to one pixel of the original image.
[0134] In this process, a fusion zone is defined at the boundary between the two regions. Pixels closer to the visible lesion area within the fusion zone are referenced to the pixel values of the visible lesion area, and pixels closer to the padded area are referenced to the pixel values of the padded area. The final brightness value of each pixel within the fusion zone is obtained through weighted calculation. The specific steps are as follows:
[0135] Extend to both sides along the boundary between the visible lesion area and the completed area. 1 pixel, To achieve the fusion of width on one side, the total width is... The fusion zone; all pixels within the fusion zone are mapped to coordinates based on their "distance from the visible area":
[0136] Among them, based on the image resolution commonly used for chili leaf detection, the determination is... The basic range is when the resolution is 1280×960. Use 5-8 pixels; at a resolution of 640×640, Take 3-5 pixels;
[0137] Let a pixel within the fusion band be... Define the vertical distance from this pixel to one side boundary of the visible lesion area as... ; fusion of pixels within the band The range of values is ,in Corresponding to the boundary pixels of the visible lesion area, Corresponding to the boundary pixels of the completed region;
[0138] Based on pixels distance Calculate the weighting coefficients of pixel values in the visible lesion area. and weighting coefficients of pixel values in the completed region Both satisfy the normalization constraint. ;
[0139] ;
[0140] Among them, the closer the pixel is to the visible lesion area, the larger the weight coefficient; the closer the pixel is to the completion area, the larger the completion weight coefficient.
[0141] Set pixel points The reference brightness value on the side of the visible lesion area is , The average value of the neighboring pixels at the edge of the visible lesion area; pixel points The reference brightness value on the completed area side is , Pixel values generated by texture interpolation;
[0142] Then the final brightness value of the pixel :
[0143] ;
[0144] Among them, the boundary between the visible lesion area and the fusion zone is taken as the boundary. A 3×3 pixel block on the visible side is considered as the neighborhood. The visible side refers to the boundary between the visible area and the blending zone, with each pixel as the boundary. The space on the side closest to the unobstructed lesion area;
[0145] The brightness values of all pixels in the neighborhood are counted, summed, and then divided by the total number of valid pixels in the neighborhood to obtain the mean value of the neighborhood pixels.
[0146] The pixel values generated by texture interpolation refer to the pixel brightness values that match the texture features of the visible area within the occluded area, generated by an interpolation algorithm based on the baseline texture features of the initial lesion type.
[0147] Based on the above embodiments, the training parameters of the improved YOLOv11n include: input image size, optimizer, momentum, weight decay coefficient, initial learning rate, batch size, and training epochs;
[0148] The input image size is used to standardize and improve the image specifications of YOLOv11n input. The input image size is 640×640×3, where 640×640 is the width × height of the image, and 3 represents the number of channels in the image.
[0149] The optimizer is used to guide the improvement of the core algorithm for updating weights in YOLOv11n, and determines how YOLOv11n "learns" sample features. The optimizer is SGD.
[0150] Momentum is used to accelerate the convergence speed of SGD and avoid the improved YOLOv11n from getting trapped in local optima. The momentum is 0.937.
[0151] The weight decay factor is used to prevent overfitting in the improved YOLOv11n and improve generalization ability. The weight decay factor is 0.0005.
[0152] The initial learning rate is used to control the step size of the YOLOv11n parameter updates and is a core hyperparameter for training. The initial learning rate is 0.01.
[0153] The batch size is the number of samples input to the improved YOLOv11n during each training iteration; the batch size is 16.
[0154] The number of training epochs controls the number of times the improved YOLOv11n traverses the training set, determining the sufficiency of training. The number of training epochs is 400.
[0155] The process of training the improved YOLOv11n is as follows:
[0156] Using sample images of pepper leaves with unobstructed lesion types as input, and the labeled lesion types as output, train the improved YOLOv11n. When the maximum number of iterations is reached, stop training the improved YOLOv11n.
[0157] Based on the above, it should be noted that:
[0158] Based on the baseline texture features of the preliminary lesion type, pixel completion of the occluded area is performed. Energy, entropy, and contrast are used to guide the texture interpolation method to generate pixel information that highly matches the baseline texture features, ensuring that the texture density and brightness distribution of the completed area are completely consistent with the visible lesion area. At the same time, the pixel color of the completed area is calibrated by combining the hue mean of the visible lesion area, so that the hue of the completed area and the visible area remain homogeneous and avoid color deviation.
[0159] Based on pixel completion, feature fusion technology is used to eliminate stitching artifacts. Specifically, a fusion zone is defined at the boundary between the visible area and the completed area. A linear weighted interpolation algorithm is used to calculate the final pixel value of each pixel within the fusion zone, so that the pixel value can smoothly transition from the visible area to the completed area, thus completely solving problems such as texture discontinuity and harsh edges at the stitching point.
[0160] The final reconstructed complete leaf image not only preserved the true shape and texture details of the lesions, but also maintained the overall consistency and naturalness of the leaf image, providing a high-quality detection input image for improving YOLOv11n.
[0161] Compared to existing technologies that rely on single feature completion, resulting in regional fragmentation and feature distortion, this method effectively improves the quality of input images, significantly reduces the false detection rate caused by poor completion results, and significantly improves the accuracy and reliability of pepper pest and disease detection.
[0162] Please see Figure 2 The present invention provides a technical solution:
[0163] A pepper pest and disease detection system based on an improved YOLOv11n, the system being used to execute any of the above-described pepper pest and disease detection methods based on an improved YOLOv11n, comprising:
[0164] The first region extraction module is used to collect unobstructed chili leaf sample images with known lesion types, extract lesion regions from all sample images and determine the center point, and use the maximum pixel distance from the edge of the lesion region to the center point as the radius of the lesion region.
[0165] The second region extraction module is used to acquire the visible region image of the pepper leaf to be identified, and to extract the visible lesion region from it;
[0166] The data processing module is used to determine the preliminary lesion type of the visible lesion area, determine the lesion development stage by combining its hue mean and texture entropy value, and determine the reference radius of the visible lesion area based on the lesion development stage.
[0167] The contour completion module is used to obtain the contour and circumference of the visible lesion area. The contour, circumference and reference radius of the visible lesion area are input into the contour completion model, and the complete contour of the lesion is output.
[0168] The image reconstruction module is used to collect the baseline texture features of the preliminary lesion type, complete the pixel information of the occluded area within the complete outline of the lesion, fuse them into the complete lesion area, and reconstruct the complete leaf image. The improved YOLOv11n trained based on sample images of pepper leaves is input, and the result with the highest confidence is selected as the final lesion type of pepper leaf.
[0169] A storage medium for storing a computer program, which, when executed by a processor, implements any of the above-described methods for detecting pests and diseases in chili peppers based on an improved YOLOv11n.
[0170] The above formulas are all dimensionless calculations. The formulas are derived from software simulations based on a large amount of collected data to obtain the most recent real-world results. The preset parameters in the formulas are set by those skilled in the art according to the actual situation.
[0171] The above embodiments can be implemented, in whole or in part, by software, hardware, firmware, or any other combination thereof. When implemented in software, the above embodiments can be implemented, in whole or in part, as a computer program product. Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented by software, electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution.
[0172] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment, depending on actual needs.
[0173] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any changes or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application.
Claims
1. A method for detecting diseases and pests in chili peppers based on an improved YOLOv11n, characterized in that, The specific steps include: S1. Collect unobstructed images of pepper leaf samples with known lesion types, extract the lesion areas from all sample images and determine the center point, and use the maximum pixel distance from the edge of the lesion area to the center point as the radius of the lesion area. S2. Obtain an image of the visible area of the pepper leaf to be identified, and extract the visible lesion area from it; S3. Based on the radius of the lesion area, determine the preliminary lesion type of the visible lesion area, combine its hue mean and texture entropy value to determine the lesion development stage, and determine the reference radius of the visible lesion area according to the lesion development stage; S4. Obtain the outline and circumference of the visible lesion area. Input the outline, circumference, and reference radius of the visible lesion area into the outline completion model and output the complete outline of the lesion. S5. Collect the baseline texture features of the preliminary lesion type, complete the pixel information of the occluded area within the complete outline of the lesion, merge them into the complete lesion area, and reconstruct it into a complete leaf image. Input the improved YOLOv11n trained based on the sample images of pepper leaves, and select the result with the highest confidence as the final lesion type of pepper leaf. Based on the radius of the lesion area, the preliminary lesion type of the visible lesion area is determined. The specific logic is as follows: Take the intersection of the diagonals of the visible lesion bounding box as the center point, and calculate the maximum pixel distance from the edge of the lesion region to the center point as the radius of the visible lesion region; Statistically analyze the radius range of all lesion types at all stages. If the radius of the visible lesion area falls only within the range of a single lesion type, the lesion type is directly determined to be a preliminary lesion type. If the radius of the visible lesion area falls within the radius range of multiple lesion types, calculate the absolute value of the difference between the radius of the visible lesion area and the average radius of the multiple lesion types, and select the lesion type with the smallest absolute value of the difference as the preliminary lesion type. Among them, the average radius of lesion type refers to the arithmetic mean of the radius of the lesion area of the corresponding lesion type in the pepper leaf sample; The lesion development stage is determined by combining its mean hue value and texture entropy value. Based on the lesion development stage, the reference radius of the visible lesion area is determined. The specific logic is as follows: For the preliminarily identified lesion types, the mean range of hue and the range of texture entropy values were statistically analyzed in the three development stages of the initial stage, the peak stage and the decline stage, and a one-to-one correspondence model was established. The extracted mean hue and texture entropy values of the visible lesion area are substituted into the association model corresponding to the preliminary lesion type. If the mean hue and texture entropy values fall within the feature interval of any of the above development stages, the visible lesion is determined to be in that development stage. Retrieve the radii of all samples corresponding to the initial lesion type at this development stage, calculate the mean radius of this development stage, and use this mean radius as the reference radius of the visible lesion area.
2. The method for detecting pepper diseases and pests based on the improved YOLOv11n according to claim 1, characterized in that, The types of lesions include those caused by the green peach aphid, silver leaf whitefly, thrips, cotton bollworm, and anthracnose.
3. The method for detecting pepper diseases and pests based on the improved YOLOv11n according to claim 1, characterized in that, The specific logic for determining the center point of the lesion region in the sample image is as follows: For each lesion area, it is binarized, where the pixels in the lesion area are 1 and the background pixels are 0. Collect the coordinates of all pixels within the lesion area to form a set of pixel coordinates; Calculate the arithmetic mean of the x and y coordinates of all pixels in the pixel coordinate set, and use it as the x and y coordinates of the center point; Combine the x and y coordinates of the center point to obtain the coordinates of the center point of the lesion area.
4. The method for detecting pepper diseases and pests based on the improved YOLOv11n according to claim 3, characterized in that, The radius of the lesion region is defined by taking the center point of the lesion region as the center and the maximum pixel distance from the edge of the lesion region to the center point as the radius of the lesion region. The specific logic is as follows: Based on the coordinates of the center point of the lesion region, all edge pixels with a pixel value of 1 in the binarized image of the lesion region are extracted to form a set of edge pixel coordinates. Calculate the pixel distance from each edge pixel in the set of edge pixel coordinates to the center point; From all pixel distances, select the distance value with the largest value and use that distance value as the radius of the lesion area.
5. The method for detecting pepper diseases and pests based on the improved YOLOv11n according to claim 4, characterized in that, The baseline texture features of the preliminary lesion type are collected, the pixel information of the occluded area within the complete outline of the lesion is completed, fused into the complete lesion area, and reconstructed into a complete leaf image. The specific logic is as follows: Collect baseline texture features for preliminary lesion types. The baseline texture features include energy, entropy, and contrast. Pixel information consistent with the baseline texture features is generated using texture interpolation. The generated pixel information is then filled into the pixel space of the occluded area to complete the pixel filling of the occluded area. The filled occluded area is merged with the visible lesion area. A fusion zone is defined at the boundary between the two areas. Pixels closer to the visible lesion area within the fusion zone are referenced to the pixel values of the visible lesion area, and pixels closer to the filled area are referenced to the pixel values of the filled area. The final brightness and darkness values of each pixel within the fusion zone are obtained through weighted calculation to form the complete lesion area. Using the original image of the pepper leaf to be identified as a base, the coordinates of the center of the complete lesion area are read to locate the position and range of the lesion in the original image. Based on the center, the fused complete lesion area is mapped to the corresponding position according to the size ratio of the original image, replacing the pixels of the lesion part in the original image, and retaining the pixels of the non-lesion part to obtain the complete leaf image.
6. A pepper pest and disease detection system based on an improved YOLOv11n, the system being used to execute the pepper pest and disease detection method based on an improved YOLOv11n as described in any one of claims 1-5, characterized in that, include: The first region extraction module is used to collect unobstructed chili leaf sample images with known lesion types, extract lesion regions from all sample images and determine the center point, and use the maximum pixel distance from the edge of the lesion region to the center point as the radius of the lesion region. The second region extraction module is used to acquire the visible region image of the pepper leaf to be identified, and to extract the visible lesion region from it; The data processing module is used to determine the preliminary lesion type of the visible lesion area, determine the lesion development stage by combining its hue mean and texture entropy value, and determine the reference radius of the visible lesion area based on the lesion development stage. The contour completion module is used to obtain the contour and circumference of the visible lesion area. The contour, circumference and reference radius of the visible lesion area are input into the contour completion model, and the complete contour of the lesion is output. The image reconstruction module is used to collect the baseline texture features of the preliminary lesion type, complete the pixel information of the occluded area within the complete outline of the lesion, fuse them into the complete lesion area, and reconstruct the complete leaf image. The improved YOLOv11n trained based on sample images of pepper leaves is input, and the result with the highest confidence is selected as the final lesion type of pepper leaf.
7. A storage medium, characterized in that, Used to store a computer program, which, when executed by a processor, implements the chili pepper pest and disease detection method based on any one of claims 1-5.
Citation Information
Patent Citations
Pepper pathology speculation method and device based on image recognition
CN117274981A
Image processing-based pest and disease identification method and system, and medium
CN120932105A