Glass bottle label defect detection method and system based on image processing
The method uses fixed-angle lighting and near-infrared illumination with gradient enhancement filtering to improve glass bottle label defect detection precision and robustness by analyzing fiber direction and density at multiple scales, addressing the limitations of existing methods.
Patent Information
- Application Number
- CN202510247632.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-04
- Publication Date
- 2025-07-15
- Estimated Expiration
- 2045-03-04
AI Technical Summary
In the detection of glass bottle label defects, edge detection, color abnormality recognition and morphological treatment methods are insufficient in the accuracy of complex backgrounds or light changes, and it is difficult to adapt to the diversity of label materials and changes in light conditions, resulting in insufficient detection stability and accuracy.
Fixed-angle light sources and near-infrared irradiation are used to obtain high-resolution images, combined with gradient enhancement filtering to suppress noise, fiber orientation consistency and break point density are calculated through fiber arrangement direction analysis and multi-scale anomaly identification, and defect classification is performed by combining fluctuation accumulation amplitude and direction deviation values.
It improves the accuracy of label area identification, enhances the stability and adaptability of defect detection, and can effectively distinguish the degree of fiber fracture and classify defects such as minor scratches, tear, drops, label misalignment.
Smart Images

Figure CN120318477A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image analysis and detection, and particularly to a method and system for detecting bottle label defects based on image processing. Background Art
[0002] The technical field of image analysis and detection includes methods such as object recognition, feature extraction, defect detection, and classification processing based on image data. The core content of this technical field is to analyze image data through computer vision, pattern recognition, and image processing technologies to achieve automatic detection and evaluation of target objects. Image analysis and detection technologies are widely used in many fields such as industrial production quality control, medical image analysis, security monitoring, and automated detection. Its systematic content includes key links such as image acquisition, preprocessing, feature extraction, target detection, and classification. Common technical means include methods such as edge detection, morphological processing, texture analysis, and deep learning to achieve automatic recognition and classification of different objects or defects.
[0003] Among them, the method for detecting bottle label defects based on image processing refers to using an image acquisition device to obtain the label image on the surface of the bottle, and detecting label defects through steps such as image preprocessing, feature analysis, and classification judgment. This method covers key technical matters such as label area extraction, image comparison analysis, geometric shape detection, and color anomaly recognition. Specific methods include obtaining label boundary information through edge detection methods to segment the effective detection area; using color space conversion and histogram analysis methods to identify color anomalies of the label; using morphological processing methods to detect geometric deformations such as label breakage and wrinkling; and comparing the content of the label image based on feature matching methods to identify defects such as missing and misalignment. The entire detection process takes image processing technology as the core, and comprehensively evaluates the label image through various analysis methods to complete the automatic detection of bottle label defects.
[0004] In the prior art, during the label area extraction process, it usually relies on edge detection methods to obtain boundary information. In the case of complex backgrounds or large changes in illumination, it is easy to produce incorrect segmentation, affecting the detection accuracy. The color anomaly recognition method is only based on color space conversion and histogram analysis, and it is difficult to adapt to the diversity of label materials and color changes under different illumination conditions, resulting in insufficient detection stability. When the morphological processing method is used to detect geometric deformations such as label breakage and wrinkling, it relies on fixed structural elements and is difficult to adaptively adjust for different types of labels, easily ignoring subtle defects. The feature matching method is mainly based on template comparison. In the case of complex label patterns or printing errors, it is easy to produce false detections and missed detections. The overall detection process lacks multi-level and multi-scale data analysis means and fails to fully utilize the texture and structural characteristics of label materials, resulting in limitations in detection accuracy and robustness and being difficult to meet the requirements of high-precision quality detection in practical applications. Summary of the Invention
[0005] To solve the technical problems existing in the prior art, an embodiment of the present invention provides a method and system for detecting defects in glass bottle labels based on image processing. The technical solution is as follows:
[0006] A method for detecting defects in glass bottle labels based on image processing, comprising the following steps:
[0007] S1: Obtain a high-resolution image by using a fixed-angle light source and near-infrared irradiation, perform noise suppression processing through gradient enhancement filtering, detect the label edge, identify the boundary of the label area, and obtain the label area image;
[0008] S2: Divide the detection units on the label surface according to the label area image, extract the fiber arrangement direction, calculate the main direction angle of the label, analyze the direction gradient change rate, judge the abnormal fiber arrangement, and obtain the direction abnormal area;
[0009] S3: According to the direction abnormal area, detect the fiber direction mutation points in the abnormal area on the label surface, calculate the spatial density value of the mutation points, screen the density of the mutation points according to the fracture density threshold, and obtain the fiber fracture area;
[0010] S4: Based on the fiber fracture area, obtain the fiber direction consistency index and the fracture point density at each scale, calculate the difference value of the abnormal degree at each scale, screen the abnormal areas where the difference value exceeds the difference value threshold, and obtain the scale abnormal area;
[0011] S5: According to the scale abnormal area, analyze the fluctuation cumulative amplitude and the direction concentration deviation value of each abnormal area, classify and identify minor scratches, tears, drops, and label misalignment defects, and obtain the classification result of glass bottle label defects.
[0012] As a further solution of the present invention, the label area image includes edge gradient direction data, label area boundary information, and gradient enhancement filtering results. The direction abnormal area includes direction gradient change rate data, direction consistency index value, and direction consistency abnormal interval. The fiber fracture area includes mutation point spatial density value, fracture density threshold, and fiber fracture distribution area. The scale abnormal area includes consistency volatility calculation value, density change rate evaluation value, and abnormal detection difference threshold. The glass bottle label defect result includes minor scratch defect, label tear defect, label drop defect, and label misalignment defect.
[0013] As a further solution of the present invention, the specific steps of obtaining a high-resolution image by using a fixed-angle light source and near-infrared irradiation, performing noise suppression processing through gradient enhancement filtering, detecting the label edge, and identifying the boundary of the label area are as follows:
[0014] S101: Obtain the image of the glass bottle label irradiated by a fixed-angle light source. Invoke a near-infrared band light source, adjust the illumination angle to a fixed range, use a high-resolution imaging device to record the optical characteristics of the label surface, screen the pixel regions that meet the set illumination intensity range, eliminate the uneven illumination regions, and obtain the illumination uniformity data of the label surface;
[0015] S102: Based on the illumination uniformity data of the label surface, invoke gradient-enhanced filtering, calculate the gray gradient values of the image pixel points, calculate the local gray change rate for the high-frequency noise regions, set the local gray change rate threshold, screen the noise regions that exceed the threshold and adjust the gray values of these regions, and obtain the smoothness data of the label image;
[0016] S103: According to the smoothness data of the label image, detect the edge pixels with prominent gray gradient changes, calculate the gradient direction, screen the label region according to connectivity analysis, eliminate the non-connected regions, extract the pixel information of the label region, and obtain the label region image.
[0017] As a further solution of the present invention, the specific steps for dividing the detection units on the label surface according to the label region image, extracting the fiber arrangement direction, calculating the main direction angle of the label, analyzing the direction gradient change rate, and judging the abnormal fiber arrangement to obtain the direction abnormal region are as follows:
[0018] S201: According to the label region image, divide the local detection units, extract the pixel data and pixel gray gradient values within the units, screen the stable regions and obtain the gradient direction, and obtain the fiber arrangement direction data;
[0019] S202: Based on the fiber arrangement direction data, invoke the structure tensor to calculate the local gradient information, screen the regions where the gradient amplitude exceeds the set threshold, calculate the main direction angle within the detection unit, record the direction angle as two-dimensional direction data, calculate the direction change rate between adjacent units, screen the regions with prominent changes, and obtain the local direction gradient change rate;
[0020] S203: According to the local direction gradient change rate, calculate the direction consistency index, screen the deviated regions according to the consistency threshold, judge whether the fiber arrangement is abnormal, mark the abnormal regions, and obtain the direction abnormal region.
[0021] As a further solution of the present invention, the specific steps for detecting the fiber direction mutation points in the abnormal region on the label surface according to the direction abnormal region, calculating the spatial density value of the mutation points, and screening the density of the mutation points according to the fracture density threshold to obtain the fiber fracture region are as follows:
[0022] S301: Based on the direction abnormal region, detect the fiber direction mutation points within the abnormal region, extract the pixel coordinates of the mutation points, calculate the Euclidean distance between adjacent mutation points, screen the mutation point aggregation regions not exceeding the Euclidean distance, and obtain the mutation point spatial density data;
[0023] S302: According to the mutation point spatial density data, calculate the number of mutation points within the current spatial area, record the density value and construct the regional distribution range, set the fracture density threshold, screen the regions where the mutation point density exceeds the threshold, judge the connectivity of the high-density regions, eliminate the isolated high-density points, screen the continuous regions meeting the criteria, mark their boundaries, and obtain the fiber fracture density distribution;
[0024] S303: According to the fiber fracture density distribution, extract the regions with density exceeding the limit, calculate the regional connectivity, screen the connected regions, establish the boundary of the fiber fracture region, and obtain the fiber fracture region.
[0025] As a further solution of the present invention, for calculating the Euclidean distance d between adjacent mutation points ij , the formula is adopted:
[0026]
[0027] where x i , x j respectively represent the horizontal coordinates of mutation points i and j in the image coordinate system, y i , y j respectively represent the vertical coordinates of mutation points i and j in the image coordinate system, θ k represents the fiber direction angle of the kth mutation point, θ mean represents the average direction angle of all mutation points, and N represents the total number of mutation points within the calculation region.
[0028] As a further solution of the present invention, based on the fiber fracture region, the specific steps to obtain the fiber direction consistency index and fracture point density at each scale, calculate the difference value of the abnormal degree at each scale, and screen the abnormal regions where the difference value exceeds the difference value threshold to obtain the scale abnormal region are as follows:
[0029] S401: Based on the fiber fracture region, obtain the fiber direction consistency index and fracture point density at each scale, extract the direction change trend at each scale, calculate the consistency volatility, and obtain the scale direction change data;
[0030] S402: According to the scale direction change data, calculate the difference value of the abnormal degree at each scale, screen the detection units exceeding the preset difference value threshold, analyze the connectivity based on the spatial distribution of the detection units, eliminate the isolated abnormal units, retain the continuous abnormal regions, and record the abnormal region range to obtain the scale abnormal difference value distribution;
[0031] S403: According to the distribution of the scale anomaly difference values, screen the regions that are anomalous at all scales, analyze the connectivity of the scale anomaly regions, eliminate isolated anomaly units, construct the boundaries of the anomaly regions, and obtain the scale anomaly regions.
[0032] As a further solution of the present invention, for calculating the difference value D of the anomaly degree at each scale scale , the formula:
[0033]
[0034] where N is the total number of detection units at the current scale, M is the total number of detection units in the anomaly region, θ i,scale is the fiber direction angle of the i-th detection unit at the current scale, θ mean,scale is the average direction angle of all detection units at the current scale, θ i,scale-1 is the fiber direction angle of the i-th detection unit at the previous scale, θ mean,scale-1 is the average direction angle of all detection units at the previous scale, δ j,scale is the direction deviation value of the j-th anomaly detection unit at the current scale, δ j,scale-1 is the direction deviation value of the j-th anomaly detection unit at the previous scale.
[0035] As a further solution of the present invention, according to the scale anomaly regions, analyze the fluctuation cumulative amplitude and direction concentration deviation value of each anomaly region, classify and identify minor scratches, tears, drops, and label misalignment defects, and the specific steps for obtaining the classification result of the glass bottle label defects are as follows:
[0036] S501: Based on the scale anomaly regions, with reference to the fiber fracture regions and direction anomaly regions, calculate the fluctuation cumulative amplitude of the anomaly regions, extract the fluctuation change trend and analyze the spatial distribution characteristics, and obtain the fluctuation cumulative data of the anomaly regions;
[0037] S502: According to the fluctuation cumulative data of the anomaly regions, calculate the direction concentration deviation value of the anomaly regions, analyze the gradient change of the direction deviation value, according to the spatial distribution difference of the fluctuation cumulative amplitude and the gradient distribution of the direction concentration deviation value, compare the direction stability within the anomaly regions, screen the regions with the same type of direction deviation characteristics, and obtain the direction deviation distribution of the anomaly regions;
[0038] S503: According to the direction deviation distribution of the anomaly regions, judge the defect types of the anomaly regions, screen the regions that meet the defect characteristics, classify minor scratches, tears, drops, and label misalignment, and obtain the classification result of the glass bottle label defects.
[0039] An image processing-based glass bottle label defect detection system, the system includes:
[0040] The optical imaging module uses a fixed-angle light source and near-infrared band illumination to obtain a high-resolution label image, suppresses noise through gradient-enhanced filtering, detects edge features and identifies the boundary of the label area, and generates a label area image;
[0041] The direction feature analysis module divides local detection units according to the label area image, calculates the fiber arrangement direction, obtains gradient information using the structure tensor, analyzes the direction difference between adjacent units, calculates the direction consistency index, and obtains the direction anomaly area;
[0042] The fiber breakage detection module detects the fiber direction mutation points in the abnormal area on the label surface according to the direction anomaly area, extracts the spatial distribution density of the mutation points and calculates the spatial density value of the mutation points, screens the mutation point density according to the breakage density threshold, and obtains the fiber breakage area;
[0043] The multi-scale anomaly recognition module recalculates the fiber direction consistency index and the breakage point density at each scale based on the fiber breakage area, obtains the direction change trend at each scale, calculates the difference value of the anomaly degree at each scale through the cross-validation of the consistency volatility and the density change rate at each scale, marks the detection units with the difference value exceeding the difference value threshold as abnormal areas, and screens the areas that are abnormal at each scale to obtain the scale anomaly area;
[0044] The defect classification and evaluation module calculates the cumulative amplitude of fluctuations and the direction concentration deviation of the abnormal area based on the scale anomaly area, classifies through the spatial distribution difference of the cumulative amplitude of fluctuations and the gradient distribution difference of the direction concentration deviation value, and identifies defects such as minor scratches, tears, drops, and label misalignment, to obtain the glass bottle label defect result.
[0045] The beneficial effects brought by the technical solution provided by the embodiments of the present invention at least include:
[0046] The combination of high-resolution image acquisition and gradient-enhanced filtering improves the recognition accuracy of the label area. The division of local detection units and the analysis of the fiber arrangement direction make the positioning of the direction anomaly area more accurate. The spatial density analysis of the mutation point distribution effectively distinguishes the degree of fiber breakage and avoids misjudgment. The multi-scale calculation combined with the cross-validation of the consistency volatility and the density change rate enhances the stability of defect detection. The gradient analysis of the cumulative amplitude of fluctuations and the direction concentration deviation value improves the accuracy of defect classification and can effectively distinguish defects such as scratches, tears, drops, and label misalignment. The comprehensive multi-dimensional data analysis and optimization strategy enhance the detection adaptability and reliability and meet the complex quality assessment requirements. Description of the Drawings
[0047] To more clearly illustrate the technical solutions in the embodiments of the present invention, the following will briefly introduce the drawings required for the description of the embodiments. Obviously, the drawings in the following description are only some embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other drawings can be obtained based on these drawings.
[0048] Figure 1 is the method flow chart of the present invention;
[0049] Figure 2 is the schematic diagram of the refinement process of step S1 of the present invention;
[0050] Figure 3 is the schematic diagram of the refinement process of step S2 of the present invention;
[0051] Figure 4 is the schematic diagram of the refinement process of step S3 of the present invention;
[0052] Figure 5 is the schematic diagram of the refinement process of step S4 of the present invention;
[0053] Figure 6 is the schematic diagram of the refinement process of step S5 of the present invention;
[0054] Figure 7 is the system module diagram of the present invention. Specific embodiments
[0055] The following will describe the technical solutions in the present invention with reference to the drawings.
[0056] In the embodiments of the present invention, words such as "exemplarily" and "for example" are used to represent examples, illustrations or explanations. Any embodiment or design solution described as an "example" in the present invention should not be construed as being more preferred or more advantageous than other embodiments or design solutions. Exactly, the use of the word "example" is intended to present concepts in a specific manner. In addition, in the embodiments of the present invention, the meaning expressed by "and / or" can be both, or either one of the two can be selected.
[0057] In the embodiments of the present invention, "image" and "picture" can sometimes be used interchangeably. It should be noted that when their differences are not emphasized, the meanings they express are the same. "(of)", "corresponding" and "corresponding" can sometimes be used interchangeably. It should be noted that when their differences are not emphasized, the meanings they express are the same.
[0058] In the embodiments of the present invention, sometimes subscripts such as W1 may be written in a non-subscript form such as W1. When their differences are not emphasized, the meanings they express are the same.
[0059] To make the technical problems, technical solutions and advantages to be solved by the present invention clearer, the following will be described in detail with reference to the accompanying drawings and specific embodiments.
[0060] Please refer to Figure 1 , the present invention provides a technical solution: a method for detecting bottle label defects based on image processing, including the following steps:
[0061] S1: Obtain a high-resolution image by using a fixed-angle light source and near-infrared irradiation, perform noise suppression processing through gradient enhancement filtering, detect the label edge, identify the label area boundary, and obtain the label area image;
[0062] S2: Divide the detection units on the label surface according to the label area image, extract the fiber arrangement direction, calculate the main direction angle of the label, analyze the direction gradient change rate, judge the abnormal fiber arrangement, and obtain the direction abnormal area;
[0063] S3: According to the direction abnormal area, detect the fiber direction mutation points in the abnormal area on the label surface, calculate the spatial density value of the mutation points, screen the mutation point density according to the fracture density threshold, and obtain the fiber fracture area;
[0064] S4: Based on the fiber fracture area, obtain the fiber direction consistency index and fracture point density at each scale, calculate the difference value of the abnormal degree at each scale, screen the abnormal areas with the difference value exceeding the difference value threshold, and obtain the scale abnormal area;
[0065] S5: According to the scale abnormal area, analyze the fluctuation cumulative amplitude and direction concentration deviation value of each abnormal area, classify and identify minor scratches, tears, drops, and label misalignment defects, and obtain the classification result of bottle label defects.
[0066] The label area image includes edge gradient direction data, label area boundary information, and gradient enhancement filtering results. The direction abnormal area includes direction gradient change rate data, direction consistency index value, and direction consistency abnormal interval. The fiber fracture area includes mutation point spatial density value, fracture density threshold, and fiber fracture distribution area. The scale abnormal area includes consistency volatility calculation value, density change rate evaluation value, and abnormal detection difference threshold. The bottle label defect result includes minor scratch defect, label tear defect, label drop defect, and label misalignment defect.
[0067] Please refer to Figure 2 , the specific steps of obtaining a high-resolution image by using a fixed-angle light source and near-infrared irradiation, performing noise suppression processing through gradient enhancement filtering, detecting the label edge, and identifying the label area boundary are as follows:
[0068] S101: Obtain the image of the glass bottle label irradiated by a fixed-angle light source. Call the near-infrared band light source, adjust the illumination angle to a fixed range, use a high-resolution imaging device to record the optical characteristics of the label surface, screen the pixel regions that meet the set illumination intensity range, eliminate the uneven illumination regions, and obtain the illumination uniformity data of the label surface;
[0069] When obtaining the image of the glass bottle label, first irradiate the surface of the glass bottle with a fixed-angle light source. After calling the near-infrared band light source, adjust the incident angle between the light source and the label surface to the set range. For example, set the incident angle to be between 30° and 45°. Use an optical angle measuring instrument to monitor the incident light angle in real time, and control its error within 0.5°. Then use a high-resolution imaging device, such as a 50-million-pixel industrial camera, to record the optical characteristics of the label surface. The optical characteristics include pixel brightness, reflectivity, surface texture information, etc. During this process, perform pixel brightness analysis on the obtained image. Set the illumination intensity range to 120 to 180 gray values, and call the pixel point brightness calculation formula L = 0.299R + 0.587G + 0.114B to obtain the brightness value of each pixel, where R, G, and B are the pixel values of the red, green, and blue channels respectively. Compare the set threshold range, screen the pixel regions that meet the illumination intensity range, and eliminate all pixel points below 120 or above 180 to ensure the illumination uniformity of the label surface. Subsequently, calculate the illumination uniformity based on the screened pixel regions, and use the local mean calculation method to obtain the brightness mean of each region. For example, calculate the average brightness of a 10×10 pixel region where L i is the brightness value of each pixel in this region. Eliminate the data of the regions where the uniformity exceeds the set deviation range (for example, the uniformity deviation exceeds 15%) to ensure the reliability of the finally obtained illumination uniformity data of the label surface.
[0070] S102: Based on the illumination uniformity data of the label surface, call gradient enhancement filtering, calculate the gray gradient value of the image pixel points, calculate the local gray change rate for the high-frequency noise regions, set the local gray change rate threshold, screen the noise regions that exceed the threshold and adjust the gray value of this region to obtain the smoothness data of the label image;
[0071] Based on the obtained illumination uniformity data of the label surface, perform gradient enhancement filtering on the image and calculate the gray gradient value of each pixel point. First, call the neighborhood difference calculation method to calculate the gray gradient difference in the up, down, left, right, and diagonal directions of each pixel respectively, and use the formula to calculate the gradient value, where I x,yRepresents the grayscale value of a pixel at the (x, y) coordinates. After calculation, it is compared with a set threshold. For example, if the set gradient threshold is 15, and the gradient value of a certain pixel exceeds this threshold, it is marked as a high-frequency noise area. Subsequently, the local grayscale change rate is calculated for the high-frequency noise area. A 5×5 pixel area centered on this pixel is selected, the grayscale mean M is calculated, and then the grayscale change rate of all pixels within this area is calculated. If the grayscale change rate is greater than 0.2, it is determined that this pixel is an abnormal grayscale point and needs to be adjusted. The adjustment method uses local mean replacement, that is, the average grayscale value of this area is used to replace the original grayscale value of this pixel. Finally, the adjusted image is obtained, and the overall label image smoothness data is further calculated. The calculation method uses the mean square error method to obtain the global grayscale uniformity of the image, such as calculating the mean square error. Where is the global grayscale mean of the image, N is the total number of pixels, and the D value is used as a measure of smoothness.
[0072] S103: According to the label image smoothness data, detect the edge pixels with prominent grayscale gradient changes, calculate the gradient direction, analyze and screen the label areas according to connectivity, eliminate non-connected areas, extract the pixel information of the label areas, and obtain the label area image;
[0073] According to the calculated label image smoothness data, further detect the edge pixels with prominent grayscale gradient changes. Select the pixel points with grayscale gradient values greater than 20 as candidate edge pixels, and calculate their gradient directions. The gradient direction is determined by the formula After obtaining the gradient direction, use the connectivity analysis method to check the continuity of adjacent edge pixels. Analyze in an 8-neighborhood manner, that is, if at least 3 of the 8 pixels adjacent to a certain edge pixel are also edge pixels, it is determined that it belongs to a continuous edge, otherwise this pixel is eliminated. Finally, retain the connected areas and perform screening. Use the regional area calculation method to calculate the number of pixels in the connected area. If the number of pixels in a certain connected area is less than 100, it is determined that it is an isolated edge and is eliminated. Only retain the label areas that meet the set area range. Finally, extract the pixel information of the label areas to form a complete label area image.
[0074] Please refer to Figure 3 , and divide the detection units on the label surface according to the label area image, extract the fiber arrangement direction, calculate the main direction angle of the label, analyze the direction gradient change rate, and judge the abnormal fiber arrangement. The specific steps for obtaining the direction abnormal area are as follows:
[0075] S201: According to the label area image, divide the local detection units, extract the pixel data within each unit, analyze the fiber arrangement direction within each unit, and obtain the fiber arrangement direction data;
[0076] According to the label area image, first divide the label area into multiple local detection units. The division method can be based on the image resolution and the actual size of the label area. Set the size of each detection unit to 50×50 pixels. Subsequently, extract the pixel data within each unit, including the grayscale values of all pixels in each unit. For each local unit, calculate the main direction of the pixels in this area. First, calculate the grayscale values of the pixel points in each unit. Using the structure tensor method, calculate the local grayscale change situation to determine the fiber arrangement direction within the unit. The structure tensor is composed of local image gradient information. During the calculation process, use the gradient calculation formula. Set the neighborhood of each pixel within the unit to a 3×3 pixel block. The local gradient value calculation method is as follows: Then calculate the covariance matrix of the local gradient, obtain the main eigenvalue and eigenvector, thereby determining the fiber arrangement direction of each unit. For example, when the eigenvector of a certain detection unit points to 45°, it indicates that the fibers in this area are mainly arranged along the 45° direction. Finally, by calculating the fiber directions of all units, the overall data of the fiber arrangement direction within the entire label area is obtained.
[0077] S202: Based on the fiber arrangement direction data, call the structure tensor to calculate the local gradient information, filter the areas where the gradient amplitude exceeds the set threshold, calculate the main direction angle within the detection unit, record the direction angle as two-dimensional direction data, calculate the direction change rate between adjacent units, filter the areas with prominent changes, and obtain the local direction gradient change rate;
[0078] Based on the fiber arrangement direction data, then call the structure tensor to calculate the local gradient information. For each detection unit, calculate the gradient amplitude within this unit. The calculation method can use the gradient amplitude formula, and the formula is By calculating the gradient amplitude of each detection unit, filter out the areas where the gradient amplitude exceeds the set threshold. Set the gradient amplitude threshold to 0.5. When the gradient amplitude is greater than 0.5, this area is considered a gradient mutation area. Then calculate the main direction angle of this area. The main direction angle is obtained by calculating the angle of the eigenvector. For example, when the direction of the main eigenvector is Record the main direction angle as two-dimensional direction data. The recorded value of the main direction angle is between -180° and 180°. Then calculate the direction change rate between adjacent units. The direction change rate can be obtained by calculating the difference in the main directions of adjacent units. Set the threshold to 10°. If the difference in the main directions of two adjacent units is greater than 10°, it is considered that the direction in this area has changed significantly. Finally, filter out the areas with prominent changes and calculate the gradient change rate of the local direction. The calculation method is: where θ1 and θ2 are the main direction angles of adjacent units. If the change rate is greater than 0.5, it is considered that there is a relatively significant direction gradient change in this area. Finally, obtain the local direction gradient change rate data.
[0079] S203: Calculate the direction consistency index based on the local direction gradient change rate, screen the deviation regions according to the consistency threshold, determine whether the fiber arrangement is abnormal, mark the abnormal regions, and obtain the direction abnormal regions;
[0080] Based on the calculated local direction gradient change rate, calculate the direction consistency index. The direction consistency index is used to measure the consistency of fiber arrangement within each detection unit, and is obtained according to the difference in direction angles within each detection unit. The calculation formula is: where, θ i is the main direction angle of the i-th detection unit, θ avg is the average main direction angle of all units, N is the number of detection units. The obtained direction consistency index C value should be between 0 and 1. When the C value is close to 1, it indicates that the fiber arrangement is highly consistent; otherwise, it indicates that the arrangement is relatively scattered. According to the set consistency threshold, for example, the consistency threshold is set to 0.8. If the consistency index C of a certain region is less than 0.8, it is considered that the fiber arrangement in this region is abnormal, and the abnormal region is marked as the direction abnormal region. Finally, the data of the direction abnormal region is obtained. These abnormal regions may be caused by uneven fiber arrangement or defects. The marked regions can be used for further analysis or quality control.
[0081] Please refer to Figure 4 , according to the direction abnormal region, detect the fiber direction mutation points in the abnormal region on the label surface, calculate the spatial density value of the mutation points, and screen the mutation point density according to the fracture density threshold. The specific steps to obtain the fiber fracture region are as follows:
[0082] S301: Based on the direction abnormal region, detect the fiber direction mutation points in the abnormal region, extract the pixel coordinates of the mutation points, calculate the Euclidean distance between adjacent mutation points, screen the mutation point aggregation regions that do not exceed the Euclidean distance, and obtain the spatial density data of the mutation points;
[0083] For the Euclidean distance between adjacent mutation points, use the formula:
[0084]
[0085] Calculate the corrected Euclidean distance between mutation points, screen the mutation point aggregation regions that do not exceed the Euclidean distance, and obtain the spatial density data of the mutation points;
[0086] where, d ij represents the corrected Euclidean distance between adjacent mutation points i and j, x i , x j represent the horizontal coordinates of mutation points i and j in the image coordinate system respectively, y i , y j represent the vertical coordinates of mutation points i and j in the image coordinate system respectively, θk The fiber orientation angle representing the k-th mutation point, θ mean represents the average orientation angle of all mutation points, and N represents the total number of mutation points within the calculation region;
[0087] Detailed explanation of the formula and the derivation process of formula calculation:
[0088] d ij represents the modified Euclidean distance between adjacent mutation points i and j, indicating the spatial distance between the two mutation points, and is corrected by combining the deviation of their directions. This value is used to measure the degree of spatial aggregation between mutation points.
[0089] x i ,x j are the horizontal coordinates of mutation points i and j in the image coordinate system, and y i ,y j are their vertical coordinates. The coordinate data is obtained from the pixel positions of the mutation points acquired in the image.
[0090] θ k represents the fiber orientation angle of the k-th mutation point, and this orientation angle is based on the angle of each mutation point relative to the image coordinate system during the detection process. The orientation angle is calculated through the light intensity gradient or direction change of the corresponding point in the image. Usually, the change in the gray value of the image is used to estimate the orientation angle, which is specifically obtained through the gradient method or direction calculation.
[0091] θ mean is the average orientation angle of all mutation points. This value is calculated by taking the average of the orientation angles of all mutation points:
[0092]
[0093] where N is the total number of mutation points.
[0094] N represents the total number of mutation points, and usually, the image processing program identifies the positions of mutation points according to the criteria defined by threshold changes or direction deviations. Suppose 100 mutation points are detected in a certain region, then N = 100.
[0095] Calculation process:
[0096] Calculate the Euclidean distance: Suppose the coordinates of mutation points i and j are x i = 15, y i = 30 and x j = 18, y j = 35,
[0097]
[0098] This indicates that the spatial distance between mutation points i and j is 5.83 pixels.
[0099] Calculate the direction deviation: Suppose there are 3 mutation points with direction angles of θ1 = 45°, θ2 = 50°, and θ3 = 55°. Calculate the average direction angle:
[0100]
[0101] For the mutation point k = 1, its direction deviation is:
[0102] |θ1 - θ mean | = |45° - 50°| = 5°;
[0103] For other mutation points, calculate the direction deviation and sum them up:
[0104] |θ2 - θ mean | = |50° - 50°| = 0°;
[0105] |θ3 - θ mean | = |55° - 50°| = 5°;
[0106] Sum up the direction deviations and divide by the total number of mutation points N = 3:
[0107]
[0108] Correct the Euclidean distance: Substitute the result obtained above into the formula. Suppose the calculated spatial distance is 5.83 and the direction deviation is 3.33. Finally, we get:
[0109] d ij = 5.83 + 3.33 = 9.16;
[0110] This result indicates that the corrected Euclidean distance between mutation points i and j is 9.16, which comprehensively considers the spatial distance and direction deviation. This value can reflect the clustering situation among mutation points. If the distance in the clustering region is less than a certain set threshold (e.g., 10), then these mutation points can be considered to belong to the same clustering region.
[0111] S302: According to the spatial density data of mutation points, calculate the number of mutation points in the current spatial area, record the density value, construct the regional distribution range, set the fracture density threshold, screen the regions where the mutation point density exceeds the threshold, judge the connectivity of the high-density regions, remove isolated high-density points, screen the continuous regions that meet the criteria, mark their boundaries, and obtain the fiber fracture density distribution;
[0112] According to the spatial density data of mutation points, first calculate the number of mutation points in the current spatial area. The spatial area of each detection region is set to 100×100 pixels. The calculation method is to count the total number N of all mutation points in this region, and then calculate the density value D. The formula is Where A is the total number of pixels in the detection area. Record the density values of all detection areas and construct the regional distribution range. Normalize the density values of each area. The normalization calculation method uses Where D min and D max are the minimum and maximum density values in all areas respectively. Set the fracture density threshold. For example, set the threshold to 0.7. When the normalized density value of a certain area is greater than 0.7, it is determined as a high-density area. Then judge the connectivity of the high-density area. The connectivity judgment uses the 8-neighborhood analysis method, that is, if at least 50% of the adjacent pixel points of a certain high-density area belong to the high-density area, it is determined as a connected area, otherwise this point is excluded as an isolated high-density point. Finally, screen the continuous areas that meet the standards and use the boundary tracking algorithm to mark their boundaries. The boundary tracking method uses the clockwise search method. Starting from the high-density point in the upper left corner, move along the edge of the high-density area, mark the coordinates of all boundary points, and record the final boundary data. Finally, obtain the fiber fracture density distribution.
[0113] S303: According to the fiber fracture density distribution, extract the density overrun areas, calculate the regional connectivity, screen the connected areas, establish the boundary of the fiber fracture area, and obtain the fiber fracture area;
[0114] According to the fiber fracture density distribution, first extract the density overrun areas. The screening method for the overrun areas is to check whether the density value exceeds the set threshold. For example, the density threshold is set to 0.8. If the density value D′ of a certain area is greater than 0.8, it is determined as an overrun area. Then calculate the regional connectivity. The connectivity calculation method uses the depth-first search (DFS) method. Starting from each overrun area, gradually search its adjacent overrun areas. If an area is connected to at least 3 adjacent areas, it is determined as a continuous area, otherwise this area is excluded. Subsequently, screen all connected areas and establish the boundary of the fiber fracture area. The boundary establishment method is to perform edge detection on the connected areas, extract the coordinates of all boundary pixels, and record the boundary data. Finally, obtain the fiber fracture area.
[0115] Please refer to Figure 5 , based on the fiber fracture area, obtain the fiber direction consistency index and the fracture point density at each scale, calculate the difference value under the abnormal degree at each scale, and screen the abnormal areas where the difference value exceeds the difference value threshold. The specific steps to obtain the scale abnormal areas are as follows:
[0116] S401: Based on the fiber fracture area, obtain the fiber direction consistency index and the fracture point density at each scale, extract the change trend of each scale direction, calculate the consistency volatility, and obtain the scale direction change data;
[0117] Based on the fiber fracture region, first obtain the fiber direction consistency index at each scale. The consistency index can be obtained by calculating the standard deviation of the fiber directions within each detection unit. Set the detection unit at each scale to be 50×50 pixels, calculate the fiber directions of all pixels within the unit, and use, for example, the mean and standard deviation of the direction angles to measure the consistency of the fiber arrangement within the region. If the standard deviation is small, it indicates that the fiber arrangement in the region is relatively consistent; otherwise, it indicates inconsistency. Then, obtain the fracture point density at each scale. The density is calculated by counting the number of fracture points within a unit area. Set the area to be a 100×100 pixel region. If the number of fracture points within the region is 20, the density of this region is 0.2 fracture points / pixel. Subsequently, extract the direction change trend at each scale. The direction change trend is measured by calculating the change in fiber direction between adjacent scales. The calculation method is: Δθ=|θ scale -θ scale+1 |, where θ scale is the fiber direction angle at the current scale, and Δθ represents the change in fiber direction. If the change amount exceeds the set threshold (for example, the set threshold is 15°), it is considered that the fiber direction in this region has changed significantly. Finally, calculate the consistency volatility. The volatility can be determined by calculating the standard deviation of the direction changes between multiple scales. If the standard deviation is large, it indicates that the direction changes at multiple scales are relatively drastic. Finally, obtain the scale direction change data.
[0118] S402: According to the scale direction change data, calculate the difference value of the anomaly degree at each scale, screen out the detection units that exceed the preset difference value threshold, analyze the connectivity based on the spatial distribution of the detection units, eliminate isolated anomaly units, retain continuous anomaly regions, and record the range of the anomaly regions to obtain the scale anomaly difference value distribution;
[0119] Calculate the difference value of the anomaly degree at each scale, using the formula:
[0120]
[0121] Screen out the detection units that exceed the preset difference value threshold, analyze the connectivity based on the spatial distribution of the detection units, eliminate isolated anomaly units, retain continuous anomaly regions, and record the range of the anomaly regions to obtain the scale anomaly difference value distribution;
[0122] Among them, D scale represents the anomaly difference value at the current scale, N is the total number of detection units at the current scale, M is the total number of detection units in the anomaly region, θ i,scale is the fiber direction angle of the i-th detection unit at the current scale, θ mean,scale is the average direction angle of all detection units at the current scale, θ i,scale-1 is the fiber direction angle of the i-th detection unit at the previous scale, θmean,scale-1 is the average direction angle of all detection units at the previous scale, δ j,scale is the direction deviation value of the j-th anomaly detection unit at the current scale, δ j,scale-1 is the direction deviation value of the j-th anomaly detection unit at the previous scale;
[0123] D scale represents the anomaly difference value at the current scale, indicating the direction change difference between the current scale and the previous scale, and its calculation is based on the direction deviation of each detection unit and the direction deviation of the anomaly unit; N is the total number of detection units at the current scale, that is, the number of detection units divided in the image at this scale. Assuming there are 100 detection units at the current scale, then N = 100; θ i,scale is the fiber direction angle of the i-th detection unit at the current scale, representing the main direction of this detection unit. Assuming the direction angle of the 1st detection unit at the current scale is θ 1,scale = 45°, and the 2nd detection unit is θ 2,scale = 50°, and so on; θ mean,scale is the average direction angle of all detection units at the current scale, and the calculation formula is:
[0124]
[0125] Assuming the direction angles of all detection units are 45°, 50°, 48°, 52° respectively, then:
[0126]
[0127] θ i,scale-1 is the fiber direction angle of the i-th detection unit at the previous scale. Assuming the direction angle of the 1st detection unit at the previous scale is θ 1,scale-1 = 47°, and the 2nd detection unit is θ 2,scale-1 = 49°, and so on. θ mean,scale-1 is the average direction angle of all detection units at the previous scale. Assuming this value is θ mean,scale-1 = 48°. δ j,scale is the direction deviation value of the j-th anomaly detection unit at the current scale, indicating the difference between this unit and the average direction angle of the current scale. Assuming the direction deviation of the first anomaly unit at the current scale is δ 1,scale = |45° - 48.75°| = 3.75°. δ j,scale-1 is the direction deviation value of the j-th anomaly detection unit at the previous scale. Assuming its value is δ 1,scale-1 = |47° - 48°| = 1°. M is the total number of anomaly detection units. Assuming this value is 10, that is, there are 10 anomaly detection units at the current scale.
[0128] Operation steps:
[0129] 1. Calculate the directional deviation difference of each detection unit between the current scale and the previous scale:
[0130] |(θ 1,scale - θ mean,scale ) - (θ 1,scale-1 - θ mean,scale-1 )| = |(45° - 48.75°) - (47° - 48°)| = |(-3.75°) - (-1°)| = |-3.75° + 1°| = 2.75°;
[0131] 2. Calculate and sum up the differences of all detection units. Assume the sum is 3. Calculate the total sum of the directional deviation differences:
[0132]
[0133] 4. Substitute into the formula to calculate D scale :
[0134]
[0135] The result shows that the abnormal difference value at the current scale is 1.575°, indicating that the abnormal directional deviation at this scale is relatively significant, suggesting large directional fluctuations and inconsistencies. This value can be further used to screen abnormal regions, detect whether there are unstable directional features within the detection region, and thus support subsequent defect classification and processing.
[0136] S403: According to the distribution of scale abnormal difference values, screen the regions that are abnormal at all scales, analyze the connectivity of the scale abnormal regions, eliminate isolated abnormal units, construct the boundaries of the abnormal regions, and obtain the scale abnormal regions;
[0137] According to the distribution of scale abnormal difference values, first screen out the regions that are abnormal at all scales. The screening method is to check the abnormal marks of each detection unit at all scales. If a unit is marked as abnormal at each scale, then this unit is considered as an overall abnormal region. Then, analyze the connectivity of the scale abnormal regions. The connectivity is judged by the depth - first search (DFS) algorithm. If an abnormal region is connected to at least three adjacent regions, it is considered as a connected abnormal region. Otherwise, eliminate the isolated abnormal units, and further construct the boundaries of the abnormal regions. The boundary construction method is realized through edge detection. Use the edge detection algorithm to extract the outer contour of the connected region. Finally, obtain the complete scale abnormal regions. By calibrating the boundaries and recording the region coordinates, finally obtain the clear scale abnormal regions and mark the coordinate positions of all abnormal units.
[0138] Please refer to Figure 6, according to the scale anomaly regions, analyze the cumulative amplitude of fluctuations and the directional concentration deviation values of each anomaly region, classify and identify minor scratches, tears, drops, and label misalignment defects. The specific steps to obtain the classification results of glass bottle label defects are as follows:
[0139] S501: Based on the scale anomaly regions, referring to the fiber fracture regions and directional anomaly regions, calculate the cumulative amplitude of fluctuations in the anomaly regions, extract the fluctuation change trends, and analyze the spatial distribution characteristics to obtain the cumulative fluctuation data of the anomaly regions;
[0140] Based on the scale anomaly regions, first, according to the previously calculated fiber fracture regions and directional anomaly regions, calculate the cumulative amplitude of fluctuations in the anomaly regions. The calculation of the cumulative amplitude of fluctuations is achieved by comparing the change amplitudes within the region at each scale. Set the cumulative amplitude of fluctuations within the region as the sum of the changes between multiple measurement scales. Use the formula: where W is the cumulative amplitude of fluctuations, and ΔX i represents the change amplitude at the i-th scale, n is the number of scales. The change amplitude is calculated as the difference value of the fiber direction in adjacent scales for each region. If the change amplitude at a certain scale is greater than the set threshold (for example, the set threshold is 10°), it is considered that the cumulative amplitude of fluctuations in this region is large. Then, extract the fluctuation change trends at each scale. The fluctuation change trend refers to the trend of the change direction and its amplitude at multiple scales. The extraction method is to calculate the relative change rate of fluctuations at each scale. Use the formula: Calculate the volatility of each scale. If the volatility of a certain scale exceeds the set threshold (such as 0.3), it is considered that the fluctuations in this region are relatively intense. Finally, by analyzing the spatial distribution characteristics, obtain the cumulative fluctuation data of the anomaly regions. The analysis of the spatial distribution characteristics is completed by comparing the cumulative amplitudes of fluctuations in different regions. Finally, obtain the cumulative fluctuation data of each anomaly region.
[0141] S502: According to the cumulative fluctuation data of the anomaly regions, calculate the directional concentration deviation values of the anomaly regions, analyze the gradient changes of the directional deviation values, and based on the spatial distribution differences of the cumulative amplitudes of fluctuations and the gradient distribution of the directional concentration deviation values, compare the directional stability within the anomaly regions, and screen out the regions with similar directional deviation characteristics to obtain the directional deviation distribution of the anomaly regions;
[0142] According to the cumulative fluctuation data of the anomaly regions, first calculate the directional concentration deviation values of each anomaly region. The directional concentration deviation values are obtained by calculating the deviation degrees of the directions of each detection unit within the region. The calculation method is: where θ i is the direction angle of the i-th detection unit, θ meanis the average direction angle of all detection units in the area, and N is the number of detection units. If the deviation value is greater than the set threshold (for example, 20°), it is considered that the direction in this area is relatively scattered. Then, analyze the gradient change of the direction deviation value. The gradient change represents the change speed of the deviation value in space, and the calculation method is as follows: where δ current and δ previous are the deviation values at the current and previous positions respectively, and Δx is the spatial distance between the two. If the gradient change exceeds the set threshold (for example, 0.5), it is considered that the direction in this area fluctuates greatly. Subsequently, according to the difference in the spatial distribution of the fluctuation cumulative amplitude and the gradient distribution of the direction concentration deviation value, the areas with similar direction deviation characteristics are screened out. The similar direction deviation characteristics within the area can be measured by calculating the standard deviation of the deviation value. If the standard deviation is less than the set value (for example, less than 10°), it is considered that the area has consistent direction deviation characteristics, and finally, the direction deviation distribution of the abnormal area is obtained.
[0143] S503: According to the direction deviation distribution of the abnormal area, judge the defect type of the abnormal area, screen out the areas that meet the defect characteristics, classify minor scratches, tears, drops, and label misalignments, and obtain the classification result of the glass bottle label defects;
[0144] According to the direction deviation distribution of the abnormal area, judge the defect type of the abnormal area. The basis for judging the defect type is the distribution of the direction deviation within the area. If the deviation value within a certain area is large and changes violently, it may belong to defects such as tears or drops. If the deviation value is small and relatively uniform, it may be minor scratches or label misalignments. When screening out the areas that meet the defect characteristics, the standard deviation of the deviation value distribution is used to assist in the judgment. The areas with a larger standard deviation are classified as larger defects such as tears and drops, and the areas with a smaller standard deviation are classified as minor scratches or label misalignments. Then, classify according to the characteristics of the deviation distribution. The classification basis is the fluctuation range of the deviation value and the change trend within the area. Finally, the classification result of the glass bottle label defects is obtained. The classification result includes several common defect types such as minor scratches, tears, drops, and label misalignments. Each type of area has corresponding standard values and intervals in the defect type classification.
[0145] Please refer to Figure 7 , an image - based glass bottle label defect detection system, which includes:
[0146] The optical imaging module uses a fixed - angle light source and near - infrared band illumination to obtain a high - resolution label image. Gradient - enhanced filtering suppresses noise, detects edge features, and identifies the boundary of the label area to generate a label area image;
[0147] The direction feature analysis module divides the local detection units according to the label area image, calculates the fiber arrangement direction, obtains the gradient information using the structure tensor, analyzes the direction difference between adjacent units, calculates the direction consistency index, and obtains the direction anomaly area.
[0148] The fiber breakage detection module detects the fiber direction mutation points in the abnormal area on the label surface according to the direction anomaly area, extracts the spatial distribution density of the mutation points and calculates the spatial density value of the mutation points, and screens the mutation point density according to the breakage density threshold to obtain the fiber breakage area.
[0149] The multi-scale anomaly recognition module is based on the fiber breakage area, recalculates the fiber direction consistency index and the breakage point density at each scale, obtains the direction change trend at each scale, and calculates the difference value of the anomaly degree at each scale through the cross-validation of the consistency volatility and the density change rate at each scale. Mark the detection units with the difference value exceeding the difference value threshold as the abnormal area, and screen the areas that are abnormal at each scale to obtain the scale abnormal area.
[0150] The defect classification and evaluation module is based on the scale abnormal area, calculates the cumulative amplitude of fluctuations and the direction concentration deviation of the abnormal area, classifies through the spatial distribution difference of the cumulative amplitude of fluctuations and the gradient distribution difference of the direction concentration deviation value, and identifies slight scratches, tears, drops and label misalignment defects to obtain the glass bottle label defect result.
[0151] As described above, it is only the specific implementation manner of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art within the technical scope disclosed by the present invention can easily think of changes or substitutions, which should all be covered within the protection scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.
Claims
1. A method for detecting defects in glass bottle labels based on image processing, characterized in that, It includes the following steps: S1: Obtain a high-resolution image by using a fixed-angle light source and near-infrared irradiation, perform noise suppression processing through gradient enhancement filtering, detect the label edge, identify the label area boundary, and obtain the label area image; S2: Divide the detection units on the label surface according to the label area image, extract the fiber arrangement direction, calculate the main direction angle of the label, analyze the direction gradient change rate, judge the abnormal fiber arrangement, and obtain the direction abnormal area; S3: According to the direction abnormal area, detect the fiber direction mutation points in the abnormal area on the label surface, calculate the spatial density value of the mutation points, screen the mutation point density according to the fracture density threshold, and obtain the fiber fracture area; S4: Based on the fiber fracture area, obtain the fiber direction consistency index and the fracture point density at each scale, calculate the difference value of the abnormal degree at each scale, screen the abnormal areas with the difference value exceeding the difference value threshold, and obtain the scale abnormal area; S5: According to the scale abnormal area, analyze the fluctuation cumulative amplitude and the direction concentration deviation value of each abnormal area, classify and identify minor scratches, tears, drops, and label misalignment defects, and obtain the classification result of the glass bottle label defects.
2. The method for detecting defects of glass bottle labels based on image processing according to claim 1, wherein: The label area image includes edge gradient direction data, label area boundary information, and gradient enhancement filtering results. The direction abnormal area includes direction gradient change rate data, direction consistency index values, and direction consistency abnormal intervals. The fiber fracture area includes mutation point spatial density values, fracture density thresholds, and fiber fracture distribution areas. The scale abnormal area includes consistency volatility calculation values, density change rate evaluation values, and abnormal detection difference thresholds. The glass bottle label defect results include minor scratch defects, label tear defects, label drop defects, and label misalignment defects.
3. The method for detecting defects of glass bottle labels based on image processing according to claim 1, wherein: The specific steps for obtaining a high-resolution image by using a fixed-angle light source and near-infrared irradiation, performing noise suppression processing through gradient enhancement filtering, detecting the label edge, and identifying the label area boundary are as follows: S101: Obtain the glass bottle label image irradiated by the fixed-angle light source, call the near-infrared band light source, adjust the illumination angle to a fixed range, use a high-resolution imaging device to record the optical characteristics of the label surface, screen the pixel area that meets the set illumination intensity range, eliminate the uneven illumination area, and obtain the label surface illumination uniformity data; S102: Based on the label surface illumination uniformity data, call the gradient enhancement filtering, calculate the gray gradient value of the image pixel points, calculate the local gray change rate for the high-frequency noise area, set the local gray change rate threshold, screen the noise area exceeding the threshold and adjust the gray value of this area, and obtain the label image smoothness data; S103: According to the label image smoothness data, detect the edge pixels with prominent gray gradient changes, calculate the gradient direction, screen the label area according to the connectivity analysis, eliminate the non-connected area, extract the pixel information of the label area, and obtain the label area image.
4. The method for detecting defects of glass bottle labels based on image processing according to claim 1, characterized in that: The specific steps for detecting the unit that divides the label surface according to the label area image, extracting the fiber arrangement direction, calculating the main direction angle of the label, analyzing the direction gradient change rate, and judging the abnormal fiber arrangement to obtain the direction abnormal area are as follows: S201: According to the label area image, divide the local detection unit, extract the pixel data within the unit, calculate the pixel gray gradient value, screen the stable area and obtain the gradient direction to obtain the fiber arrangement direction data; S202: Based on the fiber arrangement direction data, call the structure tensor to calculate the local gradient information, screen the areas where the gradient amplitude exceeds the set threshold, calculate the main direction angle within the detection unit, record the direction angle as two-dimensional direction data, calculate the direction change rate between adjacent units, screen the areas with prominent changes, and obtain the local direction gradient change rate; S203: According to the local direction gradient change rate, calculate the direction consistency index, screen the deviation areas according to the consistency threshold, judge whether the fiber arrangement is abnormal, mark the abnormal areas, and obtain the direction abnormal area.
5. The method for detecting defects of glass bottle labels based on image processing according to claim 1, wherein: The specific steps for detecting the fiber direction mutation points in the abnormal area of the label surface according to the direction abnormal area, calculating the spatial density value of the mutation points, and screening the mutation point density according to the fracture density threshold to obtain the fiber fracture area are as follows: S301: Based on the direction abnormal area, detect the fiber direction mutation points in the abnormal area, extract the pixel coordinates of the mutation points, calculate the Euclidean distance between adjacent mutation points, screen the mutation point aggregation areas that do not exceed the Euclidean distance, and obtain the mutation point spatial density data; S302: According to the mutation point spatial density data, calculate the number of mutation points within the current spatial area, record the density value and construct the regional distribution range, set the fracture density threshold, screen the areas where the mutation point density exceeds the threshold, judge the connectivity of the high-density areas, remove the isolated high-density points, screen the continuous areas that meet the standards, mark their boundaries, and obtain the fiber fracture density distribution; S303: According to the fiber fracture density distribution, extract the density overrun areas, calculate the regional connectivity, screen the connected areas, establish the boundary of the fiber fracture area, and obtain the fiber fracture area.
6. The method for detecting defects of glass bottle labels based on image processing according to claim 5, characterized in that: For calculating the Euclidean distance d between adjacent mutation points ij , the formula is used: where x i , x j represent the horizontal coordinates of mutation points i and j in the image coordinate system respectively, and y i , y j represent the vertical coordinates of mutation points i and j in the image coordinate system respectively, and θ k represents the fiber orientation angle of the k-th mutation point, and θ mean represents the average orientation angle of all mutation points, and N represents the total number of mutation points in the calculation area.
7. The method for detecting defects of glass bottle labels based on image processing according to claim 1, characterized in that: The specific steps for obtaining the fiber direction consistency index and fracture point density at each scale based on the fiber fracture area, calculating the difference value of the abnormal degree at each scale, and screening the abnormal areas where the difference value exceeds the difference value threshold to obtain the scale abnormal area are as follows: S401: Based on the fiber fracture area, obtain the fiber direction consistency index and fracture point density at each scale, extract the direction change trend at each scale, calculate the consistency volatility, and obtain the scale direction change data; S402: According to the scale direction change data, calculate the difference value of the abnormal degree at each scale, screen the detection units that exceed the preset difference value threshold, analyze the connectivity based on the spatial distribution of the detection units, remove the isolated abnormal units, retain the continuous abnormal areas, and record the abnormal area range to obtain the scale abnormal difference value distribution; S403: According to the distribution of the scale anomaly difference values, screen the regions that are anomalous at all scales, analyze the connectivity of the scale anomaly regions, remove isolated anomaly units, construct the boundaries of the anomaly regions, and obtain the scale anomaly regions.
8. The method for detecting defects of glass bottle labels based on image processing according to claim 7, characterized in that: For calculating the difference value D of the anomaly degree at each scale scale , the formula is adopted: Among them, N is the total number of detection units at the current scale, M is the total number of detection units in the abnormal area, and θ i,scale is the fiber orientation angle of the i-th detection unit at the current scale, and θ mean,scale is the average orientation angle of all detection units at the current scale, and θ i,scale-1 is the fiber orientation angle of the i-th detection unit at the previous scale, and θ mean,scale-1 is the average orientation angle of all detection units at the previous scale, and δ j,scale is the direction deviation value of the j-th abnormal detection unit at the current scale, and δ j,scale-1 is the direction deviation value of the j-th abnormal detection unit at the previous scale.
9. The method for detecting defects of glass bottle labels based on image processing according to claim 1, wherein: Based on the scale anomaly regions, analyze the cumulative amplitude of fluctuations and the direction concentration deviation values of each anomaly region, classify and identify minor scratches, tears, drops, and label misalignment defects, and the specific steps for obtaining the classification results of glass bottle label defects are as follows: S501: Based on the scale anomaly regions, with reference to the fiber fracture regions and the direction anomaly regions, calculate the cumulative amplitude of fluctuations in the anomaly regions, extract the trend of fluctuations and analyze the spatial distribution characteristics, and obtain the cumulative fluctuation data of the anomaly regions; S502: According to the cumulative fluctuation data of the anomaly regions, calculate the direction concentration deviation values of the anomaly regions, analyze the gradient changes of the direction deviation values, and based on the spatial distribution differences of the cumulative amplitude of fluctuations and the gradient distribution of the direction concentration deviation values, compare the direction stability within the anomaly regions, screen the regions with similar direction deviation characteristics, and obtain the direction deviation distribution of the anomaly regions; S503: According to the direction deviation distribution of the anomaly regions, determine the defect types of the anomaly regions, screen the regions that meet the defect characteristics, classify minor scratches, tears, drops, and label misalignment, and obtain the classification results of glass bottle label defects.
10. A glass bottle label defect detection system based on image processing, characterized in that, Execute according to the image - processing - based glass bottle label defect detection method described in any one of claims 1 - 9. The system includes: The optical imaging module uses a fixed - angle light source and near - infrared band illumination to obtain a high - resolution label image, suppresses noise through gradient - enhanced filtering, detects edge features and identifies the boundaries of the label region, and generates a label region image; The direction feature analysis module divides the local detection units according to the label region image, calculates the fiber arrangement direction, obtains gradient information using the structure tensor, analyzes the direction differences between adjacent units, calculates the direction consistency index, and obtains the direction anomaly regions; The fiber fracture detection module, based on the direction anomaly regions, detects the fiber direction mutation points in the abnormal regions on the label surface, extracts the spatial distribution density of the mutation points and calculates the spatial density value of the mutation points, and screens the mutation point density according to the fracture density threshold to obtain the fiber fracture regions; The multi - scale anomaly recognition module, based on the fiber fracture regions, recalculates the fiber direction consistency index and the fracture point density at each scale, obtains the direction change trend at each scale, calculates the difference values of the anomaly degree at each scale through the cross - verification of the consistency volatility and density change rate at each scale, marks the detection units with difference values exceeding the difference value threshold as anomaly regions, screens the regions that are anomalous at all scales, and obtains the scale anomaly regions; The defect classification and evaluation module, based on the scale anomaly regions, calculates the cumulative amplitude of fluctuations and the direction concentration deviation of the anomaly regions, classifies through the spatial distribution differences of the cumulative amplitude of fluctuations and the gradient distribution differences of the direction concentration deviation values, and identifies minor scratches, tears, drops, and label misalignment defects to obtain the glass bottle label defect results.
Citation Information
Patent Citations
Periodic texture background defect label automatic labeling method and device, equipment and medium
CN111739020A
Defect detection method for adaptively matching bottle body label based on template
CN113537301A
Label detection method and device, electronic equipment and storage medium
CN116543173A
Label printing defect detection method and system based on machine vision
CN117368226A
Label inspection method and inspection device
JP2020134365A
Cited By
Tire tread production control method based on image recognition
CN120894374A
Defect segmentation positioning method and system for inorganic mineral casting image
CN121073980A
Defect segmentation positioning method and system for inorganic mineral cast image
CN121073980B
Anchor cable defect identification method based on artificial intelligence
CN121095681A
Vision and sensing fusion-based medicine bottle array detection system
CN121259032A