Artificial intelligence-based agricultural image pest region extraction method and system

By using weighted transformation of color weight matrix and edge morphology template and fusion of multi-dimensional feature maps, combined with merging strategy and confidence propagation, the problem of insufficient accuracy in disease and pest region extraction is solved, achieving higher completeness and boundary accuracy in disease and pest region segmentation.

CN122391896APending Publication Date: 2026-07-14四川井宇科技有限公司

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
四川井宇科技有限公司
Filing Date
2026-06-11
Publication Date
2026-07-14

Smart Images

  • Figure CN122391896A_ABST
    Figure CN122391896A_ABST
Patent Text Reader

Abstract

The application provides an agricultural image pest area extraction method and system based on artificial intelligence, and belongs to the technical field of agricultural image processing. The application obtains a color weight matrix and an edge shape template, and generates a color transformation graph by weighting and transforming a target leaf image; the edge response intensity is obtained by calculating the multi-directional gradient intensity of each pixel, and the edge shape feature is matched with the template to obtain a matching score; then, a multi-dimensional feature graph is formed by fusing an evaluation graph and the color transformation graph; subsequently, adjacent sub-regions are iteratively merged according to the merging cost as a criterion until the common boundary matching value exceeds a judgment value, and a merging tree is constructed; finally, the confidence of each node is calculated according to the mean value of the feature value and the color weight matrix from the root node, and is propagated to the child nodes, and the pest area is determined. The application can realize the accurate and automatic positioning and extraction of the leaf pest infection area.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application belongs to the technical field of agricultural image processing, and in particular relates to a method and system for extracting pest and disease areas from agricultural images based on artificial intelligence. Background Technology

[0002] Non-destructive testing and early identification of crop diseases and pests are key to the development of precision agriculture and ecological agriculture. Computer vision technology has brought about a revolution in agriculture, especially in the critical link of disease and pest detection, which has shown great potential. It has not only improved the efficiency and quality of agricultural production, but also provided technical support for the development of sustainable agriculture.

[0003] Currently, disease image recognition mainly relies on traditional machine learning, which involves manually selecting features through image preprocessing, image segmentation, and feature extraction techniques. Then, machine learning algorithms such as support vector machines and random forests are used to train the system to classify specific feature vectors, thereby achieving the goal of identifying disease and pest images.

[0004] However, the above methods have obvious shortcomings. Since the characteristics of pests and diseases are often very subtle, deep learning models often have difficulty capturing these subtle features, resulting in poor detection results. Changes in light, occlusion, complex backgrounds, and similarities between disease symptoms are the main challenges currently faced in plant disease detection and identification. In particular, when the boundaries of lesions are blurred and color features overlap with background interference, existing methods are unable to achieve robust and accurate localization of infected areas. Summary of the Invention

[0005] The purpose of this application is to provide an artificial intelligence-based method and system for extracting disease and pest areas from agricultural images, in order to solve the problem of insufficient accuracy in extracting disease and pest infection areas in existing technologies.

[0006] To address the aforementioned technical problems, in a first aspect, this application provides a method for extracting pest and disease regions from agricultural images based on artificial intelligence, comprising: Obtain the color weight matrix and edge morphology template determined from leaf images of crops infected with pests and diseases; A color transformation map is obtained by weighting each color channel of the target leaf image based on the color weight matrix. The edge response intensity of each pixel is obtained by calculating the gradient intensity of each pixel along multiple directions in the color transformation image. The boundary morphology features of the edge position determined by the edge response intensity in the color transformation image are matched with the edge morphology template to obtain the matching score. The evaluation map generated based on edge response intensity and matching score is fused with the color transformation map to obtain a multi-dimensional feature map; The multidimensional feature map is initialized into a set of sub-regions. The merging cost is obtained based on the feature value difference between adjacent sub-regions and the length of the common boundary. The adjacent sub-regions with the smallest merging cost in the sub-region set are merged until the matching value of the common boundary of the adjacent sub-regions and the edge morphology template is greater than the preset judgment value, thus obtaining a merging tree with sub-regions as child nodes. Starting from the root node of the merged tree, the confidence level of each node is determined based on the mean eigenvalues ​​of the sub-regions corresponding to each node and the color weight matrix. The confidence level is then propagated to the child nodes corresponding to each node to update the confidence level of the child nodes. Sub-regions with confidence levels greater than a preset threshold are identified as pest and disease areas.

[0007] Optionally, before obtaining the color weight matrix and edge morphology template determined from leaf images of crops infected with pests and diseases, the method further includes: Collect reference leaf images of crops infected with pests and diseases, and statistically analyze the mean pixel value and distribution range of the diseased and healthy areas in each color channel of the reference leaf images. Calculate the color shift of the diseased area relative to the healthy area in each color channel. Based on the color offset, the color anomaly data of pests and diseases are obtained by statistically analyzing the area ratio and spatial distribution of color anomaly regions in the reference leaf image. Based on the color anomaly data, the relative magnitude of each color channel in the color offset is calculated to determine the sensitivity weight of each color channel for disease identification, and the sensitivity weights are arranged according to the color channel dimension to generate a color weight matrix. The curvature range of the curvature value is determined by calculating the curvature value of each pixel at the edge of the lesion in the reference leaf image, the amplitude range of the color gradient value is determined by calculating the color gradient amplitude at the boundary of the lesion, and the pixel width range from the lesion area to the healthy area is calculated. Based on the curvature range, amplitude range, and pixel width range, an edge morphology template for the pest and disease area is constructed.

[0008] Secondly, this application provides an artificial intelligence-based system for extracting disease and pest areas from agricultural images, comprising: The acquisition module is used to acquire the color weight matrix and edge morphology template determined based on leaf images of crops under pest and disease infection. The transformation module is used to perform weighted transformation on each color channel of the target leaf image based on the color weight matrix to obtain a color transformation map. The matching module is used to obtain the edge response intensity of each pixel by calculating the gradient intensity of each pixel along multiple directions in the color transformation image, and to match the boundary morphology features of the edge position determined by the edge response intensity in the color transformation image with the edge morphology template to obtain the matching score. The fusion module is used to fuse the evaluation map generated based on the edge response intensity and matching score with the color transformation map to obtain a multi-dimensional feature map; The merging module initializes the multidimensional feature map into a set of sub-regions, obtains the merging cost based on the feature value difference between adjacent sub-regions and the length of the common boundary, merges the adjacent sub-regions with the minimum merging cost in the sub-region set, until the matching value of the common boundary of the adjacent sub-regions and the edge morphology template is greater than the preset judgment value, and obtains a merging tree with sub-regions as child nodes. The determination module starts from the root node of the merged tree, determines the confidence level of each node based on the mean feature value of the sub-regions corresponding to each node and the color weight matrix, propagates the confidence level to the child nodes corresponding to each node to update the confidence level of the child nodes, and determines the sub-regions with confidence levels greater than a preset confidence threshold as pest and disease areas.

[0009] Thirdly, this application provides an electronic device, comprising: Memory, used to store computer programs; A processor is used to execute a computer program to implement the steps of the artificial intelligence-based agricultural image pest and disease region extraction method as described in the first aspect above.

[0010] Fourthly, this application provides a computer-readable storage medium storing a computer program that, when executed by a processor, can implement the steps of the artificial intelligence-based agricultural image pest and disease area extraction method described in the first aspect above.

[0011] The AI-based method for extracting pest and disease regions from agricultural images provided in this application has the following advantages: Based on the evaluation values ​​of each pixel in the multi-dimensional feature map, the image is divided into pixel-level sub-regions. The mean difference in evaluation values, the mean difference in color response values, and the length of the common boundary between adjacent sub-regions are calculated and weighted to obtain the merging cost. The method then iteratively selects the adjacent sub-regions with the lowest merging cost, using the matching value between the common boundary and the edge morphology template as the merging stopping condition. Finally, a merging tree reflecting the hierarchical structure of the regions is constructed. This method improves the completeness and boundary accuracy of pest and disease region segmentation through a merging strategy driven by both evaluation values ​​and color dimensions. Attached Figure Description

[0012] To more clearly illustrate the technical solutions of the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0013] Figure 1A flowchart illustrating an artificial intelligence-based method for extracting disease and pest areas from agricultural images, provided in an embodiment of this application. Figure 2 A flowchart illustrating a method for generating pest and disease areas provided in an embodiment of this application; Figure 3 A flowchart illustrating a method for generating multidimensional feature maps provided in an embodiment of this application; Figure 4 A schematic diagram of the structure of an artificial intelligence-based agricultural image pest and disease area extraction system provided in this application embodiment; Figure 5 This is a schematic diagram of the hardware structure of an electronic device provided in one embodiment of this application. Detailed Implementation

[0014] Existing methods for detecting agricultural pests and diseases in images are ineffective in distinguishing between disease feature signals and irrelevant background information. At the same time, existing segmentation methods lack the ability to specifically perceive the morphology of lesion boundaries, resulting in inaccurate extraction of the boundaries of infected areas and ultimately insufficient accuracy in locating pest and disease areas.

[0015] To address this issue, this application proposes a method for extracting pest and disease areas based on color weighting and edge morphology perception. First, a color weight matrix is ​​used to enhance the color response of the affected area and reduce background interference. Then, edge morphology templates are used to specifically match lesion boundaries to filter out noisy edges. Next, color and edge information are fused to construct a multi-dimensional feature map, and regions are gradually aggregated using a merging cost, with boundary matching values ​​controlling the merging boundaries. Finally, a confidence propagation mechanism is used to accurately locate the infected area, thus effectively solving the problem of insufficient accuracy in extracting pest and disease infected areas in existing technologies.

[0016] To enable those skilled in the art to better understand the present application, the present application will be further described in detail below with reference to the accompanying drawings and specific embodiments. Obviously, the described embodiments are merely some embodiments of the present application, and not all embodiments. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0017] To address the problems of existing technologies, this application provides a method and system for extracting pest and disease regions from agricultural images based on artificial intelligence. The method for extracting pest and disease regions from agricultural images based on artificial intelligence, as provided in this application, will be described below.

[0018] Figure 1 This illustration shows a flowchart of an artificial intelligence-based method for extracting pest and disease areas from agricultural images, according to an embodiment of this application. Figure 1 As shown.

[0019] S101. Obtain the color weight matrix and edge morphology template determined based on the leaf images of crops under pest and disease infection; Before obtaining the color weight matrix and edge morphology template determined from leaf images of crops infected with pests and diseases, S101 also includes: Step 1011: Collect reference leaf images of crops under pest and disease infection, and respectively count the average pixel value and distribution range of the pest and disease area and the healthy area in each color channel in the reference leaf image, and calculate the color offset of the pest and disease area relative to the healthy area in each color channel. In this sub-step, the reference leaf image refers to an image sample of crop leaves known to be infected with pests and diseases. This can include leaf images of various disease types and different degrees of infection, used to extract the color and edge prior features of the pests and diseases. The color offset refers to the difference in the average pixel value of a certain color channel between the diseased / infected area and the healthy area, reflecting the magnitude of color change in that channel under disease infection.

[0020] In this embodiment, an image acquisition device is used to photograph crop leaves known to be infected with pests and diseases in a farmland or laboratory environment to obtain a reference leaf image; then, the pest-infested areas and healthy areas in the reference leaf image are manually labeled to obtain a pixel set of the pest-infested areas. The set of pixels in the healthy region Then, the pixel mean values ​​of the diseased and healthy areas on each color channel were calculated separately, for example, for each color channel. Extract the pixel set of the diseased and pest-infested area. All pixels in the channel The pixel values ​​on the channel are calculated, and the diseased and pest-affected areas are determined. average pixel value ,in, This represents the total number of pixels in the affected area. Pixels corresponding to the diseased and pest-infested areas In the passage The pixel values ​​on the map; similarly, traversing the set of pixels in the healthy region. All pixels in the channel, and calculate the healthy region in the channel. average pixel value ,in, The total number of pixels in the healthy area. Pixels corresponding to the healthy area In the passage The pixel value on the screen.

[0021] Then, the distribution range of the diseased and healthy areas on each color channel is statistically analyzed. For example, the pixel set of the diseased area is statistically analyzed. All pixels in the channel The minimum and maximum values ​​of the upper pixel are used to obtain the diseased and pest-affected areas in the channel. Distribution range on Then, statistically analyze the pixel set of the healthy region. All pixels in the channel The minimum and maximum values ​​of the pixels are used to obtain the healthy region in the channel. Distribution range on Then, in the passageway, the diseased and pest-infested areas... average pixel value With the health area in the passage average pixel value Subtracting them gives the color shift of that channel. .

[0022] Step 1012: Based on the color offset, obtain the color anomaly data of pests and diseases by statistically analyzing the area ratio and spatial distribution of color anomaly regions in the reference leaf image. In this sub-step, color anomaly data is used to describe the overall distribution pattern of the color characteristics of pests and diseases.

[0023] In this embodiment of the application, based on the color offset of each channel and the distribution range of the healthy zones along each channel. Calculate the preset offset threshold Among them, the preset proportional coefficient and The values ​​are usually set to 0.3 and 0.2 respectively; then, all pixels in the reference leaf image are traversed, and for each pixel... In each color channel pixel values Compared with the mean of the healthy region Calculate the absolute value of the difference to obtain the deviation magnitude. Then the deviation range With preset offset threshold If a comparison is made, Then the pixel In the passage The above is marked as a color anomaly, and the above judgment is performed on all color channels. If the pixel... If a pixel is marked as having a color aberration on at least one color channel, then that pixel is included in the set of color aberration pixels. .

[0024] Next, the set of pixels with abnormal colors was statistically analyzed. The total number of pixels in the image is divided by the total number of pixels in the reference leaf image to obtain the area ratio of the color abnormality region; then the set of color abnormal pixels is recorded. The spatial coordinates of each pixel in the image are determined, and the centroid coordinates of the color aberration pixels in the image are calculated. ,in, ,in, and The x and y coordinates of the color aberration pixels are respectively; then the spatial dispersion of the color aberration pixels relative to the centroid is calculated. The specific calculation method is to calculate the average Euclidean distance from each pixel in the color aberration pixel set A to the centroid position to obtain the spatial distribution characteristics. Finally, the area ratio and spatial distribution characteristics are combined to obtain the color aberration data.

[0025] Step 1013: Based on the color anomaly data, determine the sensitivity weight of each color channel for disease identification by calculating the relative magnitude of each color channel in the color offset, and arrange the sensitivity weights according to the color channel dimension to generate a color weight matrix. In this sub-step, the sensitivity weight refers to the weight value obtained after normalizing the relative amplitude of the color offset of each color channel, which reflects the degree of contribution of that color channel to distinguishing between diseased and healthy areas. The color weight matrix is ​​a weight vector formed by arranging the sensitivity weights of each color channel according to the channel dimension, and is used to perform weighted processing on each color channel of the leaf image.

[0026] In this embodiment of the application, the color offset of each channel in the color anomaly data is... Take the absolute value to obtain the color variation range of each channel. Then sum the color variation amplitudes of all color channels to obtain the total color variation amplitude. Then, the color variation range of each channel is... Divide by the total color change range The relative amplitude of each channel is obtained; then, the relative amplitude of each channel is used as the sensitivity weight of that channel. And sensitivity weight Satisfy the normalization condition, i.e. Then, the sensitivity weights of each color channel are arranged in channel order as a column vector to generate a color weight matrix. .

[0027] Step 1014: Determine the curvature range of the curvature value by calculating the curvature value of each pixel at the edge of the lesion in the reference leaf image; determine the amplitude range of the color gradient value by calculating the color gradient amplitude at the boundary of the lesion; and calculate the pixel width range from the lesion area to the healthy area. In this sub-step, the curvature range refers to the statistical interval of pixel curvature values ​​at the lesion edge, reflecting the distribution of the curvature degree of the lesion boundary. The amplitude range refers to the statistical interval of color gradient amplitude at the lesion boundary, reflecting the distribution of the intensity of color change between the lesion and healthy areas. The pixel width range refers to the interval of the number of pixels in the transition zone between the lesion area and the healthy area, reflecting the width distribution of the lesion boundary.

[0028] In this embodiment, based on the pixel set of the diseased area and the pixel set of the healthy area, an edge detection algorithm is used to extract the edge pixels at the boundary between the lesion area and the healthy area to obtain the lesion edge pixel set. Then, the pixel set at the edge of the lesion. Each edge pixel in Extract the preceding and following pixels of the given pixel on the edge curve, and calculate the curvature value based on the reciprocal of the radius of the arc determined by the three points. ,in, edge pixels The fitted radius of the arc at the edge curve; then traversing the set of pixels at the edge of the lesion. Calculate the curvature values ​​of all edge pixels. The minimum and maximum values ​​are used to obtain the curvature range. .

[0029] Then, the set of pixels at the edge of the lesion. Each edge pixel in Within its neighboring window, for each color channel Calculate the horizontal gradient components separately gradient components in the vertical direction The size of the neighborhood window can be set to m×m. For example, m can be 3, 5, or 7. Then, the square root of the sum of the squares of the gradient components of each channel is taken to obtain the color gradient magnitude of the edge pixel. Where n represents the number of color channels; then iterate through the set of pixels at the edge of the lesion. All edge pixels obtain amplitude range .

[0030] Finally, the set of pixels at the edge of the lesion. Each edge pixel in Calculate the normal direction of the pixel. ,in, This represents the vertical gradient component at that pixel. This represents the horizontal gradient component at that pixel, and iterates pixel by pixel along the normal direction into the lesion area until a pixel value is found that is stable at the mean value of the lesion area, that is, until a pixel value is found that is stable at the mean value of the pest and disease area in the channel in step 1011. average pixel value Nearby pixels, and get the number of pixels traversed. Then, traverse pixel by pixel along the normal direction into the healthy region until a pixel value is found that is stable at the mean of the healthy region. Nearby pixels, and get the number of pixels traversed. Then, the number of pixels traversed on both sides is added together to obtain the number of pixels in the transition zone. Finally, iterate through the set of pixels at the edge of the lesion. Count the number of pixels in the entire transition zone, including all edge pixels. The minimum and maximum values ​​are used to obtain the pixel width range. .

[0031] Step 1015: Construct an edge morphology template for the pest and disease area based on the curvature range, amplitude range, and pixel width range.

[0032] In this embodiment of the application, based on the curvature range Amplitude range and pixel width range By combining the three types of statistical intervals, a marginal morphology template is constructed. Among them, edge shape template The typical distribution ranges of the edges of pests and diseases in three morphological dimensions—curvature, color gradient amplitude, and transition zone width—are stored in the form of triples.

[0033] This application constructs a color weight matrix and edge morphology template for pest and disease characteristics by statistically analyzing the color and edge features of reference leaf images of pests and diseases. This provides a priori reference with specific disease characteristics for subsequent detection steps.

[0034] S102. Based on the color weight matrix, perform weighted transformation on each color channel of the target leaf image to obtain a color transformation map; In one specific implementation, step S102 includes: Step 1021: Calculate the product of the pixel value of each pixel in the target leaf image in each color channel with the sensitivity weight of the corresponding color channel in the color weight matrix, and sum the product values ​​of all color channels of each pixel to obtain the weighted response value of each pixel. In this sub-step, the weighted response value reflects the response intensity of the pixel in the direction of the pest or disease feature.

[0035] In this embodiment, an image of the target leaf to be detected is acquired, and the pixel values ​​of each pixel in the target leaf image in each color channel are extracted; then, for each pixel in the target leaf image... Extract the pixel in the color channel pixel values Then obtain the color channels from the color weight matrix. Corresponding sensitivity weights Then calculate the pixel value. With sensitivity weight The product value of the two values ​​gives the pixel's position in the channel. The weighted pixel values.

[0036] Next, regarding pixels The weighted response value of the pixel is obtained by summing the weighted pixel values ​​of each color channel. The process involves iterating through all pixels in the target leaf image and repeating the above calculation to obtain the weighted response value of each pixel. Specifically, if the target leaf image uses the RGB color space, then... For a pixel p, its pixel values ​​in the red, green, and blue channels are respectively , , The corresponding sensitivity weights are respectively , , Then the weighted response value of that pixel is Furthermore, the larger the weighted response value, the stronger the response of the pixel in the direction of pest and disease features, and the higher the probability that it belongs to a pest and disease area.

[0037] Step 1022: Arrange the weighted response values ​​of all pixels in ascending order and divide them into multiple response intervals. Statistically analyze the distribution of the number of pixels in each response interval and determine the boundary response value between the diseased and healthy areas in the weighted response values. In this sub-step, the response interval is used to statistically analyze the pixel quantity distribution under different response intensities. The boundary response value refers to the weighted response value threshold determined based on the pixel quantity distribution to distinguish between diseased and healthy areas. Pixels with a weighted response value higher than this threshold are identified as belonging to diseased or pest-affected areas.

[0038] In this embodiment, the weighted response values ​​of all pixels are arranged in ascending order to obtain an ordered sequence of weighted response values, and the minimum value of the weighted response values ​​is counted. With the maximum value , will the interval Divide the response into multiple equal intervals; specifically, the interval can be divided into... There are 1 response interval, and the width of each response interval is 1. ,in, The value of is typically between 10 and 50, and is determined based on the total number of pixels in the target leaf image and the distribution characteristics of the weighted response values, thus obtaining the th . The boundaries of each response interval are ,in, .

[0039] Next, iterate through the weighted response values ​​of all pixels and count the values ​​that fall into the first position. Number of pixels within each response interval A histogram was plotted with the response interval on the horizontal axis and the number of pixels on the vertical axis to observe the peak positions of the pixel number distribution. Then, based on the pixel number distribution histogram, the valley positions between two significant peaks were identified; the weighted response value corresponding to this valley position is the boundary response value. Specifically, iterate through each response interval to find the condition that is met. and range index The center value of this interval is used as the boundary response value. If multiple valleys exist in the histogram, the valley position that maximizes the inter-class variance after dividing the pixels into two classes is selected as the boundary response value. The specific formula for calculating the inter-class variance is as follows: ,in, and These represent the proportions of the two pixel categories, defined by the candidate valley locations, to the total number of pixels in the target leaf image. and These are the weighted average response values ​​for these two types of pixels, respectively.

[0040] Step 1023: Adjust the weighted response value corresponding to the diseased and pest areas that are greater than or equal to the boundary response value to a preset first value range, and adjust the weighted response value corresponding to the healthy areas that are less than the boundary response value to a preset second value range. The first value range is greater than the second value range. In this sub-step, the first numerical range refers to the range of values ​​mapped to the weighted response values ​​of the pest-affected areas after adjustment, used to enhance the contrast between the pest-affected areas and the healthy areas. The second numerical range refers to the range of values ​​mapped to the weighted response values ​​of the healthy areas after adjustment, with values ​​lower than the first numerical range.

[0041] In this embodiment of the application, a preset first numerical range is set as follows: The preset second numerical range is ,in, For example, the first numerical range can be set to The second numerical range can be set to The specific numerical range is determined based on subsequent processing requirements and image display requirements; then the weighted response value is... The weighted response value of the pixel from the range Linear mapping to the first numerical range The adjusted weighted response value is obtained. Weighted response values The weighted response value of the pixel from the range Linear mapping to the second numerical range The adjusted weighted response value is obtained. .

[0042] Step 1024: Rearrange the weighted response values ​​of each pixel according to their spatial position to generate a color transformation map that matches the spatial resolution of the target leaf image.

[0043] In this sub-step, the color transformation map refers to a two-dimensional image formed by arranging the adjusted weighted response values ​​of each pixel according to their spatial position in the target leaf image. It has the same spatial resolution as the target leaf image and is used for subsequent edge detection and region segmentation.

[0044] In this embodiment, the spatial resolution information of the target blade image, i.e., the width and height of the image, is extracted; then, the weighted response values ​​of each pixel are rearranged according to the spatial position of the pixel in the target blade image; specifically, for the target blade image located at coordinates... pixels Adjust its weighted response value Assign values ​​to the color transformation graph median coordinate The pixel value of the location; then traverse all pixels in the target leaf image to complete the color transformation map. The color transformation map is constructed with the same width and height as the target leaf image.

[0045] This application uses a color weight matrix to perform weighted transformation on each color channel of the target leaf image, highlighting the color response of the diseased and pest-infested areas, suppressing interference from healthy areas, and generating a color transformation map that enhances disease features, providing high-quality basic data for subsequent edge detection and region segmentation.

[0046] S103. The edge response intensity of each pixel is obtained by calculating the gradient intensity of each pixel along multiple directions in the color transformation image. The boundary morphology features of the edge position determined by the edge response intensity in the color transformation image are matched with the edge morphology template to obtain the matching score. In one specific implementation, step S103 includes: Step 1031: Calculate the gradient intensity of each pixel in the color transformation image in multiple preset directions, and add the gradient intensities in each direction to obtain the edge response intensity of each pixel. The multiple directions include 0 degrees, 45 degrees, 90 degrees and 135 degrees. In this sub-step, the edge response intensity reflects the probability that the pixel is located at an edge position.

[0047] In this embodiment, the gradient intensity of each pixel in the color transformation image is calculated in multiple preset directions, including the 0-degree direction, the 45-degree direction, the 90-degree direction, and the 135-degree direction, which correspond to the horizontal direction, the diagonal direction from the upper right to the lower left, the vertical direction, and the diagonal direction from the upper left to the lower right, respectively; then, for the color transformation image... For each pixel in the array, the directional gradient operator is used to perform a convolution operation on the pixel to obtain the directional gradient of that pixel. gradient intensity Specifically, for the 0-degree direction, i.e. the horizontal direction, the horizontal Sobel operator can be used for calculation; for the 90-degree direction, i.e. the vertical direction, the vertical Sobel operator can be used for calculation; and for the 45-degree and 135-degree diagonal directions, the corresponding diagonal gradient operators can be used for calculation.

[0048] Then, for the color transformation diagram For each pixel in the image, the gradient intensities at 0°, 45°, 90°, and 135° are summed to obtain the edge response intensity of that pixel. ,in, , , , These represent the gradient intensity of the pixel in the directions of 0 degrees, 45 degrees, 90 degrees, and 135 degrees, respectively.

[0049] Step 1032: Calculate the curvature value, gradient magnitude, and pixel width of the transition zone between the lesion area and the healthy area of ​​the edge curve within the neighborhood window centered on each pixel whose edge response intensity is greater than the preset response threshold, and obtain the boundary morphology features of the edge position. The edge position is the set of all pixels whose edge response intensity is greater than the preset response threshold. In this sub-step, the edge location refers to the set of all pixels whose edge response intensity is greater than a preset response threshold, representing the pixel location in the color transformation map that may be the boundary of a lesion. The boundary morphology features refer to the statistical characteristics of the curvature value, gradient magnitude, and transition zone pixel width of the edge curve at the edge location, used to describe the morphological attributes of the edge.

[0050] In this embodiment of the application, a preset response threshold is set. This threshold is determined based on the statistical distribution of the edge response intensities of all pixels. Specifically, the mean and standard deviation of the edge response intensities of all pixels are calculated, and the preset response threshold is then applied. Set the value to a multiple of the mean plus the standard deviation; for example, this could be the mean plus 1 to 2 times the standard deviation. Then, iterate through all pixels in the color transformation image, ensuring that the edge response intensity is greater than the preset response threshold. The pixels are assigned to the edge position pixel set B; then for the edge position pixel set... For each pixel in the array, a neighborhood window is constructed centered on that pixel, and the size of the neighborhood window can be set to... , or Then, based on the direction of the edge curve extracted within the neighborhood window, the curvature value of the edge curve is calculated. It uses the same method as step 1014 to calculate the curvature value based on the reciprocal of the arc radius determined by adjacent pixels on the edge curve within the neighborhood window.

[0051] Then, the color transformation map of each pixel within the neighborhood window is... The gradient components in the horizontal and vertical directions of each pixel value are calculated. The gradient magnitude is obtained by summing the squares of the gradient components and taking the square root. The maximum gradient magnitude of all pixels within the neighborhood window is taken as the gradient magnitude of the pixel at that edge position. For each pixel in the edge pixel set B, the sampling step 1014 calculates the normal direction of the pixel using the same method, and then transforms the color map along the normal direction. The process involves traversing the high-pixel-value region (the lesion area) pixel by pixel until a pixel with a stable value is encountered, and recording the number of pixels traversed. Then, the process continues along the normal direction towards the low-pixel-value region (the healthy region) pixel by pixel until a pixel with a stable value is encountered, and the number of pixels traversed is recorded. The traversal method is the same as in step 1014. Finally, the number of pixels traversed on both sides is added together to obtain the pixel width of the transition band. Finally, iterate through the set of pixels at the edge positions. For all pixels, these three types of morphological features of each pixel are combined to obtain the boundary morphological features of the edge location.

[0052] Step 1033: Compare the boundary morphological features with the feature range in the edge morphological template to obtain the matching score between the edge position and the pests and diseases.

[0053] In this sub-step, the matching score refers to the score of the degree of agreement between the boundary morphological features and the feature range in the edge morphological template, reflecting the similarity between the edge position and the edge of the pest or disease.

[0054] In this embodiment of the application, the boundary morphological features are compared with the feature range in the edge morphological template, that is, for the curvature value... Determine whether it falls within the curvature range. inside, if If the curvature dimension match is successful, the curvature matching component is assigned a value of 1; otherwise, the curvature dimension match fails, and the curvature matching component is assigned a value of 0. For gradient magnitude... Determine whether it falls within the amplitude range. inside, if If the gradient dimension match is successful, the gradient matching component is assigned a value of 1; otherwise, the gradient dimension match fails, and the gradient matching component is assigned a value of 0. For the transition band pixel width Determine whether it falls within the pixel width range. inside, if If the width dimension matches successfully, the width matching component is assigned a value of 1; otherwise, the width dimension matches unsuccessfully, and the width matching component is assigned a value of 0. Finally, the matching components of the three dimensions are summed and divided by the total number of feature dimensions, 3, to obtain the matching score of the pixel. The higher the matching score, the more similar the morphological features of the pixel at the edge position are to the edge of the pest or disease.

[0055] This application uses multi-directional gradient calculation to locate edge positions and matches the edge morphological features with edge morphological templates to filter out noisy edges unrelated to diseases, thereby obtaining a matching score that quantifies the degree of agreement between the edge and the pests and diseases, thus improving the targeting and accuracy of edge detection.

[0056] S104. The evaluation map generated based on the edge response intensity and matching score is fused with the color transformation map to obtain a multi-dimensional feature map; In one specific implementation, such as Figure 3 As shown, step S104 includes: Step 1041: Calculate the product of the edge response intensity and the matching score of each pixel at the edge location to obtain the evaluation value of each pixel. The evaluation value represents the confidence level of the corresponding pixel belonging to the edge of the lesion. In this embodiment of the application, for the set of pixels at the edge position For each pixel in the dataset, the edge response intensity of that pixel is calculated. Matching score Multiply the results to obtain the evaluation value for that pixel. Then iterate through all pixels in the edge location pixel set B, repeating the above calculation process to obtain the evaluation value of each pixel; for the edge location pixel set... Pixels outside the edge are not considered edge locations, so their evaluation value is directly assigned to 0.

[0057] Step 1042: Pixels with evaluation values ​​greater than the preset evaluation threshold are identified as edge pixels, and pixels with evaluation values ​​less than or equal to the preset evaluation threshold are identified as non-edge pixels, and an evaluation map is constructed. In this sub-step, the evaluation map refers to a two-dimensional image generated based on the comparison between the evaluation value of each pixel and a preset evaluation threshold, used to identify which pixels belong to the edge pixels of the lesion.

[0058] In this embodiment of the application, a preset evaluation threshold is set. This threshold is determined based on the statistical distribution of all pixel evaluation values, specifically, the set of pixels at statistical edge locations. Evaluation values ​​of all pixels The mean and standard deviation will be used to set a preset evaluation threshold. Set a value between the mean minus 0.5 standard deviation and the mean plus 0.5 standard deviation, or use an adaptive thresholding method to determine a threshold that can effectively distinguish edge pixels from non-edge pixels based on the distribution histogram of the evaluation values; then, define pixels with evaluation values ​​greater than the preset evaluation threshold as edge pixels, and iterate through the color transformation map. For each pixel in the set, evaluate its value. Compared with the preset evaluation threshold If a comparison is made, If so, the pixel is identified as an edge pixel and included in the evaluation map. The pixel value at that pixel location is set as the evaluation value. .

[0059] Then, pixels with evaluation values ​​less than or equal to a preset evaluation threshold are defined as non-edge pixels. If so, the pixel is determined to be a non-edge pixel and included in the evaluation map. Set the pixel value at that pixel location to 0; traverse the color transformation map. For all pixels in the evaluation image, according to the above determination rules, assign the evaluation value or 0 to each pixel. The pixel values ​​at the corresponding positions in the image are used to obtain the color transformation map. Evaluation map with consistent spatial resolution .

[0060] Step 1043: Combine the evaluation map and the color transformation map by channel to obtain a multi-dimensional feature map that includes the evaluation value and the color response value.

[0061] In this sub-step, the multi-dimensional feature map refers to the multi-channel image formed by stitching the evaluation map and the color transformation map according to the channel dimension. It can include edge evaluation channels and color response channels, which are used for subsequent region segmentation and confidence calculation.

[0062] In this embodiment of the application, the evaluation diagram will be used. As the first channel, the color transformation diagram As a second channel, the evaluation image and the color transformation image are then stitched together channel by channel; that is, for the color transformation image... Extract the pixel located at the coordinate position in the color transformation map. The pixel value in the text is the adjusted weighted response value. Extract the pixel from the evaluation map The pixel value in the evaluation value is the same as the evaluation value. Or 0; then arrange these two values ​​in channel order to form a multidimensional feature map. The pixel vector U at that coordinate position , among which, U The coordinates in the multidimensional feature map are The pixel vector, To evaluate the pixel value at this coordinate position in the image, The value is the pixel value at this coordinate position in the color transformation map. The multidimensional feature map is a dual-channel image. The first channel stores the evaluation value information of each pixel, reflecting the confidence level of the pixel belonging to the edge of the lesion. The second channel stores the color response value of each pixel, that is, the adjusted weighted response value, reflecting the response intensity of the pixel in the direction of the color feature of the pest.

[0063] This application integrates edge response intensity with matching scores to generate an evaluation map, and then stitches it with a color transformation map to form a multi-dimensional feature map that simultaneously contains edge confidence level and color response information, providing multi-dimensional feature support for subsequent region segmentation.

[0064] S105. Initialize the multidimensional feature map into a set of sub-regions. Obtain the merging cost based on the feature value difference between adjacent sub-regions and the length of the common boundary. Merge the adjacent sub-regions with the smallest merging cost in the sub-region set until the matching value between the common boundary of the adjacent sub-regions and the edge morphology template is greater than the preset judgment value, and obtain a merging tree with sub-regions as child nodes. In one specific implementation, step S105 includes: Step 1051: Based on the evaluation values ​​of each pixel in the multidimensional feature map, divide the multidimensional feature map into sub-regions composed of individual pixels to form a set of sub-regions, and use each sub-region as a node of the merge tree. In this sub-step, the sub-region set refers to the collection of all sub-regions obtained after dividing the multi-dimensional feature map. Initially, each sub-region consists of a single pixel, and the sub-regions gradually increase in size as the merging process progresses. The merging tree is a tree-shaped data structure that records the sub-region merging process. Leaf nodes correspond to the initial single-pixel sub-regions, while intermediate nodes and the root node correspond to the merged sub-regions. The hierarchical structure of the tree reflects the order and hierarchical relationship of the region merging.

[0065] In this embodiment, the evaluation value of each pixel in the multidimensional feature map is extracted, that is, the pixel value of the first channel of the multidimensional feature map. Then, for each pixel in the multidimensional feature map, the pixel is treated as a separate sub-region, and each sub-region contains only one pixel and its corresponding evaluation value and color response value. By traversing all pixels in the multidimensional feature map, each single-pixel sub-region is assigned to a sub-region set. ; followed by a sub-region set Each sub-region in the map is assigned a corresponding tree node. Initially, all nodes are leaf nodes with no parent or child nodes. Each tree node stores the attribute information of the corresponding sub-region, including the set of coordinates of the pixels contained in the sub-region, the evaluation value of the sub-region, and the color response value of the sub-region. However, after merging, each sub-region may contain multiple pixels. Therefore, the set of coordinates of the pixels contained in the merged sub-region, the average evaluation value of the sub-region, and the average color response value of the sub-region are used. Finally, the merged tree structure is initialized, and all leaf nodes are used as the initial node set of the merged tree. At this time, the number of nodes in the merged tree is equal to the total number of pixels in the multidimensional feature map.

[0066] Step 1052: Calculate the mean difference in evaluation values, the mean difference in color response values, and the length of the common boundary between adjacent sub-regions in the sub-region set, and perform weighted fusion to obtain the merging cost between adjacent sub-regions; In this sub-step, the mean difference of evaluation values ​​refers to the absolute value of the difference between the mean evaluation values ​​of adjacent sub-regions, reflecting the difference in edge confidence between the two sub-regions. The mean difference of color response values ​​refers to the absolute value of the difference between the mean color response values ​​of adjacent sub-regions, reflecting the difference in the color characteristics of pests and diseases between the two sub-regions. The common boundary length refers to the number of pixels sharing a boundary between adjacent sub-regions, reflecting the degree of spatial contact between the two sub-regions. The merging cost is a priority index for merging adjacent sub-regions calculated by combining the mean difference of evaluation values, the mean difference of color response values, and the common boundary length; the smaller the value, the more suitable the two sub-regions are for merging.

[0067] In this embodiment of the application, the sub-region set is traversed. All sub-regions are identified, and adjacent sub-region pairs are identified. Two sub-regions are considered adjacent if at least one pair of pixels in their four-neighbor or eight-neighbor range are in contact. Then, the values ​​of each pair of adjacent sub-regions are calculated. and The differences in mean evaluation values, mean color response values, and common boundary length between sub-regions. Calculate the mean of the evaluation values ​​of all pixels contained in the sub-region. For sub-regions Calculate the mean of the evaluation values ​​of all pixels contained in the sub-region. Then subtract the mean values ​​of the two sub-regions and take the absolute value to obtain the difference in the evaluation values; similarly, calculate the difference in the mean values ​​of the color response values.

[0068] Then, the length of the common boundary is calculated, which is the statistical sub-region. Middle and sub-regions The length of the common boundary is obtained by counting the number of adjacent pixels. For example, if the sub-region Contains pixels , sub-region Contains pixels If pixels With pixels If they are adjacent within their four neighboring regions, then the length of their common boundary is... Increase by 1; then set three weighting coefficients. , and These correspond to the weights of the mean difference of the evaluation values, the mean difference of the color response values, and the length of the common boundary, respectively, and the three weights satisfy the normalization condition. For example, they can be taken as 0.4, 0.4, and 0.2, respectively. To eliminate the impact of inconsistent numerical ranges on the weighted fusion result, each item needs to be normalized before weighted fusion. Specifically, the difference in the mean evaluation value of all adjacent sub-region pairs in the sub-region set R is calculated to obtain the maximum value of the difference in the mean evaluation value. Divide the mean difference in evaluation values ​​of each pair of adjacent sub-regions by This yields the normalized mean difference in evaluation values; similarly, the mean difference in color response values ​​for all adjacent sub-region pairs is calculated to obtain the maximum mean difference in color response values. Divide the mean difference in color response values ​​of each pair of adjacent sub-regions by The difference in the mean of the normalized color response values ​​is obtained; the length of the common boundary of all adjacent sub-region pairs is calculated, and the maximum value of the common boundary length is obtained. The common boundary length of each pair of adjacent sub-regions Divide by The normalized common boundary length is obtained. Next, multiply the mean difference of the normalized evaluation values ​​and the mean difference of the color response values ​​by their respective weights, multiply the reciprocal of the common boundary length by its corresponding weight, and sum them up to obtain the merging cost. ,in, The difference between the mean and mean of the normalized assessment values. The difference between the mean and mean of the normalized color response values. This is the normalized length of the common boundary.

[0069] Step 1053: Compare the common boundary of the adjacent sub-regions with the minimum merging cost with the feature range in the edge morphology template to obtain a matching value. When the matching value is less than or equal to the preset judgment value, merge the adjacent sub-regions with the minimum merging cost into one sub-region and generate a node in the merged tree with the node corresponding to the two adjacent sub-regions before merging as the parent node of the merged sub-region as the child node. Update the sub-region set and the merged tree, and return to calculate the mean difference of evaluation values, the mean difference of color response values, and the length of the common boundary between adjacent sub-regions in the sub-region set, until the matching value is greater than the preset judgment value, and obtain the constructed merged tree.

[0070] In this sub-step, the common boundary refers to the pixel sequence shared by adjacent sub-regions, used to extract the morphological features of the boundary. The matching value is a score indicating the degree of similarity between the morphological features of the common boundary and the feature range in the edge morphology template; a higher value indicates that the common boundary better matches the edge features of pests and diseases. The parent node is the node at the next higher level generated by merging two child nodes in the merge tree, storing the attribute information of the merged sub-region.

[0071] In this embodiment, the pair of adjacent sub-regions with the lowest merging cost is found and denoted as the sub-region. and Next, extract the pixel sequence on the common boundary of the adjacent sub-region pair, and calculate the curvature value, gradient magnitude, and transition zone pixel width of the common boundary; then compare the common boundary with the feature range in the edge morphology template to obtain the matching value. That is, for pixels on the common boundary, use the same method as in step 1033 to calculate the curvature value, gradient magnitude, and transition zone pixel width of all pixels on the boundary, then take the average of the curvature value, gradient magnitude, and transition zone pixel width of all pixels, and then compare them with the edge morphology template constructed in step 1015. curvature range Amplitude range and pixel width range The comparison is performed. If the morphological features of the common boundary fall within the corresponding range, then the dimension matches successfully and is assigned a value of 1; otherwise, it is assigned a value of 0. The matching results of the three dimensions are summed and divided by 3 to obtain the matching value. ; Next, set the preset judgment value. This threshold is determined based on the strictness of the pest and disease edge characteristics, and can typically be between 0.5 and 0.7, in terms of matching values. Less than or equal to the preset judgment value If the public boundary does not meet the characteristics of pest and disease edges, merging is permitted, i.e., sub-regions are created. and Merge into a new sub-region The new sub-region contains all the pixels of the original two sub-regions, and the mean evaluation value and the mean color response value of the new sub-region are calculated.

[0072] Then, create new tree nodes. and sub-region Corresponding tree nodes and sub-regions The corresponding tree node is set to child nodes, As a merged sub-region The node, its The system stores the set of pixel coordinates, mean evaluation value, and mean color response value of the merged sub-regions; then it retrieves the values ​​from the sub-region set. Remove sub-regions and , add a new sub-region Then update the node set of the merged tree, and Add to the node collection.

[0073] Finally, return to step 1052 to recalculate the mean difference in evaluation values, mean difference in color response values, and common boundary length between adjacent sub-regions in the sub-region set. Perform weighted fusion to obtain a new merging cost distribution. Then repeat step 1053 to find the new pair of adjacent sub-regions with the minimum merging cost, calculate the matching value, and determine whether to continue merging; until the matching value is found... Greater than the preset judgment value That is, if the common boundary of the adjacent sub-region pair with the lowest current merging cost meets the characteristics of the edge of pests and diseases, the merging process is stopped.

[0074] After merging stops, a global virtual parent node is constructed as the sole root node of the merge tree. All remaining unmerged sub-regions in the sub-region set R are then connected to this global virtual parent node as its children. At this point, each sub-region in the sub-region set R has reached a suitable segmentation granularity. The merge tree records the complete merging hierarchy from single-pixel sub-regions to the final segmentation result, thus obtaining the constructed merge tree. The root node of the merge tree corresponds to the aforementioned global virtual parent node, and its lower layers are directly connected to the multiple independent sub-regions generated by the final segmentation. Leaf nodes correspond to the initial single-pixel sub-regions, and intermediate nodes reflect the intermediate states of region merging. The global virtual parent node does not correspond to any actual sub-region; its confidence level is set to 0. It serves only as the unified root node of the merge tree structure and does not participate in the actual confidence propagation calculation. Confidence propagation begins with each direct child node of the global virtual parent node. Each direct child node uses its initial confidence level as its current confidence level and propagates it to its lower-level child nodes.

[0075] Based on multidimensional feature maps, this application constructs a hierarchical merging tree by iteratively merging adjacent sub-regions and using edge morphology template matching values ​​as the stopping condition. This enables adaptive perception of the boundary between pest-infested and healthy regions, effectively preventing boundary blurring caused by excessive merging.

[0076] S106. Starting from the root node of the merged tree, determine the confidence level of each node based on the mean eigenvalue of the sub-regions corresponding to each node and the color weight matrix. Propagate the confidence level to the child nodes corresponding to each node to update the confidence level of the child nodes. Sub-regions with confidence levels greater than the preset confidence threshold are identified as pest and disease areas.

[0077] In one specific implementation, such as Figure 2 As shown, step S106 includes: Step 1061: Determine the confidence level of each node in the merged tree based on the matching degree between the mean color response value of the sub-region corresponding to each node of the merged tree and the sensitivity weight corresponding to the color weight matrix. In this sub-step, the mean color response value refers to the average of the weighted response values ​​of all pixels within the sub-region after adjustment, reflecting the overall response intensity of the sub-region in the direction of the color characteristics of pests and diseases.

[0078] In this embodiment, all nodes in the merge tree are traversed, and for each sub-region corresponding to a node, the adjusted weighted response values ​​of all pixels contained in that sub-region are extracted. Then, the weighted average response values ​​of these pixels are calculated to obtain the average color response value of the sub-region. ,in, This represents the total number of pixels contained in the sub-region. For pixels in the sub-region The adjusted weighted response value; then for each pixel in the sub-region Extract the pixel in each color channel pixel values And calculate the pixel mean of each color channel in the sub-region. .

[0079] Next, the pixel average of each color channel is calculated. In the passageway between disease and pest infestation areas average pixel value The comparisons are performed, the similarity between each channel is calculated, and the corresponding sensitivity weights in the color weight matrix are used. Perform weighted blending; specifically, define the color channels. Normalized denominator In the passageway between the diseased and healthy areas The combined range of the pixel values, i.e. ,in, and The disease and pest infestation areas are located in the passageway. The maximum and minimum values ​​of the pixel. and The health area is located in the passageway. The maximum and minimum values ​​of the pixel; This represents the total distribution span of the two types of regions along the channel. Based on this, the normalized difference of each channel is calculated. ,because No more than Therefore .

[0080] Then, the similarity components of each channel are weighted and fused using the corresponding sensitivity weights in the color weight matrix to obtain the matching degree of that node. Then the matching degree This serves as the confidence level for that node.

[0081] Step 1062: Starting from the root node of the merged tree, propagate the confidence of the parent node to the corresponding lower-level child nodes. Update the confidence of each child node by weighted summation based on the confidence of each child node and the confidence received from the parent node. In this sub-step, confidence propagation refers to the process of passing the confidence of the parent node to its lower-level child nodes according to a certain weight, and weighting and integrating it with the confidence of the child node itself to update the confidence of the child node, so that the confidence of the child node can simultaneously reflect its own color characteristics and the overall disease characteristics of the upper-level area.

[0082] In this embodiment, starting from the root node of the merge tree, confidence propagation is performed on each level of nodes in a hierarchical order from the root node to the leaf node. That is, for each node in the merge tree that has child nodes, the confidence of that node is propagated. The confidence level is then propagated to its lower-level child nodes, meaning that for each child node in the merge tree, the confidence level of that child node is obtained. The confidence level propagated from the parent node of the child node, and then the propagation weight coefficient is set. This coefficient reflects the proportion of the contribution of the parent node's propagated confidence to the update of the child node's confidence. Its value ranges from 0 to 1, and for example, it can be 0.3 to 0.5. Then, the updated child node confidence is calculated by weighted summation. ,in, This represents the confidence level of the child node itself. This represents the confidence level at which the parent node propagates the message to the child node. The propagation weight coefficient for the parent node's confidence. The weights are reserved for the confidence of the child nodes themselves.

[0083] Then, the updated confidence level This serves as the current confidence level for the child node, and is used in subsequent propagation to its lower-level child nodes. The propagation value continues to be passed down, and all levels of the merge tree are traversed. The above weighted summation process is repeated for the child nodes of each level until the confidence of all leaf nodes has been updated.

[0084] Step 1063: Identify the sub-regions corresponding to the child nodes in the merged tree whose confidence level is greater than the preset confidence threshold as pest and disease areas.

[0085] In this embodiment of the application, a preset threshold is set. This threshold is determined based on the confidence distribution statistics of all nodes after the update in step 1062. Specifically, the confidence scores of all nodes are statistically analyzed. The mean and standard deviation will be used to set a pre-set confidence threshold. Set it to the mean plus a value between 0.5 and 1 standard deviation to ensure that high-confidence nodes can be effectively distinguished from low-confidence nodes.

[0086] Then iterate through all child nodes in the merge tree and update the confidence score of each child node. With preset threshold If a comparison is made, Then the sub-region corresponding to that sub-node is determined as the pest and disease area. If the sub-region corresponding to the sub-node is determined to be a healthy region, then all sub-regions corresponding to sub-nodes with confidence scores greater than the preset confidence threshold are collected. The pixel coordinate sets contained in these sub-regions are merged to obtain the final set of pixels for the diseased and pest-affected regions. The set of pixels for the diseased and pest-affected regions is then mapped back to the spatial location of the target leaf image to mark the diseased and pest-affected regions in the target leaf image.

[0087] This application calculates the initial confidence of each sub-region based on the color weight matrix, and propagates the confidence through a hierarchical merging tree to accurately locate the disease and pest infection area in the target leaf image.

[0088] Figure 4 This is a schematic diagram illustrating a specific implementation of an artificial intelligence-based agricultural image pest and disease region extraction system provided in this application. (Refer to...) Figure 4 The system may include: The acquisition module 41 is used to acquire the color weight matrix and edge morphology template determined based on the leaf images of crops under pest and disease infection. Transformation module 42 is used to perform weighted transformation on each color channel of the target leaf image based on the color weight matrix to obtain a color transformation map; The matching module 43 is used to obtain the edge response intensity of each pixel by calculating the gradient intensity of each pixel along multiple directions in the color transformation map, and to match the boundary morphology features of the edge position determined by the edge response intensity in the color transformation map with the edge morphology template to obtain the matching score. The fusion module 44 is used to fuse the evaluation map generated based on the edge response intensity and matching score with the color transformation map to obtain a multi-dimensional feature map; The merging module 45 is used to initialize the multidimensional feature map into a set of sub-regions, obtain the merging cost based on the feature value difference between adjacent sub-regions and the length of the common boundary, merge the adjacent sub-regions with the smallest merging cost in the sub-region set, until the matching value of the common boundary of the adjacent sub-regions and the edge morphology template is greater than the preset judgment value, and obtain a merging tree with sub-regions as child nodes. The determination module 46 is used to start from the root node of the merged tree, determine the confidence level of each node based on the mean feature value of the sub-regions corresponding to each node and the color weight matrix, propagate the confidence level to the child nodes corresponding to each node to update the confidence level of the child nodes, and determine the sub-regions with confidence levels greater than the preset confidence threshold as pest and disease areas.

[0089] The AI-based agricultural image pest and disease region extraction system of this application embodiment is used to implement the aforementioned AI-based agricultural image pest and disease region extraction method. Therefore, the specific implementation of the AI-based agricultural image pest and disease region extraction system can be found in the embodiment section of the AI-based agricultural image pest and disease region extraction method above. The specific implementation can be referred to the description of the corresponding embodiments, and will not be repeated here.

[0090] Figure 5 A schematic diagram of the hardware structure of an electronic device provided in one embodiment of this application is shown.

[0091] The electronic device may include a processor 510 and a memory 520 storing computer program instructions.

[0092] Specifically, the processor 510 may include a central processing unit (CPU), an application-specific integrated circuit (ASIC), or one or more integrated circuits that can be configured to implement the embodiments of this application.

[0093] Memory 520 may include mass storage for data or instructions. For example, and not limitingly, memory 520 may include a hard disk drive (HDD), floppy disk drive, flash memory, optical disk, magneto-optical disk, magnetic tape, or Universal Serial Bus (USB) drive, or a combination of two or more of these. Where appropriate, memory 520 may include removable or non-removable (or fixed) media. Where appropriate, memory 520 may be internal or external to the integrated gateway disaster recovery device. In a particular embodiment, memory 520 is non-volatile solid-state memory.

[0094] Memory may include read-only memory (ROM), random access memory (RAM), disk storage media devices, optical storage media devices, flash memory devices, and electrical, optical, or other physical / tangible memory storage devices. Therefore, typically, memory includes one or more tangible (non-transitory) computer-readable storage media (e.g., memory devices) encoded with software including computer-executable instructions, and when the software is executed (e.g., by one or more processors), it is operable to perform the operations described with reference to the method according to the first aspect of this disclosure.

[0095] The processor 510 reads and executes computer program instructions stored in the memory 520 to implement any of the artificial intelligence-based methods for extracting disease and pest areas from agricultural images in the above embodiments.

[0096] In one example, the electronic device may also include a communication interface 530 and a bus 540. Wherein, such as Figure 5 As shown, the processor 510, memory 520, and communication interface 530 are connected through bus 540 and complete communication with each other.

[0097] The communication interface 530 is mainly used to realize communication between various modules, devices, units and / or equipment in the embodiments of this application.

[0098] Bus 540 includes hardware, software, or both, that couples components of an online data traffic metering device together. For example, and not limitingly, the bus may include an Accelerated Graphics Port (AGP) or other graphics bus, an Enhanced Industry Standard Architecture (EISA) bus, a Front Side Bus (FSB), HyperTransport (HT) interconnect, an Industry Standard Architecture (ISA) bus, an Infinite Bandwidth Interconnect, a Low Pin Count (LPC) bus, a memory bus, a Microchannel Architecture (MCA) bus, a Peripheral Component Interconnect (PCI) bus, a PCI-Express (PCI-X) bus, a Serial Advanced Technology Attachment (SATA) bus, a Video Electronics Standards Association Local (VLB) bus, or other suitable buses, or combinations of two or more of these. Where appropriate, bus 540 may include one or more buses. Although specific buses are described and illustrated in embodiments of this application, any suitable bus or interconnect is contemplated herein.

[0099] The electronic device can execute the AI-based agricultural image pest and disease region extraction method in the embodiments of this application, thereby realizing the AI-based agricultural image pest and disease region extraction method described in conjunction with the accompanying drawings.

[0100] Furthermore, in conjunction with the artificial intelligence-based agricultural image pest and disease region extraction method in the above embodiments, this application embodiment can provide a computer-readable storage medium for implementation. This computer-readable storage medium stores computer program instructions; when executed by a processor, these computer program instructions implement any of the artificial intelligence-based agricultural image pest and disease region extraction methods in the above embodiments.

[0101] It should be clarified that this application is not limited to the specific configurations and processes described above and shown in the figures. For the sake of brevity, detailed descriptions of known methods are omitted here. In the above embodiments, several specific steps are described and shown as examples. However, the method process of this application is not limited to the specific steps described and shown. Those skilled in the art can make various changes, modifications, and additions, or change the order of steps, after understanding the spirit of this application.

[0102] The functional blocks shown in the above block diagram can be implemented as hardware, software, firmware, or a combination thereof. When implemented in hardware, they can be, for example, electronic circuits, application-specific integrated circuits (ASICs), appropriate firmware, plug-ins, function cards, etc. When implemented in software, the elements of this application are programs or code segments used to perform the required tasks. Programs or code segments can be stored on a machine-readable medium or transmitted over a transmission medium or communication link via data signals carried on a carrier wave. "Machine-readable medium" can include any medium capable of storing or transmitting information. Examples of machine-readable media include electronic circuits, semiconductor memory devices, ROM, flash memory, erasable ROM (EROM), floppy disks, CD-ROMs, optical disks, hard disks, fiber optic media, radio frequency (RF) links, etc. Code segments can be downloaded via computer networks such as the Internet, intranets, etc.

[0103] It should also be noted that the exemplary embodiments mentioned in this application describe methods or systems based on a series of steps or apparatus. However, this application is not limited to the order of the above steps; that is, the steps can be performed in the order mentioned in the embodiments, or in a different order, or several steps can be performed simultaneously.

Claims

1. A method for extracting pest and disease areas from agricultural images based on artificial intelligence, characterized in that, include: Obtain the color weight matrix and edge morphology template determined from leaf images of crops infected with pests and diseases; Based on the color weight matrix, a weighted transformation is performed on each color channel of the target leaf image to obtain a color transformation map; The edge response intensity of each pixel is obtained by calculating the gradient intensity of each pixel along multiple directions in the color transformation image. The boundary shape features of the edge position determined by the edge response intensity in the color transformation image are matched with the edge shape template to obtain the matching score. The evaluation map generated based on the edge response intensity and the matching score is fused with the color transformation map to obtain a multi-dimensional feature map; The multidimensional feature map is initialized into a set of sub-regions. The merging cost is obtained based on the feature value difference and common boundary length between adjacent sub-regions. The adjacent sub-regions with the smallest merging cost in the set of sub-regions are merged until the matching value between the common boundary of the adjacent sub-regions and the edge morphology template is greater than a preset judgment value, thus obtaining a merging tree with sub-regions as child nodes. Starting from the root node of the merged tree, the confidence level of each node is determined based on the mean eigenvalue of the sub-regions corresponding to each node and the color weight matrix. The confidence level is then propagated to the child nodes corresponding to each node to update the confidence level of the child nodes. Sub-regions with confidence levels greater than a preset confidence threshold are identified as pest and disease areas.

2. The method according to claim 1, characterized in that, Before obtaining the color weight matrix and edge morphology template determined based on leaf images of crops infected with pests and diseases, the method further includes: Collect reference leaf images of crops infected with pests and diseases, and statistically analyze the average pixel value and distribution range of the diseased and healthy areas in each color channel of the reference leaf images. Calculate the color shift of the diseased area relative to the healthy area in each color channel. Based on the color offset, the color anomaly data of pests and diseases are obtained by statistically analyzing the area ratio and spatial distribution of the color anomaly region in the reference leaf image. Based on the color anomaly data, the relative magnitude of each color channel in the color offset is calculated to determine the sensitivity weight of each color channel for disease identification, and the sensitivity weights are arranged according to the color channel dimension to generate a color weight matrix. The curvature range of the curvature values ​​is determined by calculating the curvature values ​​of each pixel at the edge of the lesion in the reference leaf image; the amplitude range of the color gradient amplitude is determined by calculating the color gradient amplitude at the boundary of the lesion; and the pixel width range from the lesion area to the healthy area is calculated. Based on the curvature range, the amplitude range, and the pixel width range, an edge morphology template for the pest and disease area is constructed.

3. The method according to claim 1, characterized in that, The step of performing a weighted transformation on each color channel of the target leaf image based on the color weight matrix to obtain a color transformation map includes: Calculate the product of the pixel value of each pixel in the target leaf image in each color channel with the sensitivity weight of the corresponding color channel in the color weight matrix, and sum the product values ​​of all color channels of each pixel to obtain the weighted response value of each pixel. Arrange the weighted response values ​​of all pixels in ascending order and divide them into multiple response intervals. Statistically analyze the distribution of the number of pixels in each response interval and determine the boundary response value between the diseased and healthy areas in the weighted response values. The weighted response value corresponding to the diseased and pest-infested area that is greater than or equal to the boundary response value is adjusted to a preset first numerical range, and the weighted response value corresponding to the healthy area that is less than the boundary response value is adjusted to a preset second numerical range, wherein the first numerical range is greater than the second numerical range. The weighted response values ​​of each pixel are rearranged according to their spatial location to generate a color transformation map that matches the spatial resolution of the target leaf image.

4. The method according to claim 1, characterized in that, The process involves calculating the gradient intensity of each pixel along multiple directions in the color transformation image to obtain the edge response intensity, and then matching the boundary morphology features of the edge positions determined based on the edge response intensity in the color transformation image with the edge morphology template to obtain a matching score, including: Calculate the gradient intensity of each pixel in the color transformation image in multiple preset directions, and add the gradient intensities in each direction to obtain the edge response intensity of each pixel. The multiple directions include 0 degrees, 45 degrees, 90 degrees and 135 degrees. The curvature value, gradient magnitude, and pixel width of the transition zone between the lesion area and the healthy area of ​​the edge curve within the neighborhood window centered on each pixel whose edge response intensity is greater than the preset response threshold are statistically analyzed to obtain the boundary morphology features of the edge position. The edge position is the set of all pixels whose edge response intensity is greater than the preset response threshold. The boundary morphological features are compared with the feature range in the edge morphological template to obtain the matching score between the edge position and the pests and diseases.

5. The method according to claim 1, characterized in that, The process of fusing the evaluation map generated based on the edge response intensity and the matching score with the color transformation map to obtain a multi-dimensional feature map includes: The edge response intensity of each pixel at the edge location is multiplied by the matching score to obtain the evaluation value of each pixel, which represents the confidence level of the corresponding pixel belonging to the edge of the lesion. Pixels whose evaluation value is greater than a preset evaluation threshold are identified as edge pixels, and pixels whose evaluation value is less than or equal to the preset evaluation threshold are identified as non-edge pixels, thus constructing an evaluation map; The evaluation map and the color transformation map are stitched together by channel to obtain a multi-dimensional feature map that includes evaluation values ​​and color response values.

6. The method according to claim 1, characterized in that, The process involves initializing the multidimensional feature map into a set of sub-regions, obtaining a merging cost based on the feature value difference and common boundary length between adjacent sub-regions, merging adjacent sub-regions with the minimum merging cost in the set, and continuing until the matching value between the common boundary of the adjacent sub-regions and the edge morphology template is greater than a preset judgment value, resulting in a merging tree with sub-regions as child nodes. Based on the evaluation value of each pixel in the multidimensional feature map, the multidimensional feature map is divided into sub-regions composed of individual pixels to form a set of sub-regions, and each of the sub-regions is used as a node of the merge tree. Calculate the mean difference in evaluation values, the mean difference in color response values, and the length of the common boundary between adjacent sub-regions in the sub-region set, and perform weighted fusion to obtain the merging cost between adjacent sub-regions; The common boundary of the adjacent sub-regions with the lowest merging cost is compared with the feature range in the edge morphology template to obtain a matching value. When the matching value is less than or equal to a preset judgment value, the adjacent sub-regions with the lowest merging cost are merged into one sub-region. In the merging tree, a parent node with the nodes corresponding to the two adjacent sub-regions before merging as child nodes is generated as the node of the merged sub-region. This updates the sub-region set and the merging tree. The mean difference of evaluation values, the mean difference of color response values, and the length of the common boundary between adjacent sub-regions in the sub-region set are calculated. This process continues until the matching value is greater than the preset judgment value, resulting in the constructed merging tree.

7. The method according to claim 1, characterized in that, Starting from the root node of the merged tree, determining the confidence level of each node based on the mean eigenvalue of the sub-regions corresponding to each node and the color weight matrix, propagating the confidence level to the child nodes corresponding to each node to update the confidence level of the child nodes, and identifying sub-regions with confidence levels greater than a preset threshold as pest and disease areas, includes: The confidence level of each node in the merged tree is determined based on the matching degree between the mean color response value of the sub-region corresponding to each node of the merged tree and the sensitivity weight corresponding to the color weight matrix. Starting from the root node of the merged tree, the confidence of the parent node is propagated to the corresponding lower-level child nodes. The confidence of each child node is updated by weighted summation based on the confidence of each child node and the confidence received from the parent node. The sub-regions corresponding to the child nodes in the merged tree whose confidence level is greater than a preset confidence threshold are identified as pest and disease areas.

8. An artificial intelligence-based system for extracting disease and pest areas from agricultural images, characterized in that, include: The acquisition module is used to acquire the color weight matrix and edge morphology template determined based on leaf images of crops under pest and disease infection. The transformation module is used to perform a weighted transformation on each color channel of the target leaf image based on the color weight matrix to obtain a color transformation map. The matching module is used to obtain the edge response intensity of each pixel by calculating the gradient intensity of each pixel along multiple directions in the color transformation image, and to match the boundary shape features of the edge position determined by the edge response intensity in the color transformation image with the edge shape template to obtain a matching score. The fusion module is used to fuse the evaluation map generated based on the edge response intensity and the matching score with the color transformation map to obtain a multi-dimensional feature map; The merging module is used to initialize the multidimensional feature map into a set of sub-regions, obtain a merging cost based on the feature value difference between adjacent sub-regions and the length of the common boundary, merge the adjacent sub-regions with the smallest merging cost in the set of sub-regions, until the matching value of the common boundary of the adjacent sub-regions with the edge morphology template is greater than a preset judgment value, and obtain a merging tree with sub-regions as child nodes. The determination module is used to start from the root node of the merged tree, determine the confidence level of each node based on the mean feature value of the sub-regions corresponding to each node and the color weight matrix, propagate the confidence level to the child nodes corresponding to each node to update the confidence level of the child nodes, and determine the sub-regions with the confidence level greater than a preset confidence threshold as pest and disease areas.

9. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor for executing the computer program to implement the steps of the method as described in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, can implement the method as described in any one of claims 1 to 7.