A sub-pixel bottle bubble precise segmentation method
By combining the YOLOv5x model with dilated convolution and dilated spatial pyramid pooling, the low precision and low efficiency of traditional glass bottle bubble detection are solved, achieving sub-pixel-level accurate segmentation of glass bottle bubbles and improving detection accuracy and efficiency.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-25
- Publication Date
- 2026-03-17
AI Technical Summary
Traditional glass bottle bubble detection relies on manual visual inspection, which is not very accurate or efficient and is prone to false positives and false negatives.
A subpixel bubble segmentation method based on YOLOv5x is adopted. Images are acquired by dual telecentric lenses and a telecentric light source, preprocessed and manually labeled, and trained using dilated convolution and dilated spatial pyramid pooling to achieve subpixel-level bubble segmentation.
It achieves high-precision and high-efficiency segmentation of bubbles in glass bottles, reduces false detections and missed detections, and improves the accuracy of detection.
Smart Images

Figure CN116863135B_ABST
Abstract
Description
Technical Field
[0001] This invention relates primarily to the field of image recognition technology, and in particular to a method for precise segmentation of bubbles in a subpixel glass bottle. Background Technology
[0002] Glass bottle inspection is a critical technical issue in industries such as alcohol and pharmaceuticals. During the glass bottle forming process, various factors can lead to residual air bubbles within the bottle, affecting not only its appearance but also its quality. Therefore, air bubble detection is a key inspection item in these industries. Traditionally, air bubble detection in glass bottles relies on manual visual inspection, where the inspector examines the bottle from multiple angles and under varying lighting conditions to screen for bubbles. This method is not only inefficient but also susceptible to subjective biases from the inspector, potentially leading to false positives or false negatives.
[0003] YOLOv5x is a deep learning object detection model that is often used to classify objects in images and mark their locations. In the field of industrial computer vision, it is used for the recognition and localization of related objects. Summary of the Invention
[0004] The technical problem to be solved by this invention:
[0005] This paper presents a method for precise segmentation of air bubbles in subpixel glass bottles, which solves the problem that traditional glass bottle inspection mainly relies on manual visual inspection, resulting in low accuracy and efficiency, and is prone to false detection and missed detection.
[0006] The technical solution adopted by the present invention to solve the above-mentioned technical problems is as follows:
[0007] A method for precise segmentation of air bubbles in a subpixel glass bottle includes the following steps:
[0008] Acquire images of air bubbles in the glass bottle;
[0009] The acquired images of bubbles in the glass bottle are preprocessed to improve image resolution;
[0010] A bubble segmentation model for glass bottles was established based on YOLOv5x, and the bubble segmentation model was trained using preprocessed images of glass bottle bubbles.
[0011] The bubble image of the glass bottle to be tested is then inspected.
[0012] Furthermore, when acquiring images of bubbles in the glass bottle, a dual telecentric lens is used in conjunction with a telecentric light source to illuminate the glass bottle.
[0013] Furthermore, the preprocessing of the acquired glass bottle bubble images specifically includes: using deconvolution to upsample the glass bottle bubble images to a higher resolution, then learning the mapping relationship between low-resolution and high-resolution images to recover the bubble boundaries in the high-resolution images from the low-resolution images, and manually annotating them.
[0014] Furthermore, the glass bottle bubble segmentation model based on the YOLOv5x detection model specifically includes adding dilated convolution and dilated spatial pyramid pooling to the YOLOv5x detection model.
[0015] Furthermore, the glass bottle bubble segmentation model based on YOLOv5x specifically includes: adding dilated convolution to YOLOv5x and performing dilated spatial pyramid pooling to capture the image features of glass bottle bubbles at different scales.
[0016] Furthermore, the YOLOv5x bubble segmentation model was trained using manually annotated images of bubbles in the glass bottle:
[0017] The data type of the glass bottle bubble image is converted; dilated convolution is performed on the converted image data to obtain multi-layered associated glass bottle bubble feature images; a pooling pyramid is constructed based on separable dilated convolution and ADD adder, and the glass bottle bubble feature images obtained from each layer are pooled using a concatenate cascade connector to obtain glass bottle bubble features at multiple different scales. The pooled glass bottle bubble features are fused with the original pooled image to obtain a full-size glass bottle bubble feature image; finally, the full-size glass bottle bubble image features are fused with manually labeled glass bottle bubble images; the fused image is then input into the YOLOv5x model for bubble segmentation.
[0018] The beneficial effects of this invention are:
[0019] This invention provides a sub-pixel-level precise bubble segmentation method for glass bottles. First, the illumination of the sample glass bottle is optimized. Under fixed lighting conditions, images of the bottle surface are captured from multiple angles inside and outside the bottle. Image preprocessing techniques are used to enhance the features of the bubble images. Next, a machine learning-based precise bubble segmentation model is constructed by combining manual annotation and machine learning training. Based on this, sub-pixel-level precise bubble segmentation of the glass bottle under test is achieved. This method offers advantages such as high segmentation accuracy, high segmentation precision, and high execution efficiency, providing an effective means for offline or online bubble detection in glass bottles. Attached Figure Description
[0020] Figure 1 This is a flowchart of a sub-pixel glass bottle bubble precise segmentation method according to the present invention;
[0021] Figure 2This is a schematic diagram of the lighting method for a sub-pixel glass bottle bubble precise segmentation method according to the present invention; 1 - telecentric lens, 2 - telecentric light source, 3 - rotating gripper, 4 - linear module;
[0022] Figure 3 This is a schematic diagram of the model network for a sub-pixel glass bottle bubble precise segmentation method related to the present invention;
[0023] Figure 4 This is the bubble labeling result of a subpixel glass bottle bubble precise segmentation method according to the present invention. Detailed Implementation
[0024] like Figure 1 As shown, the sub-pixel glass bottle bubble precise style segmentation method of the present invention first acquires images of the bubbles in the glass bottle, preprocesses and annotates the acquired images, establishes an image segmentation model, and trains the model using the preprocessed and annotated glass bottle bubble images; the glass bottle bubble images to be detected are processed using the same image acquisition and image preprocessing methods, and then the glass bottle bubble images to be detected are input into the image segmentation model for image segmentation. The specific processing methods of each step are shown below.
[0025] 1. Acquiring images of air bubbles in a glass bottle: such as Figure 2 As shown, the rotating gripper 3 fixes the glass bottle on the linear module 4. The dual telecentric lens 2, together with the telecentric light source 1, captures images of the glass bottle surface from multiple angles inside and outside the glass bottle. This ensures that the optical centers of the incident and outgoing rays are at different positions, thus canceling out the interference of reflections from the glass bottle wall and making the collected images of the glass bottle bubbles more accurate.
[0026] 2. Preprocessing and manual annotation of the acquired glass bottle images: After image acquisition, preprocessing is used to enhance the image features of the bubbles. Deconvolution or transposed convolution is used to upsample the bubble images to improve their resolution. By learning the mapping relationship between low-resolution and high-resolution images, the boundaries of the bubble images in high-resolution images are recovered, thereby enhancing the image features of the bubbles.
[0027] 3. A bubble segmentation model for glass bottles was established based on YOLOv5x, and the bubble segmentation model was trained using preprocessed glass bottle bubble images.
[0028] Dilated convolution is a convolution operation with dilation (or a dilation rate). While typical convolution operations apply a kernel to each pixel of the input image, dilated convolution introduces an additional gap during kernel sampling, thus expanding the receptive field. Dilated spatial pyramid pooling is a pooling operation built upon dilated convolution. Traditional pooling operations typically use a fixed-size window to sample the input image, while dilated spatial pyramid pooling introduces different dilation rates to capture multi-scale feature information.
[0029] Use labeled image samples to train accurate bubble segmentation, such as Figure 3 As shown, firstly, the 640x480 image input in this example is converted from a common data type to a data type easily processed by neural networks using the Gconv type conversion package. The convolution kernel is set to 3x3 with a dilation rate of 2. A pyramid structure is formed by repeatedly using five layers of separable dilated convolutions (DDConv-3) and ADD adders. Finally, a concatenate cascade connector is used to pool the feature maps obtained from each layer, resulting in multiple pooled features at different scales and sub-pixel levels. Next, the pooled original image is introduced, and the sub-pixel context features obtained are fused with the features of the original image size to obtain full-size context features from the original size to smaller sizes, providing a wider spectrum. Finally, the full-size sub-pixel features are fused with the original image to achieve sub-pixel level super-resolution and enhance the image resolution. The resolution-enhanced image is then input into the yolov5x model to achieve sub-pixel segmentation, obtaining the following results: Figure 4 The results of bubble segmentation in the glass bottle are shown.
[0030] Fourth, after the model training is completed, the glass bottle to be tested is image acquired and preprocessed in the same way. Then, a fine segmentation scheme based on bicubic spline interpolation and geometric active contour model is applied to obtain a higher precision subpixel bubble contour, thereby achieving subpixel level accurate bubble segmentation.
Claims
1. A method for precise segmentation of air bubbles in a sub-pixel glass bottle, characterized in that, The method comprises the following steps: Collecting a glass bottle bubble image; Pretreating the collected glass bottle bubble image to improve the image resolution; Establishing a glass bottle bubble segmentation model based on a yolov5x model and training the bubble segmentation model with the pretreated glass bottle bubble image; The step of establishing a glass bottle bubble segmentation model based on a yolov5x model specifically comprises: Adding a hole convolution in the yolov5x model to capture the features of glass bottle bubble images of different scales through hole spatial pyramid pooling; Training the glass bottle bubble segmentation model with the glass bottle bubble image after artificial labeling: converting the data type of the glass bottle bubble image; obtaining a multi-layer associated glass bottle bubble feature image through hole convolution on the converted image data; based on the separable hole convolution and the ADD adder, a pooling pyramid is formed, and the glass bottle bubble feature image obtained from each layer is pooled through a Concatenate serial connector to obtain glass bottle bubble features of multiple different scales, and the pooled glass bottle bubble features are fused with the original pooled image to obtain a full-size glass bottle bubble feature image; finally, the full-size glass bottle bubble image features are fused with the artificially labeled glass bottle bubble image; and the fused image is input into the yolov5x model for bubble segmentation; Detecting the glass bottle bubble image to be detected.
2. The method according to claim 1, wherein, When collecting the glass bottle bubble image, a double-telecentric lens is arranged to cooperate with a telecentric light source to light the glass bottle.
3. The method of claim 2, wherein the method further comprises: The step of pretreating the collected glass bottle bubble image specifically comprises: up-sampling the glass bottle bubble image to a higher resolution through deconvolution, then restoring the bubble boundary in the high-resolution image from the low-resolution image by learning the mapping relationship between the low-resolution image and the high-resolution image, and manually labeling the bubble boundary.
Citation Information
Patent Citations
Glass container defect detection method and system based on improved YOLOV5X
CN113962980A