A method for monitoring flower diseases and pests based on machine vision
By employing edge detection and adaptive distance compensation, the problem of incomplete lesion segmentation caused by false boundaries in the watershed algorithm was solved, enabling accurate monitoring and assessment of flower diseases.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-12
- Publication Date
- 2026-03-17
AI Technical Summary
In existing technologies, the watershed algorithm causes false boundaries to form when segmenting mosaic disease lesions due to the grayscale difference between leaf veins and lesions, resulting in the lesion area being fragmented and affecting the accuracy of disease identification and assessment.
Candidate pseudo-boundaries are obtained by edge detection, and their leaf vein characteristics and directional features are analyzed to screen out pseudo-boundaries. Adaptive distance compensation is then performed in the watershed algorithm to ensure the continuity of the lesion area.
It achieves complete segmentation of lesion areas, provides a reliable basis for disease monitoring and control decisions, and improves the accuracy of disease identification and assessment.
Smart Images

Figure CN121304705B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image processing technology, and in particular to a method for monitoring flower diseases and pests based on machine vision. Background Technology
[0002] Mosaic virus (MDV) is a high-frequency disease caused by viral infection. Its lesions are irregular, mottled yellow-green patches with blurred borders that intertwine with the leaf texture, making precise segmentation difficult. Insufficient segmentation accuracy easily leads to misdiagnosis and delayed control, thus accelerating its spread in the field and affecting flower yield and quality. To effectively monitor and control this disease, it is necessary to extract and identify MAV lesions, enabling the location and analysis of lesion areas. This will support subsequent precise pesticide application and control treatments, providing a technical basis for stopping the spread of the disease.
[0003] Existing technologies primarily employ image segmentation methods based on the watershed algorithm to automatically extract and identify mosaic virus lesions. The core of the watershed algorithm lies in using distance transformation to filter regions far from the boundary as deterministic foreground (lesion core) regions, thus ensuring segmentation accuracy. However, due to the significant difference between the sunken, dark texture of leaf veins and the mottled features of mosaic virus lesions, the watershed algorithm mistakenly identifies leaf veins within the lesion as non-foreground regions, forming false boundaries. This distorts the distance transformation results in the watershed algorithm, losing the true foreground core points while mistakenly capturing only pixels far from the false boundaries as foreground core points. Consequently, the originally continuous large core region of the lesion is fragmented into multiple isolated small core regions by the leaf vein false boundaries. This not only destroys the complete morphology of the lesion but also interferes with the subsequent accurate identification of lesions and the quantitative assessment of disease severity.
[0004] Therefore, how to reduce the interference of false boundaries in the lesion area on the regional segmentation, achieve complete segmentation of the lesions, and thus effectively monitor and control such pests and diseases has become an urgent problem to be solved. Summary of the Invention
[0005] In view of this, embodiments of the present invention provide a machine vision-based method for monitoring flower diseases and pests, in order to solve the problem of how to reduce the interference of false boundaries in the diseased area on the region segmentation, achieve complete segmentation of the diseased area, and thus effectively monitor and control such diseases and pests.
[0006] This invention provides a machine vision-based method for monitoring flower diseases and pests, which includes the following steps:
[0007] Acquire initial images of the leaves of the flower to be monitored, and perform grayscale processing on the initial images to obtain grayscale images;
[0008] Edge detection is performed on the grayscale image to obtain a set of candidate pseudo-boundaries. For any candidate pseudo-boundary in the set of candidate pseudo-boundaries, a local analysis region of the candidate pseudo-boundary is obtained. Based on the grayscale distribution characteristics of the pixels in the local analysis region and the linear structure characteristics of the candidate pseudo-boundary, the leaf vein feature index of the candidate pseudo-boundary is obtained.
[0009] Obtain the leaf vein feature index of each candidate pseudo boundary in the candidate pseudo boundary set, and filter at least one pseudo boundary from the candidate pseudo boundary set based on the leaf vein feature index and direction feature of each candidate pseudo boundary.
[0010] In the process of using the watershed algorithm to segment the grayscale image into regions, the initial distance of each pixel in the grayscale image after distance transformation is obtained. Based on the positional relationship between each pixel and each pseudo-boundary, adaptive distance compensation is performed on the initial distance of each pixel to obtain the compensated distance.
[0011] Based on the compensation distance of each pixel in the grayscale image, the grayscale image is segmented to obtain the lesion area. Based on the lesion area, the leaves of the flowers to be monitored are subjected to monitoring and control treatment for flower diseases and pests.
[0012] Preferably, the step of obtaining the leaf vein feature index of any candidate pseudo-boundary based on the grayscale distribution characteristics of pixels in the local analysis region and the linear structure characteristics of any candidate pseudo-boundary includes:
[0013] Based on the grayscale distribution characteristics of pixels in the local analysis region, the first vein feature index of any candidate pseudo-boundary is obtained;
[0014] Based on the linear structural features of any candidate pseudo-boundary, obtain the second vein feature index of any candidate pseudo-boundary;
[0015] The first leaf vein feature index is normalized to obtain a first normalization result. The second leaf vein feature index is normalized to obtain a second normalization result. The first normalization result and the second normalization result are weighted and summed to obtain the leaf vein feature index of any candidate pseudo-boundary.
[0016] Preferably, obtaining the first vein feature index of any candidate pseudo-boundary based on the grayscale distribution characteristics of pixels in the local analysis region includes:
[0017] Using any candidate pseudo-boundary, the pixels in the local analysis region are divided into candidate pseudo-boundary pixels, left pixels, and right pixels. The absolute value of the difference between the gray mean of all candidate pseudo-boundary pixels and the gray mean of all left pixels is obtained and recorded as the left gray difference value. The absolute value of the difference between the gray mean of all candidate pseudo-boundary pixels and the gray mean of all right pixels is obtained and recorded as the right gray difference value. The negative of the absolute value of the difference between the left gray difference value and the right gray difference value is substituted into an exponential function with the natural constant as the base to obtain the first leaf vein feature index of any candidate pseudo-boundary.
[0018] Preferably, obtaining the second vein feature index of any candidate pseudo-boundary based on the linear structural features of any candidate pseudo-boundary includes:
[0019] Starting from any endpoint of any candidate pseudo-boundary, sort the pixels in any candidate pseudo-boundary, and obtain the eight-directional chain code of each pixel in any candidate pseudo-boundary except the first pixel, forming a chain code sequence.
[0020] Based on the chain code sequence, obtain the mutation pixels of any candidate pseudo-boundary, calculate the proportion of mutation pixels in any candidate pseudo-boundary to obtain the mutation point proportion, obtain the difference between the constant 1 and the mutation point proportion, and obtain the second leaf vein feature index of any candidate pseudo-boundary.
[0021] Preferably, obtaining the abrupt change pixel point of any candidate pseudo-boundary based on the chain code sequence includes:
[0022] For any chain code data in the chain code sequence other than the last chain code data, obtain the absolute value of the difference between the any chain code data and the next chain code data to obtain the first directional difference value, and obtain the difference between the constant 8 and the directional difference value to obtain the second directional difference value.
[0023] Set a directional difference threshold, obtain the minimum value between the first directional difference value and the second directional difference value, and if the minimum value is greater than the directional difference threshold, then confirm that the pixel corresponding to any chaincode data is a mutation pixel.
[0024] Preferably, the step of selecting at least one pseudo-boundary from the set of candidate pseudo-boundaries based on the leaf vein feature index and orientation feature of each candidate pseudo-boundary includes:
[0025] Set a threshold for leaf vein feature indicators, and select candidate pseudo-boundaries from all candidate pseudo-boundaries whose leaf vein feature indicators are greater than or equal to the threshold for leaf vein feature indicators as suspected leaf vein boundaries.
[0026] Based on the directional characteristics of each suspected leaf vein boundary, obtain the leaf vein confidence score of each suspected leaf vein boundary.
[0027] Set a leaf vein confidence threshold, and select suspected leaf vein boundaries with a leaf vein confidence score greater than or equal to the leaf vein confidence threshold from all suspected leaf vein boundaries as false boundaries.
[0028] Preferably, obtaining the vein confidence score of each suspected leaf vein boundary based on the directional characteristics of each suspected leaf vein boundary includes:
[0029] For any suspected leaf vein boundary, obtain the chain code sequence corresponding to the suspected leaf vein boundary, and record the direction corresponding to the chain code data with the highest frequency in the chain code sequence as the main direction of the suspected leaf vein boundary.
[0030] Obtain the main direction of each suspected leaf vein boundary and construct a direction histogram. The horizontal axis of the direction histogram is the direction interval, and the vertical axis is the frequency corresponding to the direction interval.
[0031] In the directional histogram, the frequency of the directional interval corresponding to the main direction of any suspected leaf vein boundary is obtained and recorded as the interval frequency of any suspected leaf vein boundary. The ratio of the interval frequency to the number of all suspected leaf vein boundaries is obtained to obtain the leaf vein confidence of any suspected leaf vein boundary.
[0032] Preferably, the step of adaptively compensating the initial distance of each pixel based on the positional relationship between each pixel and each pseudo-boundary to obtain the compensated distance includes:
[0033] For any pixel, the candidate pseudo-boundary closest to the pixel is obtained from the candidate pseudo-boundary set and denoted as the nearest boundary. If the nearest boundary is a pseudo-boundary, the distance between the pixel and the nearest boundary is obtained and denoted as the nearest distance. The initial distance of the pixel is compensated using the nearest distance to obtain the compensated distance of the pixel.
[0034] If the nearest boundary is not a pseudo-boundary, then the initial distance of any pixel is used as the compensation distance of any pixel.
[0035] Preferably, the step of compensating the initial distance of any pixel using the nearest distance to obtain the compensated distance of any pixel includes:
[0036] Obtain the product of the nearest distance and the preset distance compensation coefficient, calculate the sum of the constant 1 and the product to obtain the distance compensation weight, obtain the product of the distance compensation weight and the initial distance to obtain the compensation distance of any pixel.
[0037] Preferably, obtaining the local analysis region of any candidate pseudo-boundary includes:
[0038] A morphological dilation operation is performed on any of the candidate pseudo-boundaries to obtain the local analysis region of any candidate pseudo-boundary.
[0039] The beneficial effects of the embodiments of the present invention compared with the prior art are as follows:
[0040] In this invention, leaf vein feature indicators are obtained to reflect the structural features of candidate pseudo-boundaries and the gray-scale distribution features of nearby pixels. A preliminary analysis is performed to determine whether the candidate pseudo-boundaries conform to the leaf vein boundaries within the lesion area. This is then combined with the macroscopic directional distribution features of the leaf veins to further analyze whether the candidate pseudo-boundaries are indeed pseudo-boundaries. Adaptive distance compensation is applied to the initial distance to obtain a compensation distance, ensuring that the true lesion area spanning the leaf veins remains continuous in the distance map. This ensures that the watershed algorithm can identify the complete core area of the lesion, preventing the core area from being truncated and split, thus achieving complete lesion segmentation and providing a reliable quantitative basis for monitoring and controlling flower diseases and pests. Attached Figure Description
[0041] To more clearly illustrate the technical solutions in the embodiments of the present invention, 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 the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0042] Figure 1 This is a flowchart of a method for monitoring flower diseases and pests based on machine vision, provided in Embodiment 1 of the present invention. Detailed Implementation
[0043] Embodiments of this disclosure are described in detail below, with examples of these embodiments illustrated in the accompanying drawings. The embodiments described below with reference to the accompanying drawings are exemplary and intended to explain this disclosure, and should not be construed as limiting it.
[0044] It should be noted that the terms "first," "second," etc., used in this disclosure and the accompanying drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this disclosure described herein can be implemented in orders other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this disclosure. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this disclosure.
[0045] To illustrate the technical solution of the present invention, specific embodiments are described below.
[0046] See Figure 1 This is a flowchart of a machine vision-based method for monitoring flower diseases and pests, as provided in Embodiment 1 of the present invention. Figure 1 As shown, the method may include:
[0047] Step S101: Acquire an initial image of the leaves of the flower to be monitored, and perform grayscale processing on the initial image to obtain a grayscale image.
[0048] Mosaic virus is a high-frequency disease caused by viral infection. The characteristics of its lesion areas directly determine the accuracy of disease severity assessment and the scientific nature of control decisions. Existing technologies mainly employ image segmentation methods based on watershed algorithms to achieve automatic extraction and identification of mosaic virus lesion areas.
[0049] However, the core of the watershed algorithm lies in using distance transformation to filter out regions far from the boundary as deterministic foreground (lesion core) regions, thereby ensuring the accuracy of segmentation. Because the sunken, dark texture of leaf veins differs significantly from the mottled features of mosaic disease lesions, the watershed algorithm classifies leaf veins within the lesion as non-foreground regions, thus forming false boundaries. This distorts the distance transformation results in the watershed algorithm, losing the true foreground core points while mistakenly capturing only pixels far from the false boundaries as foreground core points. Consequently, the originally continuous large lesion core region is fragmented into multiple isolated small core regions by the leaf vein false boundaries. This not only destroys the complete morphology of the lesion but also interferes with the subsequent accurate identification of lesions and the quantitative assessment of disease severity.
[0050] To address the aforementioned issues, this embodiment analyzes the boundaries in the grayscale images of flower leaves, filters out false boundaries in the grayscale images, and then performs adaptive distance compensation on pixels affected by false boundaries. This ensures that when the watershed algorithm is used to segment the grayscale image, the real lesion areas that cross the leaf veins remain continuous in the distance map, preventing the core area of the lesion from being truncated and split, thus achieving complete segmentation of the lesion and providing a reliable quantitative basis for monitoring and controlling flower diseases and pests.
[0051] First, an initial image of the leaves of the flower to be monitored is acquired using a high-resolution digital camera (resolution ≥ 20 million pixels) under standard lighting conditions (i.e., standard light source). Then, after image preprocessing, a grayscale image is obtained for subsequent analysis.
[0052] Among them, image preprocessing is an existing technology, and it is briefly described here: (1) Noise suppression: Gaussian sampling is used to smooth the initial image, retaining the main edge information while effectively suppressing noise; (2) Grayscale processing; (3) Contrast enhancement: Histogram equalization technology is applied to enhance the overall contrast of the leaf image, expand the grayscale difference between leaf veins and leaf tissue, diseased areas and healthy tissue, and improve the sensitivity of subsequent image segmentation; (4) Image cropping and alignment: According to the analysis requirements, the core area of the leaf in the initial image is cropped, and necessary rotation or alignment operations are performed to unify the image composition and eliminate the interference of irrelevant background on the analysis.
[0053] Step S102: Perform edge detection on the grayscale image to obtain a set of candidate pseudo-boundaries. For any candidate pseudo-boundary in the set of candidate pseudo-boundaries, obtain the local analysis region of the candidate pseudo-boundary. Based on the grayscale distribution characteristics of the pixels in the local analysis region and the linear structure characteristics of the candidate pseudo-boundary, obtain the leaf vein feature index of the candidate pseudo-boundary.
[0054] After obtaining the grayscale image, the Canny edge detection algorithm is used to perform edge detection on the grayscale image, obtaining all boundaries in the grayscale image and forming a candidate pseudo-boundary set. This set is used to analyze and filter out pseudo-boundaries. The Canny edge detection algorithm is existing technology and will not be elaborated upon here.
[0055] Since the boundary of the lesion area is the dividing line between the lesion area and the normal leaf vein area, it may show a grayscale distribution structure with the left side bright and the right side dark or vice versa in the grayscale image. However, the leaf veins inside the lesion area have lesion areas on both sides, and the grayscale distribution structure of the two sides is similar. In the grayscale image, it may show a grayscale distribution structure with the two sides bright and the middle leaf vein dark or vice versa. At the same time, in diseased leaves, the lesion area shows a disordered distribution, while even the leaf veins inside the lesion area have a relatively complete linear structure and directional regularity.
[0056] Therefore, in this embodiment, for any candidate pseudo-boundary in the candidate pseudo-boundary set, a morphological dilation operation is performed on the candidate pseudo-boundary to form a connected mask covering the candidate pseudo-boundary itself and its immediate adjacent regions, thus obtaining the local analysis region of the candidate pseudo-boundary. Then, based on the grayscale distribution characteristics of the pixels in the local analysis region of the candidate pseudo-boundary and the linear structure characteristics of the candidate pseudo-boundary, the leaf vein feature index of the candidate pseudo-boundary is obtained for preliminary analysis of whether the candidate pseudo-boundary conforms to the leaf vein boundary within the lesion region. The morphological dilation operation is prior art and will not be elaborated upon here.
[0057] The method for obtaining the leaf vein feature index of any candidate pseudo-boundary based on the gray-level distribution characteristics of pixels in the local analysis region of any candidate pseudo-boundary and the linear structure characteristics of any candidate pseudo-boundary is as follows:
[0058] (1) Based on the grayscale distribution characteristics of the pixels in the local analysis region, obtain the first leaf vein feature index of any candidate pseudo boundary.
[0059] Specifically, the pixels in the local analysis region are divided into candidate pseudo-boundary pixels, left pixels, and right pixels using any candidate pseudo-boundary. (In this embodiment, left pixels and right pixels are distinguished relative to the candidate pseudo-boundary. For example, if the candidate pseudo-boundary is a horizontal boundary, then in the local analysis region, pixels below the candidate pseudo-boundary are recorded as left pixels, and pixels above the candidate pseudo-boundary are recorded as right pixels; if the candidate pseudo-boundary is a closed curve boundary, then in the local analysis region, pixels inside the candidate pseudo-boundary are recorded as left pixels, and pixels outside the candidate pseudo-boundary are recorded as right pixels.)
[0060] Obtain the absolute value of the difference between the gray mean of all candidate pseudo-boundary pixels and the gray mean of all left pixels, and record it as the left gray difference value. Obtain the absolute value of the difference between the gray mean of all candidate pseudo-boundary pixels and the gray mean of all right pixels, and record it as the right gray difference value. Substitute the negative of the absolute value of the difference between the left gray difference value and the right gray difference value into an exponential function with the natural constant as the base to obtain the first leaf vein feature index of any candidate pseudo-boundary.
[0061] In one embodiment, taking the i-th candidate pseudo-boundary as an example, the calculation formula for the first vein feature index of the i-th candidate pseudo-boundary is:
[0062]
[0063] in, The first vein feature index of the i-th candidate pseudo-boundary; Let be the average gray value of the pixels at the i-th candidate pseudo-boundary; The average grayscale value of all left-side pixels; The average grayscale value of all right-side pixels; It is an exponential function with the natural constant as its base; It is the absolute value symbol.
[0064] It should be noted that, The difference in grayscale values is on the left. The difference in grayscale values is shown on the right. The larger the value, the greater the difference in gray-level distribution on both sides of the i-th candidate pseudo-boundary, and the more it matches the gray-level distribution characteristics of the lesion region edge. The smaller it is; The smaller the value, the more similar the gray-level distribution characteristics on both sides of the i-th candidate false boundary are, and the more they match the gray-level distribution characteristics of the areas on both sides of the leaf veins inside the lesion area. The larger it is.
[0065] (2) Based on the linear structural features of any candidate pseudo-boundary, obtain the second leaf vein feature index of any candidate pseudo-boundary.
[0066] Specifically, starting from any endpoint of any candidate pseudo-boundary, the pixels in any candidate pseudo-boundary are sorted (traversing all pixels in any candidate pseudo-boundary in a clockwise direction until the other endpoint is reached). The eight-directional chain code of each pixel in any candidate pseudo-boundary, excluding the first pixel, relative to the previous pixel is obtained, forming a chain code sequence. ,in For any candidate pseudo-boundary, the second pixel relative to the previous pixel is the eight-directional chain code, and so on. Let n be the eight-directional chain code of the nth pixel in any candidate pseudo-boundary relative to the previous pixel, where n is the number of pixels in any candidate pseudo-boundary.
[0067] For any chain code data in the chain code sequence other than the last chain code data, obtain the absolute value of the difference between the any chain code data and the next chain code data to obtain the first directional difference value, and obtain the difference between the constant 8 and the directional difference value to obtain the second directional difference value.
[0068] Set a directional difference threshold, obtain the minimum value between the first directional difference value and the second directional difference value. If the minimum value is greater than the directional difference threshold, then the pixel corresponding to any chain code data is confirmed as a mutation pixel. The j-th (j < n) chain code data in the chain code sequence is used as the starting point. For example, if Then, the pixel corresponding to the j-th (j < n) chain code data in the chain code sequence (i.e., the (j-1)-th pixel in any candidate pseudo-boundary) is confirmed as a mutation pixel, where, For the (j+1)th chain code data in the chain code sequence, is the absolute value symbol, min is the minimum value symbol, 8 represents the 8 directions of a pixel relative to the previous pixel, and L is the direction difference threshold. In this embodiment, L=1 is set, which corresponds to a 45° angle difference of the 8-direction chain code. This can distinguish between the natural slight curvature of leaf veins (angle difference ≤ 45°) and the obvious turning point of lesions (angle difference > 45°). There is no restriction here, and it can be set according to the specific implementation scenario.
[0069] Following the aforementioned method for confirming abruptly changed pixels, all abruptly changed pixels of any candidate pseudo-boundary are obtained. The proportion of abruptly changed pixels in any candidate pseudo-boundary is calculated to obtain the proportion of abruptly changed pixels. The difference between the constant 1 and the proportion of abruptly changed pixels is then obtained to obtain the second vein feature index of any candidate pseudo-boundary. Taking the i-th candidate pseudo-boundary as an example, the second vein feature index of the i-th candidate pseudo-boundary is... , m is the number of abruptly changed pixels in the i-th candidate pseudo-boundary, and n is the number of pixels in the i-th candidate pseudo-boundary.
[0070] (3) Normalize the first leaf vein feature index to obtain the first normalization result, normalize the second leaf vein feature index to obtain the second normalization result, and perform a weighted summation of the first normalization result and the second normalization result to obtain the leaf vein feature index of any candidate pseudo boundary.
[0071] In one embodiment, taking the i-th candidate pseudo-boundary as an example, the formula for calculating the vein feature index of the i-th candidate pseudo-boundary is:
[0072]
[0073] in, The leaf vein feature index is the i-th candidate pseudo-boundary. The first vein feature index of the i-th candidate pseudo-boundary; The second vein feature index is used for the i-th candidate pseudo-boundary. This is the normalization function; This is a weight value used to balance the contribution of the two indicators. In this embodiment, it is set as follows: To highlight the core distinguishing role of the first leaf vein characteristic indicator, there are no restrictions here, and it can be set according to the specific implementation scenario.
[0074] It should be noted that, The larger the value, the more closely the i-th candidate false boundary matches the similar gray-scale distribution characteristics of the regions on both sides of the leaf vein within the lesion area; that is, the more likely the i-th candidate false boundary is a leaf vein false boundary located within the lesion area. The larger it is; The larger the value, the smaller the proportion of mutation points in the i-th candidate pseudo-boundary, indicating better linear extensibility and a better fit with the linear direction characteristics of leaf veins. The larger it is.
[0075] Thus, the leaf vein feature index of any candidate pseudo-boundary is obtained.
[0076] Step S103: Obtain the leaf vein feature index of each candidate pseudo-boundary in the candidate pseudo-boundary set, and select at least one pseudo-boundary from the candidate pseudo-boundary set based on the leaf vein feature index and direction feature of each candidate pseudo-boundary.
[0077] Following the method described above for obtaining the leaf vein feature index of the i-th candidate pseudo-boundary, the leaf vein feature index of each candidate pseudo-boundary in the candidate pseudo-boundary set is obtained. A larger leaf vein feature index indicates that the candidate pseudo-boundary is more likely to be a leaf vein pseudo-boundary located within the lesion area; a smaller leaf vein feature index indicates that the candidate pseudo-boundary is more likely to be the true boundary of the lesion area. Therefore, a leaf vein feature index threshold is set, and candidate pseudo-boundaries with leaf vein feature indices greater than or equal to the threshold are selected as suspected leaf vein boundaries. In this embodiment, the leaf vein feature index threshold is set to 0.4, which can exclude candidate pseudo-boundaries that clearly do not conform to the local characteristics of leaf veins (candidate pseudo-boundaries that clearly belong to the true lesion boundary), balancing computational efficiency and accuracy. This is not limited here and can be set according to the specific implementation scenario.
[0078] Since the leaf vein characteristic index only analyzes the microscopic features (local grayscale distribution and linear structure characteristics) of candidate false boundaries, some lesions, due to their regular morphology, limited diffusion, or early stage, may naturally exhibit approximately symmetrical grayscale distribution characteristics within a local area and maintain good linear extension within a limited range. Therefore, they may be misjudged as suspected leaf vein boundaries at the microscopic level. Thus, further screening is needed among the suspected leaf vein boundaries to identify false boundaries.
[0079] Since the macroscopic characteristics of leaf veins are that their directional distribution is concentrated, meaning that a single leaf vein will have multiple veins in the same direction throughout the leaf, while the actual boundaries of lesions are directional and disordered, the suspected leaf vein boundaries can be further screened based on the directional characteristics of each suspected leaf vein boundary to obtain false boundaries, thereby improving the accuracy and robustness of false boundary identification.
[0080] The method for further filtering of suspected leaf vein boundaries based on the directional characteristics of each suspected leaf vein boundary to obtain false boundaries is as follows:
[0081] (1) Based on the directional characteristics of each suspected leaf vein boundary, obtain the leaf vein confidence of each suspected leaf vein boundary.
[0082] Specifically, for any suspected leaf vein boundary, the chain code sequence corresponding to the suspected leaf vein boundary is obtained, and the direction corresponding to the chain code data with the highest frequency in the chain code sequence is recorded as the main direction of the suspected leaf vein boundary.
[0083] Obtain the main direction of each suspected leaf vein boundary and construct a direction histogram. The horizontal axis of the direction histogram is the direction interval (the angle range of 0°-360° is divided into 8 intervals, each interval is 45°), and the vertical axis is the frequency corresponding to the direction interval.
[0084] In the directional histogram, the frequency of the directional interval corresponding to the main direction of any suspected leaf vein boundary is obtained and recorded as the interval frequency of any suspected leaf vein boundary. The ratio of the interval frequency to the number of all suspected leaf vein boundaries is obtained to obtain the leaf vein confidence of any suspected leaf vein boundary.
[0085] In one embodiment, taking the kth suspected leaf vein boundary as an example, the formula for calculating the vein confidence of the kth suspected leaf vein boundary is as follows:
[0086]
[0087] in, Let k be the confidence level of the suspected leaf vein boundary. denoted as the frequency of the direction interval corresponding to the main direction of the kth suspected leaf vein boundary; M is the total number of all suspected leaf vein boundaries.
[0088] It should be noted that, The dominance and concentration of the principal direction of the kth suspected leaf vein boundary in the overall directional distribution were quantified: The higher the value, the more likely the main direction of the kth suspected leaf vein boundary is within a highly concentrated dominant region, and its macroscopic directional characteristics are highly consistent with the consistency of the leaf vein network, making it more likely to be a false leaf vein boundary. The lower the value, the more likely the main direction of the kth suspected leaf vein boundary is in a discrete interval with few boundaries. Its macroscopic directional characteristics do not match the dominant directional pattern of the leaf vein network, and it is less likely to belong to a false leaf vein boundary.
[0089] (2) False boundaries are screened based on leaf vein confidence.
[0090] Specifically, a leaf vein confidence threshold is set, and suspected leaf vein boundaries with a confidence level greater than or equal to the leaf vein confidence threshold are selected as false boundaries from all suspected leaf vein boundaries.
[0091] In this embodiment, the leaf vein confidence threshold is set to 0.4. While maintaining a high detection rate, it effectively filters obvious false boundaries with discrete directions, improving screening efficiency and system robustness. There are no restrictions here, and in practical applications, it can be optimized according to the specific leaf type: for scenarios where the leaf vein direction is highly consistent, the leaf vein confidence threshold can be appropriately increased to enhance the screening strictness; for scenarios with complex leaf vein patterns, the leaf vein confidence threshold can be appropriately decreased to avoid erroneously removing real leaf vein segments.
[0092] At this point, all pseudo-boundaries in the candidate pseudo-boundary set have been obtained.
[0093] Step S104: During the process of using the watershed algorithm to segment the grayscale image into regions, the initial distance of each pixel in the grayscale image after distance transformation is obtained. Based on the positional relationship between each pixel and each pseudo-boundary, adaptive distance compensation is performed on the initial distance of each pixel to obtain the compensated distance.
[0094] After obtaining all the pseudo-boundaries in the candidate pseudo-boundary set, in order to reduce the influence of pseudo-boundaries on the distance transformation results in the watershed algorithm, during the process of using the watershed algorithm to segment the grayscale image, the distance of each pixel in the grayscale image after distance transformation is obtained and recorded as the initial distance of each pixel. Then, based on the positional relationship between each pixel and each pseudo-boundary (i.e., the degree of influence of the pseudo-boundary on the distance transformation of the pixel), adaptive distance compensation is performed on the initial distance of each pixel to obtain the compensated distance, ensuring the continuity of the real lesion area across the leaf vein and achieving complete lesion segmentation.
[0095] The method for adaptively compensating the initial distance of each pixel based on the positional relationship between each pixel and each pseudo-boundary is as follows:
[0096] For any pixel, the candidate pseudo-boundary closest to the pixel is obtained from the candidate pseudo-boundary set and denoted as the nearest boundary. If the nearest boundary is a pseudo-boundary, it means that the pixel will be disturbed by the pseudo-boundary when performing distance transformation. Then, the Euclidean distance between the pixel and the nearest boundary is obtained and denoted as the nearest distance. The product of the nearest distance and the preset distance compensation coefficient is obtained. The constant 1 is added to the product to obtain the distance compensation weight. The product of the distance compensation weight and the initial distance is obtained to obtain the compensation distance of the pixel.
[0097] If the nearest boundary is not a pseudo-boundary, it means that any pixel will not be disturbed by the pseudo-boundary when performing distance transformation. Therefore, the initial distance of any pixel is used as the compensation distance of any pixel.
[0098] In one embodiment, taking the p-th pixel in a grayscale image as an example, the formula for calculating the compensation distance of the p-th pixel is:
[0099]
[0100] in, The compensation distance for the p-th pixel; d is the initial distance of the p-th pixel; d is the Euclidean distance between the p-th pixel and its nearest boundary. In this embodiment, a preset distance compensation coefficient is set. This ensures that while effectively correcting the initial distance, it avoids distance distortion due to overcompensation. It is an exponential function with the natural constant as its base; P is the candidate pseudo-boundary closest to the p-th pixel; P is the pseudo-boundary.
[0101] It should be noted that when When performing distance transformation, the p-th pixel is affected by pseudo-boundaries. The smaller d is, the greater the interference from pseudo-boundaries on the p-th pixel, and the more necessary it is to perform distance compensation on the initial distance of the p-th pixel. The larger it is; when When the distance transformation is performed, the p-th pixel will not be affected by the pseudo-boundary, meaning that there is no need to perform distance compensation on the initial distance of the p-th pixel.
[0102] At this point, the compensation distance for each pixel in the grayscale image is obtained.
[0103] Step S105: Based on the compensation distance of each pixel in the grayscale image, the grayscale image is segmented into regions to obtain lesion regions. Based on the lesion regions, the leaves of the flowers to be monitored are subjected to monitoring and control treatment for flower diseases and pests.
[0104] Furthermore, the compensation distance of each pixel in the grayscale image is used as the distance after distance transformation of each pixel when performing region segmentation of the grayscale image using the watershed algorithm. This allows for region segmentation of the grayscale image to obtain lesion regions. Then, based on the lesion regions, the morphological characteristics and distribution parameters of the lesions are calculated, establishing a quantitative assessment system for the severity of the disease. This provides a reliable quantitative basis for monitoring and control decisions of flower diseases and pests, enabling the monitoring and control of flower diseases and pests on the leaves of the flowers to be monitored.
[0105] It is worth noting that the key point of this embodiment of the invention lies in: filtering out false boundaries in grayscale images, and performing adaptive distance compensation for each pixel when using the watershed algorithm to segment the grayscale image, thereby obtaining a complete lesion region. Using the watershed algorithm for region segmentation, and calculating the morphological characteristics and distribution parameters of lesions based on the lesion region to establish a quantitative assessment system for the severity of the disease, are existing technologies and will not be elaborated upon here.
[0106] In summary, in this embodiment of the invention, leaf vein feature indicators are obtained to reflect the structural features of candidate pseudo-boundaries and the gray-scale distribution features of nearby pixels. A preliminary analysis is conducted to determine whether the candidate pseudo-boundaries conform to the leaf vein boundaries within the lesion area. This is then combined with the macroscopic directional distribution features of the leaf veins to further analyze whether the candidate pseudo-boundaries are indeed pseudo-boundaries. Adaptive distance compensation is applied to the initial distance to obtain a compensated distance, ensuring that the true lesion area spanning the leaf veins maintains continuity in the distance map. This ensures that the watershed algorithm can identify the complete core area of the lesion, preventing the core area from being truncated and fragmented, achieving complete lesion segmentation, and providing a reliable quantitative basis for monitoring and controlling flower diseases and pests.
[0107] The above embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included within the protection scope of the present invention.
Claims
1. A method for monitoring flower diseases and insect pests based on machine vision, characterized in that, The method comprises the following steps: Collecting an initial image of a flower leaf to be monitored, and performing grayscale processing on the initial image to obtain a grayscale image; Performing edge detection on the grayscale image to obtain a candidate pseudo-boundary set, obtaining a local analysis area of any candidate pseudo-boundary in the candidate pseudo-boundary set, and obtaining a leaf vein feature index of the any candidate pseudo-boundary according to the grayscale distribution characteristics of the pixel points in the local analysis area and the linear structure characteristics of the any candidate pseudo-boundary; Obtaining the leaf vein feature index of each candidate pseudo-boundary in the candidate pseudo-boundary set, and screening at least one pseudo-boundary from the candidate pseudo-boundary set according to the leaf vein feature index and the direction characteristics of each candidate pseudo-boundary; In the process of performing region segmentation on the grayscale image by using a watershed algorithm, obtaining an initial distance of each pixel point in the grayscale image after distance transformation, and performing adaptive distance compensation on the initial distance of each pixel point according to the positional relationship between each pixel point and each pseudo-boundary to obtain a compensated distance; Performing region segmentation on the grayscale image according to the compensated distance of each pixel point in the grayscale image to obtain a lesion area, and performing monitoring and control processing on the flower leaf to be monitored according to the lesion area. The method comprises the following steps: According to the grayscale distribution characteristics of the pixel points in the local analysis area, obtaining a first leaf vein feature index of the any candidate pseudo-boundary; According to the linear structure characteristics of the any candidate pseudo-boundary, obtaining a second leaf vein feature index of the any candidate pseudo-boundary; Performing normalization processing on the first leaf vein feature index to obtain a first normalized result, performing normalization processing on the second leaf vein feature index to obtain a second normalized result, and performing weighted summation on the first normalized result and the second normalized result to obtain the leaf vein feature index of the any candidate pseudo-boundary; The method comprises the following steps: For any pixel point, obtaining a candidate pseudo-boundary closest to the any pixel point in the candidate pseudo-boundary set, denoted as the nearest boundary, if the nearest boundary is a pseudo-boundary, obtaining the distance between the any pixel point and the nearest boundary, denoted as the nearest distance, and compensating the initial distance of the any pixel point by using the nearest distance to obtain the compensated distance of the any pixel point; If the nearest boundary is not a pseudo-boundary, the initial distance of the any pixel point is taken as the compensated distance of the any pixel point.
2. The method of claim 1, wherein the method comprises: The method comprises the following steps: According to the grayscale distribution characteristics of the pixel points in the local analysis area, obtaining a first leaf vein feature index of the any candidate pseudo-boundary; Dividing the pixels in the local analysis region by the any candidate pseudo-boundary into candidate pseudo-boundary pixels, left-side pixels and right-side pixels, obtaining the absolute value of the difference between the average gray value of all candidate pseudo-boundary pixels and the average gray value of all left-side pixels, denoted as left-side gray difference value, obtaining the absolute value of the difference between the average gray value of all candidate pseudo-boundary pixels and the average gray value of all right-side pixels, denoted as right-side gray difference value, and obtaining the inverse of the absolute value of the difference between the left-side gray difference value and the right-side gray difference value by substituting it into an exponential function with a natural constant as the base number, to obtain the first vein feature index of the any candidate pseudo-boundary. 3.The flower disease and pest monitoring method based on machine vision of claim 1, wherein, The second vein feature index of the any candidate pseudo-boundary is obtained according to the linear structure feature of the any candidate pseudo-boundary, and the method comprises the following steps: Taking any endpoint of the any candidate pseudo-boundary as a starting point, the pixels in the any candidate pseudo-boundary are sorted, and the eight-direction chain code of each pixel in the any candidate pseudo-boundary except the first pixel is obtained to form a chain code sequence; According to the chain code sequence, the mutation pixels of the any candidate pseudo-boundary are obtained, the proportion of the number of the mutation pixels in the any candidate pseudo-boundary is calculated to obtain a mutation point proportion, and the difference between the constant 1 and the mutation point proportion is obtained to obtain the second vein feature index of the any candidate pseudo-boundary. 4.The method of claim 3, wherein the method further comprises: The mutation pixels of the any candidate pseudo-boundary are obtained according to the chain code sequence, and the method comprises the following steps: For any chain code data in the chain code sequence except the last chain code data, the absolute value of the difference between the any chain code data and the next chain code data thereof is obtained to obtain a first direction difference value, and the difference between the constant 8 and the direction difference value is obtained to obtain a second direction difference value; A direction difference threshold is set, the minimum value of the first direction difference value and the second direction difference value is obtained, and if the minimum value is greater than the direction difference threshold, the pixel corresponding to the any chain code data is determined as a mutation pixel. 5.The method of claim 1, wherein the method further comprises: The at least one pseudo-boundary is obtained by screening from the candidate pseudo-boundary set according to the vein feature index and the direction feature of each candidate pseudo-boundary, and the method comprises the following steps: A vein feature index threshold is set, and candidate pseudo-boundaries with a vein feature index greater than or equal to the vein feature index threshold are screened from all candidate pseudo-boundaries as suspected vein boundaries; The vein confidence of each suspected vein boundary is obtained according to the direction feature of each suspected vein boundary. A vein confidence threshold is set, and suspected vein boundaries with a vein confidence greater than or equal to the vein confidence threshold are screened from all suspected vein boundaries as pseudo-boundaries.
6. The method of claim 5, wherein the method further comprises: The vein confidence of each suspected vein boundary is obtained according to the direction feature of each suspected vein boundary, and the method comprises the following steps: For any suspected vein boundary, the direction corresponding to the chain code data with the highest frequency in the chain code sequence of the any suspected vein boundary is determined as the main direction of the any suspected vein boundary; The main direction of each suspected vein boundary is obtained, and a direction histogram is constructed, wherein the horizontal coordinate of the direction histogram is a direction interval, and the vertical coordinate of the direction histogram is the frequency corresponding to the direction interval. In the direction histogram, a frequency corresponding to a direction interval in which the main direction of the any suspected leaf vein boundary is located is obtained, and is recorded as an interval frequency of the any suspected leaf vein boundary. A ratio of the interval frequency to a number of all suspected leaf vein boundaries is obtained, and a leaf vein confidence of the any suspected leaf vein boundary is obtained.
7. The method of claim 1, wherein the method further comprises: determining a type of the flower disease or the flower pest based on the at least one feature of the flower disease or the flower pest. The initial distance of the any pixel point is compensated by using the nearest distance to obtain a compensated distance of the any pixel point, and the method comprises the following steps of: A product of the nearest distance and a preset distance compensation coefficient is obtained, an addition result of a constant 1 and the product is calculated to obtain a distance compensation weight, and a product of the distance compensation weight and the initial distance is obtained to obtain the compensated distance of the any pixel point. 8.The method of claim 1, wherein the method further comprises: determining a type of the flower disease or the flower pest based on the at least one feature of the flower disease or the flower pest. The local analysis region of the any candidate false boundary is obtained, and the method comprises the following steps of: A morphological dilation operation is performed on the any candidate false boundary to obtain the local analysis region of the any candidate false boundary.
Citation Information
Patent Citations
Segmentation method and device of protected vegetable clear-edge leaf surface disease spots
CN106127735A
Method for detecting degree of plant diseases and insect pests of plant leaves based on optimal segmentation
CN115908371A