A method and equipment for detecting leaf veins in ryegrass.
By extracting leaf and reflected light areas from ryegrass images using detection equipment, calculating the overall geometric center of gravity, and adjusting the direction of movement, the problem of reflected light interference was solved, improving the accuracy and reliability of leaf vein detection.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-27
- Publication Date
- 2026-03-31
AI Technical Summary
Ryegrass leaves develop high-intensity specular reflections on their surface under natural light, which reduces the accuracy of traditional computer vision methods in detecting leaf veins.
The leaf area and reflected light area are extracted from the ryegrass image by the detection device. The overlapping parts are marked as the set of interfering reflected light areas. The comprehensive geometric centroid is calculated and the movement direction is adjusted based on the guide vector to transfer the reflected light outside the leaf area. The halo diffusion effect is handled by combining the elliptical diffusion model to optimize the image data basis.
This method improves the topological accuracy of ryegrass leaf vein network detection, reduces the interference of reflected light on leaf vein detection, provides more reliable image data support, and ensures clear identification of the leaf vein network structure.
Smart Images

Figure CN121305534B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image processing technology, and in particular to a method and device for detecting leaf veins in ryegrass. Background Technology
[0002] In the modern dairy farming industry, the nutritional quality of feed is a core factor determining key indicators such as milk yield, milk fat percentage, and milk protein percentage in dairy cows. Ryegrass, as a major high-quality forage, directly impacts feed conversion efficiency through its nutritional value and digestibility. Scientific research shows that the leaf vein morphology of ryegrass, such as vein density, interveinal spacing, and midrib width, is a key physiological indicator of its nutritional components (e.g., crude protein content) and structural fiber content. Therefore, examining the leaf vein structure of ryegrass is of great significance for improving the final yield and quality of milk.
[0003] To meet the requirements, the relevant technologies mainly employ traditional computer vision methods to detect the vein network structure of ryegrass leaves. Specifically, this involves converting color images of ryegrass leaves into grayscale images, and then using edge detection operators (such as the Canny operator) to identify regions in the image with drastic brightness changes, which correspond to the edge contours of the veins. After detection, morphological processing operations such as erosion, dilation, opening, and closing operations are used to denoise the detection results and connect breakpoints, ultimately obtaining the vein network structure.
[0004] However, because the epidermis of ryegrass leaves is covered with a smooth waxy layer, under natural light (such as sunlight), its surface is prone to forming high-intensity specular reflection spots. These reflective areas reduce the accuracy of ryegrass leaf vein detection. Summary of the Invention
[0005] This application provides a method and equipment for detecting leaf veins in ryegrass, in order to improve the accuracy of leaf vein detection in ryegrass.
[0006] Firstly, a method for detecting leaf veins in ryegrass is provided, applied to a detection device. The method includes: the detection device extracting leaf regions and reflected light regions from a ryegrass image; when the reflected light regions overlap with the leaf regions, the detection device marks the overlapping reflected light regions as a set of interfering reflected light regions; the detection device using the arithmetic mean of the geometric centroids of the interfering reflected light regions in the set as the comprehensive geometric centroid; the detection device determining the target transfer position closest to the comprehensive geometric centroid outside the boundary of the leaf region; the detection device calculating a guiding vector from the comprehensive geometric centroid to the target transfer position; the detection device adjusting the movement direction based on the guiding vector; when a reflected light region is detected outside the leaf region, the detection device outputs a shooting confirmation signal to acquire a ryegrass image without reflected light interference; and the detection device detecting leaf veins based on the ryegrass image.
[0007] By adopting the above technical solution, the detection device extracts the leaf area and the reflected light area from the ryegrass image. When the reflected light area overlaps with the leaf area, the detection device marks the overlapping part as a set of interfering reflected light areas. By calculating the comprehensive geometric centroid of the set of interfering reflected light areas, the target transfer position is determined. Finally, the detection device adjusts the movement direction based on the guiding vector to transfer the reflected light outside the leaf area, thereby reducing the influence of reflected light on the topology of the ryegrass leaf vein network and improving the accuracy of detecting the topology of the ryegrass leaf vein network. This provides a more reliable image data basis for the nutritional value assessment of forage.
[0008] In conjunction with some embodiments of the first aspect, in some embodiments, when the reflected light region overlaps with the blade region, the detection device marks the overlapping reflected light region as a set of interfering reflected light regions. Specifically, this includes: when the reflected light region overlaps with the blade region, the detection device determines whether there are saturated pixels in the overlapping reflected light region, where a saturated pixel is a pixel whose brightness value is greater than a preset maximum response value of the sensor of the detection device; if so, the detection device expands the reflected light region based on the brightness gradient of the saturated pixel, the full-well capacity of the sensor of the detection device, and a preset halo diffusion coefficient; the detection device marks the overlapping reflected light region with the blade region as a set of interfering reflected light regions; if not, the detection device marks the overlapping reflected light region as a set of interfering reflected light regions.
[0009] By adopting the above technical solution, the detection equipment first determines whether there are saturated pixels in the reflected light area of the overlapping part. When saturated pixels are present, the reflected light area is expanded based on the brightness gradient of the saturated pixels, the full-well capacity of the sensor, and the preset halo diffusion coefficient. This can compensate for the halo diffusion effect caused by sensor overexposure, reduce the loss of leaf vein information due to halo diffusion, and improve the accuracy of boundary positioning of the reflected light area.
[0010] In conjunction with some embodiments of the first aspect, in some embodiments, the detection device expands the reflected light region based on the brightness gradient of saturated pixels, the full-well capacity of the sensor of the detection device, and a preset halo diffusion coefficient. Specifically, the detection device determines the main direction and secondary direction of halo diffusion based on the direction and magnitude of the brightness gradient vector in the eight neighborhoods of the saturated pixels. The main direction is the direction with the largest gradient magnitude, and the secondary direction is the direction perpendicular to the main direction and with the second largest gradient magnitude. The detection device constructs an elliptical diffusion model based on the main direction and the secondary direction. The major axis of the elliptical diffusion model is consistent with the main direction, and the minor axis is consistent with the secondary direction. The length of the major axis is proportional to the full-well capacity of the sensor of the detection device, and the length of the minor axis is proportional to the preset halo diffusion coefficient. The detection device uses the pixel area covered by the elliptical halo diffusion model as the expanded reflected light region.
[0011] By adopting the above technical solution, the detection device determines the main and secondary directions of halo diffusion based on the brightness gradient vector in the eight neighborhoods of saturated pixels. The determination of the main and secondary directions provides a geometric basis for constructing an elliptical diffusion model, enabling the elliptical diffusion model to better match the actual optical diffusion phenomenon, thereby improving the recognition accuracy of areas with strong reflection light and reducing the potential interference of the halo edge area on leaf vein detection.
[0012] In conjunction with some embodiments of the first aspect, in some embodiments, the detection device determines the target transfer position closest to the integrated geometric centroid outside the boundary of the blade region. Specifically, this includes: the detection device calculating the minimum bounding rectangle of the blade region; the detection device subtracting the minimum bounding rectangle from the ryegrass image to obtain the usable transfer region; and the detection device taking the pixel with the smallest distance from the integrated geometric centroid to each pixel within the usable transfer region as the target transfer position.
[0013] By employing the above technical solution, the detection equipment calculates the minimum bounding rectangle of the leaf region. This geometric operation provides a more accurate mathematical description for determining the boundary range of the leaf region. Subtracting the minimum bounding rectangle from the rye grass image yields the usable transfer region. Within this region, the pixel closest to the centroid of the overall geometry is found as the target transfer location. This shortest distance reduces the movement distance and adjustment time of the detection equipment.
[0014] In conjunction with some embodiments of the first aspect, in some embodiments, the detection device calculates a guiding vector from the comprehensive geometric center of gravity to the target transfer position, specifically including: the detection device calculating a displacement vector with the comprehensive geometric center of gravity as the starting point and the target transfer position as the ending point; the detection device mapping the horizontal and vertical components of the displacement vector to the horizontal and vertical movement distances of the detection device, respectively; and the detection device converting the horizontal and vertical movement distances into guiding vectors according to a preset device movement ratio coefficient.
[0015] By adopting the above technical solution, the detection equipment calculates the displacement vector with the comprehensive geometric center of gravity as the starting point and the target transfer position as the ending point, providing directional and distance guidance for the movement of the detection equipment. The horizontal and vertical components of the displacement vector are mapped to the horizontal and vertical movement distances of the detection equipment, respectively, enabling mutual conversion between the image pixel coordinate system and the equipment's physical coordinate system. The pre-set equipment converts the movement distance into a guide vector based on a movement scaling factor, providing a standardized command format for the positioning control of the detection equipment and improving the accuracy and repeatability of the detection equipment's movement.
[0016] In conjunction with some embodiments of the first aspect, in some embodiments, after the step of adjusting the movement direction of the detection device based on the guide vector, the method further includes: when there are multiple leaf regions and after one movement adjustment, the reflected light region still overlaps with at least one leaf region among the multiple leaf regions, the detection device acquires an image of a leaf region without a reflected light region; the detection device determines the reflected light interference intensity and minimum adjustment distance within the leaf region containing the reflected light region, where the reflected light interference intensity is the ratio of the area of the reflected light region within the leaf region to the area of the leaf region, and the minimum adjustment distance is the movement distance of the detection device required to transfer the reflected light region within the leaf region to the transfer region, and the transfer region is the region in the ryegrass image where the leaf region has been removed; the detection device uses the division of the reflected light interference intensity and the minimum adjustment distance as a processing priority score for the leaf region containing the reflected light region; the detection device uses the leaf region with the highest processing priority score as the target region; the detection device acquires an image of the target region without reflected light interference based on the guide vector of the target region; the detection device sequentially acquires images of each leaf region after the reflection light interference is removed, and stitches the images of each leaf region together to form a ryegrass image.
[0017] By employing the above technical solution, when multiple blade regions exist and, after a single adjustment, the reflected light region still overlaps with at least one blade region, the detection device first acquires images of blade regions without reflected light. For blade regions with reflected light, the detection device determines the intensity of reflected light interference and the minimum adjustment distance. The intensity of reflected light interference reflects the severity of the interference, while the minimum adjustment distance reflects the ease of processing. The division between the intensity of reflected light interference and the minimum adjustment distance is used as a processing priority score. The blade region with the highest processing priority score is selected as the target region, prioritizing the processing of the region most easily transferred by reflected light. After obtaining the target region image without reflected light interference based on the guiding vector of the target region, the target region is added to the transfer region, providing more spatial options for the transfer of reflected light from subsequent blade regions. This simplified hierarchical processing strategy reduces the situation where overlapping reflected light regions persist and cannot be completely eliminated in multi-blade scenarios by dynamically adjusting the transfer region.
[0018] In conjunction with some embodiments of the first aspect, in some embodiments, the detection device sequentially acquires images of each leaf region after the interference of reflected light, and stitches the images of each leaf region into a ryegrass image. Specifically, this includes: the detection device creating a blank canvas of the same size as the ryegrass image; the detection device placing the images of each leaf region after the interference of reflected light onto the blank canvas according to the position coordinate information of each leaf region in the ryegrass image; the detection device eliminating stitching marks at the stitching boundary based on Poisson fusion processing; and the detection device outputting a complete ryegrass image.
[0019] By adopting the above technical solution, the detection equipment creates a blank canvas of the same size as the original ryegrass image, and places the leaf areas according to the position coordinates of each leaf area in the original image, thus maintaining the original spatial layout of the leaves. The application of Poisson fusion processing can reduce splicing marks at the splicing boundary and reduce geometric distortion during the splicing process.
[0020] In a second aspect, embodiments of this application provide a detection device, which includes: one or more processors and a memory; the memory is coupled to the one or more processors, and the memory is used to store computer program code, the computer program code including computer instructions, and the one or more processors call the computer instructions to cause the detection device to perform the method described in the first aspect and any possible implementation thereof.
[0021] Thirdly, embodiments of this application provide a computer program product containing instructions that, when the computer program product is run on a testing device, cause the testing device to perform the method described in the first aspect and any possible implementation thereof.
[0022] Fourthly, embodiments of this application provide a computer-readable storage medium including instructions that, when executed on a detection device, cause the detection device to perform the method described in the first aspect and any possible implementation thereof.
[0023] Understandably, the detection equipment provided in the second aspect, the computer program product provided in the third aspect, and the computer storage medium provided in the fourth aspect are all used to execute the methods provided in the embodiments of this application. Therefore, the beneficial effects they can achieve can be referred to the beneficial effects in the corresponding methods, and will not be repeated here.
[0024] One or more technical solutions provided in the embodiments of this application have at least the following technical effects or advantages:
[0025] 1. Since the detection device extracts the leaf area and the reflected light area from the ryegrass image, when the reflected light area overlaps with the leaf area, the detection device marks the overlapping part as a set of interfering reflected light areas. By calculating the comprehensive geometric centroid of the set of interfering reflected light areas, the target transfer position is determined. Finally, the detection device adjusts the movement direction based on the guiding vector to transfer the reflected light outside the leaf area, thereby reducing the influence of reflected light on the topology of the detected ryegrass leaf vein network and improving the accuracy of detecting the topology of the ryegrass leaf vein network.
[0026] 2. Since the detection equipment determines the main and secondary directions of halo diffusion based on the brightness gradient vector in the eight neighborhoods of saturated pixels, the determination of the main and secondary directions provides a geometric basis for constructing an elliptical diffusion model, enabling the elliptical diffusion model to better match the actual optical diffusion phenomenon, thereby improving the recognition accuracy of areas with strong reflection light and reducing the potential interference of the halo edge area on leaf vein detection.
[0027] 3. When multiple blade regions exist and, after a single adjustment, the reflected light area still overlaps with at least one blade region, the detection device first acquires images of blade regions without reflected light. For blade regions with reflected light, the device determines the intensity of reflected light interference and the minimum adjustment distance. The intensity of reflected light interference reflects the severity of the interference, while the minimum adjustment distance reflects the ease of processing. The division between the intensity of reflected light interference and the minimum adjustment distance is used as a processing priority score. The blade region with the highest processing priority score is designated as the target region, prioritizing the processing of the region most easily transferred by reflected light. After obtaining the target region image without reflected light interference based on the guiding vector of the target region, this target region is added to the transfer region, providing more spatial options for the transfer of reflected light from subsequent blade regions. This simplified hierarchical processing strategy reduces the possibility of overlapping reflected light regions in multi-blade scenarios that cannot be completely eliminated by dynamically adjusting the transfer region. Attached Figure Description
[0028] Figure 1 This is a flowchart illustrating a method for detecting leaf veins in ryegrass according to an embodiment of this application.
[0029] Figure 2 This is another flowchart illustrating a method for detecting leaf veins in ryegrass according to an embodiment of this application.
[0030] Figure 3 This is another flowchart illustrating a method for detecting leaf veins in ryegrass according to an embodiment of this application.
[0031] Figure 4 This is a schematic diagram of the physical device structure of the detection equipment in the embodiments of this application. Detailed Implementation
[0032] The terminology used in the following embodiments of this application is for the purpose of describing particular embodiments only and is not intended to be limiting of this application. As used in the specification and appended claims of this application, the singular expressions “a,” “an,” “the,” “the,” “the,” and “this” are intended to include the plural expressions as well, unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used in this application refers to and includes any or all possible combinations of one or more of the listed items.
[0033] Hereinafter, the terms "first" and "second" are used for descriptive purposes only and should not be construed as implying or suggesting relative importance or implicitly indicating the number of indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature, and in the description of the embodiments of this application, unless otherwise stated, "multiple" means two or more.
[0034] This application provides a method and equipment for detecting leaf veins in ryegrass, in order to improve the accuracy of leaf vein detection in ryegrass.
[0035] In this embodiment, the detection device extracts the leaf region and reflected light region from the ryegrass image. When the reflected light region overlaps with the leaf region, the detection device marks the overlapping part as a set of interfering reflected light regions. The target transfer position is determined by calculating the comprehensive geometric centroid of the set of interfering reflected light regions. Finally, the detection device adjusts its movement direction based on the guiding vector, transferring the reflected light outside the leaf region, thereby reducing the impact of reflected light on the topology of the ryegrass leaf vein network and improving the accuracy of detecting the topology of the ryegrass leaf vein network. In this embodiment, the detection device can be an imaging module mounted on an agricultural robot, drone, or mobile gantry. The moving part of the detection device specifically refers to an XY two-dimensional moving platform equipped with an image sensor (camera). The position of the lighting system (light source) is fixed. In field applications, this fixed light source can be the sun. Due to the small movement range and fast adjustment speed of the detection device in this invention (usually completed in milliseconds to seconds), the position of the sun can be approximated as relatively fixed during this short period. Alternatively, the light source can also be a fixed LED supplementary light carried by the device itself, at a certain physical distance from the camera. This method utilizes the principle of parallax. When the light source position is fixed, the position of the bright reflection point formed on the ryegrass leaf is relatively fixed in physical space. However, when the camera moves in the XY plane, due to the change in the viewing angle, the position of this reflection point relative to the ryegrass in the camera image will move, thus obtaining an image of ryegrass without interference from reflected light.
[0036] The following describes a method for detecting leaf veins in ryegrass according to an embodiment of this application:
[0037] Please see Figure 1 This is a flowchart illustrating a method for detecting leaf veins in ryegrass according to an embodiment of this application.
[0038] S101, The detection equipment extracts the leaf area and the reflected light area from the ryegrass image.
[0039] Here, the ryegrass image refers to a digital image acquired by an image sensor, containing both the background image and the ryegrass, typically an RGB three-channel color image. The leaf area refers to the pixel area occupied by the ryegrass leaves in the image, possessing specific color, texture, and shape characteristics. The reflected light area represents the high-brightness light spots on the waxy layer of the ryegrass surface caused by ambient light, appearing in the image as a collection of locally overexposed white or near-white pixels.
[0040] Specifically, after receiving the RGB image of ryegrass, the detection device first performs image preprocessing, including removing image noise using a Gaussian filter and adjusting the overall brightness and contrast of the image through histogram equalization. Next, leaf region extraction is performed. The detection device converts the RGB image to the HSV color space. Utilizing the characteristic that ryegrass typically has hue (H channel) values in the HSV space within the range of 60-120 degrees and saturation (S channel) values greater than 0.3, color segmentation is performed by setting corresponding threshold ranges to obtain binarized leaf candidate regions. Then, a connected component analysis algorithm is used to mark all connected pixel clusters, and noise regions with areas smaller than a preset minimum leaf area threshold are filtered out based on area size, retaining the main connected leaf regions as the final leaf regions. Simultaneously, reflected light region extraction is performed. The detection device detects regions with pixel values exceeding a preset high brightness threshold based on the image's brightness information. Through connected component analysis, adjacent bright pixels are aggregated into independent reflected light regions. Finally, boundary smoothing processing is performed on each reflected light region to obtain an accurate reflected light region contour.
[0041] S102. When the reflected light area overlaps with the blade area, the detection device marks the overlapping reflected light area as a set of interfering reflected light areas.
[0042] The overlapping portion represents the set of pixels where the reflected light region and the leaf region intersect in space; these pixels are identified as both the reflected light region and the leaf region. The set of interfering reflected light regions refers to the set of all reflected light regions that interfere with leaf vein detection. These regions, due to their overlap with the leaf region, affect the correct identification and extraction of leaf vein features.
[0043] Step S102 is executed immediately after the extraction of the leaf region and reflected light region in step S101. It is used to identify and mark reflected light regions that negatively affect leaf vein detection. Specifically, the detection device first performs spatial overlap detection on the leaf region and reflected light region by calculating the logical AND operation of two binary masks to determine the position of overlapping pixels. The detection device traverses all identified reflected light regions and performs an intersection operation with the leaf region for each reflected light region. If the number of pixels in the intersection result is greater than zero, it is determined that the reflected light region overlaps with the leaf region. When an overlap is detected, the detection device extracts the pixels in the reflected light region that intersect with the leaf region to form a new sub-region. This sub-region represents the reflected light portion that actually interferes with the leaf, excluding reflected light pixels located outside the leaf that do not affect leaf vein detection. The detection device assigns a unique identifier to each such interfering reflected light sub-region and organizes all these sub-regions into a set data structure to facilitate batch processing and geometric calculations in subsequent steps. At the same time, the detection device also records the boundary coordinates, area size, and position information in the original image of each interfering reflected light region.
[0044] S103. The detection equipment uses the arithmetic mean of the geometric centroids of the interfering reflected light regions in the set of interfering reflected light regions as the comprehensive geometric centroid.
[0045] The comprehensive geometric centroid refers to the combined center point obtained by arithmetically averaging the geometric centroids of multiple interfering reflected light regions, representing the overall spatial distribution center of all interfering reflected light regions. The set of interfering reflected light regions is used to represent the set of all reflected light regions that overlap with the blade region marked in step S102. These regions need to be considered as a whole to determine the optimal adjustment direction.
[0046] Step S103 is executed after the interference reflection light area marking is completed in step S102. Its purpose is to unify the multiple scattered interference areas into a single representative spatial location point, providing a clear reference coordinate for subsequent equipment adjustments. Specifically, the detection equipment first traverses each area in the interference reflection light area set and calculates the geometric centroid coordinates for each area. The geometric centroid is calculated by summing the x-coordinates of all pixels within the area and dividing by the total number of pixels. Similarly, the y-coordinates are calculated to obtain the y-coordinate of the centroid, forming the centroid coordinate point (x, y). When the interference reflection light area set contains n areas, the detection equipment will obtain n geometric centroid coordinate points. Next, the equipment performs an arithmetic mean calculation on these n centroid coordinates, summing the x-coordinates of all centroids and dividing by n to obtain the combined x-coordinate of the centroid, and summing the y-coordinates of all centroids and dividing by n to obtain the combined y-coordinate of the centroid, ultimately forming the combined geometric centroid coordinates (X_center, Y_center). This integrated geometric centroid takes into account the spatial distribution of all interference areas and avoids adjustment direction errors caused by positional deviations in a single area, providing the equipment with a balanced and representative interference center location.
[0047] In some embodiments, the comprehensive geometric centroid can be calculated in several ways: Optionally, a method based on direct pixel coordinate calculation can be used. First, extract a list of all pixel coordinates contained in each interfering reflected light region. Then, calculate the mean of the x-coordinate and the mean of the y-coordinate of all pixels to obtain the geometric centroid of the region. Next, store the geometric centroid coordinates of all regions in a coordinate array. Finally, calculate the arithmetic mean of all x-coordinates and y-coordinates in the coordinate array to obtain the comprehensive geometric centroid. Optionally, a centroid calculation method based on region area weighting can also be used. First, calculate the area of each interfering reflected light region. Then, calculate the weighted geometric centroid of each region using the area as the weight. Next, calculate the weighted average of all weighted centroids according to their corresponding region areas to finally obtain the comprehensive geometric centroid coordinates considering the differences in region size.
[0048] It is understandable that other methods can be used to calculate the composite geometric centroid, and no limitation is made here.
[0049] S104. The detection equipment determines the target transfer position closest to the integrated geometric centroid outside the boundary of the blade area.
[0050] In this context, the boundary refers to the outer contour line of the leaf region, representing the dividing line between the leaf region and the background region, and is usually composed of a series of continuous pixels. Distance represents the spatial interval between two points; in image processing, Euclidean distance is typically used to measure the straight-line distance between pixels. The target transfer position refers to a coordinate point determined outside the leaf region; this point is the optimal position that the detection device needs to move to in order to eliminate interference from reflected light on vein detection.
[0051] Step S104 is executed after the overall geometric centroid is calculated in step S103. Its purpose is to determine an adjustment position for the detection equipment, minimizing the adjustment distance and avoiding interference from reflected light. Specifically, the detection equipment first calculates the minimum bounding rectangle of the blade region by traversing the coordinates of all pixels within the blade region to find the minimum value of the x-axis coordinate. min and maximum value x max and the minimum value of the y-axis coordinate y min and maximum value y max Thus, the coordinates of the four vertices of the rectangle are determined as (x, y, y). min y min ), (x max y min ), (x max y max ) and (x min y max The image is first processed to form a minimum bounding rectangle enclosing the leaf region. Next, the detection device subtracts this minimum bounding rectangle from the ryegrass image. Specifically, it creates a binary mask of the same size as the original image, marking pixels within the minimum bounding rectangle as 0 and pixels outside the rectangle as 1, resulting in a usable transfer region mask. The device then searches for the optimal target transfer location within this usable transfer region, iterating through all pixels with a value of 1 in the usable transfer region mask and calculating the Euclidean distance from each pixel to the centroid. The device records the coordinates of the pixel with the smallest distance to the centroid as the target transfer location.
[0052] In some embodiments, the target transfer location can be determined in several ways: Optionally, a radial search-based nearest-point search method can be used. First, multiple rays are emitted at equal angular intervals from the centroid of the composite geometry. Then, the search continues along each ray until the intersection of the blade region boundaries is found. Next, a preset distance is extended outward from each boundary intersection to obtain candidate transfer locations. Finally, the location closest to the centroid of the composite geometry is selected as the target transfer location from all candidate locations. Optionally, an optimal location calculation method based on distance transformation can also be used. First, a distance transformation is performed on the blade region mask to obtain a distance map from each pixel to the blade boundary. Then, pixels with distance values greater than a preset threshold are searched in the distance map as candidate regions. Next, the distance from each pixel to the centroid of the composite geometry is calculated within the candidate regions. Finally, the pixel with the smallest total distance is selected as the target transfer location.
[0053] It is understandable that other methods can be used to determine the target's relocation location, and this is not limited here.
[0054] S105. The detection equipment calculates the guiding vector from the comprehensive geometric centroid to the target transfer position.
[0055] Among them, the guiding vector refers to the directional vector from the comprehensive geometric centroid to the target transfer position, which is used to guide the detection equipment to adjust its spatial position.
[0056] Step S105 is executed after determining the target transfer position in step S104. Its purpose is to calculate the guidance information required for the detection device to move from its current position to the target position. Specifically, the detection device first calculates the displacement vector from the starting point to the ending point, using the overall geometric centroid coordinates (X_center, Y_center) as the starting point and the target transfer position coordinates (X_target, Y_target) as the ending point. The displacement vector is calculated by subtracting the starting point coordinates from the ending point coordinates, resulting in the displacement vector (ΔX, ΔY), where ΔX = X_target - X_center represents the horizontal pixel displacement, and ΔY = Y_target - Y_center represents the vertical pixel displacement. Next, the detection device maps the horizontal component ΔX and the vertical component ΔY of the displacement vector to the movement distance of the detection device in physical space. Based on the pixel size of the image sensor and the distance between the detection device and the detected object, the detection device calculates the mapping relationship from pixels to actual physical distances, converting the horizontal component ΔX into a horizontal movement distance d_horizontal and the vertical component ΔY into a vertical movement distance d_vertical. Then, the detection device scales the movement distance according to a preset device movement ratio coefficient k, and calculates the final guide vector components: the horizontal guide component is k×d_horizontal, and the vertical guide component is k×d_vertical, forming a complete guide vector (k×d_horizontal, k×d_vertical). This guide vector directly corresponds to the actual movement of the detection device in the horizontal and vertical directions, providing executable movement parameters for the positioning of the detection device.
[0057] In some embodiments, the calculation and transformation of the guide vector can be implemented in several ways: Optionally, a precise mapping method based on camera calibration parameters can be used. First, a transformation matrix from the pixel coordinate system to the world coordinate system is obtained through camera calibration. Then, the pixel components of the displacement vector are directly converted into distance components in physical space using the transformation matrix. Next, a movement scaling factor is set according to the mechanical structure parameters and movement accuracy requirements of the detection device, and finally, a guide vector suitable for the device to execute is generated. Optionally, a fast transformation method based on empirical parameters can also be used. First, an empirical mapping table from pixel distance to movement distance is established based on the historical movement data and effect feedback of the detection device. Then, the horizontal and vertical movement distances are quickly obtained by table lookup and interpolation. Finally, the final guide vector is calculated by applying a scaling factor optimized according to the device's movement performance.
[0058] It is understandable that other methods can be used to perform vector computation, such as multi-step mapping methods based on geometric transformations, which are not limited here.
[0059] S106. The detection equipment adjusts its movement direction based on the guide vector.
[0060] Step S106 executes after the guide vector is calculated in step S105. It is the execution stage of the entire reflected light elimination process, achieving physical elimination of reflected light interference through the actual movement of the detection equipment. Specifically, the detection equipment first analyzes the horizontal and vertical movement components in the guide vector, converting these values into movement commands that the detection equipment's movement control system can recognize. The detection equipment's movement control system controls the horizontal movement mechanism (such as a slide rail system driven by a stepper motor or servo motor) to perform a corresponding horizontal displacement based on the horizontal movement component, and simultaneously controls the vertical movement mechanism to perform a corresponding vertical displacement based on the vertical movement component. During the movement, the detection equipment monitors its current position in real time using a position sensor to ensure the accuracy of the movement distance. When the target position is reached, the movement stops and the position is locked. After the movement is complete, the detection equipment verifies whether the current position is consistent with the target transfer position; if there is a deviation, fine-tuning and correction are performed.
[0061] S107. When the area of reflected light is detected to be outside the leaf area, the detection device outputs a shooting confirmation signal to acquire an image of ryegrass without interference from reflected light.
[0062] The phrase "reflected light area located outside the leaf area" means that after the detection equipment's position is adjusted, the reflected light interference area, which originally overlapped with the leaf area, has moved outside the leaf boundary and no longer obstructs or interferes with the internal features of the leaf. The image acquisition confirmation signal is the image acquisition command issued by the detection equipment after verifying the effectiveness of the reflected light interference elimination, used to trigger the camera to take the final image. A ryegrass image without reflected light interference refers to an image obtained under conditions where reflected light interference is eliminated, in which the leaf area is clearly visible and there is no reflected light obstruction.
[0063] Step S107 is executed after the detection device position adjustment is completed in step S106. Specifically, after completing the position adjustment based on the guide vector, the detection device first activates the image preview function to acquire a real-time image of the current field of view and performs rapid image analysis to verify the positional change of the reflected light area. The detection device uses the same reflected light detection algorithm as in step S102 to re-identify the reflected light area in the current image and obtain the adjusted coordinates and range information of the reflected light area. Simultaneously, the detection device maintains tracking of the leaf area to determine the boundary position of the leaf area in the current image. Then, the detection device uses a spatial position comparison algorithm to determine the relative positional relationship between the reflected light area and the leaf area, calculates the overlap area between the two areas, and determines that the reflected light area has successfully moved outside the leaf area when the overlap area is zero or less than a preset threshold. Once the detection device confirms that the reflected light area is outside the leaf area, it immediately generates a shooting confirmation signal and transmits it to the image acquisition system. After receiving the confirmation signal, the image acquisition system uses optimal shooting parameters (including exposure time, aperture size, ISO sensitivity, etc.) to photograph the ryegrass, acquiring an image of the ryegrass without reflected light interference.
[0064] S108. The detection equipment detects leaf veins based on ryegrass images.
[0065] Leaf vein detection refers to the image processing procedure of identifying, extracting, and analyzing the leaf vein structure in ryegrass images. Computer vision algorithms are used to automatically locate the position, shape, and connection relationships of leaf veins. The ryegrass image refers to the image obtained in step S107 without reflected light interference, providing clear and unobstructed visual information for leaf vein detection. Leaf veins are the representation of the vascular bundle structure inside the leaf in the image, typically exhibiting linear or network-like texture features, including different levels of vein structure such as the midrib, lateral veins, and fine veins.
[0066] Step S108 is executed after obtaining the ryegrass image free of reflected light interference in step S107. It is the final application stage of the entire detection process. Specifically, the detection equipment first performs preprocessing optimization on the ryegrass image, including image smoothing filtering to remove noise, histogram equalization to enhance contrast, and edge sharpening to highlight leaf vein boundary features, providing an ideal input image for subsequent leaf vein detection algorithms. Then, the detection equipment applies a multi-level leaf vein detection algorithm to analyze the image. First, it uses edge detection operators such as the improved Canny operator or directional gradient operator to extract linear edge features in the image, focusing on identifying edge responses with leaf vein characteristics. Next, the detection equipment uses a linear structure enhancement algorithm based on the Hessian matrix, which enhances tubular and linear structures by analyzing the second derivative features of the image, effectively highlighting the tubular features of leaf veins and suppressing other texture interference. The detection equipment also uses mathematical morphology processing techniques such as connectivity analysis, skeleton extraction, and branch point detection to improve the leaf vein structure, remove broken edge fragments, and connect line segments belonging to the same leaf vein to form a continuous and complete leaf vein network. During leaf vein detection, the equipment establishes a hierarchical representation of leaf veins, distinguishing different levels of vein structure such as primary veins, secondary veins, and tertiary veins, and recording the length, width, orientation angle, and branching characteristics of each vein. Finally, the equipment generates detection results containing vein coordinate information, geometric parameters, topological relationships, and statistical characteristics. These results can be used for quantitative assessment of leaf quality, supporting automated leafy vegetable grading and quality control applications.
[0067] In the above embodiments, the detection device extracts the leaf region and the reflected light region from the ryegrass image. When the reflected light region overlaps with the leaf region, the detection device marks the overlapping part as a set of interfering reflected light regions. The target transfer position is determined by calculating the comprehensive geometric centroid of the set of interfering reflected light regions. Finally, the detection device adjusts the movement direction based on the guiding vector to transfer the reflected light outside the leaf region, thereby reducing the influence of reflected light on the topology of the ryegrass leaf vein network and improving the accuracy of detecting the topology of the ryegrass leaf vein network. This provides a more reliable image data basis for the nutritional value assessment of forage.
[0068] However, the waxy layer that often covers the surface of ryegrass may overexpose under strong light, causing saturated pixels on the sensor. These saturated pixels trigger a halo diffusion effect, making the actual area affected by reflected light much larger than the area directly detected by the sensor. If the method described in the above embodiment is still used to process the light based on the detected reflected light area, leaf vein information within the halo diffusion area will be lost, affecting detection accuracy.
[0069] In some embodiments, in order to reduce the influence of halo diffusion, this application proposes a preferred method for detecting leaf veins of ryegrass. In this preferred method, the following method for expanding the reflected light region of saturated pixels can be performed in the detection device marking the reflected light region of the overlapping part as a set of interfering reflected light regions.
[0070] Please see Figure 2 This is another flowchart illustrating a method for detecting leaf veins in ryegrass according to an embodiment of this application.
[0071] S201. The detection equipment extracts the leaf area and the reflected light area from the ryegrass image.
[0072] The steps in S201 are similar to those in S101, and will not be repeated here.
[0073] S202. When the reflected light area overlaps with the blade area, the detection device determines whether there are saturated pixels in the reflected light area of the overlapping part.
[0074] Saturated pixels refer to pixels whose brightness values exceed the preset maximum response value of the sensor in the detection device. When a sensor pixel receives too many photons, charge saturation occurs, causing the pixel to fail to accurately record the true light intensity. The preset maximum response value refers to the maximum brightness value that the sensor in the detection device can accurately measure under normal operating conditions. It usually corresponds to the full-well capacity of the sensor. Pixels exceeding this value will exhibit saturation and may trigger a charge overflow effect. Excess charge will leak into adjacent pixels, causing neighboring pixels that should not be illuminated to become abnormally bright, which appears as a blurred halo around the bright area in the image.
[0075] Step S202 is executed after the extraction of the blade region and the reflected light region in step S201. It is triggered when the detection device confirms that the reflected light region and the blade region have spatial overlap. Its purpose is to identify saturated pixels that may cause halo diffusion, providing a basis for determining whether the range of the reflected light region needs to be expanded. Specifically, the detection device first calculates the intersection of the blade region mask and the reflected light region mask using a logical AND operation to obtain the set of pixel coordinates for the overlapping part. This set contains all pixels that belong to both the blade region and the reflected light region. Then, the detection device traverses each pixel within the overlapping part, reads its brightness value in the original image, and compares it with the sensor's preset maximum response value. The preset maximum response value is determined according to the sensor type; for example, it is set to 255 for an 8-bit depth sensor and 4095 for a 12-bit depth sensor. This value represents the upper limit of brightness that the sensor can accurately measure. When the detection device finds pixels with brightness values equal to or exceeding the preset maximum response value within the overlapping area, these pixels are marked as saturated pixels, indicating that the sensor has reached its full capacity at these locations and cannot accommodate more photogenerated charge. The presence of saturated pixels means that the actual light intensity may far exceed the sensor's measurement range. Furthermore, due to the charge overflow effect, these saturated pixels can affect the surrounding pixels, causing halo diffusion and making the actual reflected light area larger than the detected reflected light area.
[0076] S203, the detection device expands the reflected light area based on the brightness gradient of saturated pixels, the full-well capacity of the sensor of the detection device, and the preset halo diffusion coefficient.
[0077] Among them, brightness gradient refers to the rate of change of brightness between a saturated pixel and its neighboring pixels, reflecting the spatial variation characteristics of light intensity distribution and used to determine the direction and intensity of halo diffusion. Eight neighbors refer to the eight adjacent pixels in a 3×3 pixel window centered on the saturated pixel, excluding the center pixel, including four directly adjacent pixels (top, bottom, left, and right) and four diagonally adjacent pixels. Full-well capacity refers to the maximum amount of charge that a single pixel in an image sensor can store. When the number of received photons exceeds the full-well capacity, charge overflow occurs, which is an important parameter for measuring the dynamic range of the sensor. Preset halo diffusion coefficient refers to a halo diffusion intensity parameter pre-set according to the sensor characteristics and optical system configuration, used to quantify the halo influence range caused by charge overflow.
[0078] Step S203 is executed after step S202 determines that saturated pixels exist in the overlapping area. Its purpose is to calculate and expand the actual influence range of the reflected light region based on the sensor's physical characteristics and halo diffusion patterns, thus avoiding misjudgments caused by halo interference in leaf vein detection. Specifically, the detection device first performs eight-neighborhood brightness gradient analysis on each identified saturated pixel, calculating the brightness difference between the central saturated pixel and its eight surrounding neighboring pixels. These differences are then converted into gradient vectors, with each vector pointing towards its corresponding neighboring pixel and having an amplitude equal to the brightness difference. The detection device then analyzes the distribution characteristics of these gradient vectors, determining the main direction of halo diffusion through vector analysis. The main direction corresponds to the direction with the largest gradient amplitude, indicating the strongest halo diffusion. The secondary direction corresponds to the direction perpendicular to the main direction and with the second largest gradient amplitude. Next, the detection device calculates the theoretical range of halo diffusion based on the sensor's full-well capacity parameter. A larger full-well capacity means the sensor can hold more charge, resulting in greater charge leakage when overflow occurs, leading to a wider range of halo diffusion. The detection equipment constructs an elliptical diffusion model based on a preset halo diffusion coefficient. This model is centered on a saturated pixel, with its major axis aligned with the main diffusion direction and its minor axis aligned with the secondary diffusion direction. The length of the major axis is proportional to the full-well capacity, and the length of the minor axis is proportional to the halo diffusion coefficient. Finally, the detection equipment marks all pixel areas covered by the elliptical halo diffusion model as the expanded reflected light region. This region includes not only the original reflected light pixels but also surrounding pixels affected by the halo effect, thus more accurately reflecting the range of influence of reflected light on image quality.
[0079] S204. The detection equipment marks the reflected light regions that overlap with the expanded reflected light region and the blade region as the set of interfering reflected light regions.
[0080] Step S204 is executed after the reflected light region expansion is completed in step S203. It marks the actual interference region after halo influence analysis as a set of interfering reflected light regions, providing more accurate target region location for subsequent reflected light elimination processing. Specifically, the detection device first obtains the expanded reflected light region mask output from step S203. This mask includes not only the originally detected reflected light pixels but also the surrounding pixel regions affected by the halo, calculated based on the elliptical halo diffusion model. Then, the detection device calculates the intersection between the expanded reflected light region and the blade region through spatial geometric analysis, using logical AND operations to perform pixel-level overlap detection on the two region masks, identifying all pixels that simultaneously belong to both the expanded reflected light region and the blade region. The detection device performs connectivity analysis on the overlapping regions, aggregating spatially adjacent overlapping pixels into connected overlapping region blocks, each representing an independent interference source. Finally, the detection device uniformly marks all overlapping region blocks as a set of interfering reflected light regions, assigning a unique identifier to each interference region.
[0081] S205. The detection equipment marks the overlapping reflected light areas as a set of interfering reflected light areas.
[0082] Step S205 is another execution path of the decision branch of step S202. It is executed when it is determined that there are no saturated pixels in the reflected light area of the overlapping part. Specifically, step S205 is similar to step S102, and will not be described again here.
[0083] Since a ryegrass image may contain multiple leaves, when the detection device attempts to redirect the reflected light from all leaf areas to outside the leaf area boundaries, it may be impossible to completely eliminate the interference of reflected light from all leaf areas no matter what adjustments are made.
[0084] In some embodiments, after the step of adjusting the movement direction of the detection device based on the guide vector, a preferred method of a ryegrass leaf vein detection method may be performed when there are multiple leaf regions and after one movement adjustment, the reflected light region still overlaps with at least one leaf region among the multiple leaf regions.
[0085] Please see Figure 3 This is another flowchart illustrating a method for detecting leaf veins in ryegrass according to an embodiment of this application.
[0086] S301. When there are multiple blade regions and after one movement adjustment, the reflected light region still overlaps with at least one blade region among the multiple blade regions, the detection device acquires an image of the blade region where there is no reflected light region.
[0087] Step S301 is executed after the detection device completes the position adjustment in step S106. It is triggered when multiple leaf regions exist and, after one adjustment, the reflected light region still overlaps with at least one of the multiple leaf regions. The purpose is to prioritize processing leaf regions that can obtain a clear image without additional adjustment, thus improving overall processing efficiency. Specifically, the detection device first acquires an image of ryegrass at the current position and re-identifies all leaf regions and reflected light regions in the image using the same method as in step S101. Then, the detection device checks the intersection of each leaf region and the reflected light region one by one through spatial overlap analysis, using logical AND operations to calculate the intersection of each leaf region mask and the reflected light region mask. When the number of intersection pixels is zero, it is determined that the leaf region has no reflected light interference. For the identified leaf regions without reflected light interference, the detection device immediately performs image extraction, cropping the corresponding sub-image region from the complete image based on the boundary coordinates and geometry of the leaf region. During extraction, the detection device retains an appropriate boundary buffer to improve the integrity of the leaf edge information and records the position coordinates of the sub-image in the original image, providing spatial positioning data for subsequent image stitching. The detection device stores the extracted leaf area images in the processed image library, assigns them a unique identifier and processing timestamp, and updates the status of the leaf area to indicate that processing has been completed.
[0088] S302. The detection equipment determines the intensity of reflected light interference and the minimum adjustment distance within the blade area where reflected light exists.
[0089] The reflected light interference intensity refers to the ratio of the area of the reflected light region within the leaf region to the total area of that leaf region. This value quantifies the degree of influence of reflected light on a specific leaf region; a higher ratio indicates more severe interference. The minimum adjustment distance refers to the minimum moving distance of the detection equipment required to transfer the reflected light region within the leaf region to the transfer area. This distance reflects the equipment adjustment cost required to eliminate reflected light interference in that leaf region. The transfer area refers to other areas in the ryegrass image that do not contain the leaf region where the reflected light is located.
[0090] Step S302 is executed after acquiring images of blade regions without reflected light interference in step S301. It is triggered when the detection device identifies blade regions still affected by reflected light interference. Its purpose is to establish a quantitative interference assessment and processing cost analysis for these blade regions requiring further processing, providing a data foundation for subsequent prioritization. Specifically, the detection device first identifies all blade regions with reflected light interference. It calculates the intersection of each blade region mask and the reflected light region mask using a logical AND operation. If the number of intersection pixels is greater than zero, the blade region is determined to have reflected light interference. For each interfering blade region, the detection device calculates the reflected light interference intensity, counts the number of reflected light pixels in the overlapping portion of the blade region, and simultaneously counts the total number of pixels in the blade region. The interference intensity ratio is obtained by dividing the number of overlapping pixels by the total number of pixels. The detection device also needs to analyze the distribution of transfer regions in the current image. These regions include the original background region, the gaps between blades, and the blade regions processed in step S301. The detection device locates the geometric center of the overlapping portion of reflected light within each interfering blade region and calculates the centroid coordinates of the overlapping region as the representative location of the reflected light interference. The detection device then traverses all transfer areas, calculates the Euclidean distance from the center of the reflected light interference to the boundary of the transfer area, and selects the transfer area with the shortest distance as the optimal transfer target. This shortest distance is the minimum adjustment distance for that blade area. The detection device generates evaluation data for each blade area with reflected light interference, including the reflected light interference intensity value and the minimum adjustment distance value.
[0091] S303. The detection equipment uses the division of the reflected light interference intensity and the minimum adjustment distance as the processing priority score for the blade area where reflected light exists.
[0092] Step S303 is executed immediately after step S302, which calculates the interference intensity and adjustment distance for each blade region experiencing reflected light interference. Its purpose is to establish a processing priority system and improve overall processing efficiency. Specifically, the detection equipment uses the division between the reflected light interference intensity and the minimum adjustment distance as the processing priority score for the blade region containing reflected light. The physical meaning of this calculation method is to measure the interference elimination benefit achievable per unit of movement cost; regions with high reflected light interference intensity and short adjustment distance will receive the highest priority score.
[0093] S304. The detection equipment will use the blade area with the highest processing priority score as the target area.
[0094] S305. The detection equipment acquires an image of the target area without reflected light interference based on the guiding vector of the target area.
[0095] Step S305 is executed after the target area is determined in step S304. Specifically, the detection device first calculates the guiding vector of the target area based on the method in steps S104-S105. Then, based on the guiding vector, the detection device performs the position adjustment operation in step S106 to move the reflected light area from the target leaf area to another area in the ryegrass image that does not contain the leaf area where the reflected light is located. After the movement is completed, the detection device performs the image acquisition operation in step S107, obtaining an image of the target area without reflected light interference. The detection device stores the obtained clear target area image in the processed image library, recording the spatial location information of the image. Next, the detection device updates the status information of the target area and removes the area from the list of leaf areas to be processed.
[0096] S306. The detection equipment sequentially acquires images of each leaf area after the interference of reflected light, and stitches the images of each leaf area together to form a ryegrass image.
[0097] Step S306 is executed after the processing of a single target region in step S305, forming the main control loop of the entire reflection light elimination process. Its purpose is to systematically process all leaf regions with reflection light interference, ultimately obtaining a complete image of ryegrass free from reflection light interference. The specific iterative processing flow is as follows: The detection device first initializes the loop control parameters and establishes a queue of leaf regions to be processed. This queue contains all leaf regions with reflection light interference identified in step S302. The detection device sets the loop continuation condition to a non-empty queue, meaning that the processing loop continues as long as there are still leaf regions with reflection light interference. In each loop iteration, the detection device sequentially executes the complete processing sequence from S302 to S305: re-analyzes the remaining leaf regions with reflection light interference, calculates the reflection light interference intensity and minimum adjustment distance for each region, updates the processing priority score to reflect changes in the current processing environment, selects the region with the highest score as the new target region, calculates the guiding vector based on this target region and performs position adjustment, and obtains a clear image of the processed region free from reflection light interference. After processing each target area, the detection device updates the processing queue, removes the processed areas, and reassesses the processing conditions of the remaining areas. The advantage of this iterative process is its ability to dynamically adapt to environmental changes during processing. Each time an area is processed, the number of transfer areas increases, providing more transfer options for subsequent areas while reducing the required device adjustment distance, thus gradually improving overall processing efficiency. When the processing queue is empty, it indicates that all blade areas have completed reflection light elimination processing, the loop terminates, and the detection device obtains images of all blade areas free from reflection light interference.
[0098] After eliminating reflected light from all leaf regions, the detection equipment performs image stitching to reconstruct a complete ryegrass image from the processed leaf region images. Specifically, the equipment first creates a blank canvas of the same size as the original ryegrass image, using the same resolution, color space, and pixel format to ensure consistency of image parameters in the stitched result. The equipment then acquires the precise positional coordinates of each leaf region within the original ryegrass image. These coordinates, recorded during image segmentation and remaining unchanged throughout the process, include spatial parameters such as the bounding box coordinates, geometric center position, and rotation angle of each leaf region. Based on these coordinates, the equipment places each leaf region image, now free of reflected light interference, into its corresponding position on the blank canvas, using a pixel mapping algorithm to restore each leaf region to its spatial position in the original image. Since the leaf region images are acquired separately from different equipment positions, slight differences in brightness, color shifts, or geometric discontinuities may exist at the boundaries of adjacent regions, resulting in visible stitching marks. The detection equipment employs a Poisson fusion algorithm to process these stitching boundaries. This algorithm smoothly fuses the boundaries of adjacent regions while preserving image gradient information by solving the Poisson equation, eliminating stitching artifacts and maintaining the natural appearance of the image. The detection equipment then performs quality checks and post-processing optimizations on the fused complete image, including overall brightness equalization, color consistency adjustment, and detail enhancement, ultimately outputting a complete ryegrass image.
[0099] The above describes a method for detecting leaf veins in ryegrass according to an embodiment of this application. The following describes an exemplary detection device 400 provided in an embodiment of this application.
[0100] Figure 4 This is a schematic diagram of an exemplary hardware structure of the detection device 400 provided in an embodiment of this application. In some embodiments, the detection device 400 is a computer device. The computer device includes a processor, a memory, and a network interface connected via a system bus. The processor of the computer device provides computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and internal memory. The non-volatile storage medium stores an operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage medium. The database of the computer device is used to store data. The network interface of the computer device is used to communicate with other external terminals or servers via a network connection. In some embodiments, the network interface can be a wired network interface; in some embodiments, the network interface can also be a wireless network interface. When the computer program is executed by the processor, it implements a leaf vein detection method for ryegrass according to an embodiment of this application.
[0101] Those skilled in the art will understand that Figure 4 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0102] In some embodiments of this application, a computer-readable storage medium is also provided, including instructions that, when executed on the detection device 400, cause the detection device 400 to perform a leaf vein detection method for ryegrass according to an embodiment of this application.
[0103] The above-described embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit it. Although this application 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 scope of the technical solutions of the embodiments of this application.
[0104] As used in the above embodiments, depending on the context, the term "when..." can be interpreted as meaning "if...", "after...", "in response to determining...", or "in response to detecting...". Similarly, depending on the context, the phrase "when determining..." or "if (the stated condition or event) is interpreted as meaning "if determining...", "in response to determining...", "when (the stated condition or event) is detected", or "in response to detecting (the stated condition or event)".
[0105] In the above embodiments, implementation can be achieved entirely or partially through software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented entirely or partially in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid-state drive), etc.
[0106] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. This program can be stored in a computer-readable storage medium, and when executed, it can include the processes described in the above method embodiments. The aforementioned storage medium includes various media capable of storing program code, such as ROM or random access memory (RAM), magnetic disks, or optical disks.
Claims
1. A method of detecting leaf veins of ryegrass, characterised in that, The method is applied to a detection device, and the method comprises: The detection device extracts a leaf region and a reflected light region from a ryegrass image; When the reflected light region overlaps the leaf region, the detection device labels the overlapping part of the reflected light region as a set of interference reflected light regions; The detection device calculates an arithmetic mean value of geometric barycenters of the interference reflected light regions in the set of interference reflected light regions as a comprehensive geometric barycenter; The detection device determines a target transfer position closest to the comprehensive geometric barycenter outside a boundary of the leaf region; The detection device determines a target transfer position closest to the comprehensive geometric barycenter outside a boundary of the leaf region, specifically comprising: the detection device calculates a minimum circumscribed rectangle of the leaf region; the detection device subtracts the minimum circumscribed rectangle from the ryegrass image to obtain an available transfer region; and the detection device takes a pixel point with the smallest distance to the comprehensive geometric barycenter in the available transfer region as the target transfer position; The detection device calculates a guide vector from the comprehensive geometric barycenter to the target transfer position; The detection device calculates a guide vector from the comprehensive geometric barycenter to the target transfer position, specifically comprising: the detection device calculates a displacement vector with the comprehensive geometric barycenter as a starting point and the target transfer position as a terminal point; the detection device maps a horizontal component and a vertical component of the displacement vector into a horizontal moving distance and a vertical moving distance of the detection device, respectively; and the detection device converts the horizontal moving distance and the vertical moving distance into the guide vector according to a preset device moving proportionality coefficient; The detection device adjusts a moving direction based on the guide vector; When it is detected that the reflected light region is located outside the leaf region, the detection device outputs a shooting confirmation signal to obtain a ryegrass image without the interference of the reflected light; The detection device detects a leaf vein based on the ryegrass image.
2. The method of claim 1, wherein, When the reflected light region overlaps the leaf region, the detection device labels the overlapping part of the reflected light region as a set of interference reflected light regions, specifically comprising: When the reflected light region overlaps the leaf region, the detection device determines whether there is a saturated pixel point in the overlapping part of the reflected light region, the saturated pixel point being a pixel point with a luminance value greater than a preset maximum response value of a sensor of the detection device; If yes, the detection device expands the reflected light region based on a luminance gradient of the saturated pixel point, a full well capacity of the sensor of the detection device, and a preset halo diffusion coefficient; The detection device expands the reflected light region based on the luminance gradient of the saturated pixel points, the full well capacity of the sensor of the detection device, and a preset halo diffusion coefficient, specifically including: the detection device determines the main direction and the secondary direction of halo diffusion based on the direction and amplitude of the luminance gradient vector in the eight-neighbor domain of the saturated pixel points, the main direction is the direction with the maximum gradient amplitude, and the secondary direction is the direction perpendicular to the main direction and with the second largest gradient amplitude; the detection device constructs an elliptical diffusion model based on the main direction and the secondary direction, the long axis direction of the elliptical diffusion model is consistent with the main direction, the short axis direction is consistent with the secondary direction, the long axis length is proportional to the full well capacity of the sensor of the detection device, and the short axis length is proportional to the preset halo diffusion coefficient; the detection device covers the pixel region covered by the elliptical diffusion model as the expanded reflected light region; The detection device labels the reflected light region of the overlapping part of the expanded reflected light region and the leaf region as the set of interference reflected light regions; If not, the detection device labels the reflected light region of the overlapping part as the set of interference reflected light regions.
3. The method of claim 1, wherein, After the step of adjusting the moving direction of the detection device based on the guide vector, the method further includes: When there are multiple leaf regions and after one-time moving adjustment, if the reflected light region still overlaps with at least one of the multiple leaf regions, the detection device acquires the picture of the leaf region without the reflected light region; The detection device determines the reflected light interference intensity and the minimum adjustment distance in the leaf region with the reflected light region, the reflected light interference intensity is the ratio of the area of the reflected light region in the leaf region to the area of the leaf region, and the minimum adjustment distance is the moving distance of the detection device required for the reflected light region in the leaf region to move to the transfer region, the transfer region being the region of the ryegrass image excluding the leaf region; The detection device takes the division value of the reflected light interference intensity and the minimum adjustment distance as the processing priority score of the leaf region with the reflected light region; The detection device takes the leaf region with the highest processing priority score as the target region; The detection device acquires the image of the target region without reflected light interference based on the guide vector of the target region; The detection device sequentially acquires the images of the leaf regions without reflected light interference, and splices the images of the leaf regions into a ryegrass image.
4. The method of claim 3, wherein, The detection device sequentially acquires the images of the leaf regions without reflected light interference, and splices the images of the leaf regions into a ryegrass image, specifically including: The detection device creates a blank canvas with the same size as the ryegrass image; The detection device places the images of the leaf regions without reflected light interference on the blank canvas according to the position coordinate information of the leaf regions in the ryegrass image; The detection device eliminates the splicing traces of the splicing boundary based on Poisson fusion processing; The detection device outputs the complete ryegrass image.
5. A detection device, characterized by The detection device comprises one or more processors and a memory; the memory is coupled with the one or more processors, the memory is configured to store computer program codes, the computer program codes comprise computer instructions, and the one or more processors invoke the computer instructions to enable the detection device to perform the method according to any one of claims 1-4.
6. A computer program product comprising instructions, characterized in that, When the computer program product runs on the detection device, the detection device is enabled to perform the method according to any one of claims 1-4.
7. A computer-readable storage medium comprising instructions, wherein: When the instructions run on the detection device, the detection device is enabled to perform the method according to any one of claims 1-4.
Citation Information
Patent Citations
Binocular vision three-dimensional reconstruction method based on structured light and polarization
CN112053432A
Laser positioning method based on image information and robot
CN115619860A