A detection method, system, device and medium for blood stratification identification in blood collection tubes
By defining labels in the YOLO format and building a target detection model, the problems of chaotic classification label management and insufficient adaptability of rotation states in blood stratification image processing are solved, accurate recognition and visual expression of blood stratification are achieved, and detection accuracy and stability are improved.
Patent Information
- Application Number
- CN202510897668.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-01
- Publication Date
- 2025-09-05
- Estimated Expiration
- 2045-07-01
AI Technical Summary
Existing blood stratification image processing technology has problems such as chaotic classification label management, low detection accuracy, insufficient adaptability to image rotation state, and difficulty in accurately identifying the stratified structure of blood collection tube liquid and visualizing the original image under complex backgrounds.
The YOLO format is used to define hierarchical label information, build a target detection model, extract image depth and shallow layer information through the backbone network, calculate the liquid layer boundary and calibrate the angle, identify the liquid layer junction and map the original image to draw the layer line, introduce residual connection and spatial pyramid pooling modules, perform multi-scale feature fusion, and train the model through data enhancement strategy.
The model's learning efficiency and category discrimination accuracy for hierarchical targets have been improved, high-confidence recognition and boundary extraction of liquid layer areas have been achieved, and stable recognition capabilities under complex backgrounds have been enhanced. The image preprocessing normalized expression and geometric calibration of liquid layer boundaries and visual hierarchical output have been achieved.
Smart Images

Figure CN120411079B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of medical image processing and intelligent detection technology, and in particular to a detection method, system, equipment and medium for blood stratification recognition 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-assisted diagnosis has become increasingly profound, especially in the fields of blood testing, medical imaging, and automatic specimen identification. Traditional blood centrifugation testing 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 highly subjective, but also easily affected by multiple factors such as external lighting, sample status, and operator experience. In recent years, deep learning methods, especially the introduction of real-time target detection algorithms such as YOLO, have provided new solutions for target positioning and layered recognition in medical images. They have achieved remarkable results in industrial vision, security monitoring, and vehicle-mounted recognition, and are gradually being introduced into medical image analysis to improve recognition efficiency and automation.
[0003] However, most existing blood collection tube image processing methods only focus on target detection or region segmentation, lacking the detailed modeling and stable extraction of blood stratification structures. Existing methods typically perform direct edge detection or segmentation on the entire image, failing to model specific categories separately. This results in low stratification recognition accuracy, especially in situations of light interference or blurred sample boundaries. Furthermore, most technologies fail to correct for the tilt of blood collection tubes, resulting in deviations in the recognition of liquid boundaries, affecting subsequent thickness analysis and stratification ratio determination. Traditional algorithms place high demands on model input images, making them difficult to adapt to diverse shooting environments and lacking robustness against low-quality samples. Summary of the Invention
[0004] In view of the above-mentioned 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 image rotation state, and how to achieve accurate recognition of the liquid stratification structure of blood collection tubes under complex backgrounds and visual expression of the original image.
[0006] To solve the above technical problems, the present invention provides the following technical solutions: a detection method for blood stratification identification of blood collection tubes collects multiple types of stratified images and uses the YOLO format to define stratification label information; constructs a target detection model to extract image depth and shallow layer information; calculates the liquid layer boundary and calibrates the angle, identifies the liquid layer junction and maps the original image to draw stratification lines; calculates the liquid layer boundary and calibrates the angle, including forming a closed contour by fitting the blood collection tube detection points, and performing a rotation transformation on the overall image coordinate system after calculating the inclination angle to unify the image reference direction; identifies the liquid layer junction and maps the original image to draw stratification lines, including extracting the edge coordinates of the detection frame with the highest confidence, calculating the junction points between the liquid layers, obtaining accurate boundary coordinates, dynamically determining the boundary logic, and mapping the boundary coordinates back to the original image through inverse transformation to draw clear stratification lines.
[0007] As a preferred solution of the detection method for blood stratification identification of blood collection tubes described in the present invention, the acquisition of multiple types of stratified images includes acquiring image samples containing blood components of different individuals, and avoiding ambient strong light and background reflections during the image acquisition process.
[0008] As a preferred embodiment of the detection method for stratified blood collection tube identification described in the present invention, the use of the YOLO format to define stratified label information includes labeling each detection object in the form of a rectangular frame and recording the category number. At the same time, the center position and width and height dimensions of the detection target are proportionally represented with reference to the overall image size, and the confidence coefficient of the labeled frame is added before conversion to the YOLO format.
[0009] As a preferred embodiment of the detection method for stratified blood collection tube identification described in the present invention, the target detection model is constructed by performing multi-level feature extraction on the image through a backbone network, splicing and combining the input image with the deep convolution-processed image features by direct shallow transmission, and fusing the semantic information and edge information in the image.
[0010] In the backbone network, residual connection structures are set in different module structures to transmit feature information through skip connections.
[0011] A spatial pyramid pooling module is added to the network to obtain regional features of images from 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 detailed information from bottom to top. The YOLO detection head generates the position information and category prediction of the target box, and the loss function is calculated by comparing the predicted position with the label position.
[0013] Train an object detection model.
[0014] As a preferred embodiment of the detection method for identifying blood stratification in blood collection tubes described in the present invention, the training target detection model includes updating model parameters through a gradient descent back-propagation process, and performing iterative training for model evaluation and precision optimization to gradually align the predicted position with the actual label position. After calculation, the image input model outputs the blood collection tube boundary and the specific position of each blood stratification in the image, and data enhancement is performed through rotation, flipping, color adjustment, and random cropping.
[0015] Data augmentation involves rotating the image at random angles within a given parameter range to simulate the visual effects of blood collection tubes at different angles, and learning target features at different angles based on the target detection model.
[0016] The image is flipped horizontally and vertically. By specifying the probability parameters of horizontal and vertical flipping, the training model is controlled to flip part of the image, so that the model can learn different directions of symmetrical 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 balancing and brightness enhancement techniques are used to optimize the generalization of images under different lighting and color conditions.
[0018] A random area is selected from the input image, and a sub-image is randomly cropped based on the given target image size and the area ratio range of the cropped area. The randomly cropped sub-image is then scaled to the specified size as output for model training, simulating test tubes from different perspectives.
[0019] At the same time, an early stopping mechanism is set to automatically terminate training when the performance indicators do not improve after several consecutive rounds, and analyze the stability of the model convergence speed and recognition accuracy.
[0020] 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 embodiment of the detection method for blood stratification identification of blood collection tubes described in the present invention, the calculation of the liquid layer boundary and the angle calibration include obtaining the center point of the target frame representing the blood collection tube from the detection results as the blood collection tube positioning point, removing points with a close distance to the positioning point, sorting the processed positioning points according to the x-coordinate, removing points that are approximately collinear with the positioning point, checking the distance between the processed positioning point and the blood collection tube line segment, deleting the current positioning point if it is less than a set value, removing redundant points, calculating the missing blood collection tube positioning points based on the number of detected positioning points, and forming a complete rectangular boundary; in the blood collection tube outline, calculating the inclination angle of the blood collection tube by obtaining the slope of the line connecting two opposite sides, performing coordinate transformation processing on the entire image and the detection frame, rotating the image as a whole, aligning the blood collection tube horizontally, and unifying the image reference direction for subsequent recognition processes.
[0022] As a preferred embodiment of the detection method for identifying blood stratification in blood collection tubes described in the present invention, the method of identifying the boundaries of liquid layers and mapping the original image to draw stratification lines includes selecting a candidate frame with the highest confidence from the detection frames of each layer obtained by detection, extracting the coordinates of the upper or lower edge as the boundary reference point, and calculating the connection points between different liquid layers with reference to the boundary of the blood collection tube to obtain accurate boundary coordinates.
[0023] If there is a white liquid layer in the image, the intersection of the yellow liquid layer and the white liquid layer is calculated first, and then the intersection of the white liquid layer and the blood layer is calculated.
[0024] If the white liquid layer is missing, only the intersection of the yellow liquid layer and the blood layer needs to be calculated.
[0025] Classifying and visually segmenting the liquid layers in the image includes mapping the identified boundary coordinates back to the original image coordinate system through an inverse rotation transformation, and drawing the boundaries between the 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 blood collection tubes. The system can calculate the boundaries of the liquid layers and calibrate the angles, identify the intersections of the liquid layers, and map the original image to draw the stratification lines, thereby solving the problems of current blood stratification image analysis technology, such as inconsistent posture, inaccurate identification of liquid layer intersections, and poor structural expression of results.
[0027] As a preferred solution of the detection system for blood stratification recognition of blood collection tubes described in the present invention, it includes: an image acquisition and database building module, a model building 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 collect images of different blood stratification states, control the light source, background, and shooting angle, and the label definition conversion module is used to use the YOLO format to standardize the plasma layer, white blood cell layer, and red blood cell layer in the image, record the category number, center coordinates, and size ratio, and add a confidence coefficient, and generate a data set for deep learning. The structured label file used is used to build a high-quality, 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, and splice them with shallow and deep features to fuse semantic information with edge information. The path aggregation mechanism introduced is used to effectively transmit high-level semantic information and detail information, that is, to generate target box position and category prediction through YOLO detection head and calculate loss function. The target detection model training module is used to perform gradient descent. The down-scaling and back-propagation algorithms continuously optimize the model parameters and improve the detection accuracy. It performs iterative training based on mAP, accuracy and recall, and adopts a variety of data enhancement strategies, including image rotation, flipping, color adjustment and random cropping. It is equipped with 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 layered visual module includes a blood collection tube boundary reconstruction module and a layered line drawing mapping module. The blood collection tube boundary reconstruction module is used to form a closed contour by fitting the blood collection tube detection points, and rotate the image overall coordinate system after calculating the tilt angle to unify the image reference direction. In the blood collection tube contour, the The slope of the line connecting the two opposite sides is used to calculate the inclination angle of the blood collection tube, and the coordinate transformation processing is performed on the entire image and the detection frame to rotate the image as a whole. The layered line drawing mapping module is used to select the candidate frame with the highest confidence from the detection frame of each layer obtained by detection, extract the upper or lower edge coordinates as the intersection reference point, and calculate the connection points between different liquid layers with reference to the boundary of the blood collection tube to obtain accurate boundary coordinates; the classification and visual segmentation of the liquid layer in the image includes mapping the identified boundary coordinates back to the original image coordinate system through the inverse rotation transformation, and drawing the boundaries between the blood layers in the image in the form of straight line connections.
[0028] A computer device includes a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement a step of a detection method for blood stratification identification of blood collection tubes.
[0029] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of a detection method for identifying blood stratification in blood collection tubes.
[0030] Beneficial effects of the present invention: The detection method for stratified blood collection tube identification provided by the present invention collects multiple types of stratified images, uses the YOLO format to define stratified label information, establishes a data input system with a clear structure and training-friendly nature, improves the model's learning efficiency and category discrimination accuracy for stratified targets, constructs a target detection model, extracts image deep and shallow layer information, realizes high-confidence liquid layer area identification and boundary extraction, improves the model's stable recognition ability under complex backgrounds and sample differences, calculates the liquid layer boundary and calibrates the angle, identifies the liquid layer junction and maps the original image to draw the stratification line, realizes the structured recognition of liquid stratification and image output fusion, improves the system's practicality and engineering deployment capabilities, and achieves better results in the standardized expression of image preprocessing, the multi-scale fusion recognition capability of the target detection model, and the geometric calibration of the liquid layer boundary and the visual stratified output. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0032] Figure 1 This is an overall flow chart of a detection method for blood stratification identification in blood collection tubes provided in the first embodiment of the present invention.
[0033] Figure 2 This is an example of a captured image of a detection method for identifying blood stratification in blood collection tubes provided in the second embodiment of the present invention. DETAILED DESCRIPTION
[0034] To make the above-mentioned objects, features, and advantages of the present invention more clearly understood, the following detailed description of the specific embodiments of the present invention is given in conjunction with the accompanying drawings. It is obvious that the described embodiments are only part of the embodiments of the present invention, not all of them. Based on the embodiments of the present invention, all other embodiments obtained by ordinary persons in this field without creative work should fall within the scope of protection of the present invention.
[0035] Example 1, reference Figure 1 , as one embodiment of the present invention, provides a method for detecting stratified blood samples from blood collection tubes, comprising:
[0036] S1: Collect multi-class hierarchical images and define hierarchical label information using the YOLO format.
[0037] Furthermore, collecting multi-class layered images includes collecting image samples containing different individual blood components, and avoiding ambient strong light and background reflection during the image collection process.
[0038] It should be noted that defining hierarchical label information in the YOLO format includes marking each detected object in the form of a rectangular box and recording the category number. At the same time, with the overall image size as a reference, the center position and width and height of the detected target are proportionally represented, and the confidence coefficient of the marked box is attached and converted into the YOLO format.
[0039] It should also be noted that a preferred solution for defining hierarchical label information using the YOLO format specifically includes the label format of the generated annotation file, which is expressed as:
[0040] ;
[0041] in, is the label number, 0=tube, 1=yellow, 2=blood, 3=white, The target center coordinate, The target center coordinate, is the width of the target rectangle, is the height of the target rectangle, is the confidence score of the target rectangle, and the default value for manual annotation is 1.0.
[0042] It should also be noted that by collecting image samples containing different individual blood components and avoiding interference from strong ambient light and background reflections, the quality and diversity of image input are ensured, and the representativeness and generalization ability of training data are improved. On this basis, the YOLO format is used to annotate the liquid layer areas, and each type of liquid layer (such as yellow liquid layer, blood layer, white liquid layer) is marked with a rectangular frame, and the center coordinates and size information are recorded for proportional conversion. At the same time, confidence parameters are added to achieve unified management and standardized representation of label data. This not only establishes a data input system with a clear structure and training-friendly nature, but also improves the model's learning efficiency and category discrimination accuracy for stratified targets, providing stable and reliable training data support for subsequent detection models, enabling the system to adapt to the complex and changeable stratification of blood samples, and improving the robustness and portability of the detection system.
[0043] S2: Build a target detection model to extract deep and shallow layer information of the image.
[0044] Furthermore, building a target detection model includes extracting multi-level features of the image through the backbone network, splicing and combining the input image through direct transmission in the shallow layer with the image features processed by convolution in the deep layer, and fusing the semantic information and edge information in the image.
[0045] In the backbone network, residual connection structures are set in different module structures to transmit feature information through skip connections.
[0046] A spatial pyramid pooling module is added to the network to obtain regional features of images from different scales and splice them into a unified dimension.
[0047] 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 YOLO detection head generates the position information and category prediction of the target box, and the loss function is calculated by comparing the predicted position with the label position.
[0048] Train an object detection model.
[0049] It should be noted that training the target detection model involves updating model parameters through a gradient descent backpropagation process, and performing iterative training for model evaluation and precision optimization to gradually align the predicted position with the true label position. After the image input model is calculated, it outputs the blood collection tube boundary and the specific location of each blood layer in the image. Data enhancement is performed through rotation, flipping, color adjustment, and random cropping.
[0050] Data augmentation involves rotating the image at random angles within a given parameter range to simulate the visual effects of blood collection tubes at different angles, and learning target features at different angles based on the target detection model.
[0051] The image is flipped horizontally and vertically. By specifying the probability parameters of horizontal and vertical flipping, the training model is controlled to flip part of the image, so that the model can learn different directions of symmetrical objects.
[0052] By adjusting the color channels of the image, including brightness, saturation and contrast, the color characteristics of the image are changed, and color balancing and brightness enhancement techniques are used to optimize the generalization of images under different lighting and color conditions.
[0053] A random area is selected from the input image, and a sub-image is randomly cropped based on the given target image size and the area ratio range of the cropped area. The randomly cropped sub-image is then scaled to the specified size as output for model training, simulating test tubes from different perspectives.
[0054] At the same time, an early stopping mechanism is set to automatically terminate training when the performance indicators do not improve after several consecutive rounds, and analyze the stability of the model convergence speed and recognition accuracy.
[0055] Iterative training for model evaluation and accuracy optimization includes evaluating the detection performance based on mAP, accuracy, and recall, and optimizing parameters through backpropagation of the loss function.
[0056] It should be noted that a preferred solution for constructing a target detection model extraction specifically includes extracting features from the input image content 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 uses a filter to multiply the input feature map element by element, and adds the results to generate an output feature map, and calculates the corresponding position value of the output feature map. , expressed as:
[0057] ;
[0058] in, and Represent the values of the corresponding positions of the input and output feature maps respectively, is the weight parameter of the convolution operation, that is, the filter, is a bias term used to adjust the output of the convolution operation, Indicates the row index of the current output image, corresponding to the OK, Indicates the column index of the current output image, corresponding to the List, Represents the current row index of the convolution kernel, Represents the current column index of the convolution kernel. By performing dot multiplication on the input feature map and the filter, the image features at different positions are deeply extracted and summarized. The output feature map is then normalized through the batch normalization process, which is expressed as:
[0059] ;
[0060] in, and Represent the input feature map and the normalized feature map respectively, and Represent the mean and variance of the input feature map in the current channel, respectively, and Is a small positive number to prevent division by zero and stabilize the calculation. Batch normalization also includes learnable scaling and bias parameters, expressed as:
[0061] ;
[0062] in, is the scaling parameter learned and updated during training, The offset parameters are learned and updated during the training process, with initial values of 1 and 0. is the result of batch normalization, and ReLU is used as the activation function for the next step to introduce nonlinear transformation in the calculation process, which is expressed as:
[0063] ;
[0064] in, is the output of the activation function processing, Performs a maximum operation on the function, that is, all negative input values become zero and positive values remain unchanged.
[0065] 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 true bounding box, which is expressed as:
[0066] ;
[0067] in, is the classification score, and are the predicted bounding box and the true bounding box, respectively. represents the spatial prior, and is a hyperparameter, Represents the matching score between the predicted box and the true box.
[0068] It should also be noted that a preferred solution for calculating the loss function specifically includes calculating the classification loss, confidence loss, and positioning loss. The loss function Expressed as:
[0069] ;
[0070] in, is the classification loss, is the confidence loss, is the positioning loss, 、 、 are the weights of the three losses, Used to optimize the accuracy of category prediction and calculate classification loss , expressed as:
[0071] ;
[0072] in, Represents the category index. In the detection task here, there are 4 types of targets: tube, yellow, blood, white, Representative category index The true label of the correct category is 1, and the rest are 0. Representative category index The predicted probability of .
[0073] Calculating confidence loss , measures whether the predicted box contains the target, expressed as:
[0074] ;
[0075] in, Indicates the true confidence value, 1 = target, 0 = no target, represents the prediction confidence value, Indicator variable, if If the detection box contains the target, the value is 1, otherwise it is 0. Indicator variable, if If the detection box does not contain the target, the value is 1, otherwise it is 0. Weight parameter used to reduce the impact of background areas on the loss.
[0076] Calculate the intersection-over-union ratio , and the positioning loss is obtained , expressed as:
[0077] ;
[0078] in, Represents the center point coordinates of the candidate bounding box or detection box, Represents the intersection area of the real rectangular box and the predicted rectangular box, Represents the union area of the real rectangular box and the predicted rectangular box, and calculates the positioning loss , expressed as:
[0079] ;
[0080] ;
[0081] ;
[0082] in, To predict the consistency parameter representation of the aspect ratio of the annotation box, is a weight parameter, which indicates the proportion of the aspect ratio of the predicted annotation box in the loss. 、 is the width and height of the real rectangle, 、 is the width and height of the real rectangle, is the center point of the real rectangular frame, To predict the center point of the rectangular box, is the Euclidean distance between the center point of the real rectangular box and the predicted rectangular box, It is the diagonal distance of the minimum enclosing area between the real rectangular box and the predicted rectangular box.
[0083] It should also be noted that a preferred solution for rotating the image at a random angle within a given parameter range specifically includes: Then, the corresponding affine transformation is performed on the pixel position according to the formula, which is expressed as:
[0084] ;
[0085] ;
[0086] in, Represents the original pixel coordinates, Represents the pixel coordinates after the transformation by the formula. By performing this transformation on all pixels in the image, the rotation operation of the entire image is completed.
[0087] It should also be noted that by designing a target detection network structure with the ability to fuse deep and shallow layers, and 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, thereby improving the model's ability to express 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 dealing with the recognition interference caused by changes in the size of blood collection tubes; further introducing the path aggregation network (PAN) to establish an information path between high-level semantics and low-level details, so that the model retains the abstract classification ability while enhancing the edge positioning accuracy. 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, which effectively realizes high-confidence liquid layer area recognition and boundary extraction, and improves the model's stable recognition ability under complex backgrounds and sample differences.
[0088] S3: Calculate the liquid layer boundary and calibrate the angle, identify the liquid layer boundary and map the original image to draw the layer line.
[0089] Furthermore, calculating the boundary of the liquid layer and calibrating the angle includes obtaining the center point of the target frame representing the blood collection tube from the detection results as the blood collection tube positioning point, removing points with a close distance to the positioning point, sorting the processed positioning points according to the x-coordinate, removing points that are approximately collinear with the positioning point, checking the distance from the processed positioning point to the blood collection tube line segment, deleting the current positioning point if it is less than the set value, removing redundant points, and calculating the missing blood collection tube positioning points based on the number of detected positioning points to form a complete rectangular boundary. In the blood collection tube contour, the inclination angle of the blood collection tube is calculated by taking the slope of the line connecting the two opposite sides, and the entire image and the detection frame are subjected to coordinate transformation processing, and the image is rotated as a whole to align the blood collection tube horizontally, unifying the image reference direction of the subsequent recognition process.
[0090] It should be noted that identifying the boundaries of liquid layers and mapping the original image to draw layer lines includes selecting the candidate frame with the highest confidence from the detection frame of each layer obtained by detection, extracting the upper edge or lower edge coordinates as the boundary reference point, and using the boundary of the blood collection tube as a reference to calculate the connection points between different liquid layers to obtain accurate boundary coordinates.
[0091] If there is a white liquid layer in the image, the intersection of the yellow liquid layer and the white liquid layer is calculated first, and then the intersection of the white liquid layer and the blood layer is calculated.
[0092] If the white liquid layer is missing, only the intersection of the yellow liquid layer and the blood layer needs to be calculated.
[0093] Classifying and visually segmenting the liquid layers in the image includes mapping the identified boundary coordinates back to the original image coordinate system through an inverse rotation transformation, and drawing the boundaries between the blood layers in the image in a straight line connection manner.
[0094] It should also be noted that by reading the center point of the detection frame of the "blood collection tube" category, the coordinate set of the positioning points is extracted and optimized, and then deduplication, sorting, decollinearity, edge fitting, and defect completion operations are performed in sequence to finally construct a complete rectangular boundary of the blood collection tube. The tilt angle of the blood collection tube is obtained by calculating the slope of the opposite side, and the entire image and the detection frame are geometrically transformed to correct the blood collection tube to a horizontal position and unify the reference direction of the image. This not only solves the problem of structural distortion caused by the shooting posture but also provides a stable reference system for subsequent boundary calculations. On this basis, the candidate frame with the highest confidence in each type of liquid layer is extracted, and its upper or lower edge is calculated as the layer intersection point. Combined with the blood collection tube boundary, the liquid layer intersection coordinates are obtained. Regardless of whether a white layer exists, the system can dynamically adjust the calculation logic. Finally, the layer boundary line is mapped back to the original image coordinate system and visualized. This realizes the fusion of structured recognition of liquid stratification and image output, improves the practicality and engineering deployment capabilities of the system, and lays the image foundation for automated blood analysis in clinical and experimental scenarios.
[0095] Example 2, reference Figure 2 , which is an embodiment of the present invention, provides a detection method for identifying blood stratification in blood collection tubes. In order to verify the beneficial effects of the present invention, scientific demonstration is carried out through economic benefit calculation and simulation experiments.
[0096] First, we select blood collection tube images with different blood stratification conditions and photograph them from different angles to obtain the images required for training. To further improve generalization, the resolution of the collected images is not consistent, so that the model can adapt to inputs of various sizes. The captured images include various situations that may occur in the actual production process, such as images under natural light, incandescent light and other lighting conditions, or images taken under different backgrounds to enhance the accuracy of the model. This example includes two layers of blood (without a white layer), three layers of blood, coagulated blood and other layered conditions. A total of 1,480 valid images were captured. Figure 2 Four sample pictures are taken; after the image acquisition work is completed, image preprocessing is performed, such as image screening, scale standardization, etc., to ensure the quality of the sample image; in order to better eliminate the impact of image background on subsequent operations, the target detection model is used to mark the key information of the image in the form of a rectangular frame. Since the target detection model needs to be trained with the labeled images first, the data labeling task is first performed in this step, and the image is labeled using the AnyLabeling software package. Automatic labeling generally has errors. The best method is to use manual labeling methods to generate high-quality label files. Compared with automatic labeling, manual labeling can greatly improve the accuracy of the model. Therefore, manual labeling requires dividing the data set. Generally, the image is divided into training set, verification set and test set. In the present invention, the data set is sampled and labeled by random sampling method. A total of 564 blood collection tube pictures with different stratification conditions are labeled. The data set is divided by 95% and 5% division methods, that is, 533 of them are used as training sets and 31 as verification sets. 50 unlabeled images are randomly selected and automatically labeled with the trained model to check the accuracy of model detection; the parameters in the target detection model include, Number of training rounds, The batch size for training, The training image size is expressed as:
[0097]
[0098] This model uses the loss function The loss is calculated using the formula, and then the parameters are updated through the model back propagation process. After multiple rounds of iteration, the optimal effect is obtained. After the model is trained, the model is used to detect the blood collection tube boundary and blood stratification. Model inference requires setting a confidence threshold. and coverage threshold , where the confidence threshold is the weight of the confidence loss in the model loss function. A higher confidence threshold will filter more detection frames and only retain detection frames with higher confidence probabilities. The coverage threshold is the intersection-union loss in the model loss. The lower the coverage, the lower the tolerance for overlap between detection frames. When the coverage threshold is 0, there will be no overlapping detection frames. The parameter settings in the example are expressed as:
[0099]
[0100] The final model achieved an accuracy of 1.00, a recall rate of 0.99, and an mAP of 0.988 on the validation set, and was able to accurately detect and outline the boundaries of blood collection tubes and the location of blood stratification in images.
[0101] After the target detection is completed, the image is then subjected to data augmentation to improve the diversity of the image, thereby improving the generalization of the final trained model. In this process, four data augmentation techniques are mainly used: rotation, flipping, color regularization, and random cropping. The parameter limits the angle range of image rotation. and This limits the probability of horizontal and vertical flipping of the image. Specify the random scaling range of the image. The parameters are as follows:
[0102]
[0103] By adopting the above four data enhancement technologies in this method, the performance of the model is improved when facing images of different angles, different colors, etc. After completing the data collection and data processing tasks, the core network architecture for detecting blood stratification in blood collection tubes is constructed next. In terms of network architecture design, this method selects CSPNet as the backbone network to extract image features through segmented feature extraction. Residual connections are applied in each module to skip the calculation of certain layers to avoid the gradient disappearance problem and improve the training stability and convergence speed of the network. In order to improve the performance of multi-scale target detection, a feature fusion layer is introduced to improve the coordination between features at different levels of the network. Finally, through the consistent dual allocation strategy and consistent matching metric, the efficiency and accuracy of the model in the training and inference stages are ensured. Next, the network model is trained based on the constructed network model. In this step, the training process parameters is the training image size, is the maximum number of detected targets per image, The type of optimizer used in the training process, is the training round, is the batch size for training, To control the number of rounds required for early stopping, the parameters are set as follows:
[0104] ;
[0105]
[0106] After obtaining the detection results based on the current model, the loss function is used to calculate the loss back propagation to update the parameters and weights of each layer of the model, and the model is gradually optimized. In the process of multiple rounds of iteration, the model effect is measured with mAP, accuracy, recall rate, etc., so that the loss is gradually reduced and the accuracy is gradually improved during the continuous training process. The iteration is repeated until the model gradually converges in the process of gradient descent, and the performance and detection accuracy are gradually improved, thereby obtaining the final detection model. The final model evaluation result is in the form of a confusion matrix.
[0107] Example 3 is an embodiment of the present invention, which provides a detection system for blood stratification recognition of blood collection tubes, an image acquisition and database building module, a model building and training module, and a boundary calibration and stratification visualization module.
[0108] Among them, the image acquisition and database construction 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, avoid strong light and blur, ensure image clarity and consistency, and improve the quality of the original sample. The label definition conversion module is used to use the YOLO format to standardize the annotation of the plasma layer, white blood cell layer, and red blood cell layer in the image, record the category number, center coordinates, and size ratio, and add a confidence coefficient. It also generates a structured label file that can be used for deep learning, and builds a high-quality, standardized data set for model training and verification.
[0109] It should be noted that the image acquisition and database construction module is started, and the image acquisition standardization module therein collects image samples containing different blood stratification states under the premise of controlling the ambient light source, background and shooting angle to ensure uniform image quality and clear structure; then, the label definition conversion module annotates each liquid layer in the image in YOLO format, records the category number, center coordinates, width-to-height ratio and confidence coefficient, and forms a structured label file. This process directly provides a high-quality, standardized data set for the subsequent model training stage.
[0110] The image acquisition and database construction 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 uniform quality standards (lighting, angle, background), improving the consistency and generalization of model training; then, the label definition conversion module annotates the liquid stratification information (such as plasma layer, buffy coat layer, and red blood cell layer) as a YOLO format label file to form 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.
[0111] The model construction and training module includes the target detection model construction module and the 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, and splice them with shallow and deep features to realize the fusion of semantic information and edge information. The introduced path aggregation mechanism realizes the effective transmission of high-level semantic information and detail information, and clarifies the application scenario of the module, that is, the target box position and category prediction are generated through the YOLO detection head, the loss function is calculated, and efficient target detection tasks are achieved. The target detection model training module is used to continuously optimize the model parameters through gradient descent and back propagation algorithms to improve detection accuracy. Iterative training is performed based on indicators such as mAP, accuracy and recall rate. A variety of data enhancement strategies are adopted, including image rotation, flipping, color adjustment and random cropping, to enhance the model's generalization ability at different angles, lighting and viewing angles. An early stopping mechanism is provided to automatically judge and terminate training according to the changes in performance indicators during training to ensure that the model achieves a balance between convergence speed and recognition accuracy.
[0112] It should be noted that the target detection model construction module builds a target detection network that integrates shallow edge information and deep semantic information, extracts multi-scale regional features through spatial pyramid pooling, and introduces a path aggregation mechanism to improve the high-level and low-level feature transmission capabilities, and finally uses the YOLO detection head to output the position of the detection box and the classification results; subsequently, the target detection model training module carries out training tasks based on the aforementioned structure, continuously optimizes the model parameters using gradient descent and back propagation algorithms, and improves the model's robustness to changes in different angles, illumination, and perspectives through various data enhancement methods such as image rotation, flipping, color adjustment, and cropping. An early stopping mechanism is set during training to ensure that the training process is automatically terminated when the performance indicators stabilize or decrease, thereby balancing model accuracy and training efficiency.
[0113] After the model building and training module is trained through the target 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 target detection model training module include the blood collection tube frame, the target frame position of each liquid layer, and the category prediction results. These prediction results are directly passed to the boundary calibration and layered visualization module as input data for subsequent image space correction and boundary analysis.
[0114] The boundary calibration and layered visualization module includes a blood collection tube boundary reconstruction module and a layered line drawing mapping module. The blood collection tube boundary reconstruction module is used to form a closed contour by fitting the blood collection tube detection points, calculate the inclination angle and then rotate the overall coordinate system of the image to unify the image reference direction. In the blood collection tube contour, the inclination angle of the blood collection tube is calculated by taking the slope of the line connecting the two opposite sides, and the entire image and the detection frame are subjected to coordinate transformation processing. The image is rotated as a whole to align the blood collection tube horizontally and unify the image reference direction of the subsequent recognition process. The layered line drawing mapping module is used to select the candidate frame with the highest confidence from the detection frame of each layer obtained by detection, extract the upper edge or lower edge coordinates as the intersection reference point, and calculate the connection points between different liquid layers with reference to the blood collection tube boundary to obtain accurate boundary coordinates; classification and visual segmentation of liquid layers in the image include mapping the identified boundary coordinates back to the original image coordinate system through an inverse rotation transformation, and drawing the boundaries between the blood layers in the image in the form of straight line connections.
[0115] It should be noted that the blood collection tube boundary reconstruction module first fits the blood collection tube boundary through the detection points, corrects its tilt angle, rotates the entire image and the detection frame coordinates, and realizes the standardization of the image reference direction, which is convenient for unifying the basis of subsequent image analysis. Next, the layered line drawing mapping module selects the detection frame 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, and further calculates the accurate layered line coordinates based on the blood collection tube boundary reference frame. Finally, these dividing points are mapped back to the original image coordinate system through the inverse rotation transformation, and the boundaries of each blood layer are drawn in the image in a straight line manner to realize the visual output of the liquid stratification results.
[0116] The boundary calibration and layered visualization module not only completes the blood collection tube posture correction and layered line drawing, but also can perform quality backtracking through its output results; on the one hand, the visual output results can be used as a basis for manual verification to trace problems in the collected images or labels, and feedback is fed back to the image acquisition and database construction module; on the other hand, the analysis results of the recognition errors can also be used for model fine-tuning and incremental training, and fed 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 method for detecting stratification of blood in blood collection tubes, characterized in that: include: Collect multi-class hierarchical images and define hierarchical label information using the YOLO format; Build a target detection model to extract deep and shallow layer information of the image; Calculate the liquid layer boundary and calibrate the angle, identify the liquid layer boundary and map the original image to draw the layer line; Calculating the liquid layer boundary and calibrating the angle includes obtaining the center point of the target frame representing the blood collection tube from the detection results as the blood collection tube positioning point, removing points with a close distance to the positioning point, sorting the processed positioning points according to the x-coordinate, removing points that are approximately collinear with the positioning point, checking the distance between the processed positioning point and the blood collection tube line segment, deleting the current positioning point if it is less than a set value, removing redundant points, calculating the missing blood collection tube positioning points based on the number of detected positioning points, forming a complete rectangular boundary, calculating the inclination angle of the blood collection tube by taking the slope of the line connecting two opposite sides in the blood collection tube outline, and performing coordinate transformation processing on the entire image and the detection frame, rotating the image as a whole to align the blood collection tube horizontally, and unifying the image reference direction for subsequent recognition processes; Identifying the boundaries of liquid layers and mapping the original image to draw layer lines involves selecting the candidate frame with the highest confidence from the detection frames of each layer, extracting the coordinates of the upper or lower edge as the boundary reference point, and calculating the connection points between different liquid layers with the blood collection tube boundary as a reference to obtain accurate boundary coordinates. If there is a white liquid layer in the image, the intersection of the yellow liquid layer and the white liquid layer is calculated first, and then the intersection of the white liquid layer and the blood layer is calculated; If the white liquid layer is missing, only the intersection of the yellow liquid layer and the blood layer needs to be calculated; Classifying and visually segmenting the liquid layers in the image involves mapping the identified boundary coordinates back to the original image coordinate system through an inverse rotation transformation, and drawing the boundaries between the blood layers in the image by connecting them with straight lines; 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 rotating the image coordinate system to unify the image reference direction; Identifying the boundaries of liquid layers and mapping the original image to draw layer lines includes extracting the edge coordinates of the detection frame with the highest confidence, calculating the boundary points between liquid layers, obtaining accurate boundary coordinates, dynamically determining the boundary logic, and mapping the boundary coordinates back to the original image through inverse transformation to draw clear layer lines.
2. The method for detecting blood stratification in blood collection tubes according to claim 1, wherein: The collecting of multi-class layered images includes: Collect image samples containing different individual blood components, and avoid strong ambient light and background reflections during image acquisition.
3. The method for detecting blood stratification in blood collection tubes according to claim 1 or 2, wherein: Defining hierarchical label information using the YOLO format includes: Each detected object is marked in the form of a rectangular box and the category number is recorded. At the same time, the center position and width and height of the detected target are proportionally represented with the overall image size as a reference, and the confidence coefficient of the marked box is added and converted into YOLO format.
4. The method for detecting blood stratification in blood collection tubes according to claim 1, wherein: The target detection model construction includes: The backbone network extracts multi-level features from the image, directly transfers the input image through the shallow layer, and combines it with the image features processed by convolution in the deep layer, fusing the semantic information and edge information in the image. In the backbone network, residual connection structures are set in different module structures to transmit feature information through skip connections; A spatial pyramid pooling module is added to the network to obtain regional features of images from different scales and splice them into a unified dimension; 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 YOLO detection head generates the position information and category prediction of the target box, and the loss function is calculated by comparing the predicted position with the label position. Train an object detection model.
5. The method for detecting blood stratification in blood collection tubes according to claim 4, wherein: The training target detection model includes: The model parameters are updated through the gradient descent back-propagation process, and iterative training for model evaluation and precision optimization is performed to gradually align the predicted position with the actual label position. After the image input model is calculated, the output is the blood collection tube boundary and the specific position of each blood layer in the image. Data enhancement is performed through rotation, flipping, color adjustment, and random cropping. Data augmentation involves rotating the image at random angles within a given parameter range to simulate the visual effects of blood collection tubes at different angles, and learning target features at different angles based on the target detection model; Flip the image horizontally and vertically. By specifying the probability parameters for horizontal and vertical flipping, the model can be trained to flip part of the image, allowing the model to learn different directions of symmetrical objects. By adjusting the color channels of the image, including brightness, saturation, and contrast, the color characteristics of the image are changed, and color balancing and brightness enhancement techniques are used to optimize the generalization of the image under different lighting and color conditions; Randomly select an area from the input image and randomly crop a sub-image based on the given target image size and the area ratio range of the cropped area. Then, scale the randomly cropped sub-image to the specified size as output for model training, simulating test tubes from different perspectives. At the same time, an early stopping mechanism is set up to automatically terminate training when performance indicators do not improve after several consecutive rounds, and analyze the stability of the model convergence speed and recognition accuracy; Iterative training for model evaluation and accuracy optimization includes evaluating the detection performance based on mAP, accuracy, and recall, and optimizing parameters through backpropagation of the loss function.
6. A detection system for identifying blood stratification in blood collection tubes, characterized in that: The detection system implements the steps of the detection method for blood stratification identification of blood collection tubes according to any one of claims 1 to 5, including an image acquisition and database building module, a model building and training module, and a boundary calibration and stratification visualization module; The image acquisition and database construction module includes an image acquisition and standardization module and a label definition conversion module. The image acquisition and standardization module is used to acquire images of different blood stratification states and control the light source, background, and shooting angle. The label definition conversion module is used to standardize the annotation of the plasma layer, white blood cell layer, and red blood cell layer in the image using the YOLO format, record the category number, center coordinates, and size ratio, and add a confidence coefficient. It also generates a structured label file that can be used for deep learning, thereby building a high-quality, standardized dataset 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, and splice them with shallow and deep features to fuse semantic information with edge information. The introduced path aggregation mechanism is used to effectively transmit high-level semantic information and detail information, generate 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 model parameters through gradient descent and back propagation algorithms, perform iterative training based on mAP, accuracy and recall rate, adopt multiple data enhancement strategies, including image rotation, flipping, color adjustment and random cropping, and have an early stopping mechanism to automatically judge and terminate training according to changes in performance indicators during training; The boundary calibration and layered visualization module includes a blood collection tube boundary reconstruction module and a layered line drawing mapping module. The blood collection tube boundary reconstruction module is used to form a closed contour by fitting the blood collection tube detection points, calculate the inclination angle and then perform a rotation transformation on the overall coordinate system of the image to unify the image reference direction. In the blood collection tube contour, the inclination angle of the blood collection tube is calculated by taking the slope of the line connecting two opposite sides, and the entire image and the detection frame are subjected to coordinate transformation processing to rotate the image as a whole. The layered line drawing mapping module is used to select a candidate frame with the highest confidence from the detection frame of each layer obtained by detection, extract the coordinates of the upper edge or lower edge as the intersection reference point, calculate the connection points between different liquid layers with reference to the blood collection tube boundary, and obtain accurate boundary 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 an inverse rotation transformation, and drawing the boundaries between the blood layers in the image in the form of straight line connections.
7. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method for detecting blood stratification identification in blood collection tubes according to any one of claims 1 to 5 are implemented.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the detection method for identifying blood stratification in blood collection tubes according to any one of claims 1 to 5 are implemented.
Citation Information
Patent Citations
Blood layering image segmentation method based on multi-channel alternating current attention network
CN115841573A
Blood cell detection method based on improved YOLOv8
CN120198409A