Method for identifying impurities and bubbles in wine bottle based on multi-feature comprehensive judgment
By introducing a comprehensive determination method of multiple features in liquid impurities and bubble identification detection, the problem of low detection accuracy in the prior art is solved, and higher detection accuracy and robustness are achieved.
Patent Information
- Application Number
- CN202411654361.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-19
- Publication Date
- 2025-03-14
AI Technical Summary
In the prior art, the accuracy of liquid impurities and bubble identification detection is low, and the method is complex and the calculation amount is large.
Using a method based on multi-feature comprehensive judgment, a variety of features such as roundness, grayscale mean, grayscale uniformity, texture analysis and color space analysis are introduced to comprehensively judge bubbles and impurities through steps such as image acquisition, preprocessing, edge detection, image segmentation, feature extraction and comprehensive judgment.
The accuracy and robustness of the detection are greatly improved, the limitations of a single feature are avoided, more accurate classification is achieved, and the reliability of the identification results is further optimized through post-processing steps.
Smart Images

Figure CN119624876A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image processing and computer vision technology, and in particular to a method for identifying impurities and bubbles in a wine bottle based on multi-feature comprehensive judgment. Background Art
[0002] Feature detection is an important technology in the field of computer vision and image processing, and is widely used in object recognition, classification, tracking, etc. In feature detection, features such as shape, color, texture, etc. are usually extracted from the image for analysis and processing.
[0003] In the prior art, patent CN105869154B discloses "A classification, identification and detection method for visible foreign matter and bubbles in 250ml medical infusion", and its technical solution includes the following steps: 1) Continuously obtain multiple frames of images of the infusion being detected; 2) Image preprocessing: Apply Top-Hat morphological filtering to the image; 3) Image segmentation: Apply the inter-frame difference method based on maximum information entropy to the filtered image to obtain the segmented image; 4 Defect edge extraction: Use the SUSAN algorithm to extract the edges of visible foreign matter and bubbles; 5) Image feature extraction algorithm: Through the study and analysis of defect feature extraction, the shape, grayscale, and motion feature parameters of visible foreign matter and bubbles are described; 6) Defect classification and identification: Use the IDS-ELM algorithm to realize the identification and classification of visible foreign matter and bubbles. However, this technology mainly relies on shape, grayscale and motion features for classification, and the detection accuracy and robustness are not high. In addition, this method uses the inter-frame difference method based on maximum information entropy for image segmentation, which is relatively complex and computationally intensive.
[0004] Another example is the "Detection and Identification Method of Visible Moving Foreign Matter and Bubbles in Liquid Medicines" disclosed in patent CN101354359B, whose technical solution includes the following steps: 1) obtaining multiple frames of continuous images of the current liquid medicine to be detected; 2) image preprocessing; 3) extracting moving targets to obtain enhanced images; 4) segmenting moving targets: applying an improved two-dimensional maximum entropy threshold segmentation algorithm to the enhanced image, using a two-dimensional histogram consisting of grayscale and neighborhood average grayscale to select a threshold, and obtaining a segmented image; 5) tracking moving targets; 6) image recognition and judgment: obtaining the target motion trajectory through the tracking results, and distinguishing foreign matter and bubble targets by using the continuity and directionality of the target trajectory, so as to finally judge whether the current liquid medicine is qualified. However, this method mainly relies on the continuity and directionality of the trajectory of the moving target for judgment, and has a single feature, which may not be able to fully capture the different characteristics of bubbles and impurities. In addition, the image preprocessing of this method is not specifically described, and basic image enhancement technology may be used. Finally, this method relies on the continuity and directionality of the target trajectory for judgment, and has a single feature dimension. Summary of the invention
[0005] The present invention aims to solve the problem of low detection accuracy in the prior art for liquid impurity and bubble identification and detection technology, and proposes a method for identifying impurities and bubbles in wine bottles based on multi-feature comprehensive judgment. By introducing multiple features such as circularity, grayscale mean, grayscale uniformity, texture analysis and color space analysis, a comprehensive judgment of bubbles and impurities is made, which greatly improves the accuracy and robustness of detection.
[0006] In order to achieve the above-mentioned object of the invention, the technical solution of the present invention is as follows:
[0007] A method for identifying impurities and bubbles in a wine bottle based on multi-feature comprehensive judgment comprises the following steps:
[0008] Image acquisition: A high-resolution industrial camera combined with an LED light source is used to continuously capture multiple frames of images of the wine bottle under consistent shooting angles and lighting conditions;
[0009] Image preprocessing: Adaptive histogram equalization and Gaussian blur method are used to preprocess the collected images;
[0010] Edge detection: Use the Canny edge detection algorithm to extract the edges of impurities and bubbles in the wine bottle on the image to obtain an edge image;
[0011] Image segmentation: Use contour detection technology to segment the edge image into multiple target areas, and extract possible bubbles and impurity areas from the edge image;
[0012] Feature extraction: Extract target area features, including circularity, grayscale mean, grayscale uniformity, texture features, and color space;
[0013] Comprehensive judgment: Based on the extracted features, comprehensive judgment rules are applied to distinguish bubbles and impurities.
[0014] Furthermore, the post-processing step is also included: using differential operations to remove fixed traces on the image, binarizing the differential results, extracting areas of significant changes, and then using morphological operations to remove small noise points to further optimize the binarization results; based on the binarization results, filtering possible false detection results in the comprehensive judgment results, and then drawing the final detection results of bubbles and impurities on the original image.
[0015] Furthermore, circularity is used to measure the circularity of the target area shape, and the calculation formula is as follows:
[0016] Where S i is the area of the i-th target area, L i is the circumference of the i-th target area, and Cirularity is the circularity value;
[0017] Furthermore, the grayscale mean is the average grayscale value of all pixels in the target area, and the calculation formula is:
[0018] Among them, P ij is the jth pixel in the i-th target area, N i is the number of pixels in the i-th target area, and Mean Gray Value is the grayscale mean;
[0019] Furthermore, grayscale uniformity is the uniformity of the distribution of all pixel values in the target area, and its calculation formula is:
[0020] where μ i is the grayscale mean of the i-th target area, and GrayUniformity is the grayscale uniformity.
[0021] Furthermore, the texture feature is calculated using the LBP method, and the formula is as follows:
[0022] Among them, s(x) is the threshold function, i p is the surrounding pixel value, i c is the center pixel value.
[0023] Furthermore, the color space converts the target area from the RGB color space to the HSV color space and calculates its mean, thereby extracting the color distribution characteristics of the target area.
[0024] Furthermore, the image segmentation step specifically includes:
[0025] 1) Use the findContours function in the OpenCV library to detect contours in the image;
[0026] 2) Filter out contours with too small an area by using area threshold;
[0027] 3) Calculate the bounding box for each filtered contour;
[0028] 4) Draw the calculated bounding box on the original image using the rectangle library function, and display and save the segmentation result image.
[0029] Furthermore, based on the extracted features, a comprehensive judgment rule is applied to distinguish bubbles from impurities, including: first, setting a threshold and weight for each feature; then, scoring the features of the target area according to the threshold of each feature; then, multiplying the score of each feature by the corresponding weight and adding them up to obtain a comprehensive score of the target area; finally, comparing the comprehensive score with a preset judgment threshold to determine whether the target area is a bubble or an impurity.
[0030] In summary, the present invention has the following advantages:
[0031] 1. The present invention introduces multiple features such as circularity, grayscale mean, grayscale uniformity, texture analysis and color space analysis to comprehensively judge bubbles and impurities, greatly improving the accuracy and robustness of detection;
[0032] 2. The present invention sets thresholds and weights of multiple features and calculates comprehensive scores to determine bubbles and impurities, thus avoiding the limitations of a single feature and achieving more accurate classification;
[0033] 3. The present invention uses image preprocessing technologies such as adaptive histogram equalization and Gaussian blur to significantly enhance image contrast, suppress noise, improve the visibility of edges and details, and make the distinction between bubbles and impurities clearer;
[0034] 4. The present invention adopts differential operation to post-process the comprehensive determination result, removes the fixed marks on the bottle body, further filters the possible false detection results in the comprehensive determination, and ensures the reliability of the final recognition result. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] Figure 1 This is a framework flow chart of a method for identifying impurities and bubbles in a wine bottle based on comprehensive multi-feature judgment according to the present invention;
[0036] Figure 2 This is a flowchart of image preprocessing in an embodiment of the present invention;
[0037] Figure 3 This is a flowchart of image segmentation in an embodiment of the present invention;
[0038] Figure 4 This is a comprehensive determination flow chart in an embodiment of the present invention;
[0039] Figure 5 Schematic diagram of comprehensive determination in an embodiment of the present invention. DETAILED DESCRIPTION
[0040] In order to explain the present invention more clearly, the present invention is further described below in conjunction with preferred embodiments and drawings. It should be understood by those skilled in the art that the content described below is illustrative rather than restrictive, and should not be used to limit the scope of protection of the present invention.
[0041] The present invention provides a method for identifying impurities and bubbles in a wine bottle based on comprehensive judgment of multiple features. Figure 1 As shown, it includes steps such as image acquisition, image preprocessing, edge detection, image segmentation, feature extraction, comprehensive judgment and post-processing. The following is a detailed description of each implementation step:
[0042] Step 1: Image acquisition
[0043] The present invention uses a high-resolution industrial camera for image acquisition, and the specific parameters are set to a resolution of 1920x1080 pixels and a frame rate of 30 frames per second. In order to ensure image quality, a high-brightness LED light source is used for illumination to ensure uniform illumination and avoid shadows or reflection interference caused by uneven light. The relative position of the camera and the light source is precisely calibrated so that each image acquired has a consistent shooting angle and lighting conditions. During the acquisition process, multiple frames of images are taken continuously to ensure that enough information is captured for subsequent processing and analysis. The high-resolution image data finally obtained will be used as the input for image preprocessing.
[0044] Step 2: Image preprocessing
[0045] In order to improve the image quality and provide a reliable data basis for subsequent edge detection, image segmentation and feature extraction, this step uses adaptive histogram equalization (CLAHE) and Gaussian blur method for image preprocessing. CLAHE effectively enhances the image contrast, making the edges of impurities and bubbles more obvious; Gaussian blur smoothes the image and suppresses noise. The image preprocessing flow chart is shown in the figure. Figure 2 shown.
[0046] CLAHE is a technique for enhancing image contrast, especially for improving local contrast and keeping global contrast stable. First, the image is divided into several grids, each grid is histogram equalized separately, and then these small blocks are spliced together through bilinear interpolation. The specific steps are as follows: First, the image is divided into 8x8 grids, and each grid is independently equalized. Then, for each pixel in each grid, its cumulative distribution function (CDF) is calculated, and its grayscale value is redistributed according to CDF to enhance the contrast. Finally, the processed small blocks are spliced together through bilinear interpolation to form an overall image with uniform transition. The calculation formula is as follows:
[0047] CLANE(I)=I new ; Where I is the original image, I new The image is processed by adaptive histogram equalization.
[0048] Gaussian blur is a technique to reduce image noise and details. It suppresses high-frequency noise in an image by performing a convolution operation on the image. Specifically, a suitable Gaussian kernel such as 5x5 and a standard deviation of 2 are selected to construct a Gaussian filter. The image is convolved, and the new value of each pixel is the weighted average of the values of its neighboring pixels. The weighting coefficient is determined by the Gaussian function, and the calculation formula is as follows:
[0049]
[0050] Among them, I(x,y) is the image after adaptive histogram equalization, G is the Gaussian kernel, and I new (x, y) is the image after Gaussian blur processing, k is the radius of the kernel matrix, which usually determines the size of the kernel. The present invention implements Gaussian blur by calling the OpenCV library function.
[0051] Step 3: Edge Detection
[0052] In the present invention, the Canny edge detection algorithm is used to extract the edges of impurities and bubbles in the wine bottle. In specific implementation, first, the Sobel operator is used to calculate the gradient of the image in the horizontal direction (X direction) and the vertical direction (Y direction), and the size and direction of the gradient are used to determine the strength and direction of the edge; then, the gradient amplitude is non-maximum suppressed, non-edge points are eliminated, and edge points are retained. This step compares the neighborhood pixels of each pixel point in the gradient direction, retains the local maximum value, and then uses high thresholds and low thresholds to detect the edge. The high threshold is used to determine the strong edge, and the low threshold is used to connect the weak edge and the strong edge to form a complete edge. Finally, starting from the strong edge detected by the high threshold, the weak edge detected by the low threshold is traced along the gradient direction to form the final edge map.
[0053] Step 4: Image Segmentation
[0054] The image segmentation process is as follows Figure 3 As shown. In the present invention, the image is segmented into multiple target areas using contour detection technology. The purpose of this step is to extract possible bubbles and impurity areas from the edge detection results, providing a basis for subsequent feature extraction. The specific implementation process is:
[0055] 1) First, use the findContours function in the OpenCV library to detect contours in the image;
[0056] 2) Filter out contours with too small an area by using area threshold;
[0057] 3) Calculate the bounding box for each filtered contour;
[0058] 4) Draw the calculated bounding box on the original image using the rectangle library function, and display and save the segmentation result image.
[0059] Step 5: Feature extraction
[0060] Feature detection is the core technology for distinguishing foreign matter from bubbles in wine bottles. By extracting and analyzing multiple image features, accurate identification of impurities and bubbles can be achieved. The features extracted by the present invention include circularity, grayscale mean, grayscale uniformity, texture features, and color space features. Each feature provides different information for more accurate distinction between bubbles and impurities.
[0061] Circularity calculation: Circularity is used to measure the circularity of the target area. Bubbles usually have a higher circularity, while impurities have an irregular shape. By calculating the circularity value of the target area, bubbles and impurities can be preliminarily distinguished. The calculation formula for circularity is as follows:
[0062] Where S i is the area of the i-th target area, L i is the circumference of the i-th target area, and Cirularity is the circularity value.
[0063] Grayscale mean calculation: Grayscale mean is the average grayscale value of all pixels in the target area. Bubbles usually have brighter images and higher grayscale mean, while impurities have darker images. The grayscale mean calculation formula is as follows:
[0064] Among them, P ij is the jth pixel in the i-th target area, N i is the number of pixels in the i-th target area, and Mean Gray Value is the grayscale mean.
[0065] Grayscale uniformity calculation: Grayscale uniformity is the uniformity of the distribution of all pixel values in the target area. Bubbles are usually darker at the edges and brighter in the middle, while impurities are generally darker and more uniform. The calculation formula is as follows:
[0066] where μ i is the grayscale mean of the i-th target area, and GrayUniformity is the grayscale uniformity.
[0067] Bubbles and impurities can be further distinguished through the two grayscale features of grayscale mean and grayscale uniformity.
[0068] Texture feature analysis: Use the LBP method to calculate the texture features of the target area. The bubble surface is smooth and the texture features are relatively simple, while the impurity surface is rough and the texture features are complex. The calculation formula is as follows:
[0069] Among them, s(x) is the threshold function, i p is the surrounding pixel value, i c is the center pixel value.
[0070] Color space feature analysis: Convert the target area from RGB color space to HSV color space and calculate its mean to extract the color distribution characteristics of the target area. The calculation formula is as follows:
[0071] HSV=f(RGB)
[0072] Bubbles and impurities may appear differently in different color spaces. Color features can be used as an auxiliary basis for judgment to further improve recognition accuracy.
[0073] Step 6: Comprehensive judgment
[0074] Based on the extracted features, comprehensive judgment rules are applied to distinguish bubbles and impurities. The comprehensive judgment process is as follows: Figure 4 and Figure 5 shown.
[0075] 1) Set threshold and weight value
[0076] Thresholds and weights are set for each feature, and the weights are used to adjust the importance of each feature in the comprehensive judgment.
[0077] The feature thresholds are set as follows:
[0078] Circularity 0.8 Grayscale mean 150 Gray uniformity 50 Texture features 0.2 Color space characteristics (100,100,100)
[0079] The feature weights are set as follows:
[0080]
[0081]
[0082] 2) Calculate single feature score
[0083] According to the threshold of each feature, the features of the target area are scored, and the scoring result is 0 or 1. If the feature value exceeds the threshold, it is 1, otherwise it is 0. The specific calculation formula is as follows:
[0084]
[0085] 3) Calculate the comprehensive score
[0086] The score of each feature is multiplied by the corresponding weight and then added up to get the comprehensive score of the target area. The calculation formula is as follows:
[0087] Score = w c ·f c +w m ·f m +w u ·f u +w t ·f t +w s ·f s ;
[0088] Among them, f c is the roundness score, f m is the grayscale mean score, f u is the gray uniformity score, f tScore the texture feature, f s Score the color space feature, w c 、w m 、w u 、w t 、w s is the weight.
[0089] 4) Set the judgment threshold
[0090] The judgment threshold is set to 0.5. If the comprehensive score exceeds the threshold, it is judged as a bubble, otherwise it is an impurity.
[0091] 5) Final decision
[0092] Based on the comprehensive score and the preset judgment threshold, it is determined whether the target area is a bubble or an impurity. Through the five features, multiple features can be effectively used to classify the target area, improving the accuracy and robustness of bubble and impurity identification.
[0093] Step 7: Post-processing
[0094] The comprehensive determination result is further optimized and cleaned to ensure the accuracy and reliability of the final detection result. In the present invention, the post-processing includes the steps of removing the fixed marks on the bottle body by differential operation and further filtering out the false detection.
[0095] 1) Differential operation to remove fixed traces
[0096] Perform differential operations on multiple frames of images to remove fixed traces on the bottle (such as labels, printed text, etc.) to ensure that only bubbles and impurities in the liquid are detected. Specifically, first perform differential operations on multiple frames of images to remove fixed traces on the bottle and retain moving bubbles and impurities; then perform binarization on the differential results to extract areas with significant changes; then use morphological operations (opening operations) to remove small noise points and further optimize the binarization results.
[0097] 2) False detection filtering
[0098] Further filter possible false detection results in the comprehensive judgment to ensure the reliability of the final result, and then draw the final detection result (an image with bubbles and impurities marked) on the original image.
[0099] The above description is only a preferred embodiment of the present invention and does not limit the present invention in any form. Any simple modification or equivalent change made to the above embodiment based on the technical essence of the present invention shall fall within the protection scope of the present invention.
Claims
1. A method for identifying impurities and bubbles in wine bottles based on multi-feature comprehensive judgment, characterized in that: include: Image acquisition steps: Use a high-resolution industrial camera combined with an LED light source to continuously capture multiple frames of images of the wine bottle under consistent shooting angles and lighting conditions; Image preprocessing steps: Adaptive histogram equalization and Gaussian blur method are used to preprocess the collected images; Edge detection step: Use the Canny edge detection algorithm to extract the edges of impurities and bubbles in the wine bottle on the image to obtain an edge image; Image segmentation step: Use contour detection technology to segment the edge image into multiple target areas, and extract possible bubbles and impurity areas from the edge image; Feature extraction step: extracting target area features, including circularity, grayscale mean, grayscale uniformity, texture features, and color space; Comprehensive judgment step: Based on the extracted features, apply comprehensive judgment rules to distinguish bubbles from impurities.
2. The method for identifying impurities and bubbles in a wine bottle based on comprehensive multi-feature judgment as claimed in claim 1, characterized in that: The method also includes post-processing steps: using differential operations to remove fixed traces on the image, binarizing the differential results, extracting areas of significant changes, and then using morphological operations to remove small noise points to further optimize the binarization results; based on the binarization results, filtering possible false detection results in the comprehensive judgment results, and then drawing the final detection results of bubbles and impurities on the original image.
3. The method for identifying impurities and bubbles in a wine bottle based on comprehensive multi-feature judgment as claimed in claim 1, characterized in that: Circularity is used to measure the circularity of the target area. The calculation formula is as follows: Where S i is the area of the i-th target area, L i is the circumference of the i-th target area, and Cirularity is the circularity value.
4. The method for identifying impurities and bubbles in a wine bottle based on multi-feature comprehensive judgment as claimed in claim 1, characterized in that: The grayscale mean is the average grayscale value of all pixels in the target area, and the calculation formula is: Among them, P ij is the jth pixel in the i-th target area, N i is the number of pixels in the i-th target area, and Mean Gray Value is the grayscale mean.
5. The method for identifying impurities and bubbles in a wine bottle based on comprehensive multi-feature judgment as claimed in claim 1, characterized in that: Grayscale uniformity is the uniformity of the distribution of all pixel values in the target area, and its calculation formula is: where μ i is the grayscale mean of the i-th target area, and GrayUniformity is the grayscale uniformity.
6. The method for identifying impurities and bubbles in a wine bottle based on comprehensive multi-feature judgment as claimed in claim 1, characterized in that: The texture feature is calculated using the LBP method, and the formula is as follows: Among them, s(x) is the threshold function, i p is the surrounding pixel value, i c is the center pixel value.
7. The method for identifying impurities and bubbles in a wine bottle based on comprehensive multi-feature judgment as claimed in claim 1, characterized in that: The color space is to convert the target area from the RGB color space to the HSV color space and calculate its mean to extract the color distribution characteristics of the target area.
8. The method for identifying impurities and bubbles in a wine bottle based on comprehensive multi-feature judgment as claimed in claim 1, characterized in that: The image segmentation steps specifically include: 1) Use the findContours function in the OpenCV library to detect contours in the image; 2) Filter out contours with too small an area by using area threshold; 3) Calculate the bounding box for each filtered contour; 4) Draw the calculated bounding box on the original image using the rectangle library function, and display and save the segmentation result image.
9. The method for identifying impurities and bubbles in a wine bottle based on multi-feature comprehensive judgment as claimed in claim 1, characterized in that: Based on the extracted features, comprehensive judgment rules are applied to distinguish bubbles from impurities, including: first, setting thresholds and weights for each feature; then, scoring the features of the target area according to the threshold of each feature; then, multiplying the scores of each feature by the corresponding weights and adding them up to obtain a comprehensive score for the target area; finally, comparing the comprehensive score with the preset judgment threshold to determine whether the target area is a bubble or an impurity.
Citation Information
Patent Citations
Method for detecting, tracking and recognizing movement visible exogenous impurity in medicine liquid
CN101354359B
A Classification, Identification and Detection Method for Visible Foreign Objects and Air Bubbles in 250ml Medical Infusion
CN105869154B
Cited By
Honey quality detection method based on machine vision
CN120102475A
Judgment method for particle uniformity of steam foaming foam plastic
CN120182613A
Automatic stirring control system and method in white spirit brewing process
CN120526171A
Method for identifying solid hanging on wall on chemical reaction bottle
CN120544098A
Scraper fineness testing method based on machine vision and intelligent algorithm
CN120577177A