Detection method, system, equipment and medium for blood sampling tube blood layering identification

Through YOLO format, the label information is defined and the target detection model is constructed, which solves the problems of chaotic classification label management and insufficient adaptability of rotation states in blood hierarchical image processing, and the accurate identification and visual expression of blood hierarchical are realized, which improves the detection accuracy and system stability.

CN120411079AActive Publication Date: 2025-08-01NANJING AGRICULTURAL UNIVERSITY +2

Patent Information

Application Number
CN202510897668.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-07-01
Publication Date
2025-08-01
Estimated Expiration
2045-07-01

AI Technical Summary

Technical Problem

The existing blood hierarchical image processing technology has confusion in classification label management, low detection accuracy, insufficient adaptability to image rotation state, and it is difficult to achieve accurate identification and visual expression of the hierarchical structure of the blood collection tube in complex backgrounds.

Method used

The YOLO format is used to define the hierarchical label information, build an object detection model, extract the depth and shallow layer information of the image through the backbone network, calculate the boundaries of the liquid layer and calibrate the angle, identify the boundaries of the liquid layer and map the original drawing to draw the hierarchical line, introduce data enhancement strategies for model training, including image rotation, flip and color adjustment, and set up the early stop mechanism optimization model.

Benefits of technology

The model's learning efficiency and category discrimination accuracy of the hierarchical targets are improved, the stable recognition ability under complex backgrounds and sample differences is improved, the structured recognition of liquid hierarchical is integrated with image output, and the practicality of the system and engineering deployment ability are enhanced.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120411079A_ABST
    Figure CN120411079A_ABST
Patent Text Reader

Abstract

The invention discloses a detection method, system, equipment and medium for blood sampling tube blood layered recognition, and relates to the technical field of medical image processing and intelligent detection.The detection method comprises the steps that multiple types of layered images are collected, and layered label information is defined in a YOLO format; constructing a target detection model, and extracting image deep and shallow layer information; and calculating a liquid layer boundary and calibrating an angle, identifying the liquid layer boundary and mapping an original drawing to draw a layering line. According to the method, a data input system which is clear in structure and friendly in training is established, the learning efficiency and category discrimination precision of the model for layered targets are improved, high-confidence liquid layer region identification and boundary extraction are realized, the stable identification capability of the model under complex backgrounds and sample differences is improved, and the method is suitable for popularization and application. Structured recognition of liquid layering and image output fusion are achieved, and the practicability and the engineering deployment capacity of the system are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of medical image processing and intelligent detection, and particularly to a detection method, system, device and medium for identifying blood stratification in blood collection tubes. Background Art

[0002] With the continuous development of intelligent medicine and image processing technology, the application of computer vision in medical auxiliary diagnosis has gradually deepened, especially in the fields of blood detection, medical imaging and automatic specimen recognition. Traditional blood centrifugation detection relies on manual visual judgment of the stratification of blood samples, including different liquid layers such as plasma, blood cells, and buffy coat. Manual operation is not only inefficient and subjective, but also easily affected by multiple factors such as external light, sample state, and operation experience. In recent years, the emergence of deep learning methods, especially real-time object detection algorithms such as YOLO, has provided a new solution path for target localization and stratification recognition in medical images. It has achieved remarkable results in the fields of industrial vision, security monitoring, vehicle-mounted recognition, etc., and has gradually been introduced into medical image analysis to improve the recognition efficiency and automation level.

[0003] However, most of the existing blood collection tube image processing methods only stay at the level of target detection or region segmentation, lacking fine modeling and stable extraction of the blood stratification structure. Existing methods usually directly perform edge detection or segmentation on the entire image, unable to model specific categories separately, resulting in low stratification recognition accuracy, especially in the case of light interference or blurred sample boundaries, the recognition performance deteriorates. Secondly, most technologies do not correct the tilt state of the blood collection tube, resulting in deviations in identifying the liquid boundary line, affecting subsequent thickness analysis and stratification ratio judgment. Traditional algorithms have high requirements for the input images of the model, are difficult to adapt to diverse shooting environments, and lack robustness to low-quality samples. Summary of the Invention

[0004] In view of the above problems, the present invention is proposed.

[0005] Therefore, the technical problems solved by the present invention are: the existing blood stratification image processing technology has chaotic classification label management, low detection accuracy, insufficient adaptability to the rotation state of the image, and how to achieve accurate recognition of the liquid stratification structure of the blood collection tube under complex backgrounds and visual representation of the original image.

[0006] To solve the above technical problems, the present invention provides the following technical solutions: A detection method for blood layer identification in blood collection tubes collects multiple types of layered images, and defines layered label information in YOLO format; constructs an object detection model to extract deep and shallow layer information of the images; calculates the liquid layer boundary and calibrates the angle, identifies the liquid layer junction and maps it to the original image to draw a layered line; calculating the liquid layer boundary and calibrating the angle includes forming a closed contour by fitting the detection points of the blood collection tube, calculating the tilt angle and then performing a rotation transformation on the overall coordinate system of the image to unify the reference direction of the image; identifying the liquid layer junction and mapping it to the original image to draw a layered line includes extracting the edge coordinates of the detection box with the highest confidence, calculating the junction points between the liquid layers, obtaining accurate demarcation coordinates, dynamically determining the demarcation logic, mapping the boundary coordinates back to the original image through inverse transformation, and drawing a clear layered line.

[0007] As a preferred solution of the detection method for blood layer identification in blood collection tubes according to the present invention, wherein: the collecting multiple types of layered images includes collecting image samples containing different individual blood components, and avoiding environmental strong light and background reflection during the image collection process.

[0008] As a preferred solution of the detection method for blood layer identification in blood collection tubes according to the present invention, wherein: the using YOLO format to define layered label information includes annotating each detection object in the form of a rectangular box and recording the category number, and at the same time, taking the overall size of the image as a reference, representing the center position and the width and height dimensions of the detection target proportionally, and attaching the confidence coefficient of the annotation box, and converting it into YOLO format.

[0009] As a preferred solution of the detection method for blood layer identification in blood collection tubes according to the present invention, wherein: the constructing the object detection model includes performing multi-level feature extraction on the image through the backbone network, splicing and combining the input image with the image features processed by convolution in the deep layer in a direct transmission manner in the shallow layer, and fusing the semantic information and edge information in the image.

[0010] Residual connection structures are set in different module structures in the backbone network, and feature information is transmitted through skip connections.

[0011] A spatial pyramid pooling module is added to the network to obtain regional features of the image at different scales and splice them into a unified dimension.

[0012] At the same time, a path aggregation mechanism is introduced to transmit high-level semantic information from top to bottom and detail information from bottom to top, generate the position information and category prediction of the target box through the YOLO detection head, and calculate the loss function by comparing the predicted position with the label position.

[0013] Train the object detection model.

[0014] As a preferred solution of the detection method for blood layer identification in blood collection tubes according to the present invention, wherein: the training object detection model includes updating model parameters through the gradient descent backpropagation process, and performing model evaluation and accuracy optimization iterative training to gradually approximate the predicted position to the true label position. After the image is input into the model and calculated, the boundaries of the blood collection tubes and the specific positions of each blood layer in the image are output, and data augmentation is performed through rotation, flipping, color adjustment, and random cropping.

[0015] Data augmentation includes rotating the image at a random angle within a given parameter range to simulate the visual effects of blood collection tubes at different angles, and the object detection model learns the object features at different angles.

[0016] The image is flipped horizontally and vertically. By specifying the probability parameters of horizontal and vertical flips, the flipping of some parts of the images for training the model is controlled, so that the model learns different directions of symmetric objects.

[0017] By adjusting the color channels of the image, including brightness, saturation, and contrast, the color characteristics of the image are changed, and color balance and brightness enhancement techniques are used to optimize the generalization of images under different lighting and color conditions.

[0018] For the input image, a region is randomly selected, and according to the given target image size and the parameter range of the area ratio of the cropped region, a sub-image is randomly cropped. Then, the randomly cropped sub-image is scaled to the specified size as the output for model training to simulate test tubes from different perspectives.

[0019] At the same time, an early stopping mechanism is set to automatically terminate the training when the performance index does not improve for several consecutive rounds, and the convergence speed of the model and the stability of the recognition accuracy are analyzed.

[0020] Performing model evaluation and accuracy optimization iterative training includes evaluating the detection performance based on mAP, accuracy, and recall, and optimizing the parameters through backpropagation of the loss function.

[0021] As a preferred solution of the detection method for identifying blood stratification in a blood collection tube according to the present invention, wherein: calculating the boundary of the liquid layer and calibrating the angle includes obtaining the center point of the target box representing the blood collection tube from the detection result as the positioning point of the blood collection tube, removing points with similar distances from the positioning point, sorting the processed positioning points according to the x coordinate, removing points approximately collinear with the positioning point, checking the distance from the processed positioning point to the line segment of the blood collection tube, deleting the current positioning point if it is less than the set value, removing redundant points, calculating the missing positioning points of the blood collection tube based on the detected number of positioning points, forming a complete rectangular boundary, calculating the inclination angle of the blood collection tube by obtaining the slope of the connection line of two opposite sides in the contour of the blood collection tube, and performing coordinate transformation processing on the entire image and the detection frame, rotating the image as a whole to horizontally align the blood collection tube and unifying the image reference direction for the subsequent recognition process.

[0022] As a preferred solution of the detection method for identifying blood stratification in a blood collection tube according to the present invention, wherein: identifying the junction of the liquid layer and mapping the original image to draw the stratification line includes, in the detection frame of each layer obtained by detection, selecting the candidate box with the highest confidence, extracting the upper edge or lower edge coordinates as the basis points for the junction, and calculating the connection points between different liquid layers with the boundary of the blood collection tube as a reference to obtain accurate demarcation coordinates.

[0023] If there is a white liquid layer in the image, first calculate the intersection point of the yellow liquid layer and the white liquid layer, and then calculate the intersection point of the white liquid layer and the blood layer.

[0024] If the white liquid layer is missing, only the intersection point of the yellow liquid layer and the blood layer needs to be calculated.

[0025] Classifying and visually segmenting the liquid layer in the image includes mapping the identified boundary coordinates back to the original image coordinate system through inverse rotation transformation and drawing the boundaries between different blood layers in the image in a straight-line connection manner.

[0026] Another object of the present invention is to provide a detection system for identifying blood stratification in a blood collection tube, which can calculate the boundary of the liquid layer and calibrate the angle, identify the junction of the liquid layer and map the original image to draw the stratification line, and solve the problems of inconsistent posture, inaccurate identification of the liquid layer junction, and poor structural expression of the results in the current blood stratification image analysis technology.

[0027] As a preferred solution of the detection system for identifying blood stratification in blood collection tubes according to the present invention, it includes: an image acquisition and database building module, a model construction and training module, and a boundary calibration and stratification visualization module; the image acquisition and database building module includes an image acquisition standardization module and a label definition conversion module. The image acquisition standardization module is used to acquire images of different blood stratification states, control the light source, background, and shooting angle. The label definition conversion module is used to perform standardized annotation on the plasma layer, white blood cell layer, and red blood cell layer in the image in YOLO format, record the category number, center coordinates, and size ratio, and attach a confidence coefficient at the same time, and generate a structured label file for deep learning use, constructing a high-quality and standardized data set for model training and verification; the model construction and training module includes a target detection model construction module and a target detection model training module. The target detection model construction module is used to perform multi-scale feature fusion, extract image features from multiple scales through spatial pyramid pooling, splice them with shallow and deep features, perform semantic information and edge information fusion, introduce a path aggregation mechanism to effectively transfer high-level semantic information and detailed information, that is, generate the target box position and category prediction through the YOLO detection head, and calculate the loss function. The target detection model training module is used to continuously optimize the model parameters through the gradient descent and backpropagation algorithms, improve the detection accuracy, perform iterative training based on mAP, accuracy, and recall rate, adopt a variety of data augmentation strategies, including image rotation, flipping, color adjustment, and random cropping, and have an early stopping mechanism to automatically judge and terminate the training according to the change of performance indicators during the training process; the boundary calibration and stratification visualization module includes a blood collection tube boundary reconstruction module and a stratification line drawing and mapping module. The blood collection tube boundary reconstruction module is used to form a closed contour by fitting the detection points of the blood collection tube, calculate the tilt angle and then perform a rotation transformation on the overall coordinate system of the image to unify the reference direction of the image. In the blood collection tube contour, calculate the tilt angle of the blood collection tube by obtaining the slope of the connection line of two opposite sides, and perform coordinate transformation processing on the whole image and the detection box to rotate the whole image. The stratification line drawing and mapping module is used to select the candidate box with the highest confidence in the detection box of each layer obtained by detection, extract the upper edge or lower edge coordinates as the boundary basis points, calculate the connection points between different liquid layers with the blood collection tube boundary as the reference to obtain accurate demarcation coordinates; classifying and visually segmenting the liquid layer in the image includes mapping the identified boundary coordinates back to the original image coordinate system through inverse rotation transformation and drawing the boundaries between different blood layers in the image in a straight-line connection manner.

[0028] A computer device includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the steps of the detection method for identifying blood stratification in blood collection tubes.

[0029] A computer-readable storage medium stores a computer program thereon, and when the computer program is executed by a processor, the steps of a detection method for identifying blood stratification in a blood collection tube are implemented.

[0030] Advantages of the present invention: The detection method for identifying blood stratification in a blood collection tube provided by the present invention collects multiple types of stratification images, defines stratification label information in the YOLO format, establishes a data input system with clear structure and friendly training, improves the learning efficiency of the model for stratification targets and the category discrimination accuracy, constructs an object detection model, extracts deep and shallow layer information of the image, realizes the recognition and boundary extraction of the liquid layer region with high confidence, improves the stable recognition ability of the model under complex backgrounds and sample differences, calculates the liquid layer boundary and calibrates the angle, recognizes the liquid layer junction and maps the original image to draw a stratification line, realizes the integration of structured recognition and image output of liquid stratification, improves the practicability and engineering deployment ability of the system, and the present invention achieves better results in the standardized expression of image preprocessing, the multi-scale fusion recognition ability of the object detection model, and the geometric calibration and visual stratification output of the liquid layer boundary. BRIEF DESCRIPTION OF THE DRAWINGS

[0031] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following will briefly introduce the drawings required for the description of the embodiments. Obviously, the following drawings are only some embodiments of the present invention, and those of ordinary skill in the art can obtain other drawings based on these drawings without creative efforts.

[0032] Figure 1 It is the overall flowchart of a detection method for identifying blood stratification in a blood collection tube provided by the first embodiment of the present invention.

[0033] Figure 2 It is an example diagram of the collected image of a detection method for identifying blood stratification in a blood collection tube provided by the second embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0034] In order to make the above objects, features, and advantages of the present invention more obvious and understandable, the following will describe the specific embodiments of the present invention in detail with reference to the drawings of the specification. Obviously, the described embodiments are some embodiments of the present invention, rather than all embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention.

[0035] Embodiment 1, referring to Figure 1 , which is an embodiment of the present invention, provides a detection method for identifying blood stratification in a blood collection tube, including: S1: Collect multiple types of stratification images and define stratification label information in the YOLO format.

[0036] Furthermore, collecting multi-class stratified images includes collecting image samples containing different individuals' blood components, and avoiding environmental strong light and background reflection during the image collection process.

[0037] It should be noted that defining stratified label information in the YOLO format includes annotating each detection object in the form of a rectangular box and recording the class number. At the same time, with reference to the overall size of the image, the central position and width and height dimensions of the detection target are represented proportionally, and the confidence coefficient of the annotation box is added and converted into the YOLO format.

[0038] It should also be noted that a preferred solution for defining stratified label information in the YOLO format specifically includes the label format of the generated annotation file, which is expressed as: ; Among them, is the label number, 0 = tube, 1 = yellow, 2 = blood, 3 = white, is the coordinate of the target center position, is the coordinate of the target center position, is the width of the target rectangular box, is the height of the target rectangular box, is the confidence score of the target rectangular box, and the default value of manual annotation is 1.0.

[0039] It should also be noted that by collecting image samples containing different individuals' blood components and avoiding interference from environmental strong light and background reflection, the quality and diversity of image input are ensured, and the representativeness and generalization ability of training data are improved. On this basis, each liquid layer area is annotated in the YOLO format, and each type of liquid layer (such as the yellow liquid layer, blood layer, white liquid layer) is identified with a rectangular box, and the central coordinates and size information are proportionally converted, and at the same time, a confidence parameter is added to realize the unified management and standardized representation of label data. This not only establishes a data input system with clear structure and friendly to training, but also improves the learning efficiency and category discrimination accuracy of the model for stratified targets, provides stable and reliable training data support for the subsequent detection model, enables the system to adapt to the complex and changeable stratified situations of blood samples, and improves the robustness and transferability of the detection system.

[0040] S2: Construct a target detection model and extract deep and shallow layer information of the image.

[0041] Further, building the object detection model includes extracting multi-level features of the image through the backbone network, splicing and combining the input image with the directly transmitted shallow layer and the convolutionally processed deep layer image features, and fusing the semantic information and edge information in the image.

[0042] Residual connection structures are set within different module structures in the backbone network, and feature information is transmitted through skip connections.

[0043] A spatial pyramid pooling module is added to the network to obtain regional features of the image at different scales and splice them into a unified dimension.

[0044] At the same time, a path aggregation mechanism is introduced to transmit high-level semantic information from top to bottom and detailed information from bottom to top. The position information and class prediction of the target box are generated through the YOLO detection head. By comparing the predicted position with the label position, the loss function is calculated.

[0045] Train the object detection model.

[0046] It should be noted that training the object detection model includes updating the model parameters through the gradient descent backpropagation process, and performing model evaluation and precision optimization iterative training to gradually approximate the predicted position to the true label position. After the image is input into the model and calculated, the boundary of the blood collection tube and the specific positions of each blood layer in the image are output. Data augmentation is performed through rotation, flipping, color adjustment, and random cropping; Data augmentation includes rotating the image at a random angle within a given parameter range to simulate the visual effects of the blood collection tube at different angles and enable the object detection model to learn the object features at different angles.

[0047] The image is flipped horizontally and vertically. By specifying the probability parameters of horizontal and vertical flipping, a part of the images used to train the model are flipped to enable the model to learn different directions of symmetric objects.

[0048] By adjusting the color channels of the image, including brightness, saturation, and contrast, the color characteristics of the image are changed, and color balance and brightness enhancement techniques are used to optimize the generalization of images under different lighting and color conditions.

[0049] For the input image, a region is randomly selected, and according to the given target image size and the parameter of the area ratio range of the cropped region, a sub-image is randomly cropped. Then, the randomly cropped sub-image is scaled to the specified size as the output for model training to simulate test tubes from different perspectives.

[0050] At the same time, an early stopping mechanism is set to automatically terminate the training when the performance index does not improve for several consecutive rounds, and analyze the stability of the model convergence speed and recognition accuracy.

[0051] Model evaluation and precision optimization iterative training include evaluating the detection performance based on mAP, accuracy, and recall, and optimizing parameters through backpropagation of the loss function.

[0052] It should be noted that a preferred solution for constructing the object detection model extraction specifically includes, for the input image content, extracting features through multiple convolutional layers and convolutional blocks. The basic unit of the convolutional block includes a convolutional layer, batch normalization, and activation operation. The convolutional layer multiplies the filter element-wise with the input feature map and sums the results to generate the output feature map, and calculates the value at the corresponding position of the output feature map , expressed as: ; Among them, and respectively represent the values at the corresponding positions of the input and output feature maps, is the weight parameter of the convolution operation, that is, the filter, is the bias term, used to adjust the output of the convolution operation, represents the row index of the current output image, corresponding to the row, represents the column index of the current output image, corresponding to the column, represents the current row index of the convolution kernel, represents the current column index of the convolution kernel. Through the dot product calculation of the input feature map and the filter, the image features at different positions are deeply extracted and summarized, and then the output feature map is normalized through the batch normalization process, expressed as: ; Among them, and respectively represent the input feature map and the normalized feature map, and respectively represent the mean and variance of the input feature map in the current channel, while is a very small positive number, used to prevent the divisor from being zero and stabilize the calculation. Batch normalization also includes learnable scaling and bias parameters, expressed as: ; Among them, is the scaling parameter learned and updated during the training process, is the offset parameter learned and updated during the training process, with initial values of 1 and 0, is the result obtained by batch normalization. ReLU is used as the next activation function to introduce non-linear transformation during the calculation process, expressed as: ; Among them, is the output result of the activation function processing process, performs a maximum value operation on the function execution, that is, all negative inputs become zero and positive numbers remain unchanged.

[0053] It should also be noted that a preferred solution for training the object detection model specifically includes using a consistent matching metric to evaluate the consistency between the predicted bounding box and the ground truth bounding box, expressed as: ; Among them, is the classification score, and are the predicted bounding box and the ground truth bounding box respectively, represents the spatial prior, and are hyperparameters, represents the matching score between the predicted box and the ground truth box.

[0054] It should also be noted that a preferred solution for calculating the loss function specifically includes calculating the classification loss, confidence loss, and localization loss. The loss function is expressed as: ; Among them, is the classification loss, is the confidence loss, is the localization loss, , , are the weights of the three losses respectively, is used to optimize the accuracy of class prediction. To calculate the classification loss , it is expressed as: ; Among them, represents the class index. In this detection task, there are 4 types of objects: tube, yellow, blood, white, represents the class index of the ground truth label. Only the correct class value is 1, and the rest are 0, represents the class index of the predicted probability.

[0055] To calculate the confidence loss , which measures whether the predicted box contains an object, is expressed as: ; Among them, represents the true confidence value, 1 = there is an object, 0 = there is no object, represents the predicted confidence value, An indicator variable, if the th detection box contains the target, the value is 1, otherwise it is 0. An indicator variable, if the th detection box does not contain the target, the value is 1, otherwise it is 0. A weight parameter used to reduce the impact of the background area on the loss.

[0056] Calculate the intersection over union , and obtain the localization loss , expressed as: ; Among them, represents the center point coordinates of the candidate bounding box or detection box, represents the intersection area of the ground truth rectangle and the predicted rectangle, represents the union area of the ground truth rectangle and the predicted rectangle, calculate the localization loss , expressed as: ; ; ; Among them, is the consistency parameter representation of the aspect ratio of the predicted annotation box, is the weight parameter, representing the proportion of the aspect ratio of the predicted annotation box in the loss, , are the width and height of the ground truth rectangle, , are the width and height of the ground truth rectangle, is the center point of the ground truth rectangle, is the center point of the predicted rectangle, is the Euclidean distance between the center points of the ground truth rectangle and the predicted rectangle, is the diagonal distance of the minimum enclosing region of the ground truth rectangle and the predicted rectangle.

[0057] It should also be noted that a preferred scheme for rotating the image by a random angle within a given parameter range specifically includes performing an affine transformation on the pixel positions according to the formula after specifying the rotation angle , expressed as: ; ; Among them, represents the original pixel coordinates, represents the pixel coordinates after the formula transformation. By performing this transformation on all pixel points in the image, the rotation operation of the entire picture is completed.

[0058] It should also be noted that by designing a target detection network structure with the ability of shallow and deep layer fusion, introducing the residual connection structure and feature splicing mechanism in the backbone network, the edge information and semantic information of the image can be efficiently integrated between the shallow and deep layers, improving the model's expression ability for hierarchical details. At the same time, the spatial pyramid pooling module is integrated to obtain the spatial features of the image at different scales, effectively coping with the recognition interference caused by the size change of the blood collection tube. Furthermore, the path aggregation network (PAN) is introduced to establish an information path between the high-level semantics and the low-level details, enabling the model to enhance the edge localization accuracy while retaining the abstract classification ability. Finally, the target box and its category prediction are output through the YOLO detection head, and the loss function is calculated in combination with the label information for training, effectively realizing the recognition and boundary extraction of the liquid layer region with high confidence, and improving the model's stable recognition ability under complex backgrounds and sample differences.

[0059] S3: Calculate the liquid layer boundary and calibrate the angle, identify the liquid layer junction and map it to the original image to draw the stratification line.

[0060] Furthermore, calculating the liquid layer boundary and calibrating the angle includes obtaining the center point of the target box representing the blood collection tube in the detection result as the blood collection tube positioning point. After removing the points with similar distances to the positioning point, sort the processed positioning points according to the x coordinate, remove the points approximately collinear with the positioning point, check the distance from the processed positioning point to the blood collection tube line segment, and if it is less than the set value, delete the current positioning point, remove redundant points, calculate the missing blood collection tube positioning points based on the detected number of positioning points, form a complete rectangular boundary. In the blood collection tube contour, calculate the inclination angle of the blood collection tube by obtaining the slope of the line connecting two opposite sides, and perform coordinate transformation processing on the entire image and the detection frame, rotate the image as a whole to horizontally align the blood collection tube, and unify the image reference direction for the subsequent recognition process.

[0061] It should be noted that identifying the liquid layer junction and mapping it to the original image to draw the stratification line includes, in the detection box of each layer obtained by detection, selecting the candidate box with the highest confidence, extracting the upper edge or lower edge coordinates as the junction basis points, and calculating the connection points between different liquid layers with the blood collection tube boundary as a reference to obtain the accurate demarcation coordinates.

[0062] If there is a white liquid layer in the image, first calculate the intersection point of the yellow liquid layer and the white liquid layer, and then calculate the intersection point of the white liquid layer and the blood layer.

[0063] If the white liquid layer is missing, only the intersection point of the yellow liquid layer and the blood layer needs to be calculated.

[0064] Classifying and visually segmenting the liquid layer in the image includes mapping the identified boundary coordinates back to the original image coordinate system through rotation inverse transformation, and drawing the boundaries between different blood layers in the image by connecting them with straight lines.

[0065] It should also be noted that by reading the center points of the detection frames with the category of "blood collection tube", extracting and optimizing the coordinate set of the positioning points, and successively performing operations such as duplicate removal, sorting, collinearity removal, edge fitting, and defect complementation, a complete rectangular boundary of the blood collection tube is finally constructed; by calculating the slope of the opposite sides, the inclination angle of the blood collection tube is obtained, and geometric transformation is performed on the entire image and the detection frame to correct the blood collection tube to the horizontal position and unify the reference direction of the image, which not only solves the problem of structural distortion caused by the shooting posture and provides a stable reference system for subsequent boundary calculation. On this basis, the candidate box with the highest confidence in each type of liquid layer is extracted, and its upper or lower edge is calculated as the stratification intersection point. Combining with the boundary of the blood collection tube, the liquid layer intersection coordinates are obtained. Whether the white layer exists or not, the system can dynamically adjust the calculation logic, and finally map the stratification boundary line back to the original image coordinate system and perform visual drawing, realizing the integration of structured recognition and image output of liquid stratification, improving the practicability and engineering deployment ability of the system, and laying an image foundation for the automation of blood analysis in clinical and experimental scenarios.

[0066] Example 2, referring to Figure 2 , is an embodiment of the present invention, providing a detection method for identifying blood stratification in a blood collection tube. In order to verify the beneficial effects of the present invention, scientific demonstration is carried out through economic benefit calculation and simulation experiments.

[0067] First, select blood collection tube images with different blood stratification situations and photograph them from different angles to obtain the images required for training. In order to further improve the generalization ability, the resolutions of the collected images are not consistent, so that the model can adapt to inputs of various sizes. The photographed images include various situations that may occur in the actual production process, such as images under natural light, incandescent lamp and other lighting conditions, or images photographed against different backgrounds, so as to enhance the accuracy of the model. In this example, there are two types of stratified blood (without white layer), three types of stratified blood, coagulated blood and other multiple stratification situations, and a total of 1480 effective images are photographed. Figure 2There are four example pictures for shooting; after the image acquisition work is completed, image preprocessing is carried out, such as image screening, scale standardization, etc., to ensure the quality of the sample images; in order to better eliminate the influence of the image background, etc. on the subsequent operations, a target detection model is used to mark the key information of the image in the form of a rectangular box. Since the target detection model needs to be trained first using the labeled images, the data annotation task is carried out first in this step. The AnyLabeling software package is used to annotate the images. There are generally errors in automatic annotation. The best method is to use the manual annotation method to generate high-quality label files. Compared with automatic annotation, manual annotation can greatly improve the accuracy of the model. Therefore, for manual annotation, the dataset needs to be divided. Generally, the images are divided into a training set, a validation set, and a test set. In the present invention, the random sampling method is used to sample and annotate the dataset. A total of 564 pictures of blood collection tubes with different stratification situations are annotated. The dataset is divided in a ratio of 95% and 5%, that is, 533 of them are used as the training set, 31 are used as the validation set, and 50 unlabeled images are randomly selected to be automatically annotated using the trained model to check the accuracy of the model detection; the parameters in the target detection model include, the number of training epochs, the batch size of training, the size of the training pictures, expressed as:

[0068] This model uses the loss function to calculate the loss according to the formula, and then updates the parameters through the model backpropagation process. After multiple rounds of iteration, the optimal effect is obtained. Then, after the model is trained, the model is used to detect the boundary of the blood collection tube and the blood stratification; for model inference, the confidence threshold and the coverage threshold need to be set. Among them, the confidence threshold is the weight of the confidence loss in the model loss function. A higher confidence threshold will filter more detection boxes and only retain the detection boxes with a higher probability of confidence; the coverage threshold is the intersection over union loss in the model loss. The lower the coverage, the lower the tolerance for the overlap between detection boxes. When the coverage threshold is 0, there will be no overlapping detection boxes. The parameter settings in the example are expressed as:

[0069] Finally, the accuracy of the model on the validation set reaches 1.00, the recall rate reaches 0.99, and the mAP reaches 0.988, and it can accurately detect and frame the positions of the boundary of the blood collection tube and the blood stratification in the image.

[0070] After object detection is completed, data augmentation is immediately performed on the image to enhance the diversity of the image, thereby improving the generalization of the finally trained model. In this process, four data augmentation techniques, namely rotation, flipping, color regularization, and random cropping, are mainly used. Among them, the parameter limits the angle range of image rotation, and limit the probabilities of horizontal and vertical flipping of the image, specifies the random scaling ratio range of the image, and the parameter settings are as follows:

[0071] By adopting the above four data augmentation techniques in this method, the performance of the model in the face of images with different angles, different colors, etc. is improved. After completing the data collection and data processing tasks, the core network architecture for detecting the blood stratification in the blood collection tube is then constructed. In the design of the network architecture, this method selects CSPNet as the backbone network to extract image features through the method of segmented feature extraction. Residual connections are applied in each module to skip the calculations of some layers, avoid the problem of gradient disappearance, and improve the training stability and convergence speed of the network. To improve the performance of multi-scale object detection, a feature fusion layer is introduced to enhance the coordination between features at different levels. Finally, through the consistent dual assignment strategy and consistent matching metric, the efficiency and accuracy of the model in the training and inference stages are ensured. Next, according to the constructed network model, network model training is carried out. In this step, the training process parameters is the training image size, is the maximum number of detection targets per image, is the type of optimizer used in the training process, is the number of training epochs, is the batch size of training, is the number of epochs required to control early stopping, and the parameter settings are as follows: ;

[0072] After obtaining the detection result according to the current model, the loss function is used to calculate the loss and backpropagate to update the parameters and weights of each layer of the model, gradually optimizing the model. In the process of multiple rounds of iteration, the model effect is measured by standards such as mAP, accuracy, recall rate, etc., so that the loss gradually decreases and the accuracy gradually increases in the continuous training process. The loop iteration continues until the model gradually converges in the gradient descent process, and the performance and detection accuracy are gradually improved, thus obtaining the final detection model. The evaluation result of the final model is in the form of a confusion matrix.

[0073] Embodiment 3, an embodiment of the present invention, provides a detection system for identifying blood stratification in blood collection tubes, including an image acquisition and database building module, a model construction and training module, and a boundary calibration and stratification visualization module.

[0074] Among them, the image acquisition and database building module includes an image acquisition standardization module and a label definition conversion module. The image acquisition standardization module is used to collect images of different blood stratification states, control the light source, background, and shooting angle, avoid strong light and blur, ensure the images are clear and consistent, improve the quality of the original samples. The label definition conversion module is used to perform standardized annotation on the plasma layer, white blood cell layer, red blood cell layer, etc. in the image in YOLO format, record the category number, center coordinates, and size ratio, and at the same time attach a confidence coefficient, and generate a structured label file for deep learning use, and construct a high-quality, standardized data set for model training and verification.

[0075] It should be noted that when the image acquisition and database building module is started, the image acquisition standardization module therein collects image samples containing different blood stratification states on the premise of controlling the environmental light source, background, and shooting angle, ensuring the unity of image quality and clear structure; subsequently, the label definition conversion module performs YOLO format annotation on each liquid layer in the image, records the category number, center coordinates, width-height ratio, and confidence coefficient, and forms a structured label file, which directly provides a high-quality, standardized data set for the subsequent model training stage.

[0076] The image acquisition and database building module is the starting point of the entire system. Its function is not only to collect blood stratification images, but also to undertake the structured conversion of image labels. The image acquisition standardization module ensures that the collected images have a unified quality standard (lighting, angle, background), improving the consistency and generalization of model training; subsequently, the label definition conversion module annotates the liquid stratification information (such as plasma layer, buffy coat layer, red blood cell layer) as a label file in YOLO format, forming a standardized data set; these images and corresponding labels will be directly passed as input data to the model construction and training module for building the network architecture and training.

[0077] The model construction and training module includes an object detection model construction module and an object detection model training module. The object detection model construction module is used for multi-scale feature fusion. It extracts image features from multiple scales through spatial pyramid pooling, and splices them with shallow and deep features to achieve the fusion of semantic information and edge information. The introduced path aggregation mechanism realizes the effective transmission of high-level semantic information and detailed information, and clarifies the application scenario of the module, that is, generating the position and category prediction of the target box through the YOLO detection head, calculating the loss function, and realizing an efficient object detection task. The object detection model training module is used to continuously optimize the model parameters through the gradient descent and backpropagation algorithms, improve the detection accuracy, and perform iterative training based on indicators such as mAP, accuracy, and recall rate. It adopts a variety of data augmentation strategies, including image rotation, flipping, color adjustment, and random cropping, to enhance the generalization ability of the model under different angles, illuminations, and perspectives. There is an early stopping mechanism, which automatically judges and terminates the training according to the change of performance indicators during the training process, ensuring a balance between the convergence speed and recognition accuracy of the model.

[0078] It should be noted that the object detection model construction module builds an object detection network that fuses shallow edge information and deep semantic information, extracts multi-scale region features through spatial pyramid pooling, and introduces a path aggregation mechanism to improve the high-low layer feature transmission ability. Finally, the position and classification results of the detection box are output by means of the YOLO detection head; subsequently, the object detection model training module conducts training tasks based on the foregoing structure, continuously optimizes the model parameters by using the gradient descent and backpropagation algorithms, and improves the robustness of the model to different angle, illumination, and perspective changes through various data augmentation means such as image rotation, flipping, color adjustment, and cropping. An early stopping mechanism is set during the training process to ensure that the training process automatically terminates when the performance indicators are stable or decreasing, balancing the model accuracy and training efficiency.

[0079] After the model construction and training module is trained through the object detection network (including multi-scale feature fusion and semantic-edge information integration), it has the ability to detect various liquid layers in blood images. The detection results output by the object detection model training module include the position and category prediction results of the blood collection tube box and the target boxes of each liquid layer. These prediction results are directly transmitted as input data to the boundary calibration and stratification visualization module for subsequent image spatial correction and boundary analysis.

[0080] The boundary calibration and stratification visualization module includes a blood collection tube boundary reconstruction module and a stratification line drawing and mapping module. The blood collection tube boundary reconstruction module is used to form a closed contour by fitting the detection points of the blood collection tube, calculate the tilt angle, and then perform a rotation transformation on the overall coordinate system of the image to unify the reference direction of the image. In the contour of the blood collection tube, the tilt angle of the blood collection tube is calculated by obtaining the slope of the connection line between two opposite sides, and coordinate transformation processing is performed on the entire image and the detection frame to rotate the entire image so that the blood collection tube is horizontally aligned, unifying the reference direction of the subsequent recognition process. The stratification line drawing and mapping module is used to select the candidate box with the highest confidence in the detection box of each layer obtained by detection, extract the upper or lower edge coordinates as the intersection basis points, calculate the connection points between different liquid layers with the blood collection tube boundary as the reference, and obtain accurate demarcation coordinates; the classification and visual segmentation of the liquid layers in the image include mapping the identified boundary coordinates back to the original image coordinate system through inverse rotation transformation, and drawing the boundaries between the blood layers in the image in a straight-line connection manner.

[0081] It should be noted that the blood collection tube boundary reconstruction module first fits the blood collection tube boundary through detection points, corrects its tilt angle, and performs rotation processing on the coordinates of the entire image and the detection box to standardize the reference direction of the image, facilitating the unification of the subsequent image analysis basis. Immediately afterwards, the stratification line drawing and mapping module selects the detection box with the highest confidence in each type of liquid layer in the rotated image, calculates the intersection points between different liquid layers through the edge coordinates, further calculates the accurate stratification line coordinates based on the blood collection tube boundary reference box, and finally maps these demarcation points back to the original image coordinate system through inverse rotation transformation, and draws the boundaries of each blood layer in the image in a straight-line manner to realize the visual output of the liquid stratification result.

[0082] The boundary calibration and stratification visualization module not only completes the posture correction of the blood collection tube and the drawing of the stratification line, but also can perform quality traceability through its output results; on the one hand, the visual output result can be used as a basis for manual verification to trace the problems existing in the collected image or label, and feedback back to the image acquisition and database building module; on the other hand, through the analysis result of the recognition error, it can also be used for model fine-tuning and incremental training, and be transmitted back to the model construction and training module to form a training data update mechanism, thereby continuously improving the detection accuracy and robustness of the overall system.

Claims

1. A detection method for identifying blood stratification in blood collection tubes, characterized in that, Including: Collecting multi-class stratified images and defining stratified label information in YOLO format; Constructing an object detection model to extract deep and shallow layer information of the images; Calculating the liquid layer boundary and calibrating the angle, identifying the liquid layer junction and mapping the original image to draw the stratification line; Calculating the liquid layer boundary and calibrating the angle includes forming a closed contour by fitting the detection points of the blood collection tube, calculating the tilt angle and then performing a rotation transformation on the overall coordinate system of the image to unify the reference direction of the image; Identifying the liquid layer junction and mapping the original image to draw the stratification line includes extracting the edge coordinates of the detection box with the highest confidence, calculating the junction points between the liquid layers to obtain accurate demarcation coordinates, dynamically determining the demarcation logic, mapping the boundary coordinates back to the original image through inverse transformation, and drawing a clear stratification line.

2. The detection method for identifying blood stratification in blood collection tubes according to claim 1, wherein: The collecting of multi-class stratified images includes Collecting image samples containing different individuals' blood components, and avoiding environmental strong light and background reflection during the image collection process.

3. The detection method for identifying blood stratification in a blood collection tube according to claim 1 or 2, characterized in that: The defining of stratified label information in YOLO format includes Annotating each detection object in the form of a rectangular box and recording the class number, and at the same time, taking the overall size of the image as a reference, proportionally representing the center position, width, and height dimensions of the detection target, and attaching the confidence coefficient of the annotation box, and converting it to the YOLO format.

4. The detection method for identifying blood stratification in a blood collection tube according to claim 1, wherein: The constructing of the object detection model includes Performing multi-level feature extraction on the image through the backbone network, splicing and combining the input image with the image features processed by convolution in the deep layer in a direct transmission manner in the shallow layer, and fusing the semantic information and edge information in the image; Setting residual connection structures in different module structures in the backbone network to transfer feature information through skip connections; Adding a spatial pyramid pooling module to the network to obtain regional features of the image at different scales and splicing them into a unified dimension; At the same time, introducing a path aggregation mechanism to transmit high-level semantic information from top to bottom and detailed information from bottom to top, generating the position information of the target box and class prediction through the YOLO detection head, and calculating the loss function by comparing the predicted position with the label position; Training the object detection model.

5. The detection method for identifying blood stratification in a blood collection tube according to claim 4, characterized in that: The training of the object detection model includes Updating the model parameters through the gradient descent backpropagation process, and performing model evaluation and accuracy optimization iterative training to gradually approximate the predicted position to the true label position. After the image is input into the model and calculated, the boundary of the blood collection tube and the specific positions of each blood layer in the image are output, and data augmentation is performed through rotation, flipping, color adjustment, and random cropping; Data augmentation includes rotating the image at a random angle within a given parameter range to simulate the visual effects of the blood collection tube at different angles and learning the target features at different angles based on the object detection model; Performing horizontal and vertical flipping on the image, and controlling the flipping of some parts of the images used to train the model by specifying the probability parameters of horizontal and vertical flipping, so that the model learns the different directions of symmetric targets; Optimizing the generalization of images under different lighting and color conditions by adjusting the color channels of the image, including brightness, saturation, and contrast, changing the color characteristics of the image, and using color balance and brightness enhancement techniques; Randomly select a region from the input image, and randomly crop a sub-image according to the given size of the target image and the parameter of the area ratio range of the cropping region. Then, scale the randomly cropped sub-image to the specified size as the output for model training, simulating test tubes from different perspectives; At the same time, set an early stopping mechanism to automatically terminate the training when the performance index does not improve for several consecutive rounds, and analyze the stability of the model convergence speed and recognition accuracy; Perform model evaluation and precision optimization iterative training, including evaluating the detection performance based on mAP, accuracy, and recall, and optimizing the parameters through backpropagation of the loss function.

6. The detection method for identifying blood stratification in a blood collection tube according to claim 5, characterized in that: The calculation of the liquid layer boundary and angle calibration includes, Obtain the center point of the target box representing the blood collection tube in the detection result as the blood collection tube positioning point, remove the points with similar distances to the positioning point, sort the processed positioning points according to the x coordinate, remove the points approximately collinear with the positioning point, check the distance from the processed positioning point to the blood collection tube line segment, and delete the current positioning point if it is less than the set value, remove redundant points, calculate the missing blood collection tube positioning points based on the number of detected positioning points, form a complete rectangular boundary, calculate the inclination angle of the blood collection tube by obtaining the slope of the connection line of two opposite sides in the blood collection tube contour, and perform coordinate transformation processing on the entire image and the detection frame, and rotate the image as a whole to horizontally align the blood collection tube to unify the image reference direction for the subsequent recognition process.

7. The detection method for identifying blood stratification in blood collection tubes according to claim 6, characterized in that: The recognition of the liquid layer junction and mapping to the original image to draw the stratification line includes, in the detection frame of each layer obtained by detection, select the candidate box with the highest confidence, extract the upper or lower edge coordinates as the junction basis points, and calculate the connection points between different liquid layers with the blood collection tube boundary as the reference to obtain the accurate demarcation coordinates; If there is a white liquid layer in the image, first calculate the intersection point of the yellow liquid layer and the white liquid layer, and then calculate the intersection point of the white liquid layer and the blood layer; If the white liquid layer is missing, only the intersection point of the yellow liquid layer and the blood layer needs to be calculated; The classification and visualization segmentation of the liquid layer in the image include mapping the identified boundary coordinates back to the original image coordinate system through inverse rotation transformation and drawing the boundaries between the blood layers in the image in a straight-line connection manner.

8. A detection system for identifying blood stratification in blood collection tubes, characterized in that: It includes an image acquisition and database building module, a model construction and training module, and a boundary calibration and stratification visualization module; The image acquisition and database building module includes an image acquisition and standardization module and a label definition and conversion module. The image acquisition and standardization module is used to acquire images of different blood stratification states, control the light source, background, and shooting angle. The label definition and conversion module is used to standardize and annotate the plasma layer, white blood cell layer, and red blood cell layer in the image in the YOLO format, record the category number, center coordinates, and size ratio, and attach a confidence coefficient at the same time, and generate a structured label file for deep learning use, and build a high-quality and standardized data set for model training and verification; The model construction and training module includes an object detection model construction module and an object detection model training module. The object detection model construction module is used to perform multi-scale feature fusion, extract image features from multiple scales through spatial pyramid pooling, splice them with shallow and deep features, fuse semantic information and edge information, introduce a path aggregation mechanism to effectively transmit high-level semantic information and detailed information, generate the position and category prediction of the target box through the YOLO detection head, and calculate the loss function. The object detection model training module is used to continuously optimize the model parameters through the gradient descent and backpropagation algorithms, perform iterative training based on mAP, accuracy, and recall rate, adopt a variety of data augmentation strategies, including image rotation, flipping, color adjustment, and random cropping, and has an early stopping mechanism to automatically judge and terminate the training according to the changes in performance indicators during the training process; The boundary calibration and hierarchical visualization module includes a blood collection tube boundary reconstruction module and a hierarchical line drawing mapping module. The blood collection tube boundary reconstruction module is used to form a closed contour by fitting the detection points of the blood collection tube, calculate the tilt angle and then perform a rotation transformation on the overall coordinate system of the image to unify the reference direction of the image. In the blood collection tube contour, calculate the tilt angle of the blood collection tube by obtaining the slope of the connection line of two opposite sides, and perform coordinate transformation processing on the entire image and the detection box to rotate the whole image. The hierarchical line drawing mapping module is used to select the candidate box with the highest confidence in the detection box of each layer obtained by detection, extract the upper or lower edge coordinates as the intersection basis points, calculate the connection points between different liquid layers with the blood collection tube boundary as the reference to obtain accurate demarcation coordinates; classifying and visually segmenting the liquid layers in the image includes mapping the identified boundary coordinates back to the original image coordinate system through inverse rotation transformation and drawing the boundaries between different blood layers in the image in the form of straight line connections.

9. A computer device, comprising a memory and a processor, the memory storing a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the detection method for blood stratification recognition of a blood collection tube according to any one of claims 1 to 7.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the steps of the detection method for blood stratification recognition of a blood collection tube according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Blood layering image segmentation method based on multi-channel alternating current attention network

    CN115841573A

  • Blood collection tube blood detection method based on deep neural network

    CN118447004A

  • Blood cell detection method based on improved YOLOv8

    CN120198409A

  • Method and system for extracting carotid artery vessel centerline in magnetic resonance image

    WO2022095612A1

Cited By

  • Optical visual layering system and method for blood separation

    CN121564242A