Bubble detection, tracking and parameter quantification method and device based on improved YOLOv8
By employing LAB color space preprocessing, multi-scale feature enhancement, and bidirectional feature fusion, the accuracy and stability issues of bubble detection methods under complex backgrounds are resolved, achieving stable detection and parameter quantification of bubble targets, making it suitable for industrial processes and scientific research experiments.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- NANJING UNIV OF POSTS & TELECOMM
- Filing Date
- 2026-03-20
- Publication Date
- 2026-05-29
AI Technical Summary
Existing bubble detection methods are prone to missed detections, false detections, and inaccurate boundary positioning in complex backgrounds. Furthermore, they lack preprocessing procedures for bubble images with low contrast, uneven illumination, and color shift characteristics, resulting in low detection accuracy, unstable cross-frame tracking, and unreliable parameter quantization results.
By employing LAB color space preprocessing enhancement, multi-scale feature enhancement, bidirectional feature fusion, and cross-frame trajectory association, an integrated processing flow is constructed to improve the detection accuracy and tracking stability of bubble targets and achieve parameter quantization.
Stable detection and continuous tracking of bubble targets were achieved in complex backgrounds, improving detection accuracy and the reliability of parameter quantification. It is suitable for bubble visual inspection tasks in industrial processes and scientific research experiments.
Smart Images

Figure CN121884078B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of computer vision and image processing technology, specifically relating to a bubble detection, tracking, and parameter quantization method and apparatus based on an improved YOLOv8. Background Technology
[0002] In scenarios such as gas-liquid two-phase flow detection, reactor process monitoring, and experimental flow channel visualization analysis, accurate bubble detection, continuous tracking, and parametric analysis are of great significance for studying flow states, assessing process stability, and conducting quantitative experiments. Identifying and statistically analyzing bubble position, morphology, and motion states can provide data support for related process analysis and control.
[0003] Existing bubble detection methods mostly employ threshold segmentation, edge detection, or traditional feature-based recognition methods. These methods are sensitive to changes in illumination, noise interference, and transparent bubble boundaries, and are prone to missed detections, false detections, and inaccurate boundary localization in complex backgrounds. In recent years, deep learning object detection methods have achieved good results in general object recognition, but when directly applied to bubble detection scenarios, they still have the following shortcomings: First, bubbles generally exhibit characteristics such as blurred boundaries, weak internal texture, and large scale variations, limiting the representational ability of general detection networks for these types of targets; second, existing methods lack dedicated preprocessing procedures for bubble images with low contrast, uneven illumination, and color cast characteristics, leading to unstable input quality; third, existing schemes lack specificity in continuous multi-bubble tracking and parameter output, making it difficult to directly obtain quantitative results representing the bubble's morphology and motion state. Therefore, it is necessary to propose a detection, tracking, and parameter quantification method and device suitable for complex bubble scenarios. Summary of the Invention
[0004] To address the problems of low detection accuracy, unstable cross-frame tracking, and unreliable parameter quantization results caused by bubble targets in existing technologies due to their high transparency, blurred boundaries, weak internal texture, large scale variation, and uneven illumination, color shift, noise interference, and local occlusion during imaging, this invention provides a bubble detection, tracking, and parameter quantization method and apparatus based on an improved YOLOv8. This invention targets continuous-frame visible light RGB bubble images, focusing on the visual characteristics of bubble images—"weak texture, low contrast, multi-scale, and easily deformable"—and the requirements for continuous motion analysis. It constructs an integrated processing flow consisting of LAB preprocessing enhancement, multi-scale feature enhancement after P4 layer, bidirectional feature fusion, cross-frame trajectory correlation, and parameter quantization, thereby achieving stable detection, continuous tracking, and morphological and motion parameter quantization of bubble targets in complex backgrounds.
[0005] The core improvement of this invention lies in addressing the characteristics of uneven brightness, color shift perturbation, weak transparent boundaries, and easy distortion of multi-scale contours in visible light bubble images. Firstly, it employs brightness and color decoupling preprocessing in the LAB color space to improve the discriminability of transparent boundaries and local gray-level transition features. Subsequently, a multi-scale feature enhancement module is cascaded after the P4 layer feature map output by the improved YOLOv8 backbone network, combined with a bidirectional feature fusion structure integrating top-down and bottom-up approaches to enhance the representation ability of weak-boundary bubbles and small-scale bubbles. Based on the detection results, a cross-frame trajectory association mechanism based on hybrid feature vectors is further constructed, outputting bubble morphology and motion parameters. Therefore, this invention does not merely replace conventional modules in a general object detection network, but rather forms an integrated technical solution for bubble detection, tracking, and parameter quantization.
[0006] To achieve the above objectives, the present invention adopts the following technical solution:
[0007] Firstly, a bubble detection method based on improved YOLOv8 is provided, comprising: acquiring consecutive frames of visible light RGB bubble images; preprocessing the RGB bubble images based on the LAB color space to obtain a preprocessed image; inputting the preprocessed image into a bubble detection model based on improved YOLOv8, and outputting bubble detection results; wherein, the bubble detection model based on improved YOLOv8 includes: a backbone feature extraction module, used to extract multi-scale features layer by layer from the input preprocessed image to adapt to the size differences of bubbles from micrometers to millimeters; and a multi-scale feature enhancement module connected in series with the backbone feature extraction module. The module includes a strong feature enhancement module, which combines standard convolution, depthwise separable convolution, and spatial attention mechanisms to enhance the representation of transparent bubble boundaries, weak texture regions, and multi-scale contours. A bidirectional feature fusion module employs a combined top-down and bottom-up feature fusion structure, and uses a C2f structure for feature reshaping after each fusion stage to cascade and fuse the extracted multi-scale features to obtain fused features. A detection head module uses a decoupled detection head structure and an anchorless detection mechanism to perform classification prediction and bounding box regression on the fused features, outputting bubble detection results containing bubble bounding boxes, confidence levels, and category information.
[0008] Furthermore, the preprocessing is not a simple grayscale conversion or uniform enhancement of the input image, but rather, taking into account the characteristics of bubble edges being sensitive to brightness changes but less sensitive to color disturbances, preprocessing the RGB bubble image based on the LAB color space, including: firstly, processing the input RGB bubble image... Convert to LAB color space image This is to achieve decoupling of the luminance component and the color component.
[0009] Local adaptive histogram equalization enhancement is performed on the brightness channel L to obtain the enhanced L channel. The image is then divided into several sub-blocks, and the cumulative distribution function of the gray value g in the k-th sub-block is defined as:
[0010] ;
[0011] in, This represents the number of pixels with a grayscale value of u in the k-th sub-block, where u = 0, 1, 2, ..., g; This represents the total number of pixels in the sub-block. Histograms exceeding a set clipping threshold are truncated, and the excess portions are redistributed to suppress excessive amplification of local noise. Subsequently, bilinear interpolation between adjacent sub-blocks is used to obtain the enhanced luminance channel. .
[0012] Simultaneously, color equalization is performed on channels A and B to obtain color-balanced channels A and B, which are denoted as follows: , This is done to reduce the impact of color cast in the imaging environment and fluctuations in the liquid background color on the detection results. The enhanced three channels are then recombined to obtain the enhanced image.
[0013] ;
[0014] Where L' represents the enhanced L channel, and Merge indicates the channel merging operation. To reduce the differences in image statistical distribution between different acquisition batches and under different exposure conditions, this invention further performs channel-level normalization processing on the enhanced image:
[0015] ;
[0016] in, This represents the normalization result of the c-th channel. This represents the raw pixel value of the c-th channel. and These represent the mean and standard deviation of the corresponding channels, respectively. To prevent extremely small constants with a denominator of zero, the standardized result is further subjected to min-max normalization:
[0017] ;
[0018] in, This indicates taking the minimum value. This indicates taking the maximum value; thus obtaining the preprocessed image. The above processing enhances the transparent boundary and local gray-level transition features while preserving the overall bubble contour information, providing a more stable input basis for subsequent feature extraction.
[0019] Furthermore, the bubble detection model based on the improved YOLOv8 includes a backbone feature extraction module, a multi-scale feature enhancement module, a bidirectional feature fusion module, and a detection head module. The backbone feature extraction module is used to extract multi-scale features layer by layer from the preprocessed image; the bidirectional feature fusion module is used to fuse high-level semantic information and shallow detail information; and the detection head module is used to output the bounding box, class score, and confidence score of the bubble target.
[0020] Furthermore, in the backbone feature extraction module, the preprocessed image first extracts basic features through an initial convolutional layer and a C2f structure, generating pyramid feature maps of different scales step by step. , and Considering the characteristics of bubble targets, such as blurred boundaries, a high proportion of small targets, and significant changes in contour shape, this invention introduces a multi-scale feature enhancement module after the high-level (P4 layer) feature map to jointly model local edge responses, context region responses, and salient region responses. The output of the multi-scale feature enhancement module can be expressed as:
[0021] ;
[0022] Where F represents the input feature map, This represents the standard convolution operation, used to extract local texture and edge information; This indicates a depthwise separable convolution operation, used to expand the receptive field with lower computational cost; This represents a saliency weight map generated based on the attention mechanism. This indicates element-wise multiplication. This structure allows the model to simultaneously focus on bubble boundary details and surrounding local context, thereby improving its ability to represent weakly edged bubbles and densely packed small bubbles.
[0023] Furthermore, a spatial attention mechanism is introduced at the end of the multi-scale feature enhancement module to enhance salient regions of the bubble. (Spatial attention map) Represented as:
[0024] ;
[0025] in, and These represent average pooling and max pooling along the channel dimension, respectively. Indicates feature splicing, This represents a 7×7 convolution operation. Let represent the Sigmoid activation function. The final enhanced feature can be written as:
[0026] ;
[0027] This improves the network's response to bubble edges, areas of abrupt brightness changes, and closed contour regions, while suppressing interference from complex backgrounds and non-target textures.
[0028] Furthermore, the bidirectional feature fusion module adopts a bidirectional fusion topology combining top-down and bottom-up approaches. First, high-level semantic features are upsampled and concatenated with adjacent shallow-level features along their channels, then refined through convolution to obtain intermediate features fused from the top-down perspective. Next, these intermediate features are downsampled and concatenated again with the high-level semantic features, then refined through convolution to obtain output features fused from the bottom-up perspective. After each fusion stage, a C2f structure is used for feature reshaping. For the first... Layer features, and their fusion result can be expressed as:
[0029] ;
[0030] ;
[0031] in, Indicates the first Layer input feature map, Indicates the first Layer input feature map, This indicates the feature remodeling module. Indicates the first The intermediate feature map obtained by fusing layers from top to bottom. Indicates the first The output feature map after the layers are fused from bottom to top. and These represent upsampling and downsampling operations, respectively. This indicates a channel splicing operation. This bidirectional fusion method enables the fine-grained edge features of the shallow layer to fully interact with the semantic discriminative features of the higher layer, making it more suitable for detecting bubble targets with large size spans and significant contour changes.
[0032] Furthermore, the detection head module adopts a decoupled detection head structure, reducing coupling interference between category discrimination and target localization by setting separate classification and bounding box regression branches; simultaneously, an anchorless mechanism is used to reduce the limitation of the preset anchor box size on the adaptability of bubble targets of different sizes. The CIoU loss function is used in the bounding box regression:
[0033] ;
[0034] Where b is the center of the predicted bounding box. Centered on the true bounding box represents the Euclidean distance, c represents the diagonal length of the minimum bounding box, and v represents the aspect ratio difference between the predicted and actual bounding boxes. The IOU represents the intersection-union ratio between the predicted bounding box and the ground truth bounding box, indicating the balance factor. This represents the CIoU regression loss. This regression method considers not only the degree of overlap, but also the center distance and aspect ratio consistency, making it particularly suitable for locating irregular bubble targets with significant contour stretching and compression.
[0035] In a second aspect, a bubble detection device based on an improved YOLOv8 is provided, comprising a memory and a processor; the memory stores program instructions; the processor is used to invoke the program instructions to execute the bubble detection method based on the improved YOLOv8 described in the first aspect.
[0036] Thirdly, a bubble tracking method is provided, comprising: obtaining bubble detection results in each frame of image based on the bubble detection method based on the improved YOLOv8 described in the first aspect; extracting position features, scale features, morphological features, and appearance embedding features of bubbles based on the bubble detection results of each frame, and constructing a hybrid feature vector for association matching; based on the hybrid feature vector, first performing initial association according to the intersection-union ratio between the detection box of the current frame and the historical trajectory prediction box, and then performing cascade matching on unmatched targets to obtain a bubble trajectory sequence with unique identification information; performing state update for successfully associated trajectories using Kalman filtering, and performing time update for trajectories that are temporarily not successfully associated; when the trajectory is temporarily lost but still within the effective lifespan, performing short-term position prediction based on the historical trajectory sequence to improve the re-association success rate in occlusion or local deformation scenarios.
[0037] Furthermore, the tracking does not employ a single IoU matching method. Instead, it addresses the characteristics of bubble targets—such as easy deformation, local occlusion, and short-term boundary fluctuations—by constructing a tracking mechanism that combines multimodal features with cascaded association. For the m-th bubble target in frame t, its position, scale, shape, and appearance information are extracted to form an associated feature vector:
[0038] ;
[0039] in, With the center coordinates, , These are the width and height of the detection frame, respectively. For morphological description, For appearance embedding features, This is a mixed feature vector. The comprehensive matching similarity between the current detected target and the historical trajectory is defined as:
[0040] ;
[0041] in, This represents the overall similarity between the m-th detected target in the current frame and the n-th historical trajectory. This represents the intersection-union ratio (IoU) between the m-th detection box in the current frame and the n-th predicted trajectory box in the past. The cosine similarity of appearance features is represented by... and Indicates the center position of the corresponding target. , , These are the weighting coefficients, and , The position attenuation coefficient is used. For successfully associated trajectories, Kalman filtering is applied for state updates. For newly detected targets, they are set as active trajectories after successful association within a preset number of consecutive frames. Trajectories that fail to be associated within a preset number of consecutive frames are terminated. This invention prioritizes IoU for fast association. When IoU cannot achieve stable association, it combines comprehensive similarity for cascaded determination, thereby improving the robustness of association in scenarios involving deformed bubbles, close-to-bubbles, and short-term occlusion.
[0042] Furthermore, in the trajectory management phase, Kalman filtering is used to update the state of associated trajectories, and short-term prediction is performed for temporarily unassociated trajectories. When a trajectory is temporarily lost but still within its valid lifespan, LSTM is introduced to model the historical trajectory state sequence and output the trajectory state prediction result for the next time step to assist in trajectory reassociation. Let the historical state sequence be... Then the predicted state at the next moment can be expressed as:
[0043] ;
[0044] in, This represents the position and motion state vector of the trajectory at time t. This represents the state quantity at time t-m+1. This represents the predicted trajectory state for the next moment. Through this mechanism, the probability of tracking failure caused by bubble trajectory breakage, identity switching, and short-term occlusion can be reduced.
[0045] Fourthly, a bubble parameter quantization method is provided, comprising: using the bubble tracking method described in the third aspect to obtain the bubble detection results and corresponding bubble trajectory sequences in each frame of the image, and calculating the morphological parameter R characterizing the degree of bubble deformation based on the detection bounding box corresponding to the same trajectory.
[0046] ;
[0047] in, and These are the width and height of the bubble detection frame, respectively. When When, it indicates that the bubble is being stretched in the horizontal direction; when When the value is 0, it indicates that the bubble is relatively extended in the vertical direction. This parameter can be used to characterize the stress-deformation state of the bubble in the flow field.
[0048] Furthermore, the motion parameters include velocity calculated based on changes in the center position of consecutive frames. :
[0049] ;
[0050] ;
[0051] in, This represents the x-coordinate of the bubble center at time t. This represents the y-coordinate of the bubble center at time t. This represents the x-coordinate of the bubble center at time t-1. This represents the y-coordinate of the bubble center at time t-1. This represents the displacement of the center point of the same bubble in two adjacent frames. This represents the inter-frame time interval; when the imaging frame rate is FPS, we have:
[0052] ;
[0053] Therefore, we can conclude that:
[0054] ;
[0055] Using the above methods, the deformation and motion information of bubbles can be directly obtained from the detection results and trajectory sequences, providing quantitative basis for fluid analysis, reaction process monitoring and experimental evaluation.
[0056] Fifthly, a bubble parameter quantization device is provided, characterized in that it includes a memory and a processor; the memory stores program instructions; the processor is used to call the program instructions to execute the bubble parameter quantization method described in the fourth aspect.
[0057] Compared with the prior art, the present invention has the following beneficial effects:
[0058] This invention, starting from the imaging and motion characteristics of bubble targets, constructs an integrated technical solution that seamlessly integrates preprocessing enhancement, detection and recognition, trajectory association, and parameter quantization. Compared to solutions that simply replace or overlay attention modules on a general target detection network, this invention improves the distinguishability of transparent boundary bubbles through brightness and color decoupling enhancement; enhances the detection capability of bubbles at different scales, especially small bubbles and weakly boundary bubbles, through multi-scale feature enhancement and bidirectional fusion; improves trajectory continuity in complex flow scenarios through multi-modal feature cascade matching and short-time prediction; and enhances the usability and analytical value of detection results through direct quantification of morphological and motion parameters. Therefore, this invention not only improves bubble detection accuracy and robustness but also enhances subsequent trajectory analysis and quantitative evaluation capabilities, making it suitable for bubble visual detection tasks in complex industrial processes and scientific research experiments. Attached Figure Description
[0059] Figure 1 This is a schematic diagram of the overall architecture of a bubble detection, tracking, and parameter quantization device based on an improved YOLOv8, provided in an embodiment of the present invention.
[0060] Figure 2 This is a flowchart of data preprocessing in an embodiment of the present invention;
[0061] Figure 3 This is a schematic diagram of the overall structure of the improved YOLOv8 network in an embodiment of the present invention;
[0062] Figure 4 This is a schematic diagram of the main process of bubble tracking in an embodiment of the present invention. Detailed Implementation
[0063] The present invention will be further described below with reference to the accompanying drawings. It should be understood that the following embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit the scope of protection of the present invention. Equivalent substitutions or conventional modifications made by those skilled in the art based on this specification without departing from the concept of the present invention should all fall within the scope of protection of the present invention.
[0064] Example 1
[0065] This embodiment provides a bubble detection method based on an improved YOLOv8.
[0066] like Figure 1As shown, the bubble detection, tracking, and parameter quantization device based on the improved YOLOv8 in this embodiment includes a preprocessing module, a detection module, a tracking module, and a parameter calculation module. The input is a continuous frame of visible light RGB bubble images or a bubble video sequence, and the output is the detection result of the bubble target, its trajectory sequence, and the corresponding morphological and motion parameters. The device can be deployed in industrial reactor observation windows, experimental flow channel imaging systems, bubble column visual monitoring systems, or other gas-liquid two-phase flow observation scenarios.
[0067] The bubble detection method in this embodiment includes the following steps:
[0068] Step S101: Acquire consecutive frames of visible light RGB bubble images.
[0069] The RGB bubble image can be acquired by an industrial camera, a laboratory high-speed camera, or conventional video acquisition equipment. Preferably, the acquired object is a bubble image in a transparent or semi-transparent medium, and the bubble target has the characteristics of weak boundary, weak texture, large scale span, and susceptibility to the effects of light and reflection.
[0070] Step S102: Preprocess the acquired RGB bubble image to obtain a preprocessed image.
[0071] like Figure 2 As shown, the preprocessing module includes two parts: contrast enhancement processing and normalization processing.
[0072] In this embodiment, the input RGB bubble image is first converted to the LAB color space to obtain the luminance channel L and color channels A and B. The reason for using the LAB color space is that the boundaries and contours of transparent bubbles are mainly manifested as luminance changes in imaging, while color information is more easily disturbed by background liquid and imaging environment. Therefore, decoupling the luminance information from the color information is more conducive to highlighting the bubble boundary response.
[0073] Subsequently, the L channel is divided into several sub-blocks, and adaptive histogram equalization enhancement is performed based on the cumulative distribution function of each sub-block. Histogram distributions exceeding a set truncation threshold are truncated, and the excess portion is redistributed to various gray levels. Then, bilinear interpolation between adjacent sub-blocks is used to obtain the enhanced L channel. For the k-th sub-block, its cumulative distribution function can be expressed as:
[0074] ;
[0075] Where g represents the grayscale value, This represents the number of pixels with a grayscale value of u in the k-th sub-block, where u = 0, 1, 2, ..., g; This represents the total number of pixels in the k-th sub-block. For histogram portions exceeding a set clipping threshold, the excess can be redistributed to different gray levels to suppress excessive amplification of local noise. Bilinear interpolation is preferably used for smooth transitions between adjacent sub-blocks to avoid block artifacts. The processed result is the brightness-enhanced channel L'.
[0076] Color equalization is performed on channels A and B to reduce color cast and unevenness caused by differences in the imaging environment, resulting in equalized channels A' and B'. Then, L', A', and B' are merged again to obtain the enhanced LAB image. .
[0077] To reduce input distribution fluctuations caused by different acquisition batches, illumination conditions, and lens configurations, the enhanced images undergo further standardization processing. For the c-th channel, its normalized standard deviation can be expressed as:
[0078] ;
[0079] in, This represents the normalization result of the c-th channel. This represents the raw pixel value of the c-th channel. and These represent the mean and standard deviation of the corresponding channels, respectively. To prevent extremely small constants with a denominator of zero, the standardized result is further subjected to min-max normalization:
[0080] ;
[0081] in, This indicates taking the minimum value. This indicates taking the maximum value; after the above processing, the preprocessed image is obtained. If necessary, the image can be cropped at the center, the region of interest can be extracted, or the size can be standardized according to the actual imaging area to meet the input requirements of the detection network. Preferably, the input size can be set to 640×640, but it is not limited to this value.
[0082] Step S103: Input the preprocessed image into the bubble detection model based on the improved YOLOv8 and output the bubble detection results.
[0083] like Figure 3 As shown, the bubble detection model based on the improved YOLOv8 includes a backbone feature extraction module, a multi-scale feature enhancement module, a bidirectional feature fusion module, and a detection head module.
[0084] The backbone feature extraction module is used to extract multi-scale features from the input image layer by layer. The input image first passes through an initial convolutional layer to obtain low-level edge and texture features, and then enters a C2f structure to enhance feature representation and maintain good gradient propagation. Preferably, the backbone feature extraction module generates feature maps of layers P1, P2, P3, and P4, where P2, P3, and P4 correspond to feature representations at different resolution levels.
[0085] To improve the model's ability to represent transparent bubble boundaries, weakly textured regions, and multi-scale contours, a multi-scale feature enhancement module, MS-FEM, is introduced after layer P4. This module preferably first extracts local structural information using standard convolution, then expands the receptive field and reduces computational cost through depthwise separable convolution, followed by batch normalization and SiLU activation to output enhanced features. Furthermore, a spatial attention mechanism is introduced at the end of the module to enhance the saliency response of transparent boundaries, weakly textured regions, and closed contour regions. The spatial attention map can be represented as:
[0086] ;
[0087] Where F represents the input feature map, and These represent average pooling and max pooling along the channel dimension, respectively. Indicates feature splicing, This represents a 7×7 convolution operation. This represents the Sigmoid activation function. This represents the spatial attention map of the input feature map. The final enhanced feature is:
[0088] ;
[0089] in, This represents element-wise multiplication. This method can enhance the response of bubble boundaries, contour-closed regions, and locally salient areas against complex backgrounds, while suppressing interference from background reflections, clutter textures, and non-bubble targets.
[0090] The bidirectional feature fusion module adopts a bidirectional fusion structure combining top-down and bottom-up approaches to jointly represent high-level semantic features and shallow detail features. Specifically, high-level features can be upsampled and then concatenated with adjacent shallow features by channel, followed by feature reshaping through a C2f structure. Simultaneously, the fused mid-level features can be downsampled and further fused with higher-level features to take into account both small bubble details and the overall outline information of large bubbles.
[0091] After the extracted multi-scale features enter the bidirectional feature fusion module, the bidirectional feature fusion module upsamples the high-level semantic features and concatenates them with the shallow features of the adjacent layers by channel, and then performs convolutional refinement; at the same time, it downsamples the fused mid-level features and fuses them with the high-level semantic features again to form a pyramid-shaped multi-level feature fusion structure; after each fusion, the C2f structure is used to reshape the features to obtain the fused features.
[0092] Among them, the The fusion relationship of layer features is as follows:
[0093] ;
[0094] ;
[0095] in, Indicates the first Layer input feature map, Indicates the first Layer input feature map, This indicates the feature remodeling module. Indicates the first The intermediate feature map obtained by fusing layers from top to bottom. Indicates the first The output feature map after the layers are fused from bottom to top. Indicates an upsampling operation. This indicates a downsampling operation. This indicates a channel splicing operation.
[0096] The detection head module adopts a decoupled detection head structure, with separate classification and bounding box regression branches to reduce coupling interference between the classification and localization tasks. Preferably, the detection head uses an anchorless detection method, directly predicting the center position and width / height of the bounding boxes. During the inference phase, low-confidence detection boxes are first removed based on a confidence threshold, then redundant boxes are removed using non-maximum suppression, finally outputting the bubble detection results. Bounding box regression can use CIoU loss, the expression of which is:
[0097] ;
[0098] Where b is the center of the predicted bounding box. Centered on the true bounding box represents the Euclidean distance, c represents the diagonal length of the minimum bounding box, and v represents the aspect ratio difference between the predicted and actual bounding boxes. The IOU represents the intersection-union ratio between the predicted bounding box and the ground truth bounding box, indicating the balance factor. This represents the CIoU regression loss.
[0099] In this embodiment, the output bubble detection results include the bounding box coordinates, confidence score, and category information for each bubble target. Since this invention mainly targets single-class bubble target detection, the category information can be set to a single bubble category.
[0100] Example 2
[0101] Based on the bubble detection method based on improved YOLOv8 described in Embodiment 1, this embodiment provides a bubble detection device based on improved YOLOv8, including a memory and a processor; the memory is used to store program instructions; the processor is used to call the program instructions to execute the bubble detection method based on improved YOLOv8 described in Embodiment 1.
[0102] Example 3
[0103] Based on the bubble detection method described in Embodiment 1, this embodiment provides a bubble tracking method, including: obtaining bubble detection results in consecutive frame images; inputting the bubble detection results in each frame image into a bubble tracking module, and outputting a bubble trajectory sequence with unique identification information.
[0104] like Figure 4 As shown, the bubble tracking module includes a feature extraction layer, a matching management layer, and a trajectory management layer.
[0105] The feature extraction layer is used to extract the multimodal features of the bubble and form a hybrid feature vector. These multimodal features include appearance features, geometric features, and motion features. Appearance features can be represented by an embedding vector obtained by cropping the detection box region and inputting it into the re-identification network; geometric features include the bounding box center coordinates, width, height, area, and aspect ratio; motion features include position and velocity information predicted from the previous time step. For the i-th bubble in the current frame, the following hybrid feature vector can be constructed:
[0106] ;
[0107] in, Let m be the center coordinates of the m-th detected target in frame t. , These represent the width and height of the detection frame, respectively. For morphological description, Represents the appearance embedding vector. It is a mixed feature vector.
[0108] The matching management layer is used to establish the association between the current detection results and historical trajectories. Preferably, initial filtering is first performed based on the intersection-union ratio (IU). For the m-th detection box in the current frame... The predicted bounding box of the nth trajectory in the previous frame Its IoU can be expressed as:
[0109] ;
[0110] when When the overlap is greater than a preset threshold, the detection box is considered to have a high spatial overlap with the corresponding trajectory and is given priority in entering the matching candidate set; when the IoU is insufficient to establish a stable association, a secondary judgment is made based on the comprehensive similarity. (Comprehensive Similarity) It can be represented as:
[0111] ;
[0112] in, This represents the overall similarity of cascaded matching. This represents the intersection-union ratio (IoU) between the current detection bounding box and the historical trajectory prediction bounding boxes. The cosine similarity of appearance features is represented by... and Indicates the center position of the corresponding target. , , These are the weighting coefficients, and , This represents the position attenuation coefficient. Preferably, given the characteristics of rapid boundary shape changes and weak texture in the bubble scene, higher weights are assigned to appearance features and motion features. When the overall similarity exceeds the threshold, the association is considered successful; otherwise, the unassociated state is maintained, and the process proceeds to either new trajectory initialization or temporary trajectory management.
[0113] The trajectory management layer is used to update and predict trajectory states. For successfully associated trajectories, a Kalman filter is used to update their states.
[0114] ;
[0115] in, This represents the prior state estimate. This represents the posterior state estimate. Indicates Kalman gain, Let H represent the observations and H represent the observation matrix. For unassociated trajectories, only time updates are performed, and they are marked as temporarily lost; if they are not re-associated for several consecutive frames, the trajectory is terminated. For newly detected targets that are not associated, a new trajectory is initialized and a new trajectory identifier is assigned. Preferably, the new trajectory needs to be re-associated within several consecutive frames before it becomes an effective active state, in order to reduce the probability of false trajectory establishment caused by noisy targets.
[0116] In some implementations, when a trajectory is temporarily lost but still within its effective lifespan, an LSTM short-time-series prediction model can be introduced to predict the target's position at the next moment based on historical trajectory sequences, thereby improving the re-association success rate in scenarios involving occlusion, slippage, or abrupt changes in local boundaries. The entire association process can also be combined with the Hungarian algorithm to achieve globally optimal matching, reducing identity switching in dense multi-target scenarios.
[0117] Example 4
[0118] Based on the bubble tracking method described in Embodiment 3, this embodiment provides a bubble tracking device, including a memory and a processor; the memory is used to store program instructions; the processor is used to call the program instructions to execute the bubble tracking method described in Embodiment 3.
[0119] Example 5
[0120] Based on the bubble tracking method described in Embodiment 3, this embodiment provides a bubble parameter quantization method, including: obtaining bubble detection results and bubble trajectory sequences in each frame of image; and quantizing and outputting the morphological parameters and motion parameters of the bubble based on the detection results and trajectory sequences.
[0121] Among them, the preferred morphological parameter is the aspect ratio R, which reflects the degree of bubble deformation, and its expression is:
[0122] ;
[0123] in, and These represent the width and height of the bubble detection bounding box, respectively. When R is greater than 1, it indicates that the bubble is relatively stretched in the horizontal direction; when R is less than 1, it indicates that the bubble is relatively extended in the vertical direction. This parameter characterizes the deformation state of the bubble in the flow field.
[0124] The preferred motion parameter is velocity v. For the center position of the same bubble in two consecutive frames, let its displacement be... Then we have:
[0125] ;
[0126] in, This represents the displacement of the center point of the same bubble in two adjacent frames. This represents the x-coordinate of the bubble center at time t. This represents the y-coordinate of the bubble center at time t. This represents the x-coordinate of the bubble center at time t-1. This represents the y-coordinate of the bubble center at time t-1.
[0127] If the time interval between two adjacent frames is Δt, then the bubble velocity is:
[0128] ;
[0129] When the frame rate of the image sequence is FPS, we have:
[0130] ;
[0131] Therefore, the velocity can also be written as:
[0132] ;
[0133] In some implementations, to reduce the instantaneous error caused by single-frame jitter, a moving average can be applied to the displacement or velocity results of several consecutive frames. In addition to instantaneous velocity, derived parameters such as average velocity, maximum velocity, trajectory duration, and trajectory length can be obtained by statistical analysis of the trajectory, and these parameters can be associated with the corresponding trajectory identifiers for output, facilitating subsequent experimental analysis, process monitoring, or data archiving.
[0134] Example 6
[0135] Based on the bubble parameter quantization method described in Embodiment 5, this embodiment provides a bubble parameter quantization device, including a memory and a processor; the memory is used to store program instructions; the processor is used to call the program instructions to execute the bubble parameter quantization method described in Embodiment 5.
[0136] Those skilled in the art will understand that the method steps in the above embodiments can be implemented by program instructions executed on a processor, or by dedicated hardware circuits, programmable logic devices, or a combination of hardware and software. The program instructions can be stored in a computer-readable storage medium, and when executed by the processor, the bubble detection, bubble tracking, and bubble parameter quantization steps described in this specification can be implemented.
[0137] Furthermore, the parameter settings, module connection order, threshold selection, network width, and number of channels in the above embodiments are all preferred examples. Those skilled in the art can make adaptive adjustments according to the actual acquisition equipment, image resolution, bubble scale range, and processing speed requirements without departing from the technical concept of the present invention.
Claims
1. A bubble detection method based on an improved YOLOv8, characterized in that, include: Acquire continuous frames of visible light RGB bubble images; The RGB bubble image is preprocessed based on the LAB color space to obtain a preprocessed image; The preprocessed image is input into a bubble detection model based on improved YOLOv8, and the bubble detection results are output. The bubble detection model based on the improved YOLOv8 includes: The backbone feature extraction module is used to extract multi-scale features layer by layer from the input preprocessed image to adapt to the size differences of bubbles ranging from micrometers to millimeters. A multi-scale feature enhancement module is connected in the backbone feature extraction module. The multi-scale feature enhancement module combines standard convolution, depthwise separable convolution and spatial attention mechanism to enhance the expression of transparent bubble boundaries, weak texture regions and multi-scale contours. The bidirectional feature fusion module is used to employ a bidirectional feature fusion structure that combines top-down and bottom-up approaches. After each level of fusion, a C2f structure is used for feature reshaping, and the extracted multi-scale features are cascaded and fused to obtain fused features. The detection head module is used to perform classification prediction and bounding box regression on the fused features by adopting a decoupled detection head structure and an anchorless detection mechanism, and outputs bubble detection results containing bubble bounding boxes, confidence scores and category information. In the backbone feature extraction module, the input preprocessed image first passes through the initial convolutional layer to obtain low-level features, and then enters the C2f structure. The backbone feature extraction module generates feature maps of layers P2, P3, and P4 step by step, and then connects the multi-scale feature enhancement module after layer P4. The multi-scale feature enhancement module first uses standard convolution to extract local texture and edge features, then uses depthwise separable convolution to expand the receptive field and reduce the number of parameters and computational cost. After convolution, batch normalization and SiLU activation function are used to extract local structural features and expand the receptive field. A spatial attention mechanism is introduced at the end of the multi-scale feature enhancement module to enhance the saliency response of transparent boundaries, weakly textured regions, and contour-closed regions. The spatial attention map is as follows: ; Enhanced output features for: ; Where F represents the input feature map, and These represent average pooling and max pooling along the channel dimension, respectively. Indicates feature splicing; This represents a 7×7 convolution operation. This represents the Sigmoid activation function. The spatial attention map represents the input feature map. This indicates element-wise multiplication.
2. The bubble detection method based on improved YOLOv8 according to claim 1, characterized in that, Preprocessing of the RGB bubble image based on the LAB color space includes: Convert the input RGB bubble image to a LAB color space image, denoted as... ; The L channel is divided into multiple sub-blocks, and adaptive histogram equalization enhancement is performed based on the cumulative distribution function of each sub-block. The cumulative distribution function is: ; in, This represents the cumulative distribution function of the gray value g in the k-th sub-block. This indicates that the grayscale value in the k-th sub-block is... The number of pixels, u=0,1,2,···,g; This represents the total number of pixels in the k-th sub-block; the histogram distribution exceeding the preset clipping threshold is truncated, and the excess portion is redistributed to each gray level. The enhanced L channel is obtained through bilinear interpolation between adjacent sub-blocks. Perform color equalization processing on channels A and B to obtain color-balanced channels A and B. The enhanced L channel is merged with the color-equalized A and B channels to obtain the enhanced image. ; Enhanced image Each channel undergoes standardized processing: ; in, This represents the normalization result of the c-th channel. This represents the raw pixel value of the c-th channel. and Let represent the mean and standard deviation of the c-th channel, respectively. To prevent constants with a denominator of zero; The standardized results are then subjected to min-max normalization: ; in, This indicates taking the minimum value. This indicates taking the maximum value; This results in a preprocessed image.
3. The bubble detection method based on improved YOLOv8 according to claim 2, characterized in that, After the extracted multi-scale features enter the bidirectional feature fusion module, the bidirectional feature fusion module first upsamples the high-level semantic features and concatenates them with the shallow features of the adjacent layers by channel, and then performs convolutional refinement to obtain the intermediate features fused from top to bottom. The intermediate features are then downsampled and concatenated with the high-level semantic features by channel, followed by convolutional refinement to obtain the output features fused from bottom to top. After each fusion, a C2f structure is used for feature reshaping to enhance the interaction between shallow edge detail features and high-level semantic discriminative features, thereby obtaining fused features; Among them, the The fusion relationship of layer features is as follows: ; ; in, Indicates the first Layer input feature map, Indicates the first Layer input feature map, This indicates the feature remodeling module. Indicates the first The intermediate feature map obtained by fusing layers from top to bottom. Indicates the first The output feature map after the layers are fused from bottom to top. Indicates an upsampling operation. This indicates a downsampling operation. This indicates a channel splicing operation.
4. The bubble detection method based on improved YOLOv8 according to claim 2, characterized in that, The detection head module avoids gradient interference by constructing classification and regression branches separately, and directly predicts the center position and width and height of the bounding box using an anchorless detection mechanism. The bounding box, confidence score, and class score for each location are predicted in parallel at each detection layer. During the inference phase, low-confidence samples are first screened out using a confidence threshold, and then non-maximum suppression is performed using an IoU threshold to remove redundant boxes. The regression branch uses the CIoU loss function: ; Where b is the center of the predicted bounding box. Centered on the true bounding box represents the Euclidean distance, c represents the diagonal length of the minimum bounding box, and v represents the aspect ratio difference between the predicted and actual bounding boxes. The IOU represents the intersection-union ratio between the predicted bounding box and the ground truth bounding box, indicating the balance factor. This represents the CIoU regression loss.
5. A bubble detection device based on an improved YOLOv8, characterized in that, Including memory and processor; The memory stores program instructions; The processor is used to invoke the program instructions to execute the bubble detection method based on the improved YOLOv8 as described in any one of claims 1 to 4.
6. A bubble tracking method, characterized in that, include: The bubble detection method based on the improved YOLOv8 as described in any one of claims 1 to 4 is used to obtain bubble detection results in consecutive frame images; Based on the bubble detection results of each frame, the position features, scale features, morphological features of the bubbles, as well as the appearance embedding features extracted from the image region corresponding to the detection box, are extracted to construct a hybrid feature vector for association matching; Based on the hybrid feature vector, the initial association is first performed according to the intersection-union ratio between the detection box in the current frame and the predicted historical trajectory box, and then cascade matching is performed on the unmatched targets to obtain a bubble trajectory sequence with unique identification information. Kalman filtering is used to update the state of successfully associated trajectories, and time updates are performed on trajectories that are not yet successfully associated. When a trajectory is temporarily lost but is still within its effective lifespan, short-term position prediction is performed based on historical trajectory sequences to improve the re-association success rate in occlusion or local deformation scenarios.
7. The bubble tracking method according to claim 6, characterized in that, The appearance embedding features are extracted by inputting the image region corresponding to the detected bounding box into the appearance encoding network, and the hybrid feature vector is: ; in, This represents the center coordinates of the m-th detected target in the t-th frame. , These are the width and height of the detection frame, respectively. For morphological description quantity, For appearance embedding features, It is a mixed feature vector; The overall similarity of the cascaded matching is: ; in, This represents the overall similarity between the m-th detected target in the current frame and the n-th historical trajectory. This represents the intersection-union ratio (IoU) between the m-th detection box in the current frame and the n-th predicted trajectory box in the past. The cosine similarity of appearance features is represented by... and Indicates the center position of the corresponding target. , , These are the weighting coefficients, and , This is the position attenuation coefficient; For successfully associated trajectories, Kalman filtering is used for state updates; for newly detected targets, they are set as active trajectories after successful association within a preset number of consecutive frames; for trajectories that have not been associated within a preset number of consecutive frames, they are terminated.
8. A method for quantifying bubble parameters, characterized in that, include: Using the bubble tracking method described in claim 6 or 7, bubble detection results and corresponding bubble trajectory sequences are obtained in each frame of the image. The morphological parameter R, representing the degree of bubble deformation, is calculated based on the detection bounding box corresponding to the same trajectory. ; in, and These represent the width and height of the bubble detection bounding box, respectively. The displacement is calculated based on the change in the center position of the same trajectory in consecutive frames. : ; in, This represents the displacement of the center point of the same bubble in two adjacent frames. This represents the x-coordinate of the bubble center at time t. This represents the y-coordinate of the bubble center at time t. This represents the x-coordinate of the bubble center at time t-1. This represents the y-coordinate of the bubble center at time t-1; Based on the displacement and inter-frame time interval Calculation speed : ; When the imaging frame rate is FPS, we have: ; therefore: ; Based on the trajectory sequence, at least one statistical parameter is obtained from the following: average speed, maximum speed, trajectory duration, or trajectory length.
9. A bubble parameter quantification device, characterized in that, Including memory and processor; The memory stores program instructions; The processor is used to invoke the program instructions to execute the bubble parameter quantization method according to claim 8.