An apple disease detection system based on image processing
Through image processing technology, the gradient value and direction in the apple leaf image is calculated, the strong lesion characteristic value is obtained, and the region growing algorithm is used to detect apple leaf diseases, which solves the problem of difficulty in accurate segmentation of disease detection in the existing technology and achieves a more accurate identification of diseased spot areas and timely prevention.
Patent Information
- Application Number
- CN202411082017.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-08
- Publication Date
- 2024-09-27
- Estimated Expiration
- 2044-08-08
Smart Images

Figure CN118608529B
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image processing, and in particular to an apple disease detection system based on image processing. Background Art
[0002] Apple Anthracnose Leaf Blight is a disease caused by anthracnose bacteria that primarily harms the leaves of apple trees and, in severe cases, the fruit. The disease causes a large number of leaves to fall from the apple tree, weakening the tree and reducing yield. In order to prevent the disease in a timely manner, it is necessary to detect and intervene in the early stages. In the early stages, the lesions are small in area and sparsely distributed. Due to interference from environmental factors such as light, leaf veins, and dirt, it is difficult to observe the presence and severity of the lesions in a timely manner. Therefore, it is necessary to detect the disease on apple leaves to prevent missing the best time for intervention.
[0003] In the prior art, a single threshold is used to segment the grayscale image of an apple leaf to obtain a disease spot image, and then disease detection is performed based on the disease spot image.
[0004] Since the lesions are initially light-colored, small yellow-brown or reddish-brown spots with irregular reddish-brown or yellow-brown halos around them, which are similar to the color of the leaves themselves, the grayscale image does not show obvious changes under environmental interference, and a single threshold segmentation process cannot be used. However, since the lesions are concave and have radial growth characteristics relative to the leaves themselves, the regional growing algorithm is used to grow according to the growth characteristics of the lesions themselves, which can achieve better results and more realistic segmentation images.
[0005] Therefore, how to select the growth seed points and growth criteria in the region growing algorithm to obtain more accurate lesion images has become an urgent problem to be solved. Summary of the invention
[0006] In view of this, an embodiment of the present invention provides an apple disease detection system based on image processing to solve the problem of how to select growth seed points and growth criteria in a region growing algorithm to obtain a more accurate disease spot image.
[0007] An embodiment of the present invention provides an apple disease detection system based on image processing, the system comprising:
[0008] A suspected strong disease spot area acquisition module is used to collect an apple leaf image, perform grayscale processing on the apple leaf image to obtain a grayscale image of the apple leaf, and obtain at least one suspected strong disease spot area in the grayscale image;
[0009] A strong lesion area acquisition module, used to respectively calculate the gradient value and gradient direction of each pixel point in each of the suspected strong lesion areas, and respectively acquire the strong lesion area in each of the suspected strong lesion areas according to the gradient value and gradient direction of each pixel point;
[0010] A direction set acquisition module is used for dividing all pixel points in any strong lesion area into N direction sets according to N neighborhood directions preset in the strong lesion area;
[0011] A strong lesion feature value acquisition module is used to obtain a direction set of each of the strong lesion areas, and for any neighborhood direction, determine the strong lesion feature value of the neighborhood direction according to the gradient value and grayscale value of each pixel point in all direction sets in the neighborhood direction;
[0012] The image processing module is used to obtain the strong disease spot characteristic value in each of the neighborhood directions, and perform regional growth on the grayscale image according to the strong disease spot characteristic value in each of the neighborhood directions to obtain apple disease detection results.
[0013] Furthermore, the strong lesion area acquisition module acquires the strong lesion area in each of the suspected strong lesion areas according to the gradient value and gradient direction of each pixel point, including:
[0014] Calculating the gradient value of each pixel in the grayscale image, taking the area in the grayscale image other than the suspected strong lesion area as a lesion-free area, obtaining the gradient value of each pixel in the lesion-free area, and calculating the mean gradient value of the lesion-free area;
[0015] For any suspected strong lesion area, select the pixel points whose gradient value in the suspected strong lesion area is less than the gradient mean of the lesion-free area as the target pixel points, and the area composed of all the target pixel points as the target strong lesion area;
[0016] Extending the gradient direction of each pixel point in the target strong lesion area in the reverse direction to obtain at least one intersection point between all the reverse extension lines, and obtaining the coordinates of each intersection point;
[0017] According to the coordinates of each intersection point, all intersection points are clustered to obtain at least one cluster, the number of intersection points in each cluster is counted, and the strong lesion area is obtained according to the total number of clusters and the number of intersection points in each cluster.
[0018] Furthermore, the strong lesion area acquisition module obtains the strong lesion area according to the total number of clusters and the number of intersections in each cluster, including:
[0019] Normalizing the number of intersections in each of the clusters to obtain a normalized value, calculating the mean of all normalized values, and taking the absolute value of the difference between the mean and a preset mean as a distribution coefficient;
[0020] The pixel point with the smallest gradient value in the target strong lesion area is taken as the actual center point, the cluster with the largest number of intersections in the clusters is selected as the target cluster, and for any target cluster, the cluster center of the target cluster is obtained to obtain the distance between the cluster center and the actual center point;
[0021] The sum of the distribution coefficient and the constant 1 is used as the first variable, the sum of the distance and the constant 1 is used as the second variable, and the reciprocal of the product of the first variable and the second variable is used as the emission coefficient;
[0022] If the emission coefficient is within a preset range, the area consisting of pixel points on the reverse extension line to which the intersection point in the target cluster belongs is marked as a strong disease spot area.
[0023] Furthermore, the direction set acquisition module divides all the pixels in the strong lesion area into N direction sets according to the N neighborhood directions preset in the strong lesion area, including:
[0024] The pixel point with the smallest gradient value in the strong lesion area is selected as the target center point, and a grid of a preset size is established with the target center point as the center. All pixel points in the strong lesion area are classified according to the grid according to the preset N neighborhood directions, and the pixel points located in the same neighborhood direction are taken as a direction set to obtain N direction sets.
[0025] Furthermore, the strong lesion feature value acquisition module determines the strong lesion feature value of the neighborhood direction according to the gradient value and grayscale value of each pixel point in the set of all directions in the neighborhood direction, including:
[0026] For any strong lesion area, select the pixel point with the smallest gradient value in the strong lesion area as the target center point, calculate the gradient direction angle between each pixel point in the direction set of the strong lesion area in the neighborhood direction and the target center point, form a gradient direction angle set, and obtain the angle interval according to the gradient direction angle set;
[0027] Obtaining the angle intervals corresponding to all the strong lesion areas in the neighborhood direction, selecting at least three angle intervals from all the angle intervals to obtain at least one angle interval intersection, using the number of angle intervals involved in each of the angle interval intersections as a weight coefficient for each of the angle interval intersections, selecting the angle interval intersections whose weight coefficients are greater than a preset value for merging, and obtaining an initial angle interval;
[0028] The target center point is placed in the direction set corresponding to each of the strong lesion areas in the neighborhood direction, and the maximum grayscale value and the minimum grayscale value in each of the direction sets are obtained, and the mean of all the maximum grayscale values is calculated as the maximum mean, and the mean of all the minimum grayscale values is calculated as the minimum mean, and the difference between the maximum mean and the minimum mean is used as the initial threshold difference;
[0029] The grayscale image is divided into obvious illumination areas and no obvious illumination areas according to grayscale levels, and the initial angle interval and the initial threshold difference are increased or decreased according to the grayscale values of the obvious illumination areas and the no obvious illumination areas to obtain the strong lesion feature value in the neighborhood direction.
[0030] Furthermore, the strong lesion feature value acquisition module divides the grayscale image into obvious illumination areas and no obvious illumination areas according to the grayscale level, including:
[0031] Constructing a grayscale histogram of the grayscale image, dividing the grayscale into a plurality of grayscale intervals in the grayscale histogram, and for any grayscale interval, accumulating the frequency corresponding to each grayscale included in the grayscale interval to obtain the frequency sum of the grayscale interval;
[0032] Adding the frequency sums of all gray level intervals to obtain a total frequency sum, and taking the ratio between the frequency sum of each gray level interval and the total frequency sum as the interval frequency;
[0033] Selecting the grayscale interval corresponding to the maximum interval frequency in the interval frequencies as the target interval, and for any grayscale interval in the grayscale histogram except the grayscale interval corresponding to the maximum interval frequency, calculating the difference between the interval frequency of the grayscale interval corresponding to the maximum interval frequency and the interval frequency of the grayscale interval, if the difference is less than a preset difference, taking the grayscale interval as the target interval, and taking the area composed of all the pixels contained in the target interval as the area without obvious illumination;
[0034] A grayscale interval corresponding to the maximum grayscale level is selected from all target intervals as a threshold interval, and grayscale intervals greater than the threshold interval in all grayscale intervals are selected as reference intervals. For any two adjacent reference intervals, if the difference between the interval frequencies of the two adjacent reference intervals is less than a preset difference, the two adjacent reference intervals are selected as final intervals, and the area composed of pixels contained in all final intervals is selected as an obvious illumination area.
[0035] Furthermore, the strong lesion feature value acquisition module increases or decreases the initial angle interval and the initial threshold difference according to the grayscale values of the obvious illumination area and the area without obvious illumination to obtain the strong lesion feature value in the neighborhood direction, including:
[0036] Calculating the mean of the grayscale values of all pixels in the obvious illumination area as a first grayscale mean, calculating the mean of the grayscale values of all pixels in the area without obvious illumination as a second grayscale mean, and adding the difference between the first grayscale mean and the second grayscale mean to the initial threshold difference to obtain a final threshold difference;
[0037] Calculate the mean of the gradient direction angles of all the pixels in the obvious illumination area as the first angle mean, calculate the mean of the gradient direction angles of all the pixels in the area without obvious illumination as the second angle mean, take the difference between the first angle mean and the second angle mean as the target angle difference, subtract the target angle difference from the minimum value in the initial angle interval as the minimum angle, add the target angle difference to the maximum angle in the initial angle interval, and form a final angle interval with the minimum angle and the maximum angle;
[0038] The final threshold difference and the final angle interval are used as the strong lesion feature value in the neighborhood direction.
[0039] Furthermore, the image processing module performs region growing on the grayscale image according to the strong disease spot feature value in each of the neighborhood directions to obtain an apple disease detection result, including:
[0040] In the obvious illumination area, a pixel point with the smallest gradient value is taken as an initial seed point, and growth is performed according to the preset N neighborhood directions. For any neighborhood direction of the initial seed point, a pixel point adjacent to the initial seed point in the neighborhood direction is taken as a growth point, and a pixel point adjacent to the growth point in the neighborhood direction is taken as a point to be grown. If the difference between the gray value of the growing point and the gray value of the point to be grown is less than or equal to the final threshold difference of the neighborhood direction, and the gradient direction angle of the growing point is within the final angle interval of the neighborhood direction, the growing point and the initial seed point are marked as diseased spots;
[0041] Obtain diseased spots in each neighborhood direction of the initial seed point, extend the gradient directions of all pixels in all diseased spots except the pixel with the smallest gradient value in the diseased spots in the reverse direction, obtain the intersection points of all the reverse extension lines, calculate the emission coefficient according to the intersection points of all the reverse extension lines and the pixel with the smallest gradient value in all diseased spots, and if the emission coefficient is within the preset range, continue to grow the growth point as a new seed point to obtain all diseased spots in the obvious illumination area;
[0042] All disease spots in the obvious light-irradiated area and the area without obvious light-irradiated area are taken as the apple disease detection results.
[0043] Furthermore, the suspected strong lesion area acquisition module performs grayscale processing on the apple leaf image to obtain a grayscale image of the apple leaf, and obtains at least one suspected strong lesion area in the grayscale image, including:
[0044] Threshold segmentation and opening and closing operations are performed on the grayscale image to obtain a suspected strong lesion grayscale image, and the suspected strong lesion grayscale image is masked to obtain at least one suspected strong lesion area.
[0045] Compared with the prior art, the embodiments of the present invention have the following beneficial effects:
[0046] The present invention provides an apple disease detection system based on image processing, comprising a suspected strong disease spot area acquisition module, which is used to collect apple leaf images, grayscale the apple leaf images to obtain a grayscale image of the apple leaf, and obtain at least one suspected strong disease spot area in the grayscale image; a strong disease spot area acquisition module, which is used to respectively calculate the gradient value and gradient direction of each pixel point in each of the suspected strong disease spot areas, and respectively obtain the strong disease spot area in each of the suspected strong disease spot areas according to the gradient value and gradient direction of each pixel point; a direction set acquisition module, which is used to obtain the strong disease spot area for any strong disease spot area. Disease spot area, according to the N neighborhood directions preset in the strong disease spot area, all the pixel points in the strong disease spot area are divided into N direction sets; a strong disease spot feature value acquisition module is used to obtain the direction set of each of the strong disease spot areas, for any neighborhood direction, according to the gradient value and grayscale value of each pixel point in all direction sets in the neighborhood direction, determine the strong disease spot feature value of the neighborhood direction; an image processing module is used to obtain the strong disease spot feature value of each of the neighborhood directions, according to the strong disease spot feature value of each of the neighborhood directions, perform regional growth on the grayscale image to obtain the apple disease detection result. Among them, according to the concave characteristics and emissive characteristics of the lesions, the strong lesion area that meets the lesion characteristic law is found in the direction of the 8-neighborhood, and then the strong lesion area is grouped in the direction of the 8-neighborhood to obtain the strong lesion characteristic value in each neighborhood direction, which is used as the growth condition for the subsequent regional growth of the grayscale image. Then, the grayscale image is traversed, and the pixel point with the smallest gradient value in the grayscale image is used as the seed point. The surrounding pixels are traversed in the direction of the 8-neighborhood, and the strong lesion characteristic value is used as the growth condition. A more accurate lesion image is obtained through the regional growing algorithm, and the apple disease detection result is obtained, which is convenient for people to carry out apple disease prevention and treatment in time. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0048] Figure 1 is a structural block diagram of an apple disease detection system based on image processing provided by the first embodiment of the present invention;
[0049] Figure 2 It is a schematic diagram of dividing a strong lesion area into 8 direction sets according to 8 neighborhood directions provided in the first embodiment of the present invention. DETAILED DESCRIPTION
[0050] Embodiments of the present disclosure are described in detail below, and examples of the embodiments are shown in the accompanying drawings. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to be used to explain the present disclosure, but should not be understood as limiting the present disclosure.
[0051] It should be noted that the terms "first", "second", etc. in the specification of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure.
[0052] In order to illustrate the technical solution of the present invention, specific embodiments are provided below for illustration.
[0053] See also Figure 1 , is a structural block diagram of an apple disease detection system based on image processing provided by the first embodiment of the present invention, such as Figure 1 As shown, the system may include:
[0054] The suspected strong disease spot area acquisition module 11 is used to collect apple leaf images, grayscale the apple leaf images to obtain grayscale images of the apple leaves, and obtain at least one suspected strong disease spot area in the grayscale image.
[0055] First, an apple leaf image is captured by a camera device, and the apple leaf image is grayscaled to obtain a grayscale image of the apple leaf. Then, the grayscale image is threshold segmented and opened and closed to obtain a grayscale image of suspected strong lesions. The suspected strong lesion grayscale image is masked to obtain at least one suspected strong lesion area, wherein grayscale processing, threshold segmentation, opening and closing operations, and masking are existing technologies and will not be described in detail here.
[0056] The strong lesion area acquisition module 12 is used to respectively calculate the gradient value and gradient direction of each pixel point in each of the suspected strong lesion areas, and respectively acquire the strong lesion area in each of the suspected strong lesion areas according to the gradient value and gradient direction of each pixel point.
[0057] Since the lesion is concave, the concave area is often the point with the smallest gradient value in the grayscale image. Therefore, the gradient value at the lesion should be smaller than the gradient value of most areas in the grayscale image, that is, the gradient value of the non-lesion area. At the same time, the lesion has the characteristic of radioactivity. Therefore, the reverse extension line of the gradient direction of each pixel in the lesion area converges at the center point. However, due to the interference of environmental factors, the reverse extension line of the gradient direction of each pixel may not converge accurately at the center point, but the overall extension line is near the center point. Therefore, the intersection points obtained by the convergence of the reverse extension lines of the gradient direction of each pixel are clustered, and the strong lesion area is obtained according to the number of clusters.
[0058] In the example of the present invention, the gradient of each pixel in the grayscale image is first calculated by the Sobel operator to obtain the gradient value and gradient direction of each pixel in the grayscale image, wherein the Sobel operator is a prior art and will not be described here in detail, and then the strong lesion area in each suspected strong lesion area is obtained according to the gradient value and gradient direction of each pixel, so as to ensure that the gradient value of the pixel in the strong lesion area conforms to the lesion gradient change law.
[0059] According to the gradient value and gradient direction of each pixel point, the strong lesion area in each suspected strong lesion area is obtained respectively, including:
[0060] Calculating the gradient value of each pixel in the grayscale image, taking the area in the grayscale image other than the suspected strong lesion area as a lesion-free area, obtaining the gradient value of each pixel in the lesion-free area, and calculating the mean gradient value of the lesion-free area;
[0061] For any suspected strong lesion area, select the pixel points whose gradient value in the suspected strong lesion area is less than the gradient mean of the lesion-free area as the target pixel points, and the area composed of all the target pixel points as the target strong lesion area;
[0062] Extending the gradient direction of each pixel point in the target strong lesion area in the reverse direction to obtain at least one intersection point between all the reverse extension lines, and obtaining the coordinates of each intersection point;
[0063] According to the coordinates of each intersection point, all intersection points are clustered to obtain at least one cluster, the number of intersection points in each cluster is counted, and the strong lesion area is obtained according to the total number of clusters and the number of intersection points in each cluster.
[0064] In one embodiment, the area in the grayscale image except the suspected strong lesion spot area is taken as the lesion spot-free area, and the gradient value average of the lesion spot-free area is obtained according to the gradient value of each pixel point in the lesion spot-free area. For any suspected strong lesion spot area, the pixel point whose gradient value in the suspected strong lesion spot area is less than the gradient value average of the lesion spot area is taken as the target pixel point, and the area composed of all the target pixels is taken as the target strong lesion spot area. Similarly, the target strong lesion spot area in all the suspected strong lesion spot areas is obtained.
[0065] For any target strong lesion area, taking pixel points D and pixel point E in the target strong lesion area as examples, according to the gradient directions of these two pixel points, the reverse extension lines of the gradient direction are respectively made, and then the straight line equations of each reverse extension line are respectively obtained, where the straight line equation of the reverse extension line of pixel point D is:
[0066]
[0067] in, represents the dependent variable of the equation of the line through pixel D, It represents the gradient value of the pixel point on the y-axis that is in the same gradient direction as pixel point D and is adjacent to pixel point D on the left. It represents the gradient value of the pixel point on the y-axis that is in the same gradient direction as pixel point D and is right adjacent to pixel point D. It represents the gradient value of the pixel point on the x-axis that is in the same gradient direction as pixel point D and adjacent to pixel point D on the left. represents the gradient value of the pixel point on the x-axis that is in the same gradient direction as pixel point D and is right adjacent to pixel point D. x represents the independent variable. represents the horizontal coordinate of pixel D, Represents the vertical coordinate of pixel point D.
[0068] Similarly, the straight line equation of the reverse extension line of pixel point E is obtained, and then according to the straight line equation of pixel point D and the straight line equation of pixel point E, the coordinates of the intersection point between the two reverse extension lines can be obtained.
[0069] Similarly, by extending the gradient direction of all pixels in the target strong lesion area in the reverse direction, the coordinates of multiple intersections between all reverse extension lines are obtained. After obtaining the coordinates of all intersections, all intersections are clustered using the DBSCAN algorithm to obtain multiple clusters, and then the strong lesion area in the suspected strong lesion area is obtained according to the total number of clusters and the number of intersections in each cluster. Among them, the DBSCAN algorithm belongs to the prior art and will not be repeated here.
[0070] The strong lesion area is obtained according to the total number of clusters and the number of intersections in each cluster, including:
[0071] (1) Normalizing the number of intersections in each of the clusters to obtain a normalized value, calculating the mean of all normalized values, and taking the absolute value of the difference between the mean and a preset mean as a distribution coefficient.
[0072] In one embodiment, the number of intersections in each cluster is normalized using the norm function to obtain a corresponding normalized value, and the distribution coefficient of the total number of clusters and the number of intersections in the clusters is obtained according to the average of all normalized values. The calculation formula of the distribution coefficient is:
[0073]
[0074] in, The distribution coefficient representing the total number of clusters and the number of intersections in the clusters, represents the mean of the normalized values of the number of intersections in all clusters, represents the absolute value symbol, Indicates the preset mean.
[0075] It should be noted that Indicates how close the total number of clusters and the number of intersections in the clusters are to the normal distribution. The smaller it is, the closer the total number of clusters and the number of intersections in the clusters are to the normal distribution, because the mean of the normal distribution image is closer to Therefore, the smaller the mean difference is, the more it conforms to the normal distribution, which means that the total number of clusters is smaller.
[0076] (2) The pixel point with the smallest gradient value in the target strong lesion area is taken as the actual center point, and the cluster with the largest number of intersections in the cluster is selected as the target cluster. For any target cluster, the cluster center of the target cluster is obtained, and the distance between the cluster center and the actual center point is obtained.
[0077] In one embodiment, because the lesions are emissive, most of the intersections appear around the center point and should be in the same cluster with a large number of intersections in the cluster. Therefore, the number of intersections in each cluster is counted, and the cluster with the largest number of intersections in the cluster is taken as the target cluster. For any target cluster, the cluster center of the target cluster is obtained, and the pixel point with the smallest gradient value in the target strong lesion area is taken as the actual center point. The distance between the cluster center and the actual center point is obtained according to the coordinates of the actual center point and the cluster center of the target cluster. The distance formula is:
[0078]
[0079] Among them, S represents the distance between the cluster center of the target cluster and the actual center point, represents the abscissa of the cluster center, Represents the horizontal coordinate of the actual center point, represents the ordinate of the cluster center, Indicates the ordinate of the actual center point.
[0080] It should be noted that the smaller S is, the closer the intersection point is to the actual center point.
[0081] (3) The sum of the distribution coefficient and the constant 1 is used as the first variable, the sum of the distance and the constant 1 is used as the second variable, and the reciprocal of the product of the first variable and the second variable is used as the emission coefficient.
[0082] In one embodiment, after obtaining the distribution coefficient of the total number of clusters and the number of intersections in the clusters and the distance between the cluster center of each target cluster and the actual center point, the emission coefficient of the area corresponding to each target cluster is obtained by combining these two indicators to characterize the emission characteristics of strong lesions in the area. The formula for the emission coefficient is:
[0083]
[0084] in, represents the emission coefficient of the target cluster, It represents the distribution coefficient of the total number of clusters and the number of intersections in the clusters, S represents the distance between the cluster center and the actual center point, and 1 represents a constant.
[0085] It should be noted that since the denominator cannot be 0, and S increase the invariant 1. If and S are close to 0, then the emission coefficient The closer it is to 1, the more the area composed of pixels on the reverse extension line of the intersection point in the target cluster conforms to the emissivity law of the lesion, and the greater the probability that the target cluster is a strong lesion area.
[0086] (4) If the emission coefficient is within a preset range, the area consisting of pixel points on the reverse extension line to which the intersection point in the target cluster belongs is marked as a strong lesion area.
[0087] In one implementation, the preset range is set to [0.8, 1], which is not limited here. The implementer can set it according to the implementation scenario. If the calculated If the value is between [0.8, 1], it means that the total number and distance of clusters are small. Therefore, the area composed of pixels belonging to the target strong lesion area on the reverse extension line of the intersection point in the target cluster is marked as the strong lesion area. If it is not between [0.8, 1], the area consisting of the pixels belonging to the target strong lesion area on the reverse extension line of the intersection point in the target cluster is marked as the non-strong lesion area.
[0088] According to the above-mentioned method for obtaining the strong lesion area, the strong lesion area in each suspected strong lesion area is obtained.
[0089] The direction set acquisition module 13 is used for dividing all the pixel points in any strong lesion spot area into N direction sets according to N neighborhood directions preset in the strong lesion spot area.
[0090] Since the disease spots have many divergence angles, for any strong disease spot area, the strong disease spot area is divided into multiple direction sets according to a preset number of neighborhood directions, and all strong disease spot areas are divided into multiple direction sets according to the same neighborhood direction. For any neighborhood direction, the strong disease spot feature value of the neighborhood direction is obtained according to the gradient value and grayscale value of the pixel points in the direction set of the neighborhood direction of all strong disease spot areas, and the strong disease spot feature value is used as the growth condition of the region growing algorithm, thereby finding all disease spot areas.
[0091] For any strong lesion area, the strong lesion area is divided into multiple direction sets according to a preset number of neighborhood directions, including:
[0092] The pixel point with the smallest gradient value in the strong lesion area is selected as the target center point, and a grid of a preset size is established with the target center point as the center. All pixel points in the strong lesion area are classified according to the grid according to the preset N neighborhood directions, and the pixel points located in the same neighborhood direction are taken as a direction set to obtain N direction sets.
[0093] In one embodiment, the gradient of the pixel points in the strong lesion area is calculated by the Sobel operator, and the pixel point with the smallest gradient value in the strong lesion area is selected as the target center point. The grid is used to determine the neighborhood direction. There are 8 neighborhood directions located above, below, left, right, upper left, upper right, lower left, and lower right of the target center point in the grid, that is, N=8. Taking the 8 neighborhood directions as reference, the pixels in the strong lesion area located in the same neighborhood direction are recorded as a direction set, corresponding to 8 direction sets. Figure 2 , which is a schematic diagram of dividing the strong lesion area into 8 direction sets according to the 8-neighborhood directions. Figure 2In , the point with a gradient value of 6 is the point with the smallest gradient value. The point with the smallest gradient value is taken as the target center point. The pixel points located in the upper left direction of the target center point form a set, recorded as set I, the pixel points located in the upper direction of the target center point form a set, recorded as set II, the pixel points located in the upper right direction of the target center point form a set, recorded as set III, the pixel points located in the right direction of the target center point form a set, recorded as set IV, the pixel points located in the lower right direction of the target center point form a set, recorded as set V, the pixel points located in the lower direction of the target center point form a set, recorded as set VI, the pixel points located in the lower left direction of the target center point form a set, recorded as set VII, and the pixel points located in the left direction of the target center point form a set, recorded as set VIII. Similarly, the direction set of each strong lesion area is obtained.
[0094] The strong spot feature value acquisition module 14 is used to obtain the direction set of each strong spot area, and for any neighborhood direction, determine the strong spot feature value of the neighborhood direction according to the gradient value and grayscale value of each pixel point in all direction sets in the neighborhood direction.
[0095] According to the direction set acquisition module 13, the direction set of each strong lesion area can be obtained. Since there are multiple direction sets in each neighborhood direction, the strong lesion feature value of the strong lesion area can be obtained according to the gradient value and grayscale value of each pixel point in all direction sets of each neighborhood direction. The strong lesion feature value is used as the growth condition of the lesion in the regional growing algorithm.
[0096] Due to the influence of the environment such as lighting, it is necessary to adaptively change the strong lesion feature value to make the detection result more accurate. Therefore, in the embodiment of the present invention, for any neighborhood direction, the strong lesion feature value of the neighborhood direction is determined according to the gradient value and grayscale value of each pixel point in the set of all directions in the neighborhood direction, wherein the strong lesion feature value of the neighborhood direction is determined according to the gradient value and grayscale value of each pixel point in the set of all directions in the neighborhood direction, including:
[0097] (1) For any strong lesion area, select the pixel point with the smallest gradient value in the strong lesion area as the target center point, calculate the gradient direction angle between each pixel point in the direction set of the strong lesion area in the neighborhood direction and the target center point, form a gradient direction angle set, and obtain the angle interval according to the gradient direction angle set.
[0098] In one embodiment, the pixel point with the smallest gradient value in the strong lesion area is selected as the target center point, and any neighborhood direction is selected with the target center point as the center. Assume that the direction set of the neighborhood direction is Figure 2In the set VI, the gradient direction angle between each pixel in the set VI and the target center point is calculated. Taking the i-th pixel in the set VI as an example, the formula for obtaining the gradient direction angle between the i-th pixel and the target center point is:
[0099]
[0100] in, is the gradient direction angle between the i-th pixel and the target center point, is the inverse tangent function, is the gradient value of the i-th pixel in the x direction, is the gradient value of the i-th pixel in the y direction.
[0101] It can be obtained that the gradient direction angle set of all pixel points in the set VI of the strong lesion area is {77, 78, 80}, and then the angle interval is [77, 80].
[0102] (2) Obtaining the angle intervals corresponding to all the strong lesion areas in the neighborhood direction, selecting at least three angle intervals from all the angle intervals to obtain at least one angle interval intersection, using the number of angle intervals involved in each angle interval intersection as the weight coefficient of each angle interval intersection, selecting the angle interval intersections whose weight coefficients are greater than a preset value for merging, and obtaining an initial angle interval.
[0103] In one embodiment, the angle intervals corresponding to all strong lesion areas in the neighborhood direction are calculated, all angle intervals are counted, at least three angle intervals are selected from all angle intervals to obtain at least one angle interval intersection, and the number of angle intervals involved in each angle interval intersection is used as the weight coefficient of each angle interval intersection. For example, the angle intervals [70, 75] and [71, 80], the intersection of these two angle intervals is [71, 75], and the number of angle intervals involved in the intersection is 2, then the weight coefficient of the intersection of the angle intervals [71, 75] is 2, and then after obtaining the weight coefficient of each angle interval intersection, the preset value is set to 2, which is not limited here. The implementer can select the angle interval intersection with a weight coefficient greater than 2 for merging according to the implementation scenario setting, and the angle interval obtained after merging is used as the initial angle interval of the neighborhood direction, recorded as [ ],in Indicates the minimum value of the initial angle interval, Indicates the maximum value of the initial angle interval.
[0104] (3) The target center point is placed in the direction set corresponding to each of the strong lesion areas in the neighborhood direction, and the maximum grayscale value and the minimum grayscale value in each of the direction sets are obtained respectively. The mean of all the maximum grayscale values is calculated as the maximum mean, and the mean of all the minimum grayscale values is calculated as the minimum mean. The difference between the maximum mean and the minimum mean is used as the initial threshold difference.
[0105] In one embodiment, the target center point is placed in the direction set corresponding to each strong lesion area in the neighborhood direction, and then in each direction set where the target center point is placed, the maximum grayscale value and the minimum grayscale value in each direction set are obtained, and the difference between the mean of all maximum grayscale values and the mean of all minimum grayscale values is calculated as the initial threshold difference. The formula for the initial threshold difference is:
[0106]
[0107] Among them, t represents the initial threshold difference, MAX represents the mean of the maximum grayscale values, and MIN represents the mean of the minimum grayscale values.
[0108] Similarly, the initial angle interval and initial threshold difference of each neighborhood direction are obtained.
[0109] (4) Dividing the grayscale image into an obvious illumination area and an area without obvious illumination according to the grayscale level, increasing or decreasing the initial angle interval and the initial threshold difference according to the grayscale values of the obvious illumination area and the area without obvious illumination, and obtaining a strong lesion feature value in the neighborhood direction.
[0110] The grayscale image is divided into an obvious illumination area and an area without obvious illumination according to the grayscale level, including:
[0111] Constructing a grayscale histogram of the grayscale image, dividing the grayscale into a plurality of grayscale intervals in the grayscale histogram, and for any grayscale interval, accumulating the frequency corresponding to each grayscale included in the grayscale interval to obtain the frequency sum of the grayscale interval;
[0112] Adding the frequency sums of all gray level intervals to obtain a total frequency sum, and taking the ratio between the frequency sum of each gray level interval and the total frequency sum as the interval frequency;
[0113] Selecting the grayscale interval corresponding to the maximum interval frequency in the interval frequencies as the target interval, and for any grayscale interval in the grayscale histogram except the grayscale interval corresponding to the maximum interval frequency, calculating the difference between the interval frequency of the grayscale interval corresponding to the maximum interval frequency and the interval frequency of the grayscale interval, if the difference is less than a preset difference, taking the grayscale interval as the target interval, and taking the area composed of all the pixels contained in the target interval as the area without obvious illumination;
[0114] A grayscale interval corresponding to the maximum grayscale level is selected from all target intervals as a threshold interval, and grayscale intervals greater than the threshold interval in all grayscale intervals are selected as reference intervals. For any two adjacent reference intervals, if the difference between the interval frequencies of the two adjacent reference intervals is less than a preset difference, the two adjacent reference intervals are selected as final intervals, and the area composed of pixels contained in all final intervals is selected as an obvious illumination area.
[0115] In one implementation, a grayscale histogram is constructed based on the grayscale image, where the x-axis represents the grayscale level and the y-axis represents the frequency of occurrence of the grayscale level. The construction of the grayscale histogram belongs to the prior art and will not be described in detail herein.
[0116] Since illumination has some influence on the grayscale value of grayscale images, in the grayscale histogram, the peaks of the obviously illuminated areas will be concentrated at higher grayscale levels. The grayscale histogram of the high-brightness area usually has an obvious dynamic range, that is, the transition area from black to white is relatively smooth and has a larger distribution in grayscale, rather than being concentrated in a certain grayscale range. Therefore, the area with an obvious peak in the grayscale histogram is an area without obvious illumination, and the area with multiple no obvious peaks is an area with obvious illumination.
[0117] Therefore, in the grayscale histogram, the grayscale is divided into 8 grayscale intervals, and the range of each grayscale interval is: Level1: 0-31, Level2: 32-63, Level3: 64-95, Level4: 96-127, Level5: 128-159, Level6: 160-191, Level7: 192-223, Level8: 224-255. There is no restriction here, and the implementer can set it according to the implementation scenario. Calculate the frequency of all grayscale levels contained in each grayscale interval and add them up to get the frequency sum of each grayscale interval. Add the frequency sums of all grayscale intervals to get the total frequency sum. The ratio between the frequency sum of each grayscale interval and the total frequency sum is taken as the interval frequency. The interval frequency formula is:
[0118]
[0119] in, is the interval frequency of the nth gray level interval, represents the frequency sum of the nth gray level interval, represents the frequency sum of the first gray level interval, represents the frequency sum of the second gray level interval, represents the frequency sum of the third gray level interval, Represents the frequency sum of the 8th gray level interval.
[0120] Since the interval frequency of the grayscale interval where the obvious peak is located should be greater than the interval frequencies of other grayscale intervals, the pixel points in the grayscale interval with the largest interval frequency are found as the obvious illumination area, and the grayscale interval with the largest interval frequency is taken as the target interval. Any grayscale interval in the grayscale histogram except the grayscale interval corresponding to the largest interval frequency is taken as the candidate interval. The difference between the interval frequency of the grayscale interval corresponding to the largest interval frequency and the interval frequency of the candidate interval is calculated. The preset difference is set to 0.1. There is no restriction here. The implementer can set it according to the implementation scenario. If the difference is less than 0.1, the candidate interval is taken as the target interval. Similarly, each candidate interval is compared with the grayscale interval in the grayscale histogram except the grayscale interval corresponding to the largest interval frequency to obtain all target intervals, so that the area composed of pixels contained in all target intervals is taken as the area without obvious illumination.
[0121] The grayscale interval corresponding to the maximum grayscale level is selected from all target intervals as the threshold interval, and the grayscale intervals greater than the threshold interval in all grayscale intervals are taken as reference intervals. For any two adjacent reference intervals, if the difference between the interval frequencies of the two adjacent reference intervals is less than 0.1, the two adjacent reference intervals are taken as the final intervals, and all final intervals are obtained, and the area composed of pixels contained in all final intervals is taken as the obvious illumination area.
[0122] Among them, the initial angle interval and the initial threshold difference are increased or decreased according to the grayscale values of the obvious illumination area and the area without obvious illumination to obtain the strong lesion feature value in the neighborhood direction, including:
[0123] Calculating the mean of the grayscale values of all pixels in the obvious illumination area as a first grayscale mean, calculating the mean of the grayscale values of all pixels in the area without obvious illumination as a second grayscale mean, and adding the difference between the first grayscale mean and the second grayscale mean to the initial threshold difference to obtain a final threshold difference;
[0124] Calculate the mean of the gradient direction angles of all the pixels in the obvious illumination area as the first angle mean, calculate the mean of the gradient direction angles of all the pixels in the area without obvious illumination as the second angle mean, take the difference between the first angle mean and the second angle mean as the target angle difference, subtract the target angle difference from the minimum value in the initial angle interval as the minimum angle, add the target angle difference to the maximum angle in the initial angle interval, and form a final angle interval with the minimum angle and the maximum angle;
[0125] The final threshold difference and the final angle interval are used as the strong lesion feature value in the neighborhood direction.
[0126] In one implementation process, the difference between the mean grayscale value of all pixels in the area without obvious illumination and the mean grayscale value of all pixels in the area with obvious illumination is calculated, which is denoted as ɑ. Since the grayscale value of the pixels in the area with obvious illumination is significantly larger than the grayscale value of the pixels in the area without obvious illumination, ɑ is needed to increase the initial threshold difference in each neighborhood direction, that is, the final threshold difference T is t+ɑ.
[0127] Since illumination can cause the gradient direction angle of pixels to change, it may become larger or smaller. Therefore, the difference between the mean of the gradient direction angle of all pixels in the obvious illumination area and the mean of the gradient direction angle of all pixels in the no obvious illumination area is calculated, denoted as β. The maximum and minimum values of the initial angle interval of each neighborhood direction are increased or decreased by β, that is, the final angle interval is [ ].
[0128] The final threshold difference T and the final angle interval obtained in all neighborhood directions are used as the strong spot feature value.
[0129] The image processing module 15 is used to obtain the strong disease spot characteristic value in each of the neighborhood directions, and perform region growing on the grayscale image according to the strong disease spot characteristic value in each of the neighborhood directions to obtain apple disease detection results.
[0130] Since all pixels in the area without obvious illumination are strong disease spots, it is only necessary to obtain the strong disease spot feature value in each neighborhood direction, and then perform region growth on the obvious illumination area in the grayscale image according to the strong disease spot feature value in each neighborhood direction to find the disease spots in the obvious illumination area, and then use all the disease spots in the area without obvious illumination and the area with obvious illumination as the result of disease detection on apple leaves, so as to prevent and treat apple diseases in time. The specific process of disease detection on apple leaves is as follows:
[0131] In the obvious illumination area, a pixel point with the smallest gradient value is taken as an initial seed point, and growth is performed according to the preset N neighborhood directions. For any neighborhood direction of the initial seed point, a pixel point adjacent to the initial seed point in the neighborhood direction is taken as a growth point, and a pixel point adjacent to the growth point in the neighborhood direction is taken as a point to be grown. If the difference between the gray value of the growing point and the gray value of the point to be grown is less than or equal to the final threshold difference of the neighborhood direction, and the gradient direction angle of the growing point is within the final angle interval of the neighborhood direction, the growing point and the initial seed point are marked as diseased spots;
[0132] Obtain diseased spots in each neighborhood direction of the initial seed point, extend the gradient directions of all pixels in all diseased spots except the pixel with the smallest gradient value in the diseased spots in the reverse direction, obtain the intersection points of all the reverse extension lines, calculate the emission coefficient according to the intersection points of all the reverse extension lines and the pixel with the smallest gradient value in all diseased spots, and if the emission coefficient is within the preset range, continue to grow the growth point as a new seed point to obtain all diseased spots in the obvious illumination area;
[0133] All disease spots in the obvious light-irradiated area and the area without obvious light-irradiated area are taken as the apple disease detection results.
[0134] It should be noted that the termination condition of the region growth is: when one of the gray value and the gradient direction angle of the growth point does not meet the growth condition, the growth judgment is no longer performed on the surrounding pixels, and the growth point and its surrounding pixels are suppressed; or, if the gray value and the gradient direction angle of the growth point meet the growth condition, after the growth in the eight neighborhood directions is completed, the emission coefficient in the above-mentioned strong lesion area acquisition module 12 is analyzed according to the lesion obtained by the growth, and if the obtained emission coefficient does not meet the emission coefficient requirement (i.e. If the value is not between [0.8, 1], the growth stops and the seed point and surrounding pixels are suppressed.
[0135] The region growing algorithm belongs to the prior art. The focus of the embodiments of the present invention is on adaptively obtaining the growth conditions in the region growing algorithm. The process of performing region growing on the obvious illumination area using the strong lesion feature values in each neighborhood direction belongs to the prior art and will not be described in detail here.
[0136] In summary, the present invention provides an apple disease detection system based on image processing, including a suspected strong disease spot area acquisition module, which is used to collect apple leaf images, grayscale the apple leaf images to obtain a grayscale image of the apple leaf, and obtain at least one suspected strong disease spot area in the grayscale image; a strong disease spot area acquisition module, which is used to respectively calculate the gradient value and gradient direction of each pixel point in each of the suspected strong disease spot areas, and obtain the strong disease spot area in each of the suspected strong disease spot areas according to the gradient value and gradient direction of each pixel point; a direction set acquisition module, which is used to obtain the strong disease spot area in each of the suspected strong disease spot areas for any A strong disease spot area, according to the N neighborhood directions preset in the strong disease spot area, all the pixels in the strong disease spot area are divided into N direction sets; a strong disease spot feature value acquisition module is used to obtain the direction set of each of the strong disease spot areas, for any neighborhood direction, according to the gradient value and grayscale value of each pixel point in all direction sets in the neighborhood direction, determine the strong disease spot feature value of the neighborhood direction; an image processing module is used to obtain the strong disease spot feature value of each of the neighborhood directions, according to the strong disease spot feature value of each of the neighborhood directions, perform regional growth on the grayscale image, and obtain the apple disease detection result. Among them, according to the concave characteristics and emissive characteristics of the lesions, the strong lesion area that meets the lesion characteristic law is found in the direction of the 8-neighborhood, and then the strong lesion area is grouped in the direction of the 8-neighborhood to obtain the strong lesion characteristic value in each neighborhood direction, which is used as the growth condition for the subsequent regional growth of the grayscale image. Then, the grayscale image is traversed, and the pixel point with the smallest gradient value in the grayscale image is used as the seed point. The surrounding pixels are traversed in the direction of the 8-neighborhood, and the strong lesion characteristic value is used as the growth condition. A more accurate lesion image is obtained through the regional growing algorithm, and the apple disease detection result is obtained, which is convenient for people to carry out apple disease prevention and treatment in time.
[0137] The above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention, and should be included in the protection scope of the present invention.
Claims
1. An apple disease detection system based on image processing, characterized in that: The apple disease detection system based on image processing comprises: A suspected strong disease spot area acquisition module is used to collect an apple leaf image, perform grayscale processing on the apple leaf image to obtain a grayscale image of the apple leaf, and obtain at least one suspected strong disease spot area in the grayscale image; A strong lesion area acquisition module, used to respectively calculate the gradient value and gradient direction of each pixel point in each of the suspected strong lesion areas, and respectively acquire the strong lesion area in each of the suspected strong lesion areas according to the gradient value and gradient direction of each pixel point; A direction set acquisition module is used for dividing all pixel points in any strong lesion area into N direction sets according to N neighborhood directions preset in the strong lesion area; A strong lesion feature value acquisition module is used to obtain a direction set of each of the strong lesion areas, and for any neighborhood direction, determine the strong lesion feature value of the neighborhood direction according to the gradient value and grayscale value of each pixel point in all direction sets in the neighborhood direction; An image processing module, used for obtaining the strong disease spot characteristic value in each of the neighborhood directions, and performing region growing on the grayscale image according to the strong disease spot characteristic value in each of the neighborhood directions to obtain an apple disease detection result; The strong lesion area acquisition module acquires the strong lesion area in each of the suspected strong lesion areas according to the gradient value and the gradient direction of each pixel point, including: Calculating the gradient value of each pixel in the grayscale image, taking the area in the grayscale image other than the suspected strong lesion area as a lesion-free area, obtaining the gradient value of each pixel in the lesion-free area, and calculating the mean gradient value of the lesion-free area; For any suspected strong lesion area, select the pixel points whose gradient value in the suspected strong lesion area is less than the gradient mean of the lesion-free area as the target pixel points, and the area composed of all the target pixel points as the target strong lesion area; Extending the gradient direction of each pixel point in the target strong lesion area in the reverse direction to obtain at least one intersection point between all the reverse extension lines, and obtaining the coordinates of each intersection point; According to the coordinates of each of the intersection points, cluster all the intersection points to obtain at least one cluster, count the number of intersection points in each cluster, normalize the number of intersection points in each cluster to obtain a normalized value, calculate the mean of all normalized values, and use the absolute value of the difference between the mean and a preset mean as a distribution coefficient; The pixel point with the smallest gradient value in the target strong lesion area is taken as the actual center point, the cluster with the largest number of intersections in the clusters is selected as the target cluster, and for any target cluster, the cluster center of the target cluster is obtained to obtain the distance between the cluster center and the actual center point; The sum of the distribution coefficient and the constant 1 is used as the first variable, the sum of the distance and the constant 1 is used as the second variable, and the reciprocal of the product of the first variable and the second variable is used as the emission coefficient; If the emission coefficient is within a preset range, the area consisting of pixel points on the reverse extension line to which the intersection point in the target cluster belongs is marked as a strong lesion area; The strong lesion feature value acquisition module determines the strong lesion feature value in the neighborhood direction according to the gradient value and grayscale value of each pixel point in the set of all directions in the neighborhood direction, including: For any strong lesion area, select the pixel point with the smallest gradient value in the strong lesion area as the target center point, calculate the gradient direction angle between each pixel point in the direction set of the strong lesion area in the neighborhood direction and the target center point, form a gradient direction angle set, and obtain the angle interval according to the gradient direction angle set; Obtaining the angle intervals corresponding to all the strong lesion areas in the neighborhood direction, selecting at least three angle intervals from all the angle intervals to obtain at least one angle interval intersection, using the number of angle intervals involved in each of the angle interval intersections as a weight coefficient for each of the angle interval intersections, selecting the angle interval intersections whose weight coefficients are greater than a preset value for merging, and obtaining an initial angle interval; The target center point is placed in the direction set corresponding to each of the strong lesion areas in the neighborhood direction, and the maximum grayscale value and the minimum grayscale value in each of the direction sets are obtained, and the mean of all the maximum grayscale values is calculated as the maximum mean, and the mean of all the minimum grayscale values is calculated as the minimum mean, and the difference between the maximum mean and the minimum mean is used as the initial threshold difference; Dividing the grayscale image into an obvious illumination area and an area without obvious illumination according to the grayscale level, increasing or decreasing the initial angle interval and the initial threshold difference according to the grayscale values of the obvious illumination area and the area without obvious illumination, to obtain a strong lesion feature value in the neighborhood direction; The step of dividing the grayscale image into an obvious illumination area and an area without obvious illumination according to the grayscale level includes: Constructing a grayscale histogram of the grayscale image, dividing the grayscale into a plurality of grayscale intervals in the grayscale histogram, and for any grayscale interval, accumulating the frequency corresponding to each grayscale included in the grayscale interval to obtain the frequency sum of the grayscale interval; The frequency sums of all gray level intervals are added to obtain a total frequency sum, and the ratio between the frequency sum of each gray level interval and the total frequency sum is used as the interval frequency; Selecting the grayscale interval corresponding to the maximum interval frequency in the interval frequencies as the target interval, and for any grayscale interval in the grayscale histogram except the grayscale interval corresponding to the maximum interval frequency, calculating the difference between the interval frequency of the grayscale interval corresponding to the maximum interval frequency and the interval frequency of the grayscale interval, if the difference is less than a preset difference, taking the grayscale interval as the target interval, and taking the area composed of all the pixels contained in the target interval as the area without obvious illumination; Selecting a grayscale interval corresponding to the maximum grayscale level from among all target intervals as a threshold interval, selecting a grayscale interval greater than the threshold interval from among all grayscale intervals as a reference interval, and for any two adjacent reference intervals, if the difference between the interval frequencies of the two adjacent reference intervals is less than a preset difference, taking the two adjacent reference intervals as final intervals, and taking an area composed of pixels contained in all final intervals as an obvious illumination area; The step of increasing or decreasing the initial angle interval and the initial threshold difference according to the grayscale values of the obvious illumination area and the area without obvious illumination to obtain the strong lesion feature value in the neighborhood direction includes: Calculating the mean of the grayscale values of all pixels in the obvious illumination area as a first grayscale mean, calculating the mean of the grayscale values of all pixels in the area without obvious illumination as a second grayscale mean, and adding the difference between the first grayscale mean and the second grayscale mean to the initial threshold difference to obtain a final threshold difference; Calculate the mean of the gradient direction angles of all the pixels in the obvious illumination area as the first angle mean, calculate the mean of the gradient direction angles of all the pixels in the area without obvious illumination as the second angle mean, take the difference between the first angle mean and the second angle mean as the target angle difference, subtract the target angle difference from the minimum value in the initial angle interval as the minimum angle, add the target angle difference to the maximum angle in the initial angle interval, and form a final angle interval with the minimum angle and the maximum angle; Using the final threshold difference and the final angle interval as the strong lesion feature value in the neighborhood direction; The image processing module performs region growing on the grayscale image according to the strong disease spot feature value in each neighborhood direction to obtain the apple disease detection result, including: In the obvious illumination area, a pixel point with the smallest gradient value is taken as an initial seed point, and growth is performed according to the preset N neighborhood directions. For any neighborhood direction of the initial seed point, a pixel point adjacent to the initial seed point in the neighborhood direction is taken as a growth point, and a pixel point adjacent to the growth point in the neighborhood direction is taken as a point to be grown. If the difference between the gray value of the growing point and the gray value of the point to be grown is less than or equal to the final threshold difference of the neighborhood direction, and the gradient direction angle of the growing point is within the final angle interval of the neighborhood direction, the growing point and the initial seed point are marked as diseased spots; Obtain diseased spots in each neighborhood direction of the initial seed point, extend the gradient directions of all pixels in all diseased spots except the pixel with the smallest gradient value in all diseased spots in the reverse direction, obtain the intersection of all reverse extension lines, calculate the emission coefficient according to the intersection of all reverse extension lines and the pixel with the smallest gradient value in all diseased spots, and if the emission coefficient is within a preset range, continue to grow the growth point as a new seed point to obtain all diseased spots in the obvious illumination area; All disease spots in the obvious light-irradiated area and the area without obvious light-irradiated area are taken as the apple disease detection results.
2. The apple disease detection system based on image processing according to claim 1, characterized in that: The direction set acquisition module divides all pixel points in the strong lesion area into N direction sets according to the N neighborhood directions preset in the strong lesion area, including: The pixel point with the smallest gradient value in the strong lesion area is selected as the target center point, and a grid of a preset size is established with the target center point as the center. All pixel points in the strong lesion area are classified according to the grid according to the preset N neighborhood directions, and the pixel points located in the same neighborhood direction are taken as a direction set to obtain N direction sets.
3. The apple disease detection system based on image processing according to claim 1, characterized in that: The suspected strong lesion area acquisition module performs grayscale processing on the apple leaf image to obtain a grayscale image of the apple leaf, and obtains at least one suspected strong lesion area in the grayscale image, including: Threshold segmentation and opening and closing operations are performed on the grayscale image to obtain a suspected strong lesion grayscale image, and the suspected strong lesion grayscale image is masked to obtain at least one suspected strong lesion area.
