Online visual inspection method for glass tube
Through the combination of coaxial lighting, ring lighting and stroboscopic lighting technology, deep neural networks are trained to solve the problem of light transmission or reflection in online visual inspection of glass tubes, achieving efficient defect identification and image quality improvement under complex lighting conditions. .
Patent Information
- Application Number
- CN202410666781.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-28
- Publication Date
- 2024-09-10
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
In online visual inspection, the transparent nature of glass tubes causes the transmission or reflection of light, resulting in unclear image collection. Especially under complex lighting conditions, it is difficult to effectively suppress light refraction, which affects the detection effect.
Use coaxial lighting and ring lighting multiple combination lighting methods, combined with stroboscopic lighting or modulated light source technology, train deep neural networks, control camera exposure time and image processing algorithms, enhance image contrast and detail performance, and identify through deep learning models and texture analysis Defects, automatically adjust detection system parameters.
Accurately identify defects of different types and sizes under complex lighting conditions, improve detection robustness and image quality, reduce ambient light interference, and ensure clear outlines of pipe walls and internal structures.
Smart Images

Figure CN118624645A
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of glass tube visual inspection, and in particular to an online visual inspection method for glass tubes. Background Art
[0002] With the advancement of industrialization, the manufacturing industry has continuously increased its requirements for production efficiency and product quality. Traditional manual or semi-automatic quality inspection cannot meet the needs of large-scale and high-speed production. The development of online visual inspection technology conforms to this trend, realizing real-time, continuous and efficient defect detection, reducing labor costs and improving production efficiency. At the same time, with the research results and technological breakthroughs in the field of computer vision, such as the optimization of image processing algorithms and the introduction of artificial intelligence technologies such as deep learning, the visual system can accurately analyze the image of complex and transparent glass tubes. By optimizing the lighting technology, the image acquisition problem caused by the transparent characteristics of glass tubes can be overcome; through intelligent algorithms, tiny defects and complex textures can be accurately identified. As glass tubes are widely used in many industries such as medicine, chemical industry, and electronics, their quality directly affects the safety and performance of products. Therefore, extremely high requirements are put forward for defect detection in the production process of glass tubes. Therefore, a method for online visual inspection of glass tubes is proposed here.
[0003] After searching, patent number CN201810746410.9 discloses a panoramic structured light vision measurement system and a universal distortion model parameter calibration method, which solves the problem that in the process of light passing through a glass tube and projecting it onto the camera image plane, it refracts and causes distortion on the outer and inner surfaces of the glass tube in turn, which reduces the measurement accuracy of the system to a certain extent. It involves the field of vision measurement.
[0004] However, when performing online visual inspection on glass tubes to solve the transparent characteristics of the glass tubes, there will be a variety of different degrees of light. Different degrees of light intensities will result in light transmission or reflection, which makes it difficult to clearly distinguish the tube wall and internal structure during image acquisition, affecting the detection effect. Especially under strong light or complex lighting conditions, the refraction of light cannot be effectively suppressed. Therefore, an online visual inspection method for glass tubes is proposed. By suppressing ambient light interference based on coaxial lighting, annular lighting, and strobe lighting, a deep neural network is trained for learning. The complex patterns of glass tube defects can be trained, which can accurately identify defects of different types and sizes even under complex lighting conditions, and can mine hidden features in the image to improve the robustness of defect detection. Summary of the invention
[0005] In view of the deficiency of the prior art in solving the transparent characteristics of glass tubes in that light is transmitted or reflected, the present invention provides an online visual inspection method for glass tubes, which has the advantage of solving the illumination problem caused by the transparent tube wall.
[0006] To achieve the above object, the present invention provides the following technical solution: an online visual inspection method for glass tubes, the visual inspection method comprising the following steps:
[0007] S1: Use coaxial lighting, annular lighting and multiple combination lighting methods to provide lighting from different angles, balance the transmission and reflection of light, and use stroboscopic lighting or modulated light source technology to reduce the impact of ambient light on image acquisition;
[0008] S2: Control the camera exposure time, retain the grayscale information of the defective part and perform image enhancement, apply image processing algorithms to improve image contrast and highlight the defective area;
[0009] S3: Image enhancement technology is used to improve the overall image quality and detail performance and strengthen the tube wall boundary, and shadow correction is used to correct artifacts caused by uneven lighting;
[0010] S4: Design and train deep learning models to identify various defect features in complex backgrounds and apply texture analysis and morphological operation image processing technology to assist in identification, in order to capture atypical or minor defects;
[0011] S5: Automatically adjust camera parameters and light source intensity based on real-time inspection result feedback, regularly calibrate and maintain the visual inspection system, and update the defect database.
[0012] In S1, coaxial lighting is to place the light source in the direction of the axis of the camera lens. The light emitted by the light source is guided by a special light-guiding component, a hemispherical or annular light guide, so that the light coincides with the optical axis of the lens and reduces surface reflection. This is achieved based on the brightness of the light source, the distance between the light source and the lens, and the material and shape of the light-guiding component. It uses a high-brightness, low-heat, uniformly emitting LED light source.
[0013] The ring lighting is achieved by setting a circle of LED ring light sources around the camera to form uniform surround lighting, capture the 3D shape and surface defects of the object, and adjust the relative position of the ring light source and the glass tube based on the diameter of the light source, the spacing between the light sources, the consistency of the light source color and brightness, and the light-emitting angle of the light source, according to the specific shape and size of the glass tube, to ensure that light shines on the tube wall from all angles to achieve multi-angle lighting.
[0014] In S1, stroboscopic lighting or modulated light source technology uses a programmable controller or a dedicated driver to set the frequency of the light source for periodic opening and closing, that is, stroboscopic lighting, synchronized with the camera exposure time, to ensure that the image is captured at the moment the light source is on. Based on the stroboscopic frequency, the ratio of the duty cycle of the light source on time to the total cycle and the trigger synchronization mechanism, the modulated light source that is not synchronized with the ambient light is used to suppress the interference of fixed frequency or randomly changing ambient light on image acquisition, improve the image signal-to-noise ratio, and finally perform signal demodulation. In the later image processing stage, the software demodulation technology is used to extract the effective signal and optimize the image quality.
[0015] In S2, based on experience and on-site observation, the exposure time is manually adjusted to a suitable value so that the grayscale information of the defective part is neither overexposed nor underexposed, or automatic exposure is performed to automatically adjust the exposure time through the AE algorithm, and then the color image is converted into a grayscale image based on the formula:
[0016] gray=0.299*R+0.587*G+0.114*B
[0017] Where R, G, and B are the pixel values of the red, green, and blue channels respectively. A grayscale image is obtained, and then contrast stretching is performed to dynamically adjust the minimum and maximum grayscale values of the image according to the grayscale range, based on the formula:
[0018] new_gray=(old_gray-min_val)*scale_factor+new_min
[0019] Among them, min_val is the minimum grayscale value of the original image, scale_factor is the stretching factor, and new_min is the minimum grayscale value of the new image. Finally, local contrast enhancement is performed, and the adaptive histogram equalization algorithm is used to enhance the contrast in the local area near the defect.
[0020] In S3, the Sobel edge detection operator is used to find the tube wall boundary in the image and highlight the edge. Based on the detected edge, the tube wall boundary is strengthened by expanding the pixel value gap, enhancing the contrast and local contrast. For the tube wall area, adaptive histogram equalization is used to enhance the tube wall details, and high-frequency enhancement sharpening technology is applied to enhance the boundary. Then shadow correction is performed to eliminate the shadow on the tube wall caused by uneven lighting. Retinex shadow correction technology is used to improve the brightness of the shadow area based on the formula:
[0021] Iout(x,y)=log(I(x,y) / I0(x,y))
[0022] Where I(x,y) is the pixel brightness or color value at coordinate (x,y) of the original image;
[0023] I0(x,y) is the local average brightness or color, the average brightness of all pixels in a certain neighborhood window; log represents the natural logarithm function, which is used to compress the range of light intensity, highlight the unevenness of light, and obtain the brightness of the improved shadow area.
[0024] In S4, a large number of glass tube images with various defect labels, including atypical and minor defect instances, are first collected and data augmentation is performed, including rotation, flipping, and scaling. The images are then normalized using the Z-score normalization formula:
[0025] X_normalized=(X-μ) / σ
[0026] Where X is the original image pixel value, μ and σ are the mean and standard deviation of the data set respectively. Then the model architecture is selected, and a convolutional neural network CNN model VGG is built to add fully connected layers and output layers to adapt to specific tasks including classification and detection. The loss function is selected for the cross entropy loss of the classification task. The training parameters are set to set the learning rate, optimizer, batch size, and training round parameters. The model is trained using the training data set, and the model weights are updated through the back propagation algorithm to obtain the trained deep learning model.
[0027] In S4, after the deep learning model, the texture analysis method GLCM is applied to extract the texture features of the image. Each pixel in the region of interest, i.e., the part where defects may occur in the glass tube, is paired with the grayscale values of the surrounding pixels. The number of occurrences of this grayscale value pairing in the entire ROI is counted to form a grayscale co-occurrence matrix. Various texture features, energy, entropy, contrast, correlation, homogeneity, and coefficient of variation are extracted from GLCM to obtain the texture laws reflecting the local area of the image. They are integrated into the deep learning model or used as supplementary features alone. Morphological processing is performed on the preliminary recognition results to extract tiny defects.
[0028] In S5, when it is detected that the image is too bright or too dark, making it difficult to identify defects, the camera exposure time is automatically adjusted based on S2 according to the preset threshold or through image brightness statistical analysis. According to the color deviation of the real-time detection image, the camera white balance is automatically adjusted by calculating the RGB channel ratio. The calculation process assumes that the RGB values of a pixel are R, G, and B, respectively, and the value range of R, G, and B0-255 is usually between 0 and 255. The percentage of each channel in the overall intensity is calculated based on the formula. The total intensity formula is:
[0029] T=R+G+B
[0030] 100% formula for each channel:
[0031] P_R=(R / T)*100% P_G=(G / T)*100% P_B=(B / T)*100%
[0032] Get the relative proportions of the pixel in the red, green and blue channels to ensure that the sum of the proportions of the three channels is 100%. When the lighting conditions change, adjust the ISO sensitivity appropriately to ensure that sufficient image signals can be obtained under different light intensities.
[0033] Beneficial effects:
[0034] 1. The glass tube online visual inspection method can effectively balance the transmittance and reflection effects of transparent glass tubes under light by applying coaxial lighting, annular lighting and multi-combination lighting, while reducing the influence of ambient light on image acquisition, thereby improving the stability and accuracy of the visual inspection system.
[0035] 2. This glass tube online visual inspection method can learn the complex patterns of glass tube defects by training deep neural networks, and can accurately identify defects of different types and sizes even under complex lighting conditions. At the same time, the combination of coaxial lighting and annular lighting can ensure that the glass tube is illuminated from multiple angles, reducing shadows and highlights, making the outline of the tube wall and internal structure clearer.
[0036] 3. The glass tube online visual inspection method can effectively suppress the interference of ambient light through stroboscopic lighting or modulated light source technology, ensuring that images are collected only when the effective light source is irradiated, thereby improving the image quality and signal-to-noise ratio. At the same time, by controlling the camera exposure time, it can optimize the light and dark levels of the image, retain the grayscale information of the defective parts, avoid the loss of details caused by overexposure or underexposure, and improve the image quality and signal-to-noise ratio. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] Figure 1 A method step diagram for an online visual inspection method for glass tubes.
[0038] In the figure: S1: Coaxial lighting, annular lighting and multi-combination lighting methods are used to provide lighting from different angles, balance the transmission and reflection of light, and use stroboscopic lighting or modulated light source technology to reduce the impact of ambient light on image acquisition;
[0039] S2: Control the camera exposure time, retain the grayscale information of the defective part and perform image enhancement, apply image processing algorithms to improve image contrast and highlight the defective area;
[0040] S3: Image enhancement technology is used to improve the overall image quality and detail performance and strengthen the tube wall boundary, and shadow correction is used to correct artifacts caused by uneven lighting;
[0041] S4: Design and train deep learning models to identify various defect features in complex backgrounds and apply texture analysis and morphological operation image processing technology to assist in identification, in order to capture atypical or minor defects;
[0042] S5: Automatically adjust camera parameters and light source intensity based on real-time inspection result feedback, regularly calibrate and maintain the visual inspection system, and update the defect database. DETAILED DESCRIPTION
[0043] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0044] Embodiment 1
[0045] See also Figure 1 , a glass tube online visual inspection method, the visual inspection method steps include:
[0046] S1: Use coaxial lighting, annular lighting and multiple combination lighting methods to provide lighting from different angles, balance the transmission and reflection of light, and use stroboscopic lighting or modulated light source technology to reduce the impact of ambient light on image acquisition;
[0047] S2: Control the camera exposure time, retain the grayscale information of the defective part and perform image enhancement, apply image processing algorithms to improve image contrast and highlight the defective area;
[0048] S3: Image enhancement technology is used to improve the overall image quality and detail performance and strengthen the tube wall boundary, and shadow correction is used to correct artifacts caused by uneven lighting;
[0049] S4: Design and train deep learning models to identify various defect features in complex backgrounds and apply texture analysis and morphological operation image processing technology to assist in identification, in order to capture atypical or minor defects;
[0050] S5: Automatically adjust camera parameters and light source intensity based on real-time inspection result feedback, regularly calibrate and maintain the visual inspection system, and update the defect database.
[0051] In S1, coaxial lighting is to place the light source in the direction of the axis of the camera lens. The light emitted by the light source is guided by a special light-guiding component, a hemispherical or annular light guide, so that the light coincides with the optical axis of the lens and reduces surface reflection. This is achieved based on the brightness of the light source, the distance between the light source and the lens, and the material and shape of the light-guiding component. It uses a high-brightness, low-heat, uniformly emitting LED light source.
[0052] The ring lighting is achieved by setting a circle of LED ring light sources around the camera to form uniform surround lighting, capture the 3D shape and surface defects of the object, and adjust the relative position of the ring light source and the glass tube based on the diameter of the light source, the spacing between the light sources, the consistency of the light source color and brightness, and the light-emitting angle of the light source, according to the specific shape and size of the glass tube, to ensure that light shines on the tube wall from all angles to achieve multi-angle lighting.
[0053] In S1, stroboscopic lighting or modulated light source technology uses a programmable controller or a dedicated driver to set the frequency of the light source for periodic opening and closing, that is, stroboscopic lighting, synchronized with the camera exposure time, to ensure that the image is captured at the moment the light source is on. Based on the stroboscopic frequency, the ratio of the duty cycle of the light source on time to the total cycle and the trigger synchronization mechanism, the modulated light source that is not synchronized with the ambient light is used to suppress the interference of fixed frequency or randomly changing ambient light on image acquisition, improve the image signal-to-noise ratio, and finally perform signal demodulation. In the later image processing stage, the software demodulation technology is used to extract the effective signal and optimize the image quality.
[0054] In S2, based on experience and on-site observation, the exposure time is manually adjusted to a suitable value so that the grayscale information of the defective part is neither overexposed nor underexposed, or automatic exposure is performed to automatically adjust the exposure time through the AE algorithm, and then the color image is converted into a grayscale image based on the formula:
[0055] gray=0.299*R+0.587*G+0.114*B
[0056] Where R, G, and B are the pixel values of the red, green, and blue channels respectively. A grayscale image is obtained, and then contrast stretching is performed to dynamically adjust the minimum and maximum grayscale values of the image according to the grayscale range, based on the formula:
[0057] new_gray=(old_gray-min_val)*scale_factor+new_min
[0058] Among them, min_val is the minimum grayscale value of the original image, scale_factor is the stretching factor, and new_min is the minimum grayscale value of the new image. Finally, local contrast enhancement is performed, and the adaptive histogram equalization algorithm is used to enhance the contrast in the local area near the defect.
[0059] Among them: the process of using the adaptive histogram equalization algorithm to enhance the contrast in the local area near the defect mainly includes the following steps: first, the original image is divided into several small blocks, the size of each small block can be set according to the actual situation, and can be set to 8x8 pixels or 16x16 pixels, then the histogram of each small block is calculated, the pixel values in each small block are counted, and the histogram of the small block is generated. The histogram reflects the distribution of the grayscale values of the pixels in the small blocks in the image, and then the cumulative distribution function CDF is calculated. The cumulative distribution function is calculated for the histogram of each small block to represent the cumulative probability of the grayscale value of the pixel, and then the mapping function is calculated and the contrast is enhanced. For each small block, an enhanced mapping function is generated according to its CDF, so that the grayscale value distribution of the pixels in the small block of the output image is more uniform, thereby enhancing the contrast;
[0060] Then apply the mapping function to each pixel, apply the mapping function corresponding to the small block where each pixel is located to the pixel, replace the original pixel value with the new mapping value to complete the contrast enhancement, and then perform window processing and edge processing to avoid discontinuity at the junction of adjacent small blocks, and use weighted averaging and bilateral filtering to smooth the junction.
[0061] Embodiment 2
[0062] See also Figure 1 , based on the first embodiment, in S3, the Sobel edge detection operator is used to find the tube wall boundary in the image and highlight the edge. Based on the detected edge, the tube wall boundary is strengthened by expanding the pixel value difference, the contrast is enhanced, and the local contrast is enhanced for the tube wall area. Adaptive histogram equalization is used to enhance the details of the tube wall, and high-frequency enhancement sharpening technology is applied to enhance the boundary. Then, shadow correction is performed to eliminate the shadow on the tube wall caused by uneven lighting. Retinex shadow correction technology is used to improve the brightness of the shadow area, based on the formula:
[0063] Iout(x,y)=log(I(x,y) / I0(x,y))
[0064] Where I(x,y) is the pixel brightness or color value at coordinate (x,y) of the original image;
[0065] I0(x,y) is the local average brightness or color, the average brightness of all pixels in a certain neighborhood window; log represents the natural logarithm function, which is used to compress the range of light intensity, highlight the unevenness of light, and obtain the brightness of the improved shadow area.
[0066] In S4, a large number of glass tube images with various defect labels, including atypical and minor defect instances, are first collected and data augmentation is performed, including rotation, flipping, and scaling. The images are then normalized using the Z-score normalization formula:
[0067] X_normalized=(X-μ) / σ
[0068] Where X is the original image pixel value, μ and σ are the mean and standard deviation of the data set respectively. Then the model architecture is selected, and a convolutional neural network CNN model VGG is built to add fully connected layers and output layers to adapt to specific tasks including classification and detection. The loss function is selected for the cross entropy loss of the classification task. The training parameters are set to set the learning rate, optimizer, batch size, and training round parameters. The model is trained using the training data set, and the model weights are updated through the back propagation algorithm to obtain the trained deep learning model.
[0069] In S4, after the deep learning model, the texture analysis method GLCM is applied to extract the texture features of the image. Each pixel in the region of interest, i.e., the part where defects may occur in the glass tube, is paired with the grayscale values of the surrounding pixels. The number of occurrences of this grayscale value pairing in the entire ROI is counted to form a grayscale co-occurrence matrix. Various texture features, energy, entropy, contrast, correlation, homogeneity, and coefficient of variation are extracted from GLCM to obtain the texture laws reflecting the local area of the image. They are integrated into the deep learning model or used as supplementary features alone. Morphological processing is performed on the preliminary recognition results to extract tiny defects.
[0070] In S5, when it is detected that the image is too bright or too dark, making it difficult to identify defects, the camera exposure time is automatically adjusted based on S2 according to the preset threshold or through image brightness statistical analysis. According to the color deviation of the real-time detection image, the camera white balance is automatically adjusted by calculating the RGB channel ratio. The calculation process assumes that the RGB values of a pixel are R, G, and B, respectively, and the value range of R, G, and B0-255 is usually between 0 and 255. The percentage of each channel in the overall intensity is calculated based on the formula. The total intensity formula is:
[0071] T=R+G+B
[0072] 100% formula for each channel:
[0073] P_R=(R / T)*100% P_G=(G / T)*100% P_B=(B / T)*100%
[0074] Get the relative proportions of the pixel in the red, green and blue channels to ensure that the sum of the proportions of the three channels is 100%. When the lighting conditions change, adjust the ISO sensitivity appropriately to ensure that sufficient image signals can be obtained under different light intensities.
[0075] Among them: The region of interest (ROI) in S4 refers to the key part of an image that the user or algorithm pays attention to. In image analysis, processing or machine vision applications, we do not always need to fully analyze the entire image, but will select specific areas that are closely related to target detection or feature extraction for in-depth research. When applying the GLCM grayscale co-occurrence matrix to extract image texture features, the region of interest (ROI) usually refers to the part of the glass tube where defects may occur, or the area that may contain important texture information. In the online visual inspection of glass tubes, the ROI may be the wall of the glass tube, because we need to analyze the texture features of this part to identify whether there are defects. Each pixel in the ROI is paired with the grayscale values of the surrounding pixels, that is, in the selected area, for each pixel point, the pairing relationship of its grayscale value with the adjacent pixel points in the specified direction and distance is calculated, and then the occurrence frequency of these pairs in the entire ROI is counted to form a grayscale co-occurrence matrix, thereby extracting rich texture features.
[0076] Although embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present invention, and that the scope of the present invention is defined by the appended claims and their equivalents.
Claims
1. A method for online visual inspection of glass tubes, characterized in that: The visual inspection method steps include: S1: Use coaxial lighting, annular lighting and multiple combination lighting methods to provide lighting from different angles, balance the transmission and reflection of light, and use stroboscopic lighting or modulated light source technology to reduce the impact of ambient light on image acquisition; S2: Control the camera exposure time, retain the grayscale information of the defective part and perform image enhancement, apply image processing algorithms to improve image contrast and highlight the defective area; S3: Image enhancement technology is used to improve the overall image quality and detail performance and strengthen the tube wall boundary, and shadow correction is used to correct artifacts caused by uneven lighting; S4: Design and train deep learning models to identify various defect features in complex backgrounds and apply texture analysis and morphological operation image processing technology to assist in identification, in order to capture atypical or minor defects; S5: Automatically adjust camera parameters and light source intensity based on real-time inspection result feedback, regularly calibrate and maintain the visual inspection system, and update the defect database.
2. The method for online visual inspection of glass tubes according to claim 1, characterized in that: In S1, coaxial lighting is to place the light source in the direction of the axis of the camera lens. The light emitted by the light source is guided by a special light-guiding component, a hemispherical or annular light guide, so that the light coincides with the optical axis of the lens and reduces surface reflection. This is achieved based on the brightness of the light source, the distance between the light source and the lens, and the material and shape of the light-guiding component. It uses a high-brightness, low-heat, uniformly emitting LED light source. The ring lighting is achieved by setting a circle of LED ring light sources around the camera to form uniform surround lighting, capture the 3D shape and surface defects of the object, and adjust the relative position of the ring light source and the glass tube based on the diameter of the light source, the spacing between the light sources, the consistency of the light source color and brightness, and the light-emitting angle of the light source, according to the specific shape and size of the glass tube, to ensure that light shines on the tube wall from all angles to achieve multi-angle lighting.
3. The method for online visual inspection of glass tubes according to claim 1, characterized in that: In S1, stroboscopic lighting or modulated light source technology uses a programmable controller or a dedicated driver to set the frequency of the light source for periodic opening and closing, that is, stroboscopic lighting, synchronized with the camera exposure time, to ensure that the image is captured at the moment the light source is on. Based on the stroboscopic frequency, the ratio of the duty cycle of the light source on time to the total cycle and the trigger synchronization mechanism, the modulated light source that is not synchronized with the ambient light is used to suppress the interference of fixed frequency or randomly changing ambient light on image acquisition, improve the image signal-to-noise ratio, and finally perform signal demodulation. In the later image processing stage, the software demodulation technology is used to extract the effective signal and optimize the image quality.
4. The method for online visual inspection of glass tubes according to claim 1, characterized in that: In S2, based on experience and on-site observation, the exposure time is manually adjusted to a suitable value so that the grayscale information of the defective part is neither overexposed nor underexposed, or automatic exposure is performed to automatically adjust the exposure time through the AE algorithm, and then the color image is converted into a grayscale image based on the formula: gray=0.299*R+0.587*G+0.114*B Where R, G, and B are the pixel values of the red, green, and blue channels respectively. A grayscale image is obtained, and then contrast stretching is performed to dynamically adjust the minimum and maximum grayscale values of the image according to the grayscale range, based on the formula: new_gray=(old_gray-min_val)*scale_factor+new_min, where min_val is the minimum grayscale value of the original image, scale_factor is the stretching factor, and new_min is the minimum grayscale value of the new image. Finally, local contrast enhancement is performed, and the adaptive histogram equalization algorithm is used to enhance the contrast in the local area near the defect.
5. The method for online visual inspection of glass tubes according to claim 1, characterized in that: In S3, the Sobel edge detection operator is used to find the tube wall boundary in the image and highlight the edge. Based on the detected edge, the tube wall boundary is strengthened by expanding the pixel value gap, enhancing the contrast and local contrast. For the tube wall area, adaptive histogram equalization is used to enhance the tube wall details, and high-frequency enhancement sharpening technology is applied to enhance the boundary. Then shadow correction is performed to eliminate the shadow on the tube wall caused by uneven lighting. Retinex shadow correction technology is used to improve the brightness of the shadow area based on the formula: Iout(x,y)=log(I(x,y) / I0(x,y)) Where I(x,y) is the pixel brightness or color value at coordinate (x,y) of the original image; I0(x,y) is the local average brightness or color, the average brightness of all pixels in a certain neighborhood window; log represents the natural logarithm function, which is used to compress the range of light intensity, highlight the unevenness of light, and obtain the brightness of the improved shadow area.
6. The method for online visual inspection of glass tubes according to claim 1, characterized in that: In S4, a large number of glass tube images with various defect labels, including atypical and minor defect instances, are first collected and data augmentation is performed, including rotation, flipping, and scaling. The images are then normalized using the Z-score normalization formula: X_normalized=(X-μ) / σ Where X is the original image pixel value, μ and σ are the mean and standard deviation of the data set respectively. Then the model architecture is selected, and a convolutional neural network CNN model VGG is built to add fully connected layers and output layers to adapt to specific tasks including classification and detection. The loss function is selected for the cross entropy loss of the classification task. The training parameters are set to set the learning rate, optimizer, batch size, and training round parameters. The model is trained using the training data set, and the model weights are updated through the back propagation algorithm to obtain the trained deep learning model.
7. The method for online visual inspection of glass tubes according to claim 1, characterized in that: In S4, after the deep learning model, the texture analysis method GLCM is applied to extract the texture features of the image. Each pixel in the region of interest, i.e., the part where defects may occur in the glass tube, is paired with the grayscale values of the surrounding pixels. The number of occurrences of this grayscale value pairing in the entire ROI is counted to form a grayscale co-occurrence matrix. Various texture features, energy, entropy, contrast, correlation, homogeneity, and coefficient of variation are extracted from GLCM to obtain the texture laws reflecting the local area of the image. They are integrated into the deep learning model or used as supplementary features alone. Morphological processing is performed on the preliminary recognition results to extract tiny defects.
8. The method for online visual inspection of glass tubes according to claim 1, characterized in that: In S5, when it is detected that the image is too bright or too dark, making it difficult to identify defects, the camera exposure time is automatically adjusted based on S2 according to the preset threshold or through image brightness statistical analysis. According to the color deviation of the real-time detection image, the camera white balance is automatically adjusted by calculating the RGB channel ratio. The calculation process assumes that the RGB values of a pixel are R, G, and B, respectively, and the value range of R, G, and B0-255 is usually between 0 and 255. The percentage of each channel in the overall intensity is calculated based on the formula. The total intensity formula is: T=R+G+B 100% formula for each channel: P_R=(R / T)*100% P_G=(G / T)*100% P_B=(B / T)*100% Get the relative proportions of the pixel in the red, green and blue channels to ensure that the sum of the proportions of the three channels is 100%. When the lighting conditions change, adjust the ISO sensitivity appropriately to ensure that sufficient image signals can be obtained under different light intensities.
Citation Information
Patent Citations
Panoramic structured light vision measurement system and universal distortion model parameter calibration method
CN108917602A
Cited By
UV finish paint performance detection and analysis method and device based on image data processing
CN119417824A
Glass wine bottle surface defect detection method and system
CN119438210A
Method and system for detecting surface defects of glass wine bottles
CN119438210B
Intelligent quality inspection and process optimization system based on machine vision
CN119515851A
Visual inspection system for impeller of high-pressure compressor
CN119780120A
