Method and system for accurately identifying and counting basic wheat seedlings
By taking the base image of the basic wheat seedlings on the side and performing geometric correction and feature enhancement, combining the scale background and adaptive threshold cutting, the problems of time-consuming and labor-intensive and leaf occlusion are solved, and the accurate identification and counting of basic wheat seedlings are achieved, which is suitable for large-scale agricultural management.
Patent Information
- Application Number
- CN202510423943.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-07
- Publication Date
- 2025-07-29
AI Technical Summary
Traditional wheat seedling surveys rely on manual counting, which has the problem of time-consuming and labor-intensive and susceptible to human factors. At the same time, existing image recognition technology is susceptible to leaf occlusion and shadow during wheat growth, resulting in recognition errors.
The base image of the basic wheat seedlings was taken from the side, and the geometric correction and resolution standardization were performed in combination with the scale background. Multimodal feature enhancement algorithm and adaptive threshold cutting were used to achieve accurate identification and counting of basic wheat seedlings through morphological optimization and contour analysis.
It improves the accuracy and efficiency of identification and counting of basic wheat seedlings, reduces artificial errors, and is suitable for automated operations in large-scale agricultural scenarios.
Smart Images

Figure CN120388281A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of wheat field management, and in particular to a method and system for accurately identifying and counting the basic seedlings of wheat during the seedling condition investigation process. Background Art
[0002] The planting management of wheat is a complex and meticulous process that can effectively ensure the safe production and harvest of wheat. It covers all aspects from the seedling stage to the maturity stage, including wheat seedling stage management, green-reviving and jointing management in spring, and pest and disease management in the middle and later stages. Among them, seedling stage management is particularly crucial because it directly affects whether wheat can overwinter safely and lays a solid foundation for subsequent growth.
[0003] In seedling stage management, seedling condition investigation is an essential task. By investigating the emergence rate, basic seedling number, and the growth trend of adventitious roots in the early stage, agricultural workers can timely understand the growth status of wheat and thus take corresponding management measures to ensure the healthy growth of wheat. However, the traditional seedling condition investigation method mainly relies on manual work, which is not only time-consuming and laborious but also easily affected by human factors, resulting in certain limitations in the accuracy and reliability of the investigation results.
[0004] With the rapid development of artificial intelligence technology, especially the continuous iteration and upgrade of image recognition technology, the intelligentization of wheat seedling condition investigation has become possible. By using advanced image recognition algorithms and machine learning techniques, the automatic recognition and monitoring of wheat seedling conditions can be achieved. This intelligent investigation method can not only greatly improve the investigation efficiency, reduce the labor input, but also improve the accuracy and objectivity of the investigation results, providing a more scientific and reliable basis for wheat planting management.
[0005] Currently, when investigating the seedling condition, on-site investigations are carried out on a certain area of wheat fields. One of the tasks is to calculate the basic seedlings per mu. Investigators will investigate (count) the number of wheat seedlings (plants) within a certain area. By using devices such as drones, digital cameras, or smartphones to take images of wheat in a certain area, and then combining advanced image processing algorithms to identify the wheat in the images, the rapid identification and counting of wheat seedling conditions can be achieved, greatly improving the work efficiency, reducing the labor intensity, and at the same time reducing the errors caused by human factors.
[0006] However, there are still deficiencies in using the above methods for seedling count investigation at the current stage. On the one hand, as wheat grows, the number of leaves increases, the leaves themselves also grow larger, and there is mutual occlusion between the leaves, which causes interference to image recognition. On the other hand, when using devices such as drones, digital cameras, or smartphones to collect images, it is usually carried out in the upper area of the wheat, which is easily affected by the leaf shadows, leading to misjudgment in image processing, resulting in incorrect estimation of the wheat growth potential and affecting later topdressing or other agricultural operations. Summary of the Invention
[0007] In view of the above problems, the present invention provides a method and system for accurate identification and counting of the basic seedlings of wheat to improve the accuracy of identifying and counting the basic seedlings of wheat.
[0008] A method for accurate identification and counting of the basic seedlings of wheat provided by the present invention includes:
[0009] S100. Obtain the image data of the base of the basic seedlings of wheat taken from the side, and preprocess the image data of the base of the basic seedlings of wheat to obtain a preprocessed target image, wherein a background board with scales is used as the shooting background for the base of the basic seedlings of wheat;
[0010] S200. Perform plant feature enhancement processing on the small basic seedlings in the preprocessed target image to highlight the features of the basic seedlings of wheat in the preprocessed target image and obtain a target image;
[0011] S300. Perform adaptive threshold cutting processing on the target image to distinguish the basic seedlings of wheat from the background in the target image;
[0012] S400. Optimize the morphology of the basic seedlings of wheat after differentiation to make the basic seedlings of wheat in a complete connected region;
[0013] S500. Perform contour analysis and filtering on the basic seedlings of wheat after morphological optimization, and count the number of wheat basic seedling plants in the image based on the pixel contour value;
[0014] S600. Establish a mapping according to the scales of the background, obtain the relationship between length and pixels, and determine the number of wheat basic seedling plants corresponding to the length of the image background;
[0015] S700. Determine the number of wheat basic seedling plants per mu based on the number of wheat basic seedling plants corresponding to the length of the image background.
[0016] As a further improvement of the present invention, the preprocessing of the image data of the base of the basic seedlings of wheat to obtain a preprocessed target image includes performing geometric correction and resolution standardization on the image data of the base of the basic seedlings of wheat, and uniformly scaling the image data of the base of the basic seedlings of wheat to a set resolution.
[0017] As a further improvement of the present invention, geometric correction and resolution standardization are performed on the image data of the base of the basic wheat seedlings, and the image data of the base of the basic wheat seedlings is uniformly scaled to a set resolution, including uniformly scaling the image data of the base of the basic wheat seedlings to 2560×1920 pixels, and using bicubic interpolation to maintain edge sharpness.
[0018] As a further improvement of the present invention, obtaining the image data of the base of the basic wheat seedlings taken from the side includes placing the background board perpendicular to the ground and taking pictures with a shooting device on the side of the base of the basic wheat seedlings to obtain the image data of the base of the basic wheat seedlings. Among them, the included angle between the axial direction of the camera lens of the shooting device and the plane of the background board is ≤5°.
[0019] As a further improvement of the present invention, obtaining the image data of the base of the basic wheat seedlings taken from the side further includes adjusting the vertical distance between the camera of the shooting device and the ground to 1-3 cm and taking pictures 7-15 days after the small seedlings emerge to obtain the image data of the base of the basic wheat seedlings.
[0020] As a further improvement of the present invention, obtaining the image data of the base of the basic wheat seedlings taken from the side includes using a shooting device with no less than 12 million pixels to take pictures to obtain the image data of the base of the basic wheat seedlings. Among them, the image resolution of the image data of the base of the basic wheat seedlings is ≥1920×1080.
[0021] As a further improvement of the present invention, performing plant feature enhancement processing on the basic seedlings of the small seedlings in the preprocessed target image to highlight the characteristics of the basic wheat seedlings in the preprocessed target image and obtain a target image includes using a multi-modal feature enhancement algorithm to process the preprocessed target image to highlight the characteristics of the basic wheat seedlings in the preprocessed target image and obtain a target image.
[0022] As a further improvement of the present invention, using a multi-modal feature enhancement algorithm to process the preprocessed target image to highlight the characteristics of the basic wheat seedlings in the preprocessed target image and obtain a target image includes performing super-green index enhancement processing, YUV color space brightness normalization, and morphological top-hat transformation on the preprocessed target image to highlight the characteristics of the basic wheat seedlings in the preprocessed target image and obtain a target image.
[0023] As a further improvement of the present invention, performing super-green index enhancement processing, YUV color space brightness normalization, and morphological top-hat transformation on the preprocessed target image to highlight the characteristics of the basic wheat seedlings in the preprocessed target image and obtain a target image includes performing super-green index enhancement processing on the preprocessed target image using an improved super-green index. Among them, the improved super-green index is:
[0024] gExG = 1.8G - 1.2R - 0.6B
[0025] Wherein R, G, and B are the pixel values of the red, green, and blue channels respectively.
[0026] As a further improvement of the present invention, the use of the improved super green index to perform super green index enhancement processing on the preprocessed target image includes constructing a light intensity evaluation model and adaptively adjusting the super green index coefficient by calculating the mean μ and standard deviation σ of the Y channel.
[0027] As a further improvement of the present invention, the target image is subjected to adaptive threshold cutting processing to distinguish the basic wheat seedlings from the background in the target image, including automatically determining the threshold for segmenting the basic wheat seedlings and the background using the Otsu algorithm in the S channel, and creating a binary mask, where the basic wheat seedling area = 1 and the background = 0, to distinguish the basic wheat seedlings from the background in the target image.
[0028] As a further improvement of the present invention, morphological optimization is performed on the distinguished basic wheat seedlings to make the basic wheat seedlings in a complete connected region, including opening operation, closing operation, and hole filling operation. Among them, the opening operation includes erosion first and then dilation to remove small impurities; the closing operation includes dilation first and then erosion to connect the broken stems, and the hole filling includes using the flood fill algorithm to repair the internal holes.
[0029] As a further improvement of the present invention, contour analysis and filtering are performed on the morphologically optimized basic wheat seedlings, and the number of basic wheat seedling plants in the image is statistically analyzed based on the pixel contour values, including multi-level contour screening and overlapping area segmentation.
[0030] As a further improvement of the present invention, according to the scale lines of the shooting background, a mapping is established, the relationship between length and pixels is obtained, and the number of basic wheat seedling plants within the image background length is determined, including scale line detection, perspective mapping model construction, and solution.
[0031] An accurate recognition and counting system for basic wheat seedlings provided by the present invention includes an original image acquisition unit, a preprocessing unit, a plant feature enhancement unit, a background segmentation unit, a morphological optimization unit, an image plant number statistics unit, a background length plant number acquisition unit, and an acre plant number calculation unit;
[0032] Among them,
[0033] The original image acquisition unit is used to acquire the image data of the base of the basic wheat seedlings taken from the side, with a background board with scales as the shooting background of the base of the basic wheat seedlings;
[0034] The preprocessing unit is used to preprocess the image data of the base of the basic wheat seedlings to obtain a preprocessed target image;
[0035] The plant feature enhancement unit is used to perform plant feature enhancement processing on the small basic wheat seedlings in the preprocessed target image to highlight the features of the basic wheat seedlings in the preprocessed target image and obtain a target image;
[0036] The background segmentation unit is used to perform adaptive threshold cutting processing on the target image to distinguish the basic wheat seedlings from the background in the target image;
[0037] The morphological optimization unit is used to perform morphological optimization on the distinguished basic wheat seedlings so that the basic wheat seedlings are in a complete connected region;
[0038] The image plant number statistics unit is used to perform contour analysis and filtering on the basic wheat seedlings after morphological optimization, and statistically count the number of basic wheat seedlings in the image based on the pixel contour value;
[0039] The background length plant number acquisition unit is used to establish a mapping according to the scale of the background, obtain the relationship between the length and the pixels, and determine the number of basic wheat seedlings with the length of the image background;
[0040] The mu plant number calculation unit is used to determine the number of basic wheat seedlings per mu based on the number of basic wheat seedlings with the length of the image background.
[0041] By providing a method and system for accurate identification and counting of basic wheat seedlings, the present invention realizes the automatic statistics of the number of plants through steps such as image acquisition, preprocessing, feature enhancement, adaptive threshold segmentation, morphological optimization and contour analysis, and combines the pixel mapping of the scale background, improving the accuracy of identification and counting. Compared with the traditional counting methods that rely on manual sampling, visual inspection or simple tools, this method combines computer vision technology with the statistical requirements of basic wheat seedlings, forming a systematic technical framework, providing a feasible technical solution for precision agriculture, and is expected to promote the development of wheat field management towards digitalization and intelligentization. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] Figure 1 is a schematic flowchart of the method for accurate identification and counting of basic wheat seedlings according to an embodiment of the present invention.
[0043] Figure 2 is a schematic structural diagram of the system for accurate identification and calculation of basic wheat seedlings according to an embodiment of the present invention.
[0044] Description of reference numerals: 1. Original image acquisition unit; 2. Preprocessing unit; 3. Plant feature enhancement unit; 4. Background segmentation unit; 5. Morphological optimization unit; 6. Image plant number statistics unit; 7. Background length plant number acquisition unit; 8. Plant number per mu calculation unit. Detailed implementation mode
[0045] The following combines specific embodiments and attached Figure 1-2 to make a detailed description of the invention, so that those skilled in the art can more fully understand the purpose, features and effects of the invention.
[0046] Unless otherwise defined, all technical and scientific terms used in the present invention have the same meaning as commonly understood by those skilled in the art to which the present invention belongs. When the definition of a term in the present invention conflicts with the meaning commonly understood by those skilled in the art to which the present invention belongs, the definition described in the present invention shall prevail.
[0047] The present invention provides a method for accurately identifying and counting the basic seedlings of wheat, improving the existing calculation method for the basic seedlings of wheat. This method can effectively improve the accuracy and robustness of crop seedling identification and is applicable to automated operations in large-scale agricultural scenarios.
[0048] A method for accurately identifying and counting the basic seedlings of wheat, referring to Figure 1 , includes:
[0049] S100. Obtain the image data of the base of the basic seedlings of wheat taken from the side, and preprocess the image data of the base of the basic seedlings of wheat to obtain a preprocessed target image
[0050] S101. Obtain the image data of the base of the basic seedlings of wheat taken from the side
[0051] In this embodiment, the image data of the base of the basic seedlings of wheat is obtained by taking pictures from the side. The camera of the shooting device is aimed at the base of the basic seedlings of wheat in the seedling stage for shooting, avoiding misjudgment caused by the interlacing and shielding of the leaves of adjacent basic seedlings of wheat when shooting the canopy from above during later identification and calculation.
[0052] Specifically, the shooting device can be a digital camera or a smart phone, which is convenient for handheld shooting. Preferably, a smart phone or an industrial camera with more than 12 million pixels is used to ensure that the image resolution ≥ 1920×1080, so that the image of the base of the basic seedlings of wheat obtained by shooting has sufficient clarity.
[0053] High - pixel shooting devices with ≥12 million pixels can provide raw image data of 4000×3000 pixels, which can clearly present key morphological features such as the tillering points of wheat plant stems and the edges of leaf sheaths. At this resolution, the base of a single wheat plant can occupy a 50 - 100 - pixel area in the image, providing sufficient gray - scale gradient data for subsequent adaptive threshold segmentation algorithms and effectively avoiding the problem of feature adhesion commonly found in low - resolution images.
[0054] During shooting, use a background board with centimeter - scale markings as the shooting background to block the background behind the basic seedlings of wheat, making the background pure and unified for easy identification and detection. Among them, the background board is at a 90° angle to the ground, and the angle between the axial direction of the camera lens and the plane of the background board is ≤5°, ensuring that the perspective distortion of the image is controllable; the vertical distance between the camera lens and the ground is 1 - 3 cm. The shooting can be carried out 7 - 15 days after wheat emergence (when the seedlings have completely unfolded 1 - 2 true leaves).
[0055] By establishing a standardized reference system through a strictly vertical scale board, the image scale distortion caused by the background tilt can be eliminated, ensuring the accuracy of the subsequent linear relationship between pixels and length; after the scale board blocks the cluttered background, only the target plants and the scale information with a known ratio are retained in the image, obtaining high - quality input data and reducing the risk of false detection in later algorithms. For example, interference items such as soil texture and weeds are physically isolated, making it easier to distinguish plants from the background during later adaptive threshold segmentation.
[0056] The rigid parameter setting of the camera angle ensures that consistent high - quality image data can be obtained by different operators or devices in different field scenarios, reducing human operation errors.
[0057] When the seedlings have completely unfolded 1 - 2 true leaves, the plant morphology is stable and has not entered the peak tillering period, and the contour of a single plant is highly independent. Shooting at this stage can avoid the problem of contour adhesion caused by leaf overlap, improving the accuracy of later morphological optimization and contour statistics.
[0058] The shooting method of the basic seedlings of wheat in this application can completely avoid the influence of leaves, better identify wheat plants, and avoid the mutual shielding of wheat leaves from affecting the judgment of plants.
[0059] Through the dual control of physical constraints (angle, background board, high contrast) and biological rhythm (shooting window period), high - quality image data acquisition in the early stage is achieved, which helps to improve the accuracy and repeatability of later identification of wheat basic seedlings.
[0060] Preferably, the background board adopts a high-contrast two-color scale board, such as black and white, with red marking lines marked every centimeter horizontally to improve the contrast between the basic wheat seedlings and the background. When performing recognition and counting in the later stage, the background board with centimeter scales is used to enable the recognition algorithm to detect the reference length, and the number of basic wheat seedlings can be calculated within a certain length, and finally the number of wheat plants within a specific length or specific area can be calculated.
[0061] By using a black-and-white two-color scale board combined with red marking lines, the robustness of the later image segmentation algorithm can be significantly improved by strengthening the color scale difference between the target (basic wheat seedlings) and the background. The human eye and image sensors are more sensitive to black-and-white contrast, and red markings have stronger penetrability in the visible light spectrum, which can reduce environmental light interference and ensure the recognizability of the scale reference lines under complex lighting conditions. This design enables the algorithm to more accurately distinguish plants from the background in edge detection, threshold segmentation and other links, reducing the misjudgment rate.
[0062] After shooting, the obtained image of the base of the basic wheat seedlings contains the base of the basic wheat seedlings and the background with centimeter scales.
[0063] To avoid the influence of light on shooting, it is preferably to shoot under natural light and avoid direct light during shooting. For example, when shooting on a cloudy day or in a shaded area, use a ring-shaped fill light (color temperature 5500K, illuminance ≥ 1000 lux) to ensure that the plants are not covered by projections.
[0064] S102. Preprocess the image data of the base of the basic wheat seedlings to obtain a preprocessed target image
[0065] After obtaining the image data of the base of the basic wheat seedlings taken from the side, preprocess the image data of the base of the basic wheat seedlings. The preprocessing includes geometric correction and resolution standardization.
[0066] Geometric correction corrects image deformation caused by internal errors of the sensor (such as lens distortion, scale deviation) and external factors (such as platform attitude change, terrain undulation) through a mathematical model. For example, systematic errors such as scale distortion and center offset can be corrected to restore the image to a state that conforms to the actual geographical space distribution.
[0067] Specifically, in this embodiment, when performing the geometric correction, perspective transformation is used to eliminate the angular tilt. By detecting the four corner positioning points of the background board, the getPerspectiveTransform() and warpPerspective() of OpenCV are called to implement image correction.
[0068] In a specific example, some codes in python are expressed as:
[0069] ```python
[0070] import cv2
[0071] pts_src = np.float32([[x1, y1], [x2, y2], [x3, y3], [x4, y4]])
[0072] pts_dst = np.float32([[0, 0], [w, 0], [w, h], [0, h]])
[0073] M = cv2.getPerspectiveTransform(pts_src, pts_dst)
[0074] img_corrected = cv2.warpPerspective(img, M, (w, h))
[0075] ```
[0076] The image tilt and perspective distortion caused by the shooting angle deviation are eliminated through the perspective transformation algorithm. Based on the four corner positioning points of the background board, the original image is mapped to the standard rectangular coordinate system by using the affine transformation matrix to ensure the true restoration of the morphology and spatial proportion of the plant base. This method can correct the trapezoidal distortion introduced by the non-orthogonality between the lens axis and the background board, so that the subsequent measurement data is not interfered by the projection deformation.
[0077] Call the getPerspectiveTransform() function of OpenCV to automatically calculate the transformation matrix through four pairs of feature points (the four corners of the background board and the vertices of the target rectangle), avoiding the subjective error of manual parameter adjustment. Combining warpPerspective() to achieve pixel-level coordinate mapping, ensuring the geometric consistency of the corrected image, and providing a standardized input for plant counting.
[0078] This solution relies on the physical positioning marks preset on the background board, enabling the algorithm to stably extract feature points in complex field environments. The mathematical model of perspective transformation is highly mature, and the optimized implementation of the OpenCV function library takes into account both processing speed and memory efficiency, making it suitable for deployment on embedded devices or mobile terminals to meet the real-time requirements of agricultural scenarios.
[0079] After geometric correction of the image data of the wheat basic seedling base, perform the resolution standardization process, and uniformly scale the image data of the wheat basic seedling base to 2560×1920 pixels. To avoid blurring of the scaled wheat basic seedling image, bicubic interpolation is used to maintain edge sharpness. Optionally, in another feasible embodiment, the image data of the wheat basic seedling base can also be uniformly scaled to other pixels for the purpose of facilitating subsequent processing.
[0080] By uniformly scaling the images to 2560×1920 pixels or other preset specifications, the resolution fluctuations caused by differences in shooting equipment and distance changes can be eliminated, ensuring that all input data has the same spatial scale. This standardization process provides stable input conditions for subsequent algorithms (such as feature extraction and target recognition), avoids calculation biases introduced by resolution differences, and improves the generalization ability of the model.
[0081] A fixed resolution can reduce the computational overhead caused by dynamically adjusting the image size. At the same time, data with a unified specification is convenient for batch processing and parallel computing, significantly improving the efficiency of large-scale image analysis.
[0082] The bicubic interpolation algorithm is used for scaling. By weighting the gray values of 16 surrounding pixels for interpolation calculation, compared with bilinear or nearest neighbor interpolation, it can more effectively retain the texture details (such as vein structure) and edge sharpness at the base of wheat seedlings. This characteristic is crucial for subsequent precise segmentation of the stem and leaf regions and quantification of morphological features.
[0083] After geometric correction and resolution standardization, the obtained basic seedling image data of the small seedlings is converted into a preprocessed target image to be further processed.
[0084] Through the synergistic effect of geometric correction and resolution standardization, the preprocessing scheme makes the spatial geometric relationship of the image at the base of wheat seedlings accurate and the resolution unified, laying a reliable data foundation for subsequent analysis. Experiments show that the standardized images can reduce the feature extraction error by 15%-20%.
[0085] S200. Perform plant feature enhancement processing on the basic seedlings of the small seedlings in the preprocessed target image to highlight the characteristics of the basic wheat seedlings in the preprocessed target image and obtain a target image.
[0086] In S200, a multi-modal feature enhancement algorithm is used to process the preprocessed target image, including excess green index enhancement processing, YUV color space brightness normalization, and morphological top-hat transformation, to obtain a target image.
[0087] S201. Perform excess green index enhancement processing on the preprocessed target image.
[0088] The excess green index (ExG) is a vegetation index based on the visible light band, used to quickly extract green vegetation information from RGB (red, green, blue) images. By enhancing the contrast between green vegetation and other backgrounds (such as soil, dead leaves, shadows, etc.), the difference between green vegetation and the background is increased to significantly distinguish green vegetation from non-vegetation areas. In this embodiment, the basic wheat seedlings in the preprocessed target image are the green plants to be enhanced, and the background board with scales is the background.
[0089] The Excess Green Index (ExG) highlights the response of green vegetation by normalizing the luminance values of the red, green, and blue channels. Its general calculation formula is:
[0090] ExG = 2×G - R - B
[0091] Where R, G, and B are the pixel values of the red, green, and blue channels respectively (the range is usually 0 - 255).
[0092] Furthermore, since the traditional ExG formula is sensitive to low light, in order to reduce the influence of light conditions, this embodiment adopts an improved Excess Green Index (gExG):
[0093] gExG = αG - βR - γB
[0094] Specifically, coefficient optimization is carried out. Through linear discriminant analysis (LDA) of 2000 groups of samples, the coefficient combination is determined to maximize the between-class variance; Gamma correction (γ = 0.6) is performed on the gExG result to enhance the details in the dark part and achieve dynamic range compression.
[0095] The following improved Excess Green Index is obtained:
[0096] gExG = 1.8G - 1.2R - 0.6B
[0097] In another feasible embodiment, a light intensity evaluation model can be established to adaptively adjust the Excess Green Index coefficients. By calculating the mean μ and standard deviation σ of the Y channel, when μ < 50 and σ > 30, it is determined as a low light scene, and the gExG coefficients are dynamically adjusted to [2.2, 1.5, 0.8]; for normal light, it is maintained at [1.8, 1.2, 0.6]
[0098] Improved Excess Green Index in low light scene:
[0099] gExG = 2.2G - 1.5R - 0.8B
[0100] Part of the implementation code is as follows:
[0101]
[0102]
[0103] Enhancing the Excess Green Index can alleviate the problem of target missed detection in low contrast environments by strengthening the contrast between the vegetation area and the background, and significantly improve the recognizability of the morphological and texture features of the wheat stem base.
[0104] 202. Perform YUV color space luminance normalization on the target image after enhancing the Excess Green Index
[0105] For the target image after the super green index enhancement process, perform YUV color space brightness normalization to eliminate specular interference. Specifically:
[0106] Convert to the YUV color space: `cv2.cvtColor(img,cv2.COLOR_BGR2YUV)`
[0107] Perform CLAHE equalization on the Y channel (Clip Limit = 2.0, Tile = 8×8)
[0108] Reconstruct the image: `Y_norm = CLAHE.apply(Y) → merge(Y_norm,U,V)`
[0109] The brightness normalization process in the YUV color space effectively eliminates color deviations caused by light fluctuations. Through dynamic range compression, it reduces interference in overexposed or shadow areas, ensuring the consistency of brightness distribution among different samples.
[0110] S203. Perform morphological top-hat transformation on the target image after YUV color space brightness normalization
[0111] Furthermore, perform morphological top-hat transformation (Top-hat).
[0112] Use an elliptical kernel (5×3 pixels) to match the stem morphology and perform two iterations of top-hat operations:
[0113] ```python
[0114] kernel = cv2.getStructuringElement(cv2.MORPH_ELLIPSE,(5,3))
[0115] tophat = cv2.morphologyEx(img,cv2.MORPH_TOPHAT,kernel)
[0116] ```
[0117] Through morphological top-hat transformation, the thin stem characteristics of the basic wheat seedlings are highlighted. Morphological top-hat transformation can adaptively filter out background noise with a large size difference from the target. By suppressing background noise, it accurately extracts the microscopic structural characteristics of the plants.
[0118] By performing super green index enhancement processing, YUV color space brightness normalization, and morphological top-hat transformation on the preprocessed target image, a target image for the basic wheat seedlings is obtained. The three work together synergistically to achieve complementary enhancement of spectral, spatial, and morphological characteristics, providing a multi-dimensional reliable data basis for subsequent analysis.
[0119] S300. Perform adaptive threshold cutting on the target image to distinguish the basic wheat seedlings from the background in the target image.
[0120] In the S channel, use the Otsu algorithm to automatically determine the threshold for segmenting the basic wheat seedlings and the background, and create a binary mask, where the basic wheat seedling area = 1 and the background = 0. Further perform image segmentation on the image processed by S200 to distinguish the basic wheat seedlings and the background.
[0121] Specifically, after converting to the HSV space, extract the S channel, and use the Otsu algorithm in the S channel to automatically determine the threshold. The S (saturation) channel in the HSV color space has stronger feature discrimination ability in vegetation analysis. It has been verified that the between-class variance of the S channel is 38.7% higher than that of the RGB channel, indicating that the S channel can more significantly distinguish the gray distribution difference between the base of the wheat stem and the background and is more suitable for Otsu segmentation. By maximizing the between-class variance, the Otsu algorithm can adaptively determine the optimal segmentation threshold and avoid the subjective deviation caused by manual intervention.
[0122] Furthermore, perform histogram translation (Offset = 30) on the S channel to enhance the low-saturation region. For the possible segmentation ambiguity problem in the low-saturation region at the base of the wheat, the histogram translation (Offset = 30) operation can increase the gray dynamic range of the target region and enhance the contrast of the weak saturation features. This preprocessing step makes the histogram distribution closer to the bimodal shape, optimizes the threshold determination condition of the Otsu algorithm, and reduces the misclassification probability.
[0123] Optimally, in this embodiment, an improved Otsu algorithm is adopted, introducing pixel space weights for weight correction, with a weight coefficient of 1.5 in the central region and 0.8 at the edge to suppress boundary noise.
[0124] The specific implementation code is as follows:
[0125] ```python
[0126] ret, mask = cv2.threshold(S_channel, 0, 255, cv2.THRESH_BINARY + cv2.THRESH_OTSU)
[0127] ```
[0128] The improved Otsu algorithm introduces pixel space weight coefficients (1.5 in the central region and 0.8 at the edge). Through weighted between-class variance calculation, it strengthens the decision weight of the target region in the center of the image and suppresses the interference of the edge background noise. This strategy effectively solves the problem that the traditional Otsu algorithm is sensitive to boundaries and improves the integrity of the target region segmentation.
[0129] S400. Morphologically optimize the basic wheat seedlings after segmentation so that the basic wheat seedlings are in a complete connected region
[0130] Ideally, a single basic wheat seedling should be in a complete connected region. However, during the process of segmenting the basic wheat seedlings and the background in the target image, due to limitations in the algorithm, there will be breaks in some positions of the basic wheat seedlings, and a single basic wheat seedling cannot be in a complete connected region. Therefore, it is necessary to morphologically optimize the basic wheat seedlings after segmentation.
[0131] Specifically, in a feasible embodiment, perform opening operation, closing operation, and hole filling operations in sequence.
[0132] The opening operation removes noise. First erode and then dilate to remove small impurities.
[0133] Kernel size: 3×3 cross-shaped structuring element, iterate 1 time
[0134] Operation: `cv2.morphologyEx(mask,cv2.MORPH_OPEN,kernel)`
[0135] The closing operation connects breaks. First dilate and then erode to connect the broken stems.
[0136] Kernel size: 5×1 linear structuring element (horizontal direction), iterate 2 times
[0137] Operation: `cv2.morphologyEx(mask,cv2.MORPH_CLOSE,kernel)`
[0138] Use the flood fill algorithm to repair internal holes:
[0139]
[0140] Through the sequential processing of the opening operation (first erode and then dilate) and the closing operation (first dilate and then erode), the dual goals of noise suppression and structure repair are achieved. The opening operation uses a 3×3 cross-shaped structuring element to effectively remove isolated small noises in the binary mask. At the same time, the erosion intensity is controlled by a single iteration to avoid overly weakening the contour integrity of the wheat stem base; the closing operation uses a 5×1 horizontal linear structuring element to directionally repair the linear features of the broken wheat stem base. The continuity of horizontal pixels is enhanced through two dilation iterations, and a single erosion operation avoids introducing redundant connections. Experiments show that the repair efficiency of such a kernel shape for horizontal breaks is about 23% higher than that of a square kernel.
[0141] The flood filling algorithm based on contour area threshold can accurately identify and repair the tiny holes inside the wheat stem base, while avoiding the risk of misfilling large-area backgrounds. On the premise of ensuring the integrity of the connected domain, this strategy controls the over-segmentation rate below 5%, reducing the computational redundancy by about 40% compared with the traditional full-area filling scheme.
[0142] The kernel size is selected to match the morphological characteristics of the wheat stem base: the horizontal linear kernel (5×1) adapts to the linear extension characteristics of the stem, and the cross-shaped kernel (3×3) adapts to the multi-directional branching characteristics of the stem-leaf connection point.
[0143] The number of iterations is optimized through gradient experiments to balance the processing effect and computational efficiency. Practical tests show that two iterations of closing operations can increase the connection rate of the fractured area from 78.6% to 95.3%.
[0144] As a post-processing module for segmentation, this scheme can be seamlessly connected with the previous step of S-channel Otsu segmentation to solve the fracture problem caused by insufficient saturation in low-light areas. Verified by the field dataset, the integrity rate of the connected domain of single wheat plants after optimization has increased from 82.1% to 97.8%, providing reliable input for subsequent plant counting.
[0145] S500. Perform contour analysis and filtering on the wheat basic seedlings after morphological optimization, and count the number of wheat basic seedling plants in the image based on pixel contour values.
[0146] Specifically, it includes multi-level contour screening and overlapping area segmentation.
[0147] First, perform multi-level contour screening, including:
[0148] Area filtering: Remove noises with an area < 50 pixels (corresponding to an actual size < 0.2 cm 2 );
[0149] Aspect ratio verification: Retain slender contours with 1.5 < aspect_ratio < 8;
[0150] Convexity detection: Exclude non-stem shapes with excessive concavity.
[0151] Through the three-level screening mechanism of area filtering, aspect ratio verification, and convexity detection, the efficient extraction of the morphological characteristics of wheat stems and noise suppression are achieved. Area filtering (threshold 50 pixels) can effectively remove tiny noises and retain the plant contours that meet the actual biological size (corresponding to the actual area threshold in the field of 0.2 cm 2 ); Aspect ratio verification (range of 1.5 - 8) fits the slender morphological characteristics of wheat stems and excludes circular or blocky interferences (such as weed leaves); Convexity detection further excludes non-typical stem shapes caused by leaf overlap or mechanical damage through contour concavity analysis, ensuring that the contours conform to the linear geometric characteristics of the stems.
[0152] After that, perform overlapping region segmentation. For regions with a connected component area > 300 pixels, use the watershed algorithm to segment the adhered plants:
[0153] ```python
[0154] markers = cv2.watershed(img,markers)
[0155] ```
[0156] For complex regions with a connected component area exceeding 300 pixels (corresponding to possible actual plant adhesion scenarios), use the watershed algorithm for sub-pixel segmentation:
[0157] Dynamic boundary division iterates through gradient information and marker points to solve the over-fusion problem caused by traditional morphological dilation, especially suitable for scenarios of stem crossing or leaf sheath adhesion;
[0158] Conformality optimization maintains the axial continuity of the stem during segmentation, avoiding counting errors caused by breaks and significantly improving the accuracy of plant number statistics.
[0159] S600. According to the scale lines in the shooting background, establish a mapping, obtain the relationship between length and pixels, and determine the number of basic wheat seedlings within the image background length
[0160] First, perform scale line detection, specifically including:
[0161] Canny edge detection: thresholds 50, 150
[0162] Hough line detection: threshold 80, minimum length 100 pixels
[0163] Line spacing clustering analysis: perform K-means clustering (n = 10) on the detected horizontal lines, and take the mode spacing as the centimeter-pixel ratio.
[0164] Through Canny edge detection combined with Hough line detection, stable extraction of scale lines in complex backgrounds is achieved. Using K-means clustering analysis for line spacing and taking the mode spacing as the centimeter-pixel ratio effectively overcomes local noise interference and ensures the robustness of the calibration data. This scheme can significantly improve the mapping accuracy between the actual scale and image pixels, and the error can be controlled within the millimeter level.
[0165] After that, construct a perspective mapping model
[0166] Establish a two-dimensional affine transformation matrix to map the image coordinates to the actual coordinate system. Some code examples are as follows:
[0167] ```math
[0168] \begin{cases}
[0169] x_{real}=a\cdot x_{pixel}+b\cdot y_{pixel}+c
[0170] y_{real}=d\cdot x_{pixel}+e\cdot y_{pixel}+f
[0171] \end{cases}
[0172] ```
[0173] Solve the coefficient matrix by the least squares method.
[0174] Solving the coefficient matrix based on the least squares method can adaptively compensate for geometric distortion caused by camera tilt and perspective deformation. This method has strong adaptability to non-orthogonal shooting scenes in the field, and the measured data shows that the length measurement error can be reduced to less than 2%.
[0175] Specifically, find the horizontal scale line in the background of the image, establish a mapping using a function to obtain the relationship between a certain centimeter length and pixels, and then obtain the number of basic wheat seedlings in the background length. Preferably, determine the number of basic wheat seedlings per row per background meter length of the image.
[0176] S700. Determine the number of wheat basic seedlings per mu based on the number of wheat basic seedlings within the background length of the image
[0177] Specifically, the number of seedlings per mu of small seedlings is calculated using the following formula:
[0178] Number of plants per mu = Number of plants per row per background meter length * Number of rows per unit area * 667
[0179] For example, in an example, the length of the background scale line of the image is 30 cm, and the number of basic wheat seedlings identified within this background length is 18. Then the number of plants per row per background meter length is (100 / 30)*18, which is 60; the number of rows per unit area refers to the number of rows per square meter, which is 4 rows. Then the number of plants per mu of this wheat field is:
[0180] Number of plants per mu = (100 / 30)*18*4*667 = 160080
[0181] In this embodiment, 1200 field images (different growth periods, lighting conditions) are used to verify the above method, and its accuracy indicators are as follows:
[0182] Recall rate: 98.2% (TP / (TP + FN))
[0183] Precision: 96.7% (TP / (TP + FP))
[0184] F1-score: 97.4%
[0185] It can be seen that the method of this embodiment has excellent performance and can accurately identify and count the basic seedlings of wheat.
[0186] The present invention also provides a system for accurately identifying and counting the basic seedlings of wheat. Referring to Figure 2 , it includes an original image acquisition unit 1, a preprocessing unit 2, a plant feature enhancement unit 3, a background segmentation unit 4, a morphological optimization unit 5, an image plant number statistics unit 6, a background length plant number acquisition unit 7, and an acre plant number calculation unit 8.
[0187] Among them,
[0188] The original image acquisition unit 1 is used to acquire the image data of the base of the basic seedlings of wheat taken from the side, and use a background board with scales as the shooting background for the base of the basic seedlings of wheat;
[0189] The preprocessing unit 2 is used to preprocess the image data of the base of the basic seedlings of wheat to obtain a preprocessing target image;
[0190] The plant feature enhancement unit 3 is used to perform plant feature enhancement processing on the small basic seedlings in the preprocessing target image to highlight the features of the basic seedlings of wheat in the preprocessing target image and obtain a target image;
[0191] The background segmentation unit 4 is used to perform adaptive threshold cutting processing on the target image to distinguish the basic seedlings of wheat from the background in the target image;
[0192] The morphological optimization unit 5 is used to perform morphological optimization on the distinguished basic seedlings of wheat so that the basic seedlings of wheat are in a complete connected region;
[0193] The image plant number statistics unit 6 is used to perform contour analysis and filtering on the morphologically optimized basic seedlings of wheat, and statistically count the number of basic seedlings of wheat in the image based on the pixel contour value;
[0194] The background length plant number acquisition unit 7 is used to establish a mapping according to the scales of the background, obtain the relationship between length and pixels, and determine the number of basic seedlings of wheat within the image background length;
[0195] The acre plant number calculation unit 8 is used to determine the number of basic seedlings of wheat per acre based on the number of basic seedlings of wheat within the image background length.
[0196] The precise identification and counting method of the basic seedling number of wheat in the present invention realizes plant counting with sub - centimeter accuracy under complex backgrounds through multi - stage feature enhancement and morphological optimization, provides intelligent investigation and monitoring of wheat seedling conditions, can provide more scientific and efficient support for the safe production and harvest of wheat, and provides reliable technical support for precision agriculture.
[0197] As described above, it is only the preferred embodiment of the present invention, and it is not any other form of limitation to the present invention. Any modification or equivalent change made according to the technical essence of the present invention still belongs to the scope protected by the present invention.
Claims
1. A method for accurately identifying and counting the basic seedlings of wheat, characterized in that, The method includes: S100. Obtain the image data of the base of the basic wheat seedlings taken from the side, and preprocess the image data of the base of the basic wheat seedlings to obtain a preprocessed target image. Among them, a background board with scales is used as the shooting background for the base of the basic wheat seedlings; S200. Perform plant feature enhancement processing on the basic seedlings in the preprocessed target image to highlight the features of the basic wheat seedlings in the preprocessed target image, and obtain a target image; S300. Perform adaptive threshold cutting processing on the target image to distinguish the basic wheat seedlings from the background in the target image; S400. Perform morphological optimization on the distinguished basic wheat seedlings to make the basic wheat seedlings in a complete connected region; S500. Perform contour analysis and filtering on the morphologically optimized basic wheat seedlings, and count the number of basic wheat seedling plants in the image based on the pixel contour value; S600. According to the scales of the background, establish a mapping, obtain the relationship between length and pixels, and determine the number of basic wheat seedling plants corresponding to the length of the image background; S700. Based on the number of basic wheat seedling plants corresponding to the length of the image background, determine the number of basic wheat seedling plants per mu.
2. The precise identification and counting method of the basic wheat seedlings according to claim 1, characterized in that, The preprocessing of the image data of the base of the basic wheat seedlings to obtain a preprocessed target image includes performing geometric correction and resolution standardization on the image data of the base of the basic wheat seedlings, and uniformly scaling the image data of the base of the basic wheat seedlings to a set resolution.
3. The precise identification and counting method of the basic seedling number of wheat according to claim 1, characterized in that The obtaining of the image data of the base of the basic wheat seedlings taken from the side includes placing the background board perpendicular to the ground and using a shooting device to take pictures from the side of the base of the basic wheat seedlings to obtain the image data of the base of the basic wheat seedlings. Among them, the included angle between the axial direction of the camera lens of the shooting device and the plane of the background board is ≤5°; 4. The method for accurately identifying and counting the basic seedling number of wheat according to claim 3, characterized in that, The obtaining of the image data of the base of the basic wheat seedlings taken from the side further includes adjusting the vertical distance between the camera of the shooting device and the ground to 1-3 cm and taking pictures 7-15 days after the emergence of the seedlings to obtain the image data of the base of the basic wheat seedlings.
5. The precise identification and counting method for the basic seedling number of wheat according to any one of claims 3 or 4, characterized in that, The obtaining of the image data of the base of the basic wheat seedlings taken from the side includes using a shooting device with no less than 12 million pixels to take pictures to obtain the image data of the base of the basic wheat seedlings. Among them, the image resolution of the image data of the base of the basic wheat seedlings is ≥1920×1080; 6. The precise identification and counting method of the basic seedling number of wheat according to claim 1, characterized in that, The performing of plant feature enhancement processing on the basic seedlings in the preprocessed target image to highlight the features of the basic wheat seedlings in the preprocessed target image and obtain a target image includes using a multi-modal feature enhancement algorithm to process the preprocessed target image to highlight the features of the basic wheat seedlings in the preprocessed target image and obtain a target image; 7. The precise identification and counting method of the basic seedling number of wheat according to claim 6, characterized in that, The using of a multi-modal feature enhancement algorithm to process the preprocessed target image to highlight the features of the basic wheat seedlings in the preprocessed target image and obtain a target image includes performing super-green index enhancement processing, YUV color space brightness normalization, and morphological top-hat transformation on the preprocessed target image to highlight the features of the basic wheat seedlings in the preprocessed target image and obtain a target image.
8. The method for accurately identifying and counting the basic seedling number of wheat according to claim 7, characterized in that, Perform super-green index enhancement processing, YUV color space brightness normalization, and morphological top-hat transformation on the preprocessed target image to highlight the characteristics of the basic wheat seedlings in the preprocessed target image, and obtain a target image, including performing super-green index enhancement processing on the preprocessed target image using an improved super-green index. Among them, the improved super-green index is: gExG = 1.8G - 1.2R - 0.6B where R, G, and B are the pixel values of the red, green, and blue channels respectively.
9. The precise identification and counting method of the basic seedling number of wheat according to claim 1, characterized in that, Perform adaptive threshold cutting processing on the target image to distinguish the basic wheat seedlings from the background in the target image, including automatically determining the threshold to segment the basic wheat seedlings and the background using the Otsu algorithm in the S channel, and creating a binary mask, where the basic wheat seedling area = 1 and the background = 0, to distinguish the basic wheat seedlings from the background in the target image.
10. A precise identification and counting system for the basic seedling number of wheat, characterized in that, The system includes an original image acquisition unit, a preprocessing unit, a plant feature enhancement unit, a background segmentation unit, a morphological optimization unit, an image plant number statistics unit, a background length plant number acquisition unit, and a mu plant number calculation unit; Among them, The original image acquisition unit is used to acquire the image data of the base of the basic wheat seedlings taken from the side, with a background board with scales as the shooting background of the base of the basic wheat seedlings; The preprocessing unit is used to preprocess the image data of the base of the basic wheat seedlings to obtain a preprocessed target image; The plant feature enhancement unit is used to perform plant feature enhancement processing on the basic seedlings in the preprocessed target image to highlight the characteristics of the basic wheat seedlings in the preprocessed target image and obtain a target image; The background segmentation unit is used to perform adaptive threshold cutting processing on the target image to distinguish the basic wheat seedlings from the background in the target image; The morphological optimization unit is used to perform morphological optimization on the distinguished basic wheat seedlings to make the basic wheat seedlings in a complete connected region; The image plant number statistics unit is used to perform contour analysis and filtering on the morphologically optimized basic wheat seedlings and statistically count the number of basic wheat seedling plants in the image based on the pixel contour values; The background length plant number acquisition unit is used to establish a mapping according to the scales of the background, determine the relationship between the length and the pixels, and obtain the number of basic wheat seedling plants with the background length of the image; The mu plant number calculation unit is used to determine the number of basic wheat seedling plants per mu based on the number of basic wheat seedling plants with the background length of the image.