A deep learning-based nematode identification method and system
The nematode identification method, which combines deep learning with image preprocessing and connected component mask screening, solves the problems of subjective error and cumbersome operation in nematode sample statistics. It achieves efficient and accurate automated analysis of nematode quantity and morphological parameters, and is suitable for high-throughput experimental scenarios.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- ZHENGZHOU UNIV
- Filing Date
- 2026-02-28
- Publication Date
- 2026-06-12
AI Technical Summary
Existing technologies for nematode sample statistics suffer from problems such as large subjective errors, complicated operations, low accuracy, high costs, and slow counting speed. Furthermore, nematode images are easily affected by impurities, leading to frequent overlap, missed detections, and false detections, making it difficult to meet the needs of high-throughput screening.
A deep learning-based nematode identification method is adopted, which combines image preprocessing and connected component mask screening. The YOLOv8 network is used for nematode detection. By performing operations on the binarized connected component mask image and the nematode labeled image, overlap, missed detection, and false detection are screened and eliminated, and the morphological parameters of a single nematode image are calculated.
It enables automated and precise analysis of nematode populations and survival status, improving detection accuracy and stability, meeting the needs of high-throughput experiments, reducing the degree of human intervention, and improving processing efficiency and the integrity and reliability of results.
Smart Images

Figure CN122200735A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of intelligent biological image analysis technology, and in particular to a method and system for identifying nematodes based on deep learning. Background Technology
[0002] In biological experimental research, it is often necessary to count the total number and survival status of nematode samples in culture dishes, and further measure parameters such as body length, body width, and biomass. Current methods mostly involve sampling, separation, microscopic examination, and microscopic photography, followed by manual marking and measurement of nematodes in the images using image processing software such as ImageJ. The entire process relies on manual interpretation and operation.
[0003] With the widespread application of deep learning and image processing technologies in target detection and counting scenarios, automatic localization, automatic identification and counting of small targets such as nematodes have become an important development direction. The relevant technical approach is usually based on image annotation and preprocessing, introducing the YOLO series target detection network to realize nematode detection, and combining scale recognition conversion and contour extraction to realize size parameter calculation and result reporting.
[0004] The aforementioned manual counting and measurement process suffers from subjective errors, cumbersome operation, low accuracy, high cost, and slow counting speed, making it difficult to meet the needs of high-throughput screening. On the other hand, nematode images often have characteristics such as small nematode size, multiple nematodes in the same image, and dark corners at the edges. Direct detection is easily affected by impurities and may result in overlap, missed detection, and false detection. Therefore, it is urgent to use binary connected component masks and calculations of detection results to achieve screening and elimination, thereby improving statistical reliability. Summary of the Invention
[0005] To overcome the shortcomings of existing technologies, the purpose of this invention is to provide a nematode identification method and system based on deep learning. By combining deep learning detection with connected component mask screening, the method achieves automated and precise analysis of nematode quantity, survival status, and morphological parameters.
[0006] To achieve the above objectives, the present invention provides the following solution:
[0007] A deep learning-based method for nematode identification includes:
[0008] Image data of nematodes were collected using an optical microscope with a camera function, and the data was labeled to divide the training dataset and the validation dataset.
[0009] The nematode image data is preprocessed to obtain a binarized connected component mask image; the image preprocessing includes image denoising, image binarization, and image connected component solving;
[0010] The labeled training dataset is trained using a YOLOv8 network to obtain a trained model, and the trained model is tested using the labeled validation dataset.
[0011] The image of the nematode to be tested is input into the trained model to detect the nematode, and the detected nematode labeled image is obtained.
[0012] The binarized connected component mask image and the nematode labeled image are processed for post-detection processing to screen for overlapping, missed, and false detections of nematodes and to eliminate impurities that are similar to nematodes, thereby generating a set of effective nematode targets after screening. Based on the set of effective nematode targets, the statistical results of the number of nematodes and their survival status are output.
[0013] Based on the effective nematode target set after screening, single nematode images corresponding to single nematodes are obtained from the images of nematodes to be tested. The single nematode images are preprocessed with grayscale and binarization. Paddle OCR technology is used to obtain image scale data, and OpenCV library functions are used to process the nematode outline to obtain body length, body width and biomass.
[0014] Preferably, the image denoising step includes:
[0015] The nematode image data is divided into blocks and a reference block is selected; the reference block is a two-dimensional image block extracted from the nematode image data.
[0016] A block to be matched is searched within a preset search range, and the similarity between the block to be matched and the reference block is calculated; the block to be matched is a two-dimensional image block that is compared with the reference block within the search range.
[0017] Similar blocks are grouped according to the similarity; a similar block is the block to be matched whose similarity satisfies a preset threshold.
[0018] The grouped similar blocks are combined into a three-dimensional group, and the three-dimensional group is subjected to collaborative filtering to obtain the collaborative filtering result.
[0019] The results of the collaborative filtering process are aggregated to the corresponding original image block positions in the nematode image data to obtain the denoised nematode image data.
[0020] Preferably, the image binarization step includes:
[0021] The OpenCV threshold function is called to perform threshold segmentation on the denoised nematode image data;
[0022] Different thresholds are set to binarize the denoised nematode image data to obtain the corresponding binarized images;
[0023] The separation of nematodes, impurities, and background is achieved based on the binarized image.
[0024] Preferably, the step of solving for the connected components of the image includes:
[0025] Perform connected component analysis on the binarized image; a connected component is a region in the binarized image consisting of pixels with the same pixel value and adjacent positions;
[0026] The connected components are extracted using the connected component analysis function in OpenCV, and each connected component is labeled; wherein the connected components include nematodes and impurities.
[0027] Preferably, the YOLOv8 network consists of a Backbone, a Neck, and a Head; the Backbone is used to extract image features and adopts a typical Darknet53 structure, including a Conv Module, a C2f module, and an SPPF module; the Neck is located between the Backbone and the Head and is used for feature fusion, and adopts a PANet structure; the Head is used to output detection results and includes detection and loss function parts.
[0028] Preferably, the image of the nematode to be tested is input into the trained model for nematode detection to obtain a labeled image of the detected nematode, including:
[0029] Load the trained model in a Python environment using the Ultralytics YOLO library;
[0030] Set the prediction confidence threshold to conf=0.57;
[0031] The image of the nematode to be tested is used to perform prediction and the prediction results are saved to generate the nematode-tagged image; the identification time for multiple nematodes is less than 3 seconds and the identification accuracy is not less than 85%.
[0032] Preferably, the binarized connected component mask image and the nematode-labeled image are processed for post-detection processing to screen for overlapping, missed, and false detections of nematodes and eliminate impurities similar to nematodes, generating a set of effective nematode targets after screening. Based on this set of effective nematode targets, statistical results on the number and survival status of nematodes are output, including:
[0033] The detection results in the nematode-labeled image are subjected to mask filtering corresponding to the binarized connected component mask image to remove detection results that are inconsistent with the binarized connected component mask image;
[0034] The strategy is designed based on whether nematodes are detected in the connected components to perform false positive screening and false negative screening, and further eliminates impurities in the image that are similar to nematodes to generate the effective nematode target set after screening.
[0035] After screening, statistical results on the number of nematodes and their survival status are output and reported based on the effective nematode target set after screening.
[0036] Preferably, based on the screened effective nematode target set, obtaining a single nematode image corresponding to a single nematode from the images of nematodes to be tested includes:
[0037] The target region of a single nematode is determined from the effective nematode target set after screening; the target region is the image region in the image of the nematode to be tested that corresponds to a single nematode.
[0038] Based on the target region, an image region corresponding to the single nematode is extracted from the image of the nematode to be tested to obtain the single nematode image;
[0039] The single nematode image is used as input for grayscale and binarization preprocessing, as well as for scale data acquisition and nematode contour processing.
[0040] Preferably, OpenCV library functions are used to process the nematode outline to obtain body length, body width, and calculate biomass, including:
[0041] The contour of the single nematode image is extracted using OpenCV library functions to obtain the nematode contour.
[0042] The nematode outline is skeletonized using the vascular snake algorithm to obtain the nematode's midline;
[0043] A point is selected on the center line of the nematode, and a circle is drawn and iterated to find the maximum width. The maximum width is then converted using the scale data to obtain the body width; wherein the error range of the body width calculation is no greater than 5%.
[0044] The body length is obtained based on the nematode median line and the scale data, and the biomass is calculated based on the body length and the body width.
[0045] A deep learning-based nematode identification system includes:
[0046] The nematode image acquisition and annotation unit is used to acquire nematode image data using an optical microscope with a photographic function and to perform data annotation in order to divide the training dataset and the validation dataset.
[0047] The image preprocessing unit is used to perform image preprocessing on the nematode image data to obtain a binarized connected component mask image; the image preprocessing includes image denoising, image binarization, and image connected component solving.
[0048] The model training and testing unit is used to train the labeled training dataset through the YOLOv8 network to obtain a trained model, and to test the trained model using the labeled validation dataset.
[0049] The nematode detection unit is used to input the image of the nematode to be tested into the trained model to detect the nematode and obtain the detected nematode labeled image.
[0050] The post-detection processing and statistics unit is used to perform operations on the binarized connected component mask image and the nematode labeled image to perform post-detection processing, screen for overlapping nematodes, missed detections, and false detections, and eliminate impurities that are similar to nematodes, generate a set of effective nematode targets after screening, and output statistical results of the number of nematodes and their survival status based on the set of effective nematode targets.
[0051] The single nematode feature extraction and biomass calculation unit is used to obtain the single nematode image corresponding to the single nematode from the nematode image to be tested based on the effective nematode target set after screening, and to perform grayscale and binarization preprocessing on the single nematode image, obtain image scale data using Paddle OCR technology, and process the nematode outline using OpenCV library functions to obtain body length, body width and calculate biomass.
[0052] The present invention discloses the following technical effects:
[0053] (1) This invention utilizes a deep learning model to automatically detect nematode images and introduces a post-detection processing mechanism based on a binary connected component mask image after detection. This replaces the existing technology that relies on manual observation, labeling, and counting of nematode numbers and survival status, fundamentally reducing the degree of human involvement, avoiding subjective judgment errors caused by differences in human experience, and improving the consistency and objectivity of nematode identification and statistical results.
[0054] (2) The present invention performs calculations on the binarized connected component mask image and the nematode labeled image to form a post-detection processing flow, which can screen for nematode overlap, missed detection and false detection, and effectively eliminate interference from impurities similar to nematodes. Compared with the existing methods that rely solely on the output results of the target detection network, it significantly improves the detection accuracy and stability in complex backgrounds and multi-nematode scenarios.
[0055] (3) The technical solution of the present invention achieves rapid output of the number and survival status of nematodes by automatically detecting, screening and counting the images of the nematodes to be tested, avoiding the efficiency bottleneck caused by processing each image and each nematode in the traditional method, making the method applicable to the rapid analysis needs of a large number of nematode samples, improving the overall processing efficiency and meeting the application requirements of high-throughput experimental scenarios.
[0056] (4) The present invention further defines the effective nematode target set after screening, obtains the single nematode image corresponding to the single nematode from the image of the nematode to be tested, and completes the calculation of body length, body width and biomass in the same process, so that the nematode quantity statistics, survival discrimination and morphological parameter measurement form a unified data link, avoiding the problem of separation of counting and size measurement and data incompatibility in the prior art, and improving the integrity and traceability of the analysis results.
[0057] (5) This invention introduces scale data acquisition and combines contour processing to calculate body length, body width and biomass, so that the pixel scale in the image can be accurately converted into the actual size, overcoming the error caused by relying on manual estimation or fixed ratio conversion in the existing methods, thereby improving the accuracy and reliability of the nematode morphological parameter calculation results and enhancing the reference value of the results in biological experimental analysis. Attached Figure Description
[0058] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0059] Figure 1 A flowchart of the method provided in an embodiment of the present invention;
[0060] Figure 2 This is a schematic diagram of image slice grouping provided in an embodiment of the present invention;
[0061] Figure 3 This is a schematic diagram of reference block similarity provided in an embodiment of the present invention;
[0062] Figure 4 This is a detection network structure diagram provided in an embodiment of the present invention;
[0063] Figure 5 This is a structural diagram of the C2f module provided in an embodiment of the present invention;
[0064] Figure 6 A schematic diagram of the Neck structure provided in an embodiment of the present invention;
[0065] Figure 7 This is a schematic diagram of the nematode detection network head provided in an embodiment of the present invention. Detailed Implementation
[0066] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0067] The purpose of this invention is to provide a deep learning-based nematode identification method and system, which improves the efficiency of nematode statistics and measurement while ensuring detection accuracy, and provides a reliable technical means for high-throughput nematode image analysis.
[0068] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0069] Figure 1 The method flowchart provided in the embodiments of the present invention is as follows: Figure 1 As shown, this invention provides a deep learning-based method for nematode identification, comprising:
[0070] Step 100: Collect nematode image data using an optical microscope with a camera function, and label the data to divide the training dataset and the validation dataset.
[0071] Step 200: Perform image preprocessing on the nematode image data to obtain a binarized connected component mask image; image preprocessing includes image denoising, image binarization, and solving for connected components in the image;
[0072] Step 300: Train the labeled training dataset using the YOLOv8 network to obtain the trained model, and test the trained model using the labeled validation dataset.
[0073] Step 400: Input the nematode image to be tested into the trained model to detect nematodes and obtain the detected nematode labeled image;
[0074] Step 500: Perform post-detection processing by combining the binarized connected component mask image with the nematode labeled image to screen for overlapping, missed, and false nematodes and eliminate impurities similar to nematodes, generate a set of effective nematode targets after screening, and output statistical results on the number of nematodes and their survival status based on the effective nematode target set.
[0075] Step 600: Based on the effective nematode target set after screening, obtain the single nematode image corresponding to the single nematode from the nematode images to be tested, and perform grayscale and binarization preprocessing on the single nematode image. Use Paddle OCR technology to obtain image scale data, and use OpenCV library functions to process the nematode outline to obtain body length, body width and calculate biomass.
[0076] Specifically, in this embodiment, step 100 is performed by an optical microscope equipped with imaging and image storage functions to acquire nematode image data. The optical microscope includes an objective lens assembly, an imaging assembly, and an image acquisition assembly. The image acquisition assembly is used to image the nematode sample under the microscope in real time and output it as a digital image file. In this embodiment, the nematode sample to be tested is placed in a transparent culture dish and placed on the stage of the optical microscope. By adjusting the magnification and focal length of the objective lens, the outline of the nematode is made clearly visible in the imaging image. Subsequently, the image acquisition assembly is used to continuously or frame-by-frame photograph the nematodes in the same culture dish to form nematode image data containing multiple nematodes. The nematode image data provides basic input data for subsequent image preprocessing, model training, and detection analysis.
[0077] In this embodiment, the nematode image data is annotated to generate labeled data for training a deep learning model. The data annotation refers to manually marking the visible area of each nematode in the nematode image data and assigning it a corresponding category label to clarify the nematode's location and attributes in the image. Specifically, the operator uses an annotation tool to outline the area where the nematode is located on the displayed nematode image, forming an annotation box or annotation area, and saves the annotation information in one-to-one correspondence with the original image; wherein, the annotation box is used to characterize the spatial location of the nematode in the image, and the category label is used to characterize the annotated object as a nematode target. Through the above method, each nematode image data can be associated with at least one nematode annotation information, thereby forming a structured annotation sample.
[0078] In this embodiment, the labeled nematode image data is further divided into a training dataset and a validation dataset. The training dataset refers to the set of images and their corresponding labeled data used by the model to learn nematode features, while the validation dataset refers to the set of images and their corresponding labeled data used to test the model's training effectiveness. In this embodiment, the labeled nematode image data is randomly divided according to a preset ratio; for example, most of the images are assigned to the training dataset, and the remaining images are assigned to the validation dataset. This division method ensures consistency between the training and validation datasets in terms of image source and nematode distribution, thereby avoiding bias problems during model training. Through the above steps, a complete process from nematode image acquisition to labeling and dataset division is achieved, providing a sufficient, clear, and reproducible data foundation for subsequent model training and testing.
[0079] Specifically, step 200 in this embodiment is used to preprocess the nematode image data obtained in step 100 to reduce noise interference and highlight the nematode region, providing stable input for subsequent detection and screening. In this embodiment, the image preprocessing sequentially includes three sub-processes: image denoising, image binarization, and image connected component solving, ultimately outputting a binarized connected component mask image. The binarized connected component mask image is used to characterize the spatial distribution area of nematodes and impurities in the image. Its pixel values are only used to distinguish between target and non-target areas and do not carry color or grayscale information, thereby reducing the complexity of subsequent processing.
[0080] In this embodiment, image denoising first involves segmenting the nematode image data into blocks, and then selecting reference blocks from the segmentation results. The reference block is a two-dimensional image block extracted from the nematode image data, serving as a benchmark for similarity comparison. For example, a local region of a fixed pixel size is extracted from the entire nematode image as a reference block. Subsequently, a search for matching blocks is performed within a preset search range centered on the reference block. These matching blocks are two-dimensional image blocks located within this search range used for similarity comparison with the reference block. By calculating the similarity between the reference block and each matching block, and filtering out matching blocks that meet the similarity requirements according to a preset threshold, similar block groups are formed. These similar blocks are image blocks that are similar to the reference block in features such as texture and brightness distribution, reflecting the local consistency of the nematode region.
[0081] In this embodiment, similar blocks corresponding to the same reference block are combined to form a three-dimensional group. The three-dimensional group refers to a data structure formed by stacking multiple two-dimensional similar blocks along a new dimension, which enhances the denoising effect by utilizing redundant information between similar blocks. Subsequently, collaborative filtering is performed on the three-dimensional group to suppress random noise and preserve the structural features of the nematode; wherein, collaborative filtering refers to performing a uniform filtering operation on the entire three-dimensional group, rather than processing individual image blocks separately. After completing the collaborative filtering, the obtained collaborative filtering results are aggregated back to the corresponding original image block positions in the nematode image data, thereby obtaining the denoised nematode image data; for example, the processing results corresponding to multiple reference blocks can be overlaid or superimposed back into the original image according to their original spatial positions.
[0082] In this embodiment, image binarization processing is performed on the denoised nematode image data. Specifically, the threshold segmentation function in the image processing library is invoked to determine the threshold of the denoised nematode image data, and corresponding binarized images are generated according to different thresholds. In the binarized images, only two types of pixel values are retained: the target area and the background area. By setting multiple different thresholds and comparing the corresponding binarization results, the nematode area appears as a continuous and clear area in the binarized image, while the impurities and background areas are effectively separated. Through the above method, the nematode, impurities, and background are initially separated at the image level.
[0083] In this embodiment, connected component solving is further performed on the binarized image. A connected component refers to a region in the binarized image composed of pixels with the same pixel value and spatially adjacent pixels; its function is to characterize independently existing targets or impurities in the image. By calling the connected component analysis function in the image processing library, each connected component in the binarized image is extracted and labeled one by one; the extracted connected components include both the region corresponding to the nematode and impurity regions with similar morphology to the nematode. Based on the results of the connected component extraction and labeling, a binarized connected component mask image is generated. This mask image is used as a spatial constraint in subsequent post-detection processing to screen and verify the nematode detection results.
[0084] like Figure 2 The diagram illustrates the block-based and similarity-based grouping of nematode image data in this embodiment. Figure 2 Centered on a reference block, multiple blocks to be matched are selected within a preset search range. Blocks with similar features to the reference block are classified as similar blocks and identified through similarity judgment to reflect the consistency of the local texture and structure of the nematode. This process provides the basis for combining similar blocks into a three-dimensional group and implementing collaborative filtering, thereby effectively suppressing background noise and random interference while maintaining the morphological characteristics of the nematode.
[0085] like Figure 3As shown, Figure 3 The diagram illustrates stacking multiple two-dimensional image blocks that are similar to a reference block in spatial location along a new dimension to form a three-dimensional group. A unified collaborative filtering process is then performed on this three-dimensional group to make full use of the redundant information between similar blocks. The processing results obtained by collaborative filtering are then aggregated back to the corresponding positions in the original nematode image to obtain denoised nematode image data, providing a stable input for subsequent binarization and connected component solving.
[0086] Optionally, in this embodiment, step 300 is used to complete model training and verify the model effect based on the labeled data obtained in step 100. Specifically, in this embodiment, the training dataset with completed data labeling is used as the model learning sample, and the verification dataset with completed data labeling is used as the model test sample. The training dataset is a set of images and corresponding labeling information used for the model to learn the appearance features and spatial location relationships of nematodes; the verification dataset is a set of images and corresponding labeling information used to evaluate the generalization ability of the model. In this embodiment, a trained model is obtained by iteratively training the training dataset, and then the verification dataset is input into the trained model for testing, thereby obtaining the detection performance of the model on data that was not used for training, so as to verify whether the trained model meets the subsequent nematode detection requirements.
[0087] In this embodiment, a target detection network is used as the base network for nematode detection. This target detection network is a YOLOv8 network, consisting of a feature extraction backbone network, a feature fusion network, and a detection output network, corresponding to the Backbone, Neck, and Head, respectively. The Backbone extracts image features of different scales from the input image, employing a typical Darknet53 structure and including a convolutional module, a feature aggregation module, and a spatial pyramid pooling module. The convolutional module extracts local texture and edge information, the feature aggregation module reduces redundant computation while maintaining feature expressive power, and the spatial pyramid pooling module expands the receptive field to enhance the expressive power for nematode targets of different scales. The Neck, located between the Backbone and the Head, uses a path aggregation structure to fuse features of different scales, enabling the network to detect both small nematode targets and maintain its ability to locate longer nematode targets. The Head is used to output the detection results and includes detection and loss function parts. The detection part is used to generate information such as the location and confidence of the nematode target, and the loss function part is used to calculate the difference between the prediction results and the labeled information during training to guide the network parameter update.
[0088] In this embodiment, the training process uses the training dataset as input and the labeled information in the training dataset as supervision signals to update the parameters of the YOLOv8 network until convergence, thereby obtaining a trained model. Here, the "trained model" refers to the set of network parameters and its corresponding network structure file obtained after training, which can be directly used to detect nematodes in new input images. In this embodiment, the training dataset is read in batches during training, and the network is iteratively updated according to a preset training epoch. During training, the detection results output by the Head are compared with the labeled information in the training dataset, so that the network gradually learns the morphological, textural, and positional features of nematodes in microscopic images. To avoid data leakage between training and testing, this embodiment ensures that the training dataset and validation dataset do not overlap, and the trained model is saved after training for subsequent validation testing and nematode image inference detection.
[0089] In this embodiment, the trained model is tested using a labeled validation dataset to obtain an evaluation result of the model's detection performance. The "recognition accuracy" refers to the degree to which the model correctly detects nematode targets in the validation dataset, characterizing the consistency between the model's output nematode detection results and the labeled results in the validation dataset. Higher recognition accuracy indicates that the model is more capable of correctly identifying nematodes, reducing false positives and false negatives. For example, when the validation dataset contains several nematode images, and the nematode labeling information is clear in each image, if the model's detection results for nematode targets in these validation images are highly consistent with the labeling information, then the model can be considered to have achieved high recognition accuracy. Under the preferred conditions of this embodiment, the model's recognition accuracy is not lower than a preset threshold, for example, not lower than 85%, to ensure reliability when subsequently detecting nematode images to be tested.
[0090] In this embodiment, the image of the nematode to be tested is input into a trained model for nematode detection to obtain a labeled image of the detected nematode. Specifically, in this embodiment, the trained model is loaded in a Python environment using the Ultralytics YOLO library, and the image of the nematode to be tested is input into the model to perform prediction. The "image of the nematode to be tested" refers to an image of a nematode that has not participated in model training and validation testing and is intended for actual detection of nematode targets. The "prediction confidence threshold" is a threshold parameter used to filter the model's output detection results. Its function is to filter detection boxes with confidence levels below the threshold to reduce the probability of false detections. In this embodiment, the threshold is preferably set to a fixed value, for example, 0.57. After the model prediction is completed, this embodiment saves the prediction results and generates a labeled image of the nematode. The labeled image of the nematode refers to an image superimposed on the image of the nematode to be tested, displaying the detected nematode target location markers. This image is used to visually display the detection results and serves as input for subsequent post-detection processing. In a preferred embodiment, when the nematode image to be tested contains multiple nematode targets, the recognition time is less than 3 seconds to meet the requirements of rapid screening, while maintaining a recognition accuracy of not less than 85% to ensure the reliability of the detection results.
[0091] Figure 4 The diagram shows the detection network structure provided in this embodiment of the invention. It illustrates that the network starts with an input image of a nematode to be tested, and then performs feature extraction and downsampling sequentially through the backbone network. The backbone is composed of multiple CBS units and C2f modules connected in series, and an SPPF module is set at the end to expand the receptive field. The backbone features from different scales are further input to the Neck for multi-scale feature fusion. Finally, the Head outputs the detection result of the nematode target, which is used to generate a nematode-labeled image.
[0092] Figure 5 The diagram shows the structure of the C2f module provided in this embodiment of the invention. It illustrates that the C2f module transforms the input features using a front-end CBS unit and then performs branch splitting. Multiple Bottleneck substructures enhance the branch features step by step. Subsequently, the branch features are concatenated and fused at the Concat node, and the fused features are output through the final-end CBS unit. The C2f module is used to improve feature representation capabilities while controlling the computational load, thereby enhancing the detection effect of small nematode targets.
[0093] Figure 6The diagram shows the Neck structure provided in this embodiment of the invention. It illustrates that the Neck uses a path aggregation structure to upsample and fused multi-scale features from the Backbone, including Upsample and Concat feature fusion paths. After fusion, the features are further integrated through the C2f module and CBS unit. The Neck outputs a multi-scale fusion feature layer, which is used to form feature outputs at different detection scales to adapt to the detection requirements of nematode targets with scale changes and dense distribution in the image.
[0094] Figure 7 This is a schematic diagram of the nematode detection network head provided in an embodiment of the present invention. It shows that the detection head performs Detect prediction on fused features at different scales and outputs a Bbox branch for bounding box regression and a Cls branch for class discrimination. The Bbox branch is used to represent the location regression information of the nematode target, and the Cls branch is used to represent the class confidence information of the nematode target. The output of the detection head is used to generate a nematode-labeled image and serve as the input for subsequent post-detection processing.
[0095] Optionally, in this embodiment, step 400 is used to perform nematode detection on the nematode image to be tested, so as to obtain a nematode-labeled image after detection. Specifically, in this embodiment, the nematode image to be tested is input into the trained model obtained in step 300 for inference and prediction. The model outputs the detection result of each nematode target, and the detection result is superimposed on the nematode image to be tested in a visual manner, thereby generating a nematode-labeled image. The "nematode-labeled image" mentioned here refers to an image file containing the nematode image to be tested and the nematode target location markers. Its function is to intuitively present the distribution of nematode targets detected by the model and to serve as input data for subsequent post-detection processing. For example, when there are multiple nematodes in a nematode image to be tested, the nematode-labeled image can display multiple nematode target markers at the corresponding positions, thereby providing a basis for subsequent screening of situations such as "nematode overlap, missed detection, false detection, and false detection of impurities".
[0096] In this embodiment, step 500 takes the binarized connected component mask image obtained in step 200 and the nematode-labeled image obtained in step 400 as inputs to perform post-detection processing to improve statistical reliability. The "binarized connected component mask image" mentioned here refers to a binary mask obtained from the preprocessing of the nematode image. Its function is to characterize the region in the image where the target may exist in a spatial manner, thus imposing spatial constraints on the detection results. This embodiment first performs mask filtering on the detection results in the nematode-labeled image, corresponding to the binarized connected component mask image. That is, for each detection result, it is determined whether its label position falls within the connected component region indicated by the mask. When a detection result is inconsistent with the mask region, this embodiment determines that the detection result is unreliable and discards it. Through this mask filtering mechanism, this embodiment can preferentially exclude false detections of impurities that are similar to the nematode but do not conform to the connected component spatial constraints, thereby reducing the probability of false detections.
[0097] In this embodiment, after mask screening, a strategy is designed based on whether nematodes are detected in the connected components to perform false positive and false negative screening, while also handling overlapping nematode scenarios. The "strategy design" referred to here is the screening rule formulated in this embodiment based on the correspondence between connected components and detection results. Its function is to improve the completeness and accuracy of nematode targets in complex scenarios. For example, when a detection result exists within a connected component, this embodiment establishes a matching relationship between the connected component and the corresponding detection result; when no detection result exists within a connected component, this embodiment treats this situation as a false negative candidate and enters the false negative screening process; when a detection result appears outside the mask boundary or is significantly inconsistent with the shape of the connected component, this embodiment treats it as a false positive candidate and enters the false positive screening process; when multiple detection results appear within the same connected component or the detection results significantly overlap, this embodiment treats them as overlapping nematode candidates and performs overlapping screening and merging processing. Through the above screening, this embodiment generates a "screened effective nematode target set". The "screened effective nematode target set" refers to the set of nematode targets that are confirmed to be effective after mask screening and strategy screening. It is used to record the spatial location and corresponding identifier of each effective nematode target as a unified data benchmark for subsequent statistics and acquisition of single nematode images.
[0098] In this embodiment, after generating a set of effective nematode targets after screening, this embodiment outputs and reports statistical results on the number and survival status of nematodes based on this effective nematode target set. Here, "statistical results" refers to the quantity and survival statistics obtained by summarizing the effective nematode target set, which serves to provide intuitive quantitative output for experimental analysis; "reporting" refers to outputting the statistical results to a display interface, file records, or subsequent processing modules for easy storage and traceability. Simultaneously, this embodiment also obtains single nematode images corresponding to individual nematodes from the images of nematodes to be tested based on the screened effective nematode target set, for subsequent calculations of body length, body width, and biomass. Specifically, this embodiment determines the target region of a single nematode from the screened effective nematode target set; the target region is the image region in the image of the nematode to be tested that corresponds to a single nematode; subsequently, this embodiment extracts the corresponding image region from the image of the nematode to be tested based on the target region to obtain a single nematode image, and uses this single nematode image as input for grayscale and binarization preprocessing, scale data acquisition, and nematode contour processing. For example, when the effective nematode target set contains multiple nematode targets, this embodiment can determine the target region for each nematode target and generate a corresponding single nematode image, so that the morphological measurement and statistical results of a single nematode have the same source and consistent data correspondence.
[0099] Further, in this embodiment, step 600 uses the effective nematode target set after screening generated in step 500 as a basis to obtain a single nematode image corresponding to a single nematode from the nematode image to be tested, and performs subsequent morphological parameter calculations on the single nematode image. The "single nematode image" refers to a local image region extracted from the nematode image to be tested that contains only a single nematode target. Its function is to reduce the interference of the background and other nematode targets on the measurement, making it easier to accurately extract the contour and skeleton of the nematode. In this embodiment, grayscale preprocessing and binarization preprocessing are performed on the single nematode image in sequence to make the nematode region clearly distinguishable from the background, which is conducive to contour extraction. At the same time, this embodiment uses Paddle OCR technology to identify the scale information displayed in the single nematode image and parses the identification result into scale data. The "scale data" refers to the data used to establish the conversion relationship between pixel scale and actual size. Its function is to ensure that the body length and body width can be quantized in actual length units. For example, when the scale marked in the image corresponds to a fixed length, this embodiment identifies the scale and parses the conversion relationship corresponding to pixels for subsequent conversion of body length and body width.
[0100] In this embodiment, OpenCV library functions are used to extract the contour of the single nematode image to obtain the nematode contour. The "nematode contour" refers to the boundary curve between the nematode target region and the background region in the binarized single nematode image. Its function is to characterize the nematode's external boundary, providing a basis for skeletonization, body length calculation, and body width calculation. In this embodiment, a contour search is first performed on the binarized image to obtain the set of outer contour points of the nematode target. When noise or small holes exist, this embodiment uses a contour filtering strategy to retain only the main contour corresponding to the nematode body to avoid stray contours interfering with subsequent calculations. Through the above processing, this embodiment obtains stable nematode contour data, which is then used as input for skeletonization processing.
[0101] In this embodiment, the nematode outline is skeletonized using the "vascular snake algorithm" to obtain the nematode's centerline. The "vascular snake algorithm" is an iterative optimization method for extracting the central skeleton from a slender target structure. Its function is to abstract the nematode's slender shape into a continuous centerline, facilitating stable length and width measurements along the centerline. The "nematode centerline" refers to the nematode's central skeleton line obtained through skeletonization. Subsequently, this embodiment takes points on the nematode's centerline and iterates through circles to find the maximum width. The "maximum width" refers to the pixel width corresponding to the nematode's maximum lateral diameter obtained by circular scanning at multiple sampling positions on the nematode's centerline, reflecting the nematode's maximum body width characteristic. Subsequently, in this embodiment, the maximum width is converted using scale data to obtain the body width, and the error in the body width calculation range is constrained to be no more than five percent. For example, when the maximum width conversion result of a certain nematode is a certain actual width value, this embodiment uses the uniformity of scale conversion and the stability of outline skeletonization to control the fluctuation of repeated measurement results within a preset error range, thereby improving the reliability of body width calculation.
[0102] In this embodiment, the body length is obtained based on the nematode's median line and the scale data. The "body length" refers to the length of the nematode along the central skeletal line, and its function is to characterize the nematode's growth state and morphological scale. In this embodiment, the body length is obtained by performing pixel-by-pixel statistics on the path length of the nematode's median line and converting it to the actual length using the scale data. Furthermore, this embodiment calculates biomass based on body length and body width. "Biomass" refers to a quantitative indicator used to characterize the size of individual nematodes, and its function is to provide comparable results of individual nematode growth in addition to statistically analyzing nematode numbers and survival rates. For example, when there are differences in body length and body width among nematodes in the same batch, this embodiment uses body length and body width as the basis for biomass calculation, enabling biomass to reflect the size differences among different nematode individuals, thereby providing more comprehensive data support for subsequent experimental analysis.
[0103] Corresponding to the above method, this embodiment also provides a deep learning-based nematode identification system, including:
[0104] The nematode image acquisition and annotation unit is used to acquire nematode image data using an optical microscope with a photographic function and to perform data annotation in order to divide the training dataset and the validation dataset.
[0105] The image preprocessing unit is used to preprocess the nematode image data to obtain a binarized connected component mask image; the image preprocessing includes image denoising, image binarization, and image connected component solving.
[0106] The model training and testing unit is used to train the YOLOv8 network on the labeled training dataset to obtain the trained model, and to test the trained model using the labeled validation dataset.
[0107] The nematode detection unit is used to input the image of the nematode to be tested into the trained model to detect the nematode and obtain the nematode-labeled image after detection.
[0108] The post-detection processing and statistics unit is used to perform operations on the binarized connected component mask image and the nematode labeled image to perform post-detection processing, screen for overlapping nematodes, missed detections, and false detections, and eliminate impurities that are similar to nematodes, generate a set of effective nematode targets after screening, and output statistical results on the number of nematodes and their survival status based on the effective nematode target set.
[0109] The single nematode feature extraction and biomass calculation unit is used to extract single nematode images corresponding to single nematodes from the images of nematodes to be tested based on the effective nematode target set after screening. The single nematode images are preprocessed with grayscale and binarization, and the image scale data is obtained using Paddle OCR technology. The nematode outline is processed using OpenCV library functions to obtain body length and body width and calculate biomass.
[0110] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the systems disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the descriptions are relatively simple; relevant parts can be referred to the method section.
[0111] This document uses specific examples to illustrate the principles and implementation methods of the present invention. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of the present invention. Furthermore, those skilled in the art will recognize that, based on the ideas of the present invention, there will be changes in the specific implementation methods and application scope. Therefore, the content of this specification should not be construed as a limitation of the present invention.
Claims
1. A deep learning-based method for identifying nematodes, characterized in that, include: Image data of nematodes were collected using an optical microscope with a camera function, and the data was labeled to divide the training dataset and the validation dataset. The nematode image data is preprocessed to obtain a binarized connected component mask image; the image preprocessing includes image denoising, image binarization, and image connected component solving; The labeled training dataset is trained using a YOLOv8 network to obtain a trained model, and the trained model is tested using the labeled validation dataset. The image of the nematode to be tested is input into the trained model to detect the nematode, and the detected nematode labeled image is obtained. The binarized connected component mask image and the nematode labeled image are processed for post-detection processing to screen for overlapping, missed, and false detections of nematodes and to eliminate impurities that are similar to nematodes, thereby generating a set of effective nematode targets after screening. Based on the set of effective nematode targets, the statistical results of the number of nematodes and their survival status are output. Based on the effective nematode target set after screening, single nematode images corresponding to single nematodes are obtained from the images of nematodes to be tested. The single nematode images are preprocessed with grayscale and binarization. Paddle OCR technology is used to obtain image scale data, and OpenCV library functions are used to process the nematode outline to obtain body length, body width and biomass.
2. The deep learning-based nematode identification method according to claim 1, characterized in that, The image denoising steps include: The nematode image data is divided into blocks and a reference block is selected; the reference block is a two-dimensional image block extracted from the nematode image data. A block to be matched is searched within a preset search range, and the similarity between the block to be matched and the reference block is calculated; the block to be matched is a two-dimensional image block that is compared with the reference block within the search range. Similar blocks are grouped according to the similarity; a similar block is the block to be matched whose similarity satisfies a preset threshold. The grouped similar blocks are combined into a three-dimensional group, and the three-dimensional group is subjected to collaborative filtering to obtain the collaborative filtering result. The results of the collaborative filtering process are aggregated to the corresponding original image block positions in the nematode image data to obtain the denoised nematode image data.
3. The deep learning-based nematode identification method according to claim 2, characterized in that, The image binarization steps include: The OpenCV threshold function is called to perform threshold segmentation on the denoised nematode image data; Different thresholds are set to binarize the denoised nematode image data to obtain the corresponding binarized images; The separation of nematodes, impurities, and background is achieved based on the binarized image.
4. The deep learning-based nematode identification method according to claim 3, characterized in that, The steps for solving the connected component problem of the image include: Perform connected component analysis on the binarized image; a connected component is a region in the binarized image consisting of pixels with the same pixel value and adjacent positions; The connected components are extracted using the connected component analysis function in OpenCV, and each connected component is labeled; wherein the connected components include nematodes and impurities.
5. The deep learning-based nematode identification method according to claim 1, characterized in that, The YOLOv8 network consists of a Backbone, a Neck, and a Head. The Backbone is used to extract image features and adopts a typical Darknet53 structure. The Backbone includes a Conv Module, a C2f module, and an SPPF module. The Neck is located between the Backbone and the Head and is used for feature fusion. It adopts a PANet structure. The Head is used to output the detection results and includes the detection and loss function parts.
6. The deep learning-based nematode identification method according to claim 1, characterized in that, The image of the nematode to be tested is input into the trained model for nematode detection, resulting in a labeled image of the detected nematodes, including: Load the trained model in a Python environment using the Ultralytics YOLO library; Set the prediction confidence threshold to conf=0.57; The image of the nematode to be tested is used to perform prediction and the prediction results are saved to generate the nematode-tagged image; the identification time for multiple nematodes is less than 3 seconds and the identification accuracy is not less than 85%.
7. The deep learning-based nematode identification method according to claim 1, characterized in that, The binarized connected component mask image and the nematode-labeled image are processed for post-detection processing to screen for overlapping, missed, and false detections of nematodes and eliminate impurities that are similar to nematodes, generating a set of effective nematode targets after screening. Based on the set of effective nematode targets after screening, statistical results on the number and survival status of nematodes are output, including: The detection results in the nematode-labeled image are subjected to mask filtering corresponding to the binarized connected component mask image to remove detection results that are inconsistent with the binarized connected component mask image; The strategy is designed based on whether nematodes are detected in the connected components to perform false positive screening and false negative screening, and further eliminates impurities in the image that are similar to nematodes to generate the effective nematode target set after screening. After screening, statistical results on the number of nematodes and their survival status are output and reported based on the effective nematode target set after screening.
8. The deep learning-based nematode identification method according to claim 1, characterized in that, Based on the screened effective nematode target set, the single nematode image corresponding to a single nematode is obtained from the nematode images to be tested, including: The target region of a single nematode is determined from the effective nematode target set after screening; the target region is the image region in the image of the nematode to be tested that corresponds to a single nematode. Based on the target region, an image region corresponding to the single nematode is extracted from the image of the nematode to be tested to obtain the single nematode image; The single nematode image is used as input for grayscale and binarization preprocessing, as well as for scale data acquisition and nematode contour processing.
9. The deep learning-based nematode identification method according to claim 1, characterized in that, Using OpenCV library functions to process nematode outlines to obtain body length, body width, and calculate biomass, including: The contour of the single nematode image is extracted using OpenCV library functions to obtain the nematode contour. The nematode outline is skeletonized using the vascular snake algorithm to obtain the nematode's midline; A point is selected on the center line of the nematode, and a circle is drawn and iterated to find the maximum width. The maximum width is then converted using the scale data to obtain the body width. The error range of the body width calculation is no more than 5%. The body length is obtained based on the nematode median line and the scale data, and the biomass is calculated based on the body length and the body width.
10. A deep learning-based nematode identification system, characterized in that, include: The nematode image acquisition and annotation unit is used to acquire nematode image data using an optical microscope with a photographic function and to perform data annotation in order to divide the training dataset and the validation dataset. The image preprocessing unit is used to perform image preprocessing on the nematode image data to obtain a binarized connected component mask image; the image preprocessing includes image denoising, image binarization, and image connected component solving. The model training and testing unit is used to train the labeled training dataset through the YOLOv8 network to obtain a trained model, and to test the trained model using the labeled validation dataset. The nematode detection unit is used to input the image of the nematode to be tested into the trained model to detect the nematode and obtain the detected nematode labeled image. The post-detection processing and statistics unit is used to perform operations on the binarized connected component mask image and the nematode labeled image to perform post-detection processing, screen for overlapping nematodes, missed detections, and false detections, and eliminate impurities that are similar to nematodes, generate a set of effective nematode targets after screening, and output statistical results of the number of nematodes and their survival status based on the set of effective nematode targets. The single nematode feature extraction and biomass calculation unit is used to obtain the single nematode image corresponding to the single nematode from the nematode image to be tested based on the effective nematode target set after screening, and to perform grayscale and binarization preprocessing on the single nematode image, obtain image scale data using Paddle OCR technology, and process the nematode outline using OpenCV library functions to obtain body length, body width and calculate biomass.