A tea disease identification and detection method based on image processing
Patent Information
- Application Number
- CN202611233611.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-14
- Publication Date
- 2026-10-27
AI Technical Summary
[0003]但是,现有茶叶病害图像识别技术在自然光环境下仍存在检测准确性不足的问题
本发明通过在自然光环境下采集茶叶叶片图像后进行预处理,并进一步提取亮度通道、绿色优势通道和饱和度通道,构建叶片光照参考图和阴影补偿图,能够针对茶叶叶片图像中常见的光照不均、阴影遮挡和叶面反光问题进行针对性校正。与直接对原始图像进行阈值分割或分类识别的方式相比,本发明能够在病害识别前先提高叶片图像的亮度一致性和颜色稳定性,降低自然光变化、背景颜色干扰以及阴影残留对叶片分割结果的影响,使茶叶叶片候选分割图和茶叶有效叶片区域图像更加完整、准确。
Smart Images

Figure CN122990402A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of tea disease identification and detection technology, and in particular to a tea disease identification and detection method based on image processing. Background Technology
[0002] In recent years, with the development of agricultural informatization, machine vision, image processing, and deep learning technologies, the automatic identification of tea diseases using leaf images has gradually become an important direction for tea garden disease monitoring. Current technologies typically acquire tea leaf images via mobile phones, cameras, or drones, then perform image resizing, noise reduction, enhancement, and color space conversion. Methods such as threshold segmentation, edge detection, texture analysis, color statistics, or convolutional neural networks are then used to identify lesion areas in the leaves. Based on the color, area, texture, and morphological characteristics of the lesions, it is determined whether the tea is diseased and what type of disease it belongs to. Some solutions also combine classification models to output disease identification results for anthracnose, tea cake disease, tea cloud leaf blight, and tea ring spot, to assist in tea garden inspections and disease control.
[0003] However, existing tea disease image recognition technologies still suffer from insufficient detection accuracy under natural light conditions. On one hand, tea leaf images are easily affected by uneven lighting, shadows, leaf surface reflections, and background clutter. Existing methods often employ simple enhancement or threshold segmentation, making it difficult to accurately distinguish between effective leaf areas, residual background areas, and leaf edge shadow areas, leading to unstable extraction of lesion candidate regions. On the other hand, existing methods typically rely on single color differences or lesion area for judgment, lacking joint representation of lesion color shifts, texture roughness, edge abrupt changes, and diffusion patterns, making it difficult to form reliable responses for suspected lesions. Furthermore, ordinary classification models underutilize local lesion details, cross-regional diffusion status, and spatial distribution characteristics, affecting the comprehensive accuracy of disease type, location, and severity identification. Summary of the Invention
[0004] One objective of this invention is to propose a tea disease identification and detection method based on image processing. This invention fully utilizes image enhancement, multidimensional lesion feature fusion, and MaxViT intelligent lesion recognition technology. It describes in detail a method for accurate separation of effective leaf areas and suspected lesion areas of tea leaves under natural light interference conditions, as well as a method for disease classification and detection. It has the advantages of strong resistance to light interference, accurate lesion localization, stable identification results, and high disease detection accuracy.
[0005] A tea disease identification and detection method based on image processing according to an embodiment of the present invention includes the following steps: Images of tea leaves under natural light conditions were collected and preprocessed to generate an enhanced image set of tea leaves; The brightness channel, green dominance channel, and saturation channel of the tea leaf enhancement image set are extracted to generate a leaf illumination reference map and a shadow compensation map; The tea leaf enhancement image set was corrected based on the shadow compensation map, and candidate segmentation maps of tea leaves were generated by combining background color differences, leaf edge continuity and leaf body connectivity. Contour correction and interference removal are performed on the candidate segmentation images of tea leaves to generate images of the effective tea leaf regions. Within the effective leaf area image of tea, calculate the color shift value, texture roughness value, local edge mutation value, and regional diffusion morphology value of lesions, and fuse them to generate a response map of suspected lesions. Based on the response map of suspected lesions and the image of effective leaf area of tea, joint constraint segmentation is performed to generate candidate region images of tea lesions; Disease image features are extracted from candidate regions of tea lesions. These features are then input into the MaxViT model for lesions. Through local window attention, multi-axis grid attention, and multi-scale feature aggregation, tea disease identification and detection results are generated.
[0006] Optionally, the preprocessing includes image format unification, image size normalization, white balance correction, color correction, noise suppression, edge preservation enhancement, brightness equalization, reflection suppression, and shadow weakening.
[0007] Optionally, the generation of the leaf illumination reference map and shading compensation map includes: Each tea leaf enhanced image in the tea leaf enhanced image set is converted to Lab color space and HSV color space. The L component is extracted from the Lab color space to generate the luminance channel, and the S component is extracted from the HSV color space to generate the saturation channel. Based on the enhanced image of tea leaves, the difference between the G channel and the R and B channels in the RGB three-channel calculation is used to generate the green dominant channel; Based on the green dominance channel and saturation channel, the green stable region of the leaf is screened, and the local mean value of the brightness channel is calculated within the green stable region of the leaf to generate a local brightness distribution map of the leaf. The local brightness distribution map of the leaf is smoothed and normalized to generate a leaf illumination reference map, and the brightness value corresponding to each pixel position in the leaf illumination reference map is used as the reference brightness value. The difference between the brightness channel and the leaf illumination reference image is calculated, and the continuous low brightness area is marked to generate a shadow area marking image. The brightness compensation intensity is calculated based on the shaded area marker map and the leaf illumination reference map to generate a shaded compensation map.
[0008] Optionally, the generation of the candidate segmentation map of the tea leaves includes: The shadow compensation image and the tea leaf enhancement image set are matched according to the image number and pixel coordinates. Brightness compensation is performed on the corresponding pixels in the shadow area, and the original brightness value is maintained for the corresponding pixels in the non-shaded area to generate a light-corrected leaf image. Based on the color distribution of the image edge background region in the light-corrected leaf image, the color difference between each pixel position and the image edge background region is calculated to generate a background color difference map; Edge response extraction and broken edge connection are performed on the illumination-corrected leaf image to generate a leaf edge continuity map; Connectivity analysis is performed on the candidate pixels of the blade defined by the background color difference map and the blade edge continuity map. The continuous regions corresponding to the main body of the blade are retained to generate the main body connectivity map of the blade. The background color difference map, leaf edge continuity map, and leaf body connectivity map are matched at the pixel level to remove residual background and shadow areas, generating candidate segmentation maps of tea leaves.
[0009] Optionally, the generation of the effective leaf area image of the tea leaves includes: The candidate segmentation image of tea leaves is binarized to obtain leaf marker pixels and background marker pixels. Closed boundaries are extracted along the outside of leaf marker pixels to generate the initial outline of the leaf. The initial blade outline is scanned at breakpoints, and the outline gaps are connected based on the consistency of direction and distance between adjacent boundary points to generate the outline completion result. The contour completion result is smoothed by adjusting the sharp protruding boundaries and concave defect boundaries to the extension direction of the adjacent boundaries to generate the contour correction result. Holes are filled based on the leaf marker pixels inside the contour correction result to generate a complete leaf region; Connectivity analysis is performed on the complete leaf area. Background residual areas, shadow areas on the outer edge of the leaf, and discrete noise areas are removed according to the area of the connected regions, the center position of the regions, and the integrity of the boundaries. The continuous regions corresponding to the main body of the leaf are retained to generate an image of the effective leaf area of tea.
[0010] Optionally, the generation of the suspected lesion response map includes: The effective leaf area image of tea is divided into multiple local analysis windows, and the pixel coordinate correspondence between each local analysis window and the effective leaf area image of tea is preserved. The color shift value of the lesion is calculated based on the difference between the pixel color value in each local analysis window and the color value of the green stable area of the leaf. The texture roughness value is calculated based on the gray-level change amplitude, texture direction change, and local gray-level dispersion within each local analysis window. The local edge abruptness value is calculated based on the difference between the edge response intensity within each local analysis window and the edge response intensity of adjacent local analysis windows; The region diffusion morphology value is calculated based on the connectivity, extension direction, and outer boundary of color aberration pixels and texture aberration pixels within adjacent local analysis windows. The lesion color offset value, texture roughness value, local edge mutation value, and regional diffusion morphology value are normalized and then fused with equal weights to generate a suspected lesion response map.
[0011] Optionally, the generation of the candidate region image for tea lesions includes: The suspected lesion response map is matched with the effective leaf area image of tea according to the image number and pixel coordinates, and a leaf area mask is generated based on the effective leaf area image of tea. The response values in the suspected lesion response map are sorted in ascending order to determine the median and upper quartile of the response values. The response span value is obtained by subtracting the median of the response value from the upper quartile. The lesion response boundary value is obtained by adding half of the response span value to the upper quartile. The pixel position whose response value is greater than the lesion response threshold and is located inside the leaf area mask is marked as the initial lesion pixel; Connectivity analysis is performed on the initial pixels of the lesion to remove discrete regions located on the outer edge of the leaf, the shadow position of the leaf edge, and the residual background position, thus generating the initial region of the lesion. The fracture boundary is connected according to the outer boundary of the initial lesion area, the adjacent initial lesion areas are merged, and the corresponding pixels of the merged area are extracted from the effective leaf area image of tea to generate a candidate area image of tea lesion.
[0012] Optionally, the generation of the tea disease identification and detection results includes: The color distribution, texture distribution, boundary morphology, and spatial distribution of lesions in the candidate region images of tea lesions are organized to generate disease image features; The disease image features are input into the lesion MaxViT model, which includes a lesion feature embedding layer, a local window attention layer, a multi-axis grid attention layer, a multi-scale feature aggregation layer, and a disease classification output layer. In the lesion feature embedding layer, the lesion image features are divided into feature blocks and mapped to the initial feature sequence; In the local window attention layer, the intra-window correlation of the initial feature sequence is calculated to generate local lesion features; In the multi-axis mesh attention layer, the local lesion features are correlated and calculated along the horizontal, vertical and cross directions to generate global lesion features; In the multi-scale feature aggregation layer, local lesion features and global lesion features at different levels are fused to generate disease discrimination features; In the disease classification output layer, the disease discrimination features are classified and processed to generate tea disease identification and detection results that include disease type, disease location, disease severity, and identification confidence.
[0013] The beneficial effects of this invention are: This invention preprocesses tea leaf images acquired under natural light conditions, extracting brightness, green dominance, and saturation channels to construct a leaf illumination reference map and a shadow compensation map. This allows for targeted correction of common problems in tea leaf images, such as uneven lighting, shadow occlusion, and leaf surface reflection. Compared to directly performing threshold segmentation or classification on the original image, this invention improves the brightness consistency and color stability of the leaf image before disease identification, reducing the impact of natural light variations, background color interference, and residual shadows on the leaf segmentation results. This results in more complete and accurate candidate segmentation maps and images of effective leaf areas.
[0014] This invention generates candidate segmentation images of tea leaves by combining background color differences, leaf edge continuity, and leaf body connectivity. Further contour correction, hole filling, and interference removal are then performed, effectively separating the effective leaf area from the background residual area, the shadow area on the outer edge of the leaf, and discrete noise areas, thus improving the effective analytical range for lesion detection. Furthermore, this invention comprehensively calculates lesion color shift values, texture roughness values, local edge abrupt change values, and regional diffusion morphology values within the effective leaf area image of the tea leaf, and fuses these values to generate a suspected lesion response map. This allows lesion detection to no longer rely on a single color or area feature, but instead simultaneously reflect lesion color changes, texture changes, boundary changes, and diffusion morphology, improving the stability and reliability of suspected lesion region localization.
[0015] This invention uses joint constraint segmentation of suspected lesion response maps and effective leaf area images of tea leaves to limit candidate lesion regions to the effective leaf area, reducing the misidentification of background residue, leaf edge shadows, and invalid blank areas as lesions. Furthermore, by inputting disease image features into the lesion MaxViT model and processing them through local window attention, multi-axis grid attention, and multi-scale feature aggregation, it can simultaneously utilize local lesion details, cross-regional correlations, and spatial distribution information to improve the comprehensive accuracy of identifying tea disease type, location, severity, and identification confidence, providing more stable data support for tea garden disease inspection, early warning, and precision control. Attached Figure Description
[0016] The accompanying drawings are provided to further illustrate the invention and form part of the specification. They are used in conjunction with embodiments of the invention to explain the invention and do not constitute a limitation thereof. In the drawings: Figure 1 This is an overall flowchart of the tea disease identification and detection method based on image processing proposed in this invention; Figure 2 This is a schematic diagram illustrating the generation of candidate segmentation images for tea leaves in a tea disease identification and detection method based on image processing proposed in this invention. Figure 3 This diagram illustrates the generation of tea disease identification and detection results using an image processing-based tea disease identification and detection method proposed in this invention. Detailed Implementation
[0017] The present invention will now be described in further detail with reference to the accompanying drawings. These drawings are simplified schematic diagrams, illustrating only the basic structure of the invention, and therefore only show the components relevant to the invention.
[0018] refer to Figures 1-3 A method for identifying and detecting tea diseases based on image processing, comprising the following steps: Images of tea leaves under natural light conditions were collected and preprocessed to generate an enhanced image set of tea leaves; The brightness channel, green dominance channel, and saturation channel of the tea leaf enhancement image set are extracted to generate a leaf illumination reference map and a shadow compensation map; The tea leaf enhancement image set was corrected based on the shadow compensation map, and candidate segmentation maps of tea leaves were generated by combining background color differences, leaf edge continuity and leaf body connectivity. Contour correction and interference removal are performed on the candidate segmentation images of tea leaves to generate images of the effective tea leaf regions. Within the effective leaf area image of tea, calculate the color shift value, texture roughness value, local edge mutation value, and regional diffusion morphology value of lesions, and fuse them to generate a response map of suspected lesions. Based on the response map of suspected lesions and the image of effective leaf area of tea, joint constraint segmentation is performed to generate candidate region images of tea lesions; Disease image features are extracted from candidate regions of tea lesions. These features are then input into the MaxViT model for lesions. Through local window attention, multi-axis grid attention, and multi-scale feature aggregation, tea disease identification and detection results are generated.
[0019] In this embodiment, preprocessing includes image format unification, image size normalization, white balance correction, color correction, noise suppression, edge preservation enhancement, brightness equalization, reflection suppression, and shadow weakening.
[0020] In the specific implementation process, images of tea leaves under natural light were captured using a mobile phone camera. The captured resolution was 1920×1080 pixels, and the image format was JPG. The captured tea leaf images were uniformly converted into RGB three-channel images, and the image size was normalized to 1024×1024 pixels, maintaining the aspect ratio of the leaves. Edge gaps were filled with the average background value. White balance correction was performed on the size-normalized images. The average gray values of the R, G, and B channels were calculated and adjusted to the same grayscale reference to reduce the influence of natural light color cast. Color correction was then performed on the white balance-corrected images. The RGB color space was converted to the Lab color space, the L channel was luminance adjusted, and the a and b channels were color shift corrected to concentrate the color distribution of the green areas of the tea leaves within a stable range. Noise suppression was performed on the color-corrected images using a 3×3 median filter to remove isolated noise points. Bilateral filtering was used to preserve leaf edges and lesion boundaries. The bilateral filtering window diameter was set to 5, the color domain parameter to 45, and the spatial domain parameter to 45. Edge preservation enhancement was applied to the noise-suppressed image using an unsharpened mask to enhance leaf texture and lesion edges. The enhancement coefficient was set to 1.2, and the blur kernel size was 5×5. Brightness equalization was then applied to the edge-preserving enhanced image using contrast-limited adaptive histogram equalization of the L channel. The block size was set to 8×8, and the contrast limit parameter was set to 2.0 to reduce locally dark and locally bright areas. Reflection suppression was applied to the brightness-equalized image by identifying bright areas in the L channel with a gray value greater than 230 and a saturation lower than 0.18. The brightness values of these bright areas were replaced with the average of their surrounding 5×5 neighborhood values. Shadow weakening was applied to the image after reflection suppression by identifying areas in the L channel with a gray value lower than 80 and a continuous distribution of green dominant channel response. Brightness compensation was applied to these areas with a compensation coefficient of 1.15, generating an enhanced tea leaf image set. In this embodiment, the generation of the leaf illumination reference image and the shading compensation image includes: Each enhanced tea leaf image in the tea leaf image set is converted to the Lab and HSV color spaces. The L component is extracted from the Lab color space to generate the luminance channel, and the S component is extracted from the HSV color space to generate the saturation channel. Specifically, the red, green, and blue channels of the enhanced tea leaf images are uniformly converted to standard value ranges and mapped to the Lab color space according to color space conversion rules, resulting in luminance, red-green, and yellow-blue color components with the same dimensions as the original image. The luminance components are retained in the Lab color space and rearranged according to the pixel positions of the original image to form a luminance channel, ensuring each pixel position has a corresponding luminance value. The red, green, and blue channels of the enhanced tea leaf images are mapped to the HSV color space, resulting in hue, saturation, and lightness components with the same dimensions as the original image. The saturation components are retained in the HSV color space and rearranged according to the pixel positions of the original image to form a saturation channel, ensuring each pixel position has a corresponding color saturation level. Based on the enhanced image of tea leaves, the difference between the G channel and the R and B channels in the RGB three-channel calculation is used to generate the green dominant channel; The generation of the green dominant channel is specifically as follows: The red, green, and blue channels in the enhanced tea leaf image are processed pixel-by-pixel to obtain the corresponding red, green, and blue channel values for each pixel location. Using the green channel value as a baseline, the differences between the green channel value and the red channel value, as well as the differences between the green channel value and the blue channel value, are calculated to obtain red-green and blue-green difference results. These results are then processed at the same scale, removing negative responses to suppress the green dominance of pixels. The retained positive difference results are weighted and merged to form the green dominant response for each pixel location. The green dominant response is normalized to ensure a uniform value scale across different enhanced tea leaf images. The normalized green dominant response is then smoothed over a small area to reduce local abrupt changes caused by isolated noise points. Finally, the smoothed green dominant response is rearranged according to the original image pixel coordinates to generate a green dominant channel with the same size as the enhanced tea leaf image, while retaining the image number and pixel coordinate correspondence between the green dominant channel and the enhanced tea leaf image. Based on the green dominance channel and saturation channel, the green stable region of the leaf is screened, and the local mean value of the brightness channel is calculated within the green stable region of the leaf to generate a local brightness distribution map of the leaf. The generation of the leaf local brightness distribution map is specifically as follows: The green dominance channel and saturation channel are normalized to obtain normalized green dominance response and normalized saturation response; the median of the normalized green dominance response is calculated, and pixel positions greater than or equal to the median are designated as green dominance candidate pixels; the lower quartile and upper quartile of the normalized saturation response are calculated, and pixel positions greater than or equal to the lower quartile and less than or equal to the upper quartile are designated as saturation stable candidate pixels; pixel positions that simultaneously belong to both green dominance candidate pixels and saturation stable candidate pixels are marked as initial green stable pixels; connected component analysis is performed on the initial green stable pixels to remove isolated points and small-area broken regions, and morphological closure processing is applied to adjacent regions. A stable green region for the leaf is generated. A fixed-size local statistical window is set within the stable green region, and the brightness values of pixels belonging to the stable green region within the window are counted using the center pixel of the window as the statistical position. The average brightness value is then written to the center pixel of the window. When the local statistical window extends beyond the boundary of the stable green region, only the brightness values of pixels belonging to the stable green region within the window are used for counting. When there are no pixels belonging to the stable green region within the window, the average brightness value of the nearest stable green region is used to fill the window. The average brightness values corresponding to all pixel positions are arranged according to the original image spatial position to generate a local brightness distribution map of the leaf, and the pixel coordinate correspondence between the local brightness distribution map of the leaf and the enhanced image of the tea leaf is preserved. The local brightness distribution map of the leaf is smoothed and normalized to generate a leaf illumination reference map, and the brightness value corresponding to each pixel position in the leaf illumination reference map is used as the reference brightness value. The difference between the brightness channel and the leaf illumination reference image is calculated, and the continuous low brightness area is marked to generate a shadow area marking image. The generation of the shaded area marker map is specifically as follows: The brightness channel and the leaf illumination reference image are mapped pixel-by-pixel according to image number and pixel coordinates. For each pixel position, the actual brightness value in the brightness channel and the reference brightness value in the leaf illumination reference image are obtained. The difference between the reference brightness value and the actual brightness value is calculated to generate a brightness difference value. The brightness difference values of all pixel positions are normalized, and the normalized brightness difference values are sorted in ascending order to determine the median and upper quartile of the normalized brightness difference values. The median is subtracted from the upper quartile to obtain the quartile range. The brightness difference is calculated by adding the upper quartile to the half-quartile span value to obtain the low brightness screening threshold. Pixels with normalized brightness difference values greater than the low brightness screening threshold are marked as low brightness candidate pixels. Connectivity analysis is performed on the low brightness candidate pixels to remove isolated pixels and small discrete regions, retaining low brightness regions continuously distributed along the blade surface. Morphological closure processing is performed on the retained low brightness regions to connect the broken boundaries into continuous boundaries. The morphologically closed low brightness regions are written into a binary label map according to their original image spatial positions to generate a shadow region label map. The brightness compensation intensity is calculated based on the shaded area marker map and the leaf illumination reference map to generate a shaded compensation map.
[0021] The calculation of brightness compensation intensity is as follows: The shadow area marker image, leaf illumination reference image, and brightness channel are mapped according to pixel coordinates. The shadow marking state, reference brightness value, and actual brightness value are obtained pixel by pixel. For pixels marked as shadow areas in the shadow area marker image, the brightness difference between the reference brightness value and the actual brightness value is calculated. The ratio of this brightness difference to the reference brightness value is then used to calculate the initial compensation ratio for that pixel. A threshold limit is applied to the initial compensation ratio: initial compensation ratios below the lower compensation limit are adjusted to the lower compensation limit; initial compensation ratios above the upper compensation limit are adjusted to the upper compensation limit; and initial compensation ratios between the lower and upper compensation limits remain unchanged, resulting in a restricted compensation ratio. The lower compensation limit is determined by the lower quartile of the initial compensation ratio within the shadow area, and the upper compensation limit is determined by the upper quartile of the initial compensation ratio within the shadow area. The restricted compensation ratio is multiplied by the reference brightness value to obtain the brightness compensation intensity for that pixel. For pixels not marked as shadow areas in the shadow area marker image, the brightness compensation intensity is set to zero.
[0022] In this embodiment, the generation of candidate segmentation images for tea leaves includes: The shadow compensation image and the tea leaf enhancement image set are matched according to the image number and pixel coordinates. Brightness compensation is performed on the corresponding pixels in the shadow area, and the original brightness value is maintained for the corresponding pixels in the non-shaded area to generate a light-corrected leaf image. The generation of the light-corrected leaf image is as follows: the shadow compensation image and the tea leaf enhancement image set are matched pixel by pixel according to the image number and pixel coordinates. The brightness compensation intensity and original brightness value corresponding to each pixel position are obtained. For the pixel positions marked as shadow areas in the shadow area marking image, the original brightness value is added to the brightness compensation intensity to obtain the compensated brightness value. The compensated brightness value is limited to the effective grayscale range of the image. For the pixel positions not marked as shadow areas, the original brightness value is retained. The pixel coordinates and color channel positions are kept unchanged to generate the light-corrected leaf image. Based on the color distribution of the image edge background region in the light-corrected leaf image, the color difference between each pixel position and the image edge background region is calculated to generate a background color difference map; The background color difference map is generated as follows: the edge background region is determined based on the image boundary position of the illumination-corrected leaf image. The width of the edge background region is determined according to 5% of the image width. The color mean, color variance, and color distribution range of the pixels in the edge background region are statistically analyzed. The color value of each pixel position in the illumination-corrected leaf image is compared with the color mean of the edge background region. The difference is then normalized by combining the color variance. The color difference results are arranged according to pixel coordinates to generate the background color difference map. Edge response extraction and broken edge connection are performed on the illumination-corrected leaf image to generate a leaf edge continuity map; The generation of the blade edge continuity map is as follows: Gradient response calculation is performed on the illumination-corrected blade image to obtain the edge response value at each pixel location; the edge response values at all pixel locations are normalized, and the normalized edge response values are sorted in ascending order to determine the median and upper quartile of the edge response value distribution; the median is subtracted from the upper quartile to obtain the edge response span value; half of the edge response span value is added to the upper quartile to obtain the edge response threshold; pixel locations with normalized edge response values greater than the edge response threshold are marked as initial edge pixels; directional continuity is determined for the initial edge pixels, and initial edge pixels continuously distributed along the blade's outer contour are retained to obtain the blade contour edge pixels; neighborhood extension processing is performed on the break points between adjacent blade contour edge pixels, connecting blade contour edge pixels whose break distance is within the neighborhood connection range and whose extension direction is consistent; morphological closure processing is performed on the connected blade contour edge pixels to form a continuous boundary around the blade's outer contour, generating the blade edge continuity map. Connectivity analysis is performed on the candidate pixels of the blade defined by the background color difference map and the blade edge continuity map. The continuous regions corresponding to the main body of the blade are retained to generate the main body connectivity map of the blade. The background color difference map, leaf edge continuity map, and leaf body connectivity map are matched at the pixel level to remove residual background and shadow areas, generating candidate segmentation maps of tea leaves.
[0023] In this embodiment, the generation of the effective leaf area image of tea includes: The candidate segmentation image of tea leaves is binarized to obtain leaf marker pixels and background marker pixels. Closed boundaries are extracted along the outside of leaf marker pixels to generate the initial outline of the leaf. The binarization process is as follows: Candidate segmentation images of tea leaves are imported according to their image numbers, ensuring consistency with the pixel coordinates of the illumination-corrected leaf image. When the candidate segmentation image already contains leaf and background markers, the leaf markers are uniformly set to 1, and the background markers are uniformly set to zero. When the candidate segmentation image is stored in grayscale response format, all pixel response values are sorted in ascending order, and the median between the median and the upper quartile is taken as the binarization threshold. Pixels with values greater than or equal to the threshold are designated as leaf marker pixels, and pixels with values less than the threshold are designated as background marker pixels, generating a leaf binary mask. An eight-neighborhood scan is then performed on the leaf binary mask, and the eight-neighborhood scan is performed... Leaf marker pixels with background marker pixels in their neighborhood are recorded as candidate boundary pixels, and leaf marker pixels with eight neighboring leaf marker pixels are recorded as internal leaf pixels. Among the candidate boundary pixels, the pixel with the smallest ordinate and the smallest abscissa is selected as the starting point for boundary tracking. Adjacent candidate boundary pixels are searched in a clockwise direction and the boundary direction is recorded to form an outer boundary chain. When there is a short-distance break in the outer boundary chain, connecting pixels are added according to the extension direction of the candidate boundary pixels at both ends of the break to close the outer boundary chain. The closed outer boundary chain is written into the contour map, and the internal area of the outer boundary chain is marked as the internal area of the leaf, and the external area of the outer boundary chain is marked as the background area to generate the initial contour of the leaf. The initial blade outline is scanned at breakpoints, and the outline gaps are connected based on the consistency of direction and distance between adjacent boundary points to generate the outline completion result. The specific steps for generating the contour completion result are as follows: Generate a sequence of boundary points in a clockwise order for the outer boundary chain in the initial blade contour; calculate the pixel distance and boundary direction between adjacent boundary points one by one; sort all adjacent boundary points in ascending order, take the median pixel distance as the baseline boundary spacing, and mark the positions where the pixel distance between adjacent boundary points is greater than twice the baseline boundary spacing as candidate breakpoint positions; select three consecutive boundary points on both sides of each candidate breakpoint position, calculate the extension direction of the boundary before and after the breakpoint, and ensure that the angle between the extension directions of the two sides is no greater than 30 degrees. When the distance between breakpoints is no greater than eight times the distance between the reference boundaries, the candidate breakpoint position is determined as the contour gap position. Paths to be connected are generated along the extension direction of the front boundary of the breakpoint and the reverse extension direction of the rear boundary of the breakpoint. When two paths to be connected intersect, connecting pixels are added according to the intersection position. When two paths to be connected do not intersect, connecting pixels are added according to the straight line interpolation between the boundary points at both ends of the contour gap position. Duplicate points are removed and the order is rearranged on the outer boundary chain after adding connecting pixels, so that the sequence of boundary points after connection is continuously arranged along the outer contour of the blade, and the contour completion result is generated. The contour completion result is smoothed by adjusting the sharp protruding boundaries and concave defect boundaries to the extension direction of the adjacent boundaries to generate the contour correction result. The specific steps for generating the contour correction result are as follows: The outer boundary chain in the contour completion result is locally scanned according to the boundary point arrangement order. For each current boundary point, the same number of adjacent boundary points are selected on both sides. The extension direction of the front boundary, the extension direction of the rear boundary, and the deviation distance of the current boundary point relative to the line connecting the two boundary points are calculated. All boundary point deviation distances are sorted in ascending order, and the median and upper quartile of the deviation distance are taken. The deviation span value is obtained by subtracting the median deviation distance from the upper quartile. The abnormal deviation boundary value is obtained by adding half of the deviation span value to the upper quartile. Edges with deviation distances greater than the abnormal deviation boundary value and whose outward convex direction points towards the outside of the blade are identified. The boundary segment is marked as a sharp protruding boundary. Boundary segments with a deviation distance greater than the abnormal deviation boundary value and an inward concavity pointing towards the inside of the blade are marked as concave defect boundaries. Straight line interpolation or arc interpolation is performed on the adjacent stable boundary points at both ends of the sharp protruding boundary to replace the abnormal boundary points in the sharp protruding boundary. Smooth connection points are added to the adjacent stable boundary points at both ends of the concave defect boundary according to the boundary extension direction to fill the concave defect position. The replacement and added boundary point sequence is subjected to duplicate point removal, sequential rearrangement, and small window mean smoothing to make the corrected outer boundary chain continuously transition along the outer contour of the blade. The corrected outer boundary chain is written into the contour map to generate the contour correction result. Holes are filled based on the leaf marker pixels inside the contour correction result to generate a complete leaf region; Connectivity analysis is performed on the complete leaf area. Background residual areas, shadow areas on the outer edge of the leaf, and discrete noise areas are removed according to the area of the connected regions, the center position of the regions, and the integrity of the boundaries. The continuous regions corresponding to the main body of the leaf are retained to generate an image of the effective leaf area of tea.
[0024] The generation of the effective leaf region image of tea is specifically as follows: Connected region labeling is performed on the complete leaf region. Each continuous part composed of adjacent leaf pixels is recorded as a connected region, and the region area, center position, and boundary integrity of each connected region are calculated. The region area is obtained by counting the number of leaf pixels within the connected region; the region center position is obtained by averaging the coordinates of all leaf pixels within the connected region; and the boundary integrity is obtained by the ratio of the number of continuous boundary pixels on the outer boundary of the connected region to the total number of pixels on the outer boundary. The regions of all connected regions are sorted in descending order of area, and the connected region with the largest area and its center position falling within the neighborhood of the image center is retained as the main leaf region. When multiple connected regions with similar areas exist, the boundary integrity of each connected region is compared, and the connected region with the largest boundary integrity is retained. Unretained connected regions are marked as background residual regions, outer leaf edge shadow regions, or discrete noise regions and removed from the complete leaf region. The boundary of the main leaf region is smoothed in a small area, and the original image pixels corresponding to the main leaf region are written into the output image according to their pixel coordinates, while the remaining pixel positions are written into the background label, thus generating the effective leaf region image of tea.
[0025] In this embodiment, the generation of the suspected lesion response map includes: The effective leaf area image of tea is divided into multiple local analysis windows, and the pixel coordinate correspondence between each local analysis window and the effective leaf area image of tea is preserved. The size of the local analysis window is 16×16 pixels and the step size is 8 pixels. When the window goes beyond the boundary of the leaf area, only the pixels within the leaf area mask are counted. The color shift value of the lesion is calculated based on the difference between the pixel color value in each local analysis window and the color value of the green stable area of the leaf. The calculation of lesion color offset value is as follows: The image of the effective leaf area of tea is converted to Lab color space and RGB color space. Within the stable green area of the leaf, the median values of the brightness component, red-green direction color component, yellow-blue direction color component, and green channel proportion are statistically analyzed to generate a stable green reference color. The pixel color values within each local analysis window are statistically analyzed to obtain the window mean brightness, window mean red-green direction color, window mean yellow-blue direction color, and window mean green channel proportion. The deviation of the window mean brightness, window mean red-green direction color, window mean yellow-blue direction color, and window mean green channel proportion from the stable green reference color is calculated respectively. The deviations are normalized and merged to generate the lesion color offset value corresponding to the local analysis window. The texture roughness value is calculated based on the gray-level change amplitude, texture direction change, and local gray-level dispersion within each local analysis window. The calculation of texture roughness value is as follows: the image of the effective leaf area of tea is converted into a grayscale image; the grayscale values in each local analysis window are statistically analyzed; the grayscale change amplitude between the maximum and minimum grayscale values in the window is calculated; the dispersion of all grayscale values in the window relative to the grayscale mean is calculated; horizontal, vertical, and diagonal gradient statistics are performed on the local analysis window to obtain the texture response in multiple directions; the difference between the texture responses in each direction is taken as the texture direction change; the grayscale change amplitude, texture direction change, and local grayscale dispersion are normalized to the same numerical scale and merged with equal weight to generate the texture roughness value corresponding to the local analysis window. The local edge abruptness value is calculated based on the difference between the edge response intensity within each local analysis window and the edge response intensity of adjacent local analysis windows; The calculation of local edge mutation values is as follows: Gradient response is calculated for the effective leaf area image of tea leaves to obtain an edge response map; the mean edge response, upper quartile of the edge response, and number of consecutive pixels in the edge response are calculated within each local analysis window to generate the window edge response intensity; with the current local analysis window as the center, the adjacent local analysis windows in its eight neighborhood directions are obtained, and the differences between the window edge response intensity of the current local analysis window and the window edge response intensity of each adjacent local analysis window are calculated; the maximum difference result and the average difference result among the multiple difference results are normalized and merged to generate the local edge mutation value corresponding to the local analysis window; The region diffusion morphology value is calculated based on the connectivity, extension direction, and outer boundary of color aberration pixels and texture aberration pixels within adjacent local analysis windows. The calculation of the regional diffusion morphology value is as follows: Within each local analysis window, a color anomaly boundary value is determined based on the median and upper quartile of the pixel color deviation distribution, and pixels with a color deviation greater than the color anomaly boundary value are marked as color anomaly pixels; a texture anomaly boundary value is determined based on the median and upper quartile of the pixel texture response distribution, and pixels with a texture response greater than the texture anomaly boundary value are marked as texture anomaly pixels; interconnected color anomaly pixels and texture anomaly pixels in adjacent local analysis windows are merged into anomaly connected regions, and the number of local analysis windows crossed by the anomaly connected regions, the consistency of the main extension direction, and the integrity of the outer expansion boundary are counted; the number of crossed regions, the consistency of the main extension direction, and the integrity of the outer expansion boundary are normalized and merged to generate the regional diffusion morphology value; The lesion color offset value, texture roughness value, local edge mutation value, and regional diffusion morphology value are normalized and then fused with equal weights to generate a suspected lesion response map.
[0026] In this embodiment, the generation of candidate region images for tea lesions includes: The suspected lesion response map is matched with the effective leaf area image of tea according to the image number and pixel coordinates. A leaf area mask is generated based on the effective leaf area image of tea. Specifically, the pixel position of the main body of the leaf in the effective leaf area image of tea is written as 1, and the background position outside the main body of the leaf, the shadow position of the outer edge of the leaf and the invalid blank position are written as 0, so as to form a leaf area mask with the same size and pixel coordinates as the effective leaf area image of tea. The response values in the suspected lesion response map are sorted in ascending order to determine the median and upper quartile of the response values. The response span value is obtained by subtracting the median of the response value from the upper quartile. The lesion response boundary value is obtained by adding half of the response span value to the upper quartile. The pixel position whose response value is greater than the lesion response threshold and is located inside the leaf area mask is marked as the initial lesion pixel; Connectivity analysis is performed on the initial pixels of the lesion to remove discrete regions located on the outer edge of the leaf, the shadow position of the leaf edge, and the residual background position, thus generating the initial region of the lesion. The fracture boundary is connected according to the outer boundary of the initial lesion area, the adjacent initial lesion areas are merged, and the corresponding pixels of the merged area are extracted from the effective leaf area image of tea to generate a candidate area image of tea lesion.
[0027] In this embodiment, the generation of tea disease identification and detection results includes: The color distribution, texture distribution, boundary morphology, and spatial distribution of lesions in the candidate region images of tea lesions are organized to generate disease image features; The specific steps for generating disease image features are as follows: Candidate tea lesion images are cropped and organized according to their locations, preserving the pixel coordinate correspondence between each candidate lesion image and the effective leaf area image; color statistics are performed on each candidate lesion image, analyzing the brightness distribution, red-green direction color distribution, yellow-blue direction color distribution, and green channel proportion changes within the lesion area to generate a lesion color distribution; grayscale texture statistics are performed on each candidate lesion image, analyzing grayscale variation amplitude, local grayscale dispersion, texture direction changes, and texture continuity to generate a lesion texture distribution; along each… Boundary point sequences are extracted from the outer boundaries of candidate tea lesion images. Boundary length, curvature, closure, and irregularity are analyzed to generate lesion boundary morphology. Based on the pixel coordinates of each candidate tea lesion image in the effective leaf area image, the center position of the lesion, the area ratio of the lesion, the distance between adjacent lesions, and the distribution of lesions along the leaf direction are statistically analyzed to generate lesion spatial distribution. The lesion color distribution, texture distribution, boundary morphology, and spatial distribution are combined according to the same candidate region location and written into the corresponding candidate region location marker and image number to generate disease image features. The disease image features are input into the lesion MaxViT model, which includes a lesion feature embedding layer, a local window attention layer, a multi-axis grid attention layer, a multi-scale feature aggregation layer, and a disease classification output layer. The improvements to the MaxViT lesion model are specifically reflected in the following aspects: The original MaxViT's single image patch input is changed to an input structure involving both disease image features and suspected lesion response maps. In the lesion feature embedding layer, lesion color distribution, lesion texture distribution, lesion boundary morphology, and lesion spatial distribution are mapped into an initial feature sequence with candidate region location markers. In the local window attention layer, response weights corresponding to suspected lesion response maps are introduced, focusing attention calculations within the window on pixel blocks with significant color shifts, enhanced texture coarsening, and concentrated edge abrupt changes. In the multi-axis grid attention layer, the original MaxViT's horizontal and vertical grid interactions are expanded to a multi-axis grid interaction combining the lesion diffusion direction, allowing the continuous diffusion morphology of lesions on the leaf surface to participate in global feature modeling. In the multi-scale feature aggregation layer, local lesion features, global lesion features, and candidate region area proportions are fused to generate disease discrimination features for distinguishing tea disease types and severity. The training data sources include images taken on-site in tea gardens using mobile phones. The collected data includes images of healthy tea leaves as well as images of tea leaves affected by anthracnose, tea cake disease, tea leaf blight, and tea ring spot disease. The training sample size is 12,000 images, including 3,000 images of healthy leaves and 9,000 images of diseased leaves. Each training sample is labeled with the effective area of the leaf, the boundary of the lesion area, the disease type, and the disease severity. The disease severity label is divided into mild, moderate, and severe. The training samples are divided into training, validation, and test sets in a ratio of 7:2:1. During training, candidate lesion area images and suspected lesion response maps are generated according to the aforementioned processing steps. Disease image features are then extracted and input into the MaxViT lesion model. The model input image size is set to 224×224 pixels, the feature block size to 7×7, the local window size to 7×7, the batch size to 32, and the number of training rounds. The training process was set to 100 rounds, using AdamW as the optimizer. The initial learning rate was set to 0.0001, and the weight decay coefficient was set to 0.05. The first 10 rounds were warmed up using the learning rate, and then the learning rate was adjusted using cosine decay. The random inactivation rate was set to 0.2. During training, the loss for disease type classification, disease severity classification, lesion location regression, and suspected lesion response consistency were calculated simultaneously. The loss for disease type classification, disease severity classification, lesion location regression, and suspected lesion response consistency were weighted and merged with weights of 0.40, 0.20, 0.25, and 0.15, respectively, to obtain the total training loss of the model. The parameters of the lesion MaxViT model were updated in reverse based on the total training loss. Training was stopped when the recognition accuracy on the validation set did not improve for 10 consecutive rounds. The model parameters with the lowest overall loss on the validation set were saved as the completed lesion MaxViT model. In the lesion feature embedding layer, the lesion image features are divided into feature blocks and mapped to the initial feature sequence; In the local window attention layer, the intra-window correlation of the initial feature sequence is calculated to generate local lesion features; The local window attention layer specifically processes the following: It includes a first local window attention unit and a second local window attention unit. It receives the initial feature sequence output from the lesion feature embedding layer and retains the spatial location index corresponding to each feature block in the initial feature sequence. In the first local window attention unit, adjacent feature blocks are divided into multiple local windows based on their spatial location indices. Query features, key features, and value features are mapped to the feature blocks within each local window. The correlation weights between different feature blocks within the window are calculated, and the response intensity at the corresponding position in the suspected lesion response map is used as a weight adjustment factor in the correlation weights, thus adjusting the weights corresponding to higher lesion response positions. The feature block obtains a higher response; the adjusted correlation weights and value features are weighted and combined, and then residually connected, layer normalized, and feedforward mapped with the input features at the corresponding positions in the initial feature sequence to generate the first local lesion feature; in the second local window attention unit, the first local lesion feature is used as input, and the local window is re-divided according to the spatial position index after the window offset. The feature blocks in the offset local window are again processed by query feature, key feature and value feature mapping, correlation weight calculation, response intensity adjustment, weighted combination, residual connection, layer normalization and feedforward mapping to generate the second local lesion feature. The second local lesion feature is input into the multi-axis grid attention layer; In the multi-axis mesh attention layer, the local lesion features are correlated and calculated along the horizontal, vertical and cross directions to generate global lesion features; The multi-axis grid attention layer processes the following: It inherits the second local lesion features and retains the spatial location index and candidate region location marker corresponding to each feature block in the second local lesion features. Based on the spatial location index, feature blocks in the same horizontal direction are divided into horizontal feature groups. Query features, key features, and value features are mapped to the feature blocks within the horizontal feature groups to calculate the horizontal lesion association weights and generate horizontal lesion association features. Similarly, based on the spatial location index, feature blocks in the same vertical direction are divided into vertical feature groups. Query features, key features, and value features are mapped to the feature blocks within the vertical feature groups to calculate the vertical lesion association weights. The system generates vertical lesion association features. Based on the extension direction of high-response areas in the suspected lesion response map and the boundary direction of lesions in the candidate lesion area image of tea leaves, feature blocks in the same diagonal diffusion direction are divided into cross-directional feature groups. Query features, key features, and value features are mapped to the feature blocks within the cross-directional feature groups to calculate the cross-lesion association weights and generate cross-lesion association features. The horizontal lesion association features, vertical lesion association features, and cross-lesion association features are then concatenated and fused according to their corresponding spatial location indices. These features are then combined with the second local lesion features through residual connection, layer normalization, and feedforward mapping to generate deep global lesion features. In the multi-scale feature aggregation layer, local lesion features and global lesion features at different levels are fused to generate disease discrimination features; The multi-scale feature aggregation layer is processed as follows: First local lesion features are used as shallow local lesion features, second local lesion features as mid-level local lesion features, and deep global lesion features as global lesion features; channel mapping is performed on the shallow, mid-level, and global lesion features respectively to ensure consistent channel dimensions among the three types of features; scale aggregation weights are generated based on the average response intensity, lesion area ratio, and boundary integrity of candidate regions in the suspected lesion response map, and these scale aggregation weights are applied to the shallow local lesion features. The system identifies three types of lesion features: spot features, mid-layer local lesion features, and global lesion features. These three weighted features are then concatenated and fused according to their corresponding spatial location indices. One-dimensional convolutional mapping, residual connections, and layer normalization are then applied to generate fused lesion features. Global average pooling and max pooling are applied to the fused lesion features to obtain overall lesion distribution features and lesion saliency response features. Finally, the overall lesion distribution features, lesion saliency response features, and candidate region location markers are combined to generate disease discrimination features for disease type identification, disease severity judgment, and disease location output. In the disease classification output layer, the disease discrimination features are classified and processed to generate tea disease identification and detection results that include disease type, disease location, disease severity, and identification confidence.
[0028] The specific processing of the disease classification output layer is as follows: Feature compression and nonlinear mapping are performed on the disease discrimination features to obtain a shared discriminant representation; the shared discriminant representation is then input into the disease type classification branch, disease severity classification branch, disease location output branch, and confidence output branch, respectively; in the disease type classification branch, the shared discriminant representation undergoes category mapping processing to obtain the category response values corresponding to healthy, anthracnose, tea cake disease, tea cloud leaf blight, and tea ring spot disease, and the category with the largest category response value is selected as the disease type; in the disease severity classification branch, the proportion of lesion area, the intensity of lesion color shift, the roughness of texture, and the regional diffusion pattern are combined to... The severity of disease is classified into mild, moderate, and severe, and the corresponding severity results are output. In the disease location output branch, the coordinates of the lesion center, the location of the lesion bounding box, and the lesion area mask are output based on the candidate region location markers and the lesion candidate region boundaries. In the confidence output branch, the maximum category response value of the disease type classification branch, the response stability of the disease severity classification branch, and the consistency between the suspected lesion response map and the model's region of interest are fused to generate the recognition confidence score. The disease type, disease location, disease severity, and recognition confidence score are associated and organized according to the same tea leaf image number to generate tea disease recognition and detection results.
[0029] Example 1: To verify the feasibility of this invention in practice, it was applied to a natural light inspection scenario in a hilly tea garden. The tea garden covers approximately 30 acres, with tea trees distributed in strips. The leaves overlap and obstruct each other, and the inspection area also contained background interference from soil, branches, weeds, and adjacent leaves. Inspectors used mobile phone cameras to collect images of tea leaves along the tea rows, maintaining a shooting distance of 30cm to 45cm. The image resolution was 1920×1080 pixels, and a total of 360 images were collected, including images of healthy leaves, leaves suspected of having anthracnose, leaves suspected of having tea cake disease, leaves suspected of having tea cloud leaf blight, and leaves suspected of having tea ring spot disease. In the collected images, some leaves were under direct sunlight, with bright reflective areas on the leaf surface; some leaves were obscured by tender shoots, forming irregular shadows in the middle or along the leaf edges; in some images, the colors of the soil and dead branches were similar to the colors of the lesions, which could easily affect the identification of lesion areas. When traditional methods rely directly on color thresholds or ordinary classification models for identification, they tend to identify leaf edge shadows, dead branches in the background, or reflective broken areas as candidate areas for lesions, making the identification results of tea diseases unstable.
[0030] In this scenario, the present invention first preprocesses the acquired tea leaf images to generate an enhanced tea leaf image set. Then, it extracts the brightness, green dominance, and saturation channels, filters stable green areas of the leaves, and generates a leaf illumination reference map and a shadow compensation map accordingly. For images with continuous shadows in the leaves, the shadow compensation map can compensate for the brightness of the shadow areas, ensuring that the shadow positions remain continuous with the surrounding leaf areas in terms of brightness and color. Next, based on the illumination-corrected leaf images, the present invention statistically analyzes the color distribution of the background area at the image edge, calculates the difference between each pixel position and the background color, and combines the continuity of the leaf edges and the connectivity of the leaf body to generate a candidate segmentation map of the tea leaves. For cases where the leaf outline is incomplete, leaf edge shadows are adhered, and background fragments remain, the present invention further refines the candidate segmentation map of the tea leaves by contour correction, hole filling, and interference removal, generating an image of the effective leaf area, ensuring that subsequent lesion analysis is performed only within the effective leaf area.
[0031] Within the effective leaf area image of tea, this invention divides the leaf into multiple local analysis windows, calculating the lesion color shift value, texture roughness value, local edge mutation value, and regional diffusion morphology value respectively, and then fuses these four features to generate a suspected lesion response map. For an image of a leaf surface with yellowish-brown spots, unclear spot edges, and slightly rough texture, relying solely on color changes is insufficient to determine whether the area is a lesion. However, this invention can simultaneously combine color shift, texture change, edge mutation, and diffusion morphology to generate a more concentrated response for the area. Subsequently, this invention performs joint constraint segmentation with the effective leaf area image of tea to generate a candidate lesion region image, avoiding background residual areas, shadowed areas on the outer edge of the leaf, and invalid blank areas from entering the lesion candidate range.
[0032] After extracting candidate lesion regions, this invention organizes the color distribution, texture distribution, boundary morphology, and spatial distribution of lesions from the candidate lesion region images of tea leaves to generate disease image features, which are then input into the MaxViT lesion model. This model extracts local color boundaries and texture details of lesions through local window attention, establishes the diffusion correlation of lesions in the horizontal, vertical, and intersecting directions through multi-axis grid attention, and then fuses local and global lesion features through multi-scale feature aggregation to output disease type, disease location, disease severity, and identification confidence. During inspection and verification, tea garden managers can directly see the effective leaf area boundaries, candidate lesion region locations, and corresponding disease identification information on the terminal image; for healthy leaves, the system marks the disease location as empty; for leaves with suspected diseases, the system can provide the lesion center location, lesion area range, and corresponding disease category. Therefore, this invention can first stably separate the effective leaf area of tea leaves and then accurately constrain the suspected lesion area in tea garden inspection environments where uneven natural lighting, shadow occlusion, leaf surface reflection and complex background coexist, thereby improving the reliability of the tea disease identification and detection process.
[0033] Table 1. Comparison of the overall performance of tea disease detection methods
[0034] As shown in Table 1, regarding the false inclusion rate of background residue, the HSV threshold + SVM method has a false inclusion rate of 10.8%, the GrabCut + LBP + Random Forest method has a false inclusion rate of 8.6%, the U-Net + ResNet18 method has a false inclusion rate of 6.4%, and the method of this invention reduces it to 4.9%. This result indicates that in natural light tea garden inspection images, relying solely on color thresholding, ordinary texture features, or conventional segmentation models is still easily affected by soil, dead branches, weeds, adjacent leaf edges, and residual shadows. Before lesion analysis, this invention generates a leaf illumination reference map and a shadow compensation map using the brightness channel, green dominance channel, and saturation channel. It then combines background color differences, leaf edge continuity, and leaf body connectivity to generate a candidate segmentation map of tea leaves. Therefore, it can more stably distinguish between effective leaf areas and background interference areas, reducing the number of non-leaf areas entering the subsequent lesion detection process.
[0035] In terms of lesion candidate region localization, the accuracy of this invention is 87.1%, and the recall is 88.2%. The U-Net+ResNet18 method achieved accuracy and recall of 84.2% and 85.0%, respectively, indicating that deep learning segmentation methods have a certain ability to locate lesions. However, under conditions of strong light, leaf reflection, leaf edge shadow, and background color similar to the lesion color, lesion regions may still be missed or falsely detected. The advantage of this invention lies in that it does not directly rely on a single color change or a single segmentation model to determine lesion regions. Instead, it comprehensively calculates lesion color shift values, texture roughness values, local edge mutation values, and regional diffusion morphology values within the effective leaf area image of the tea plant, and fuses these to generate a suspected lesion response map. This allows lesion candidate regions to be jointly determined by multi-dimensional image anomalies, thus exhibiting better localization stability for early lesions with weak color changes, blurred edges, or abnormal textures.
[0036] Regarding the overlap of lesion region boundaries, the method of this invention achieves 85.9%, higher than the 82.7% of the U-Net+ResNet18 method, and also significantly higher than the HSV threshold+SVM method and the GrabCut+LBP+Random Forest method. This result demonstrates that this invention not only identifies lesion regions but also makes the boundaries of candidate lesion regions more closely match those of manually verified regions. This is because, when generating images of effective tea leaf regions, this invention performs contour correction, hole filling, and interference removal, reducing the impact of incomplete leaf edges and background fragments on lesion segmentation. Furthermore, when generating candidate lesion region images, it utilizes the suspected lesion response map and leaf region mask for joint constraint segmentation, and performs connectivity analysis, broken boundary connection, and adjacent region merging on the initial lesion region, thus reducing the problems of lesion boundary fragmentation and over-expansion.
[0037] In terms of disease type identification accuracy, the method of this invention achieves 91.2%, which is higher than the 88.6% of the U-Net+ResNet18 method, the 84.1% of the GrabCut+LBP+Random Forest method, and the 82.4% of the HSV threshold+SVM method. This result indicates that the performance improvement of this invention stems not only from front-end region segmentation but also from the further modeling of disease image features by the MaxViT lesion model. Traditional SVM and Random Forest methods mainly rely on manually designed color, texture, or morphological features, which have limited ability to distinguish between tea diseases with similar appearances. While the ordinary ResNet18 classification method can learn image features, it does not adequately utilize information on local lesion details, cross-regional diffusion status, and spatial distribution. This invention organizes lesion color distribution, lesion texture distribution, lesion boundary morphology, and lesion spatial distribution into disease image features, and through local window attention, multi-axis grid attention, and multi-scale feature aggregation processing, enables the model to simultaneously focus on local lesion texture, boundary morphology, and diffusion direction, thus making disease type identification more stable.
[0038] Regarding the accuracy of disease severity assessment, the method of this invention achieves 85.4%, higher than the 82.5% of the U-Net+ResNet18 method. Disease severity assessment is related to the proportion of lesion area, the intensity of color change, texture roughness, and the extent of spread. Traditional methods tend to underestimate or overestimate disease severity when the lesion area is incomplete or when significant background is mistakenly included. This invention applies multidimensional constraints to the lesion area using a suspected lesion response map and integrates local and global lesion features in the MaxViT lesion model. This allows disease severity assessment to simultaneously consider both local lesion manifestations and overall spread, thus making the differentiation between mild, moderate, and severe diseases more reliable.
[0039] In terms of the stability rate of sample recognition under strong light and shadow interference, the method of this invention achieves 88.7%, which is higher than the 85.6% of the U-Net+ResNet18 method. This data directly reflects the adaptability of this invention to the problem of tea disease recognition under natural light conditions. Because this invention sets up a leaf illumination reference map and a shadow compensation map at the front end, and combines background color differences, leaf edge continuity, and leaf body connectivity for joint judgment in the subsequent segmentation process, local anomalies caused by strong light, shadow, and leaf surface reflection are not easily directly converted into lesion misjudgments.
[0040] The above are merely preferred embodiments of the present invention, but the scope of protection of the present invention is not limited thereto. Any equivalent substitutions or modifications made by those skilled in the art within the scope of the technology disclosed in the present invention, based on the technical solution and inventive concept of the present invention, should be covered within the scope of protection of the present invention.
Claims
1. A method for identifying and detecting tea diseases based on image processing, characterized in that, Includes the following steps: Images of tea leaves under natural light conditions were collected and preprocessed to generate an enhanced image set of tea leaves; The brightness channel, green dominance channel, and saturation channel of the tea leaf enhancement image set are extracted to generate a leaf illumination reference map and a shadow compensation map; The tea leaf enhancement image set was corrected based on the shadow compensation map, and candidate segmentation maps of tea leaves were generated by combining background color differences, leaf edge continuity and leaf body connectivity. Contour correction and interference removal are performed on the candidate segmentation images of tea leaves to generate images of the effective tea leaf regions. Within the effective leaf area image of tea, calculate the color shift value, texture roughness value, local edge mutation value, and regional diffusion morphology value of lesions, and fuse them to generate a response map of suspected lesions. Based on the response map of suspected lesions and the image of effective leaf area of tea, joint constraint segmentation is performed to generate candidate region images of tea lesions; Disease image features are extracted from candidate regions of tea lesions. These features are then input into the MaxViT model for lesions. Through local window attention, multi-axis grid attention, and multi-scale feature aggregation, tea disease identification and detection results are generated.
2. The tea disease identification and detection method based on image processing according to claim 1, characterized in that, The preprocessing includes image format unification, image size normalization, white balance correction, color correction, noise suppression, edge preservation enhancement, brightness equalization, reflection suppression, and shadow weakening.
3. The tea disease identification and detection method based on image processing according to claim 1, characterized in that, The generation of the leaf illumination reference map and shading compensation map includes: Each tea leaf enhanced image in the tea leaf enhanced image set is converted to Lab color space and HSV color space. The L component is extracted from the Lab color space to generate the luminance channel, and the S component is extracted from the HSV color space to generate the saturation channel. Based on the enhanced image of tea leaves, the difference between the G channel and the R and B channels in the RGB three-channel calculation is used to generate the green dominant channel; Based on the green dominance channel and saturation channel, the green stable region of the leaf is screened, and the local mean value of the brightness channel is calculated within the green stable region of the leaf to generate a local brightness distribution map of the leaf. The local brightness distribution map of the leaf is smoothed and normalized to generate a leaf illumination reference map, and the brightness value corresponding to each pixel position in the leaf illumination reference map is used as the reference brightness value. The difference between the brightness channel and the leaf illumination reference image is calculated, and the continuous low brightness area is marked to generate a shadow area marking image. The brightness compensation intensity is calculated based on the shaded area marker map and the leaf illumination reference map to generate a shaded compensation map.
4. The tea disease identification and detection method based on image processing according to claim 1, characterized in that, The generation of the candidate segmentation map of the tea leaves includes: The shadow compensation image and the tea leaf enhancement image set are matched according to the image number and pixel coordinates. Brightness compensation is performed on the corresponding pixels in the shadow area, and the original brightness value is maintained for the corresponding pixels in the non-shaded area to generate a light-corrected leaf image. Based on the color distribution of the image edge background region in the light-corrected leaf image, the color difference between each pixel position and the image edge background region is calculated to generate a background color difference map; Edge response extraction and broken edge connection are performed on the illumination-corrected leaf image to generate a leaf edge continuity map; Connectivity analysis is performed on the candidate pixels of the blade defined by the background color difference map and the blade edge continuity map. The continuous regions corresponding to the main body of the blade are retained to generate the main body connectivity map of the blade. The background color difference map, leaf edge continuity map, and leaf body connectivity map are matched at the pixel level to remove residual background and shadow areas, generating candidate segmentation maps of tea leaves.
5. The tea disease identification and detection method based on image processing according to claim 1, characterized in that, The generation of the effective leaf area image of the tea leaves includes: The candidate segmentation image of tea leaves is binarized to obtain leaf marker pixels and background marker pixels. Closed boundaries are extracted along the outside of leaf marker pixels to generate the initial outline of the leaf. The initial blade outline is scanned at breakpoints, and the outline gaps are connected based on the consistency of direction and distance between adjacent boundary points to generate the outline completion result. The contour completion result is smoothed by adjusting the sharp protruding boundaries and concave defect boundaries to the extension direction of the adjacent boundaries to generate the contour correction result. Holes are filled based on the leaf marker pixels inside the contour correction result to generate a complete leaf region; Connectivity analysis is performed on the complete leaf area. Background residual areas, shadow areas on the outer edge of the leaf, and discrete noise areas are removed according to the area of the connected regions, the center position of the regions, and the integrity of the boundaries. The continuous regions corresponding to the main body of the leaf are retained to generate an image of the effective leaf area of tea.
6. The tea disease identification and detection method based on image processing according to claim 1, characterized in that, The generation of the suspected lesion response map includes: The effective leaf area image of tea is divided into multiple local analysis windows, and the pixel coordinate correspondence between each local analysis window and the effective leaf area image of tea is preserved. The color shift value of the lesion is calculated based on the difference between the pixel color value in each local analysis window and the color value of the green stable area of the leaf. The texture roughness value is calculated based on the gray-level change amplitude, texture direction change, and local gray-level dispersion within each local analysis window. The local edge abruptness value is calculated based on the difference between the edge response intensity within each local analysis window and the edge response intensity of adjacent local analysis windows; The region diffusion morphology value is calculated based on the connectivity, extension direction, and outer boundary of color aberration pixels and texture aberration pixels within adjacent local analysis windows. The lesion color offset value, texture roughness value, local edge mutation value, and regional diffusion morphology value are normalized and then fused with equal weights to generate a suspected lesion response map.
7. The tea disease identification and detection method based on image processing according to claim 1, characterized in that, The generation of the candidate region image for tea lesions includes: The suspected lesion response map is matched with the effective leaf area image of tea according to the image number and pixel coordinates, and a leaf area mask is generated based on the effective leaf area image of tea. The response values in the suspected lesion response map are sorted in ascending order to determine the median and upper quartile of the response values. The response span value is obtained by subtracting the median of the response values from the upper quartile. The lesion response boundary value is obtained by adding half of the response span value to the upper quartile. The pixel position whose response value is greater than the lesion response threshold and is located inside the leaf area mask is marked as the initial lesion pixel; Connectivity analysis is performed on the initial pixels of the lesion to remove discrete regions located on the outer edge of the leaf, the shadow position of the leaf edge, and the residual background position, thus generating the initial region of the lesion. The fracture boundary is connected according to the outer boundary of the initial lesion area, the adjacent initial lesion areas are merged, and the corresponding pixels of the merged area are extracted from the effective leaf area image of tea to generate a candidate area image of tea lesion.
8. The tea disease identification and detection method based on image processing according to claim 1, characterized in that, The generation of the tea disease identification and detection results includes: The color distribution, texture distribution, boundary morphology, and spatial distribution of lesions in the candidate region images of tea lesions are organized to generate disease image features; The disease image features are input into the lesion MaxViT model, which includes a lesion feature embedding layer, a local window attention layer, a multi-axis grid attention layer, a multi-scale feature aggregation layer, and a disease classification output layer. In the lesion feature embedding layer, the lesion image features are divided into feature blocks and mapped to the initial feature sequence; In the local window attention layer, the intra-window correlation of the initial feature sequence is calculated to generate local lesion features; In the multi-axis mesh attention layer, the local lesion features are correlated and calculated along the horizontal, vertical and cross directions to generate global lesion features; In the multi-scale feature aggregation layer, local lesion features and global lesion features at different levels are fused to generate disease discrimination features; In the disease classification output layer, the disease discrimination features are classified and processed to generate tea disease identification and detection results that include disease type, disease location, disease severity, and identification confidence.