A glass bottle label defect detection method and system based on image processing
By combining fixed-angle light source and near-infrared irradiation with gradient enhancement filtering and fiber arrangement direction analysis, the problems of insufficient accuracy and stability in glass bottle label detection in existing technologies are solved, and high-precision defect identification and classification are achieved.
Patent Information
- Application Number
- CN202510247632.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-04
- Publication Date
- 2025-10-10
- Estimated Expiration
- 2045-03-04
AI Technical Summary
In the existing technologies for glass bottle label defect detection, edge detection, color anomaly recognition and morphological processing methods lack accuracy under complex backgrounds or lighting changes, and are difficult to adapt to the diversity of label materials and changes in lighting conditions, resulting in insufficient detection stability and accuracy, and unable to meet the needs of high-precision quality inspection.
A fixed-angle light source and near-infrared irradiation are used to acquire high-resolution images, gradient enhancement filtering is used to suppress noise, label edges are detected and region boundaries are identified, fiber arrangement direction analysis and multi-scale anomaly recognition are combined to calculate fiber direction consistency and break point density, and minor scratches, tears, drops and label misalignment defects are classified and identified.
The recognition accuracy of label areas is improved, the positioning direction of abnormal areas is more accurate, the stability and classification accuracy of defect detection are enhanced, and different types of defects can be effectively distinguished to meet complex quality assessment needs.
Smart Images

Figure CN120318477B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image analysis and detection, and in particular to a method and system for detecting defects in glass bottle labels based on image processing. Background Art
[0002] The field of image analysis and inspection technology encompasses methods such as target recognition, feature extraction, defect detection, and classification based on image data. The core of this technology involves analyzing image data through computer vision, pattern recognition, and image processing techniques to achieve automatic detection and assessment of target objects. Image analysis and inspection technology is widely used in a variety of fields, including industrial production quality control, medical imaging analysis, security monitoring, and automated inspection. Its systematic approach encompasses key steps such as image acquisition, preprocessing, feature extraction, target detection, and classification. Commonly used techniques include edge detection, morphological processing, texture analysis, and deep learning to achieve automatic recognition and classification of different objects or defects.
[0003] The image processing-based glass bottle label defect detection method uses an image acquisition device to capture label images from the glass bottle surface and detects label defects through image preprocessing, feature analysis, and classification. This method encompasses key technical aspects such as label region extraction, image comparison and analysis, geometric morphology detection, and color anomaly identification. Specific methods include edge detection to obtain label boundary information to segment the effective detection area; color space conversion and histogram analysis to identify label color anomalies; morphological processing to detect geometric deformations such as label breakage and wrinkling; and feature matching to compare label image content and identify defects such as missing or misaligned parts. The entire detection process is centered on image processing technology, using a variety of analytical methods to comprehensively evaluate label images to achieve automatic detection of glass bottle label defects.
[0004] In the process of label area extraction, existing technologies usually rely on edge detection methods to obtain boundary information. In the case of complex backgrounds or large changes in lighting, 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, which is difficult to adapt to the diversity of label materials and color changes under different lighting conditions, resulting in insufficient detection stability. When morphological processing methods are used to detect geometric deformations such as label breakage and wrinkling, they rely on fixed structural elements, making it difficult to adapt to different types of labels and easily overlooking subtle defects. Feature matching methods are mainly based on template comparison, which is prone to false detection and missed detection when the label pattern is complex or there are printing errors. The overall detection process lacks multi-level and multi-scale data analysis methods, and fails to fully utilize the texture and structural characteristics of the label material, resulting in limitations in detection accuracy and robustness. In practical applications, it is difficult to meet the needs of high-precision quality detection. Summary of the Invention
[0005] In order to solve the technical problems existing in the prior art, the embodiments of the present invention provide 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 comprises the following steps:
[0007] S1: Use fixed-angle light source and near-infrared irradiation to obtain high-resolution images, suppress noise through gradient enhancement filtering, detect label edges, identify label area boundaries, and obtain label area images;
[0008] S2: Dividing the detection unit of 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, judging the fiber arrangement abnormality, and obtaining the direction abnormality area;
[0009] S3: detecting fiber direction mutation points within the abnormal region on the label surface according to the abnormal direction region, calculating the spatial density value of the mutation points, screening the density of the mutation points according to the fracture density threshold, and obtaining the fiber fracture region;
[0010] S4: Based on the fiber fracture area, obtaining the fiber direction consistency index and fracture point density at each scale, calculating the difference value of the abnormality degree at each scale, screening the abnormal area whose difference value exceeds the difference value threshold, and obtaining the scale abnormal area;
[0011] S5: Based on the scale abnormal area, analyze the fluctuation cumulative amplitude and directional concentrated deviation value of each abnormal area, classify and identify minor scratches, tears, drops, and label misalignment defects, and obtain the glass bottle label defect classification result.
[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 directional abnormality area includes directional gradient change rate data, directional consistency index value, and directional consistency abnormality interval; the fiber breakage area includes mutation point spatial density value, breakage density threshold, and fiber breakage distribution area; the scale abnormality area includes consistency fluctuation rate calculation value, density change rate evaluation value, and abnormality detection difference threshold; the glass bottle label defect results include slight scratch defects, label tear defects, label drop defects, and label misalignment defects.
[0013] As a further solution of the present invention, a fixed-angle light source and near-infrared irradiation are used to obtain a high-resolution image, and a gradient enhancement filter is used to suppress noise, detect label edges, identify label area boundaries, and obtain a label area image. The specific steps are as follows:
[0014] S101: Acquire an image of a glass bottle label illuminated by a fixed-angle light source, call a near-infrared 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, select pixel areas that meet the set illumination intensity range, eliminate areas with uneven illumination, and obtain illumination uniformity data on the label surface;
[0015] S102: Based on the label surface illumination uniformity data, a gradient enhancement filter is invoked to calculate the grayscale gradient value of the image pixel, the local grayscale change rate is calculated for the high-frequency noise area, a local grayscale change rate threshold is set, noise areas exceeding the threshold are filtered out and the grayscale value of the area is adjusted to obtain label image smoothness data;
[0016] S103: Detect edge pixels with prominent grayscale gradient changes based on the label image smoothness data, calculate the gradient direction, analyze and filter the label area based on connectivity, eliminate non-connected areas, extract label area pixel information, and obtain a label area image.
[0017] As a further solution of the present invention, the specific steps of dividing the detection unit of 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, judging the fiber arrangement abnormality, and obtaining the direction abnormality area are as follows:
[0018] S201: Divide the local detection unit according to the label area image, extract the pixel data and pixel grayscale gradient value in the unit, screen the stable area and obtain the gradient direction to obtain the fiber arrangement direction data;
[0019] S202: Based on the fiber arrangement direction data, the structural tensor is called to calculate local gradient information, regions where the gradient amplitude exceeds a set threshold are screened, the main direction angle within the detection unit is calculated, the direction angle is recorded as two-dimensional direction data, the direction change rate between adjacent units is calculated, regions with prominent changes are screened, and the local direction gradient change rate is obtained;
[0020] S203: Calculate the direction consistency index according to the local direction gradient change rate, screen the deviation area according to the consistency threshold, determine whether the fiber arrangement is abnormal, mark the abnormal area, and obtain the direction abnormal area.
[0021] As a further solution of the present invention, based on the abnormal direction area, the fiber direction mutation points in the abnormal area on the label surface are detected, the spatial density value of the mutation points is calculated, and the density of the mutation points is screened according to the fracture density threshold. The specific steps of obtaining the fiber fracture area are as follows:
[0022] S301: Based on the direction abnormal area, detecting fiber direction mutation points in the abnormal area, extracting the pixel coordinates of the mutation points, calculating the Euclidean distance between adjacent mutation points, screening the mutation point clustering area that does not exceed the Euclidean distance, and obtaining the mutation point spatial density data;
[0023] S302: Calculate the number of mutation points within the current spatial area based on the mutation point spatial density data, record the density value and construct a regional distribution range, set a fracture density threshold, filter areas where the mutation point density exceeds the threshold, determine the connectivity of high-density areas, remove isolated high-density points, filter continuous areas that meet the criteria, mark their boundaries, and obtain fiber fracture density distribution;
[0024] S303: extracting density-exceeding regions according to the fiber breakage density distribution, calculating regional connectivity, screening connected regions, establishing fiber breakage region boundaries, and obtaining fiber breakage regions.
[0025] As a further solution of the present invention, for calculating the Euclidean distance d between adjacent mutation points ij , using the formula:
[0026]
[0027] Among them, x i ,x j Represent the horizontal coordinates of mutation points i and j in the image coordinate system, y i ,y j Represent the vertical coordinates of mutation points i and j in the image coordinate system, θ k represents the fiber orientation 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 in the calculation area.
[0028] As a further solution of the present invention, based on the fiber breakage area, the fiber direction consistency index and the breakage point density are obtained at each scale, the difference value of the abnormality degree at each scale is calculated, and the abnormal area whose difference value exceeds the difference value threshold is screened. The specific steps of obtaining the scale abnormal area are as follows:
[0029] S401: Based on the fiber breakage area, obtain the fiber direction consistency index and the breakage point density at each scale, extract the direction change trend of each scale, calculate the consistency fluctuation rate, and obtain scale direction change data;
[0030] S402: Calculating the difference value of the abnormality degree at each scale based on the scale direction change data, screening the detection units that exceed the preset difference value threshold, analyzing the connectivity based on the spatial distribution of the detection units, eliminating isolated abnormal units, retaining continuous abnormal areas, and recording the range of the abnormal areas to obtain the scale abnormality difference value distribution;
[0031] S403: According to the scale anomaly difference value distribution, screen out regions that are abnormal at all scales, analyze the connectivity of the scale anomaly regions, remove isolated abnormal units, construct the abnormal region boundary, and obtain the scale anomaly region.
[0032] As a further solution of the present invention, for calculating the difference value D of the abnormality degree at each scale scale , using the formula:
[0033]
[0034] 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, θ i,scale is the fiber orientation 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 orientation angle of the i-th detection unit in the previous scale, θ mean,scale-1 is the average direction angle of all detection units at the previous scale, δ j,scale is the directional deviation value of the j-th anomaly detection unit at the current scale, δ j,scale-1 is the directional deviation value of the j-th anomaly detection unit in the previous scale.
[0035] As a further solution of the present invention, based on the scale abnormal area, the cumulative amplitude of fluctuation and the directional concentrated deviation value of each abnormal area are analyzed to classify and identify minor scratches, tears, drops, and label misalignment defects. The specific steps for obtaining the glass bottle label defect classification result are as follows:
[0036] S501: Based on the scale abnormal area, with reference to the fiber breakage area and the direction abnormal area, calculate the cumulative amplitude of the abnormal area fluctuation, extract the fluctuation change trend and analyze the spatial distribution characteristics to obtain the abnormal area fluctuation cumulative data;
[0037] S502: Calculating the directional concentration deviation value of the abnormal area based on the accumulated fluctuation data of the abnormal area, analyzing the gradient change of the directional deviation value, comparing the directional stability within the abnormal area based on the spatial distribution difference of the accumulated fluctuation amplitude and the gradient distribution of the directional concentration deviation value, screening areas with similar directional deviation characteristics, and obtaining the directional deviation distribution of the abnormal area;
[0038] S503: Determine the defect type of the abnormal area based on the directional deviation distribution of the abnormal area, screen the area that meets the defect characteristics, classify slight scratches, tears, drops, and label misalignment, and obtain a glass bottle label defect classification result.
[0039] A glass bottle label defect detection system based on image processing, the system comprising:
[0040] The optical imaging module uses a fixed-angle light source and near-infrared band illumination to obtain high-resolution label images, and uses gradient enhancement filtering to suppress noise, detect edge features, identify label area boundaries, and generate label area images.
[0041] The directional feature analysis module divides the local detection unit according to the label area image, calculates the fiber arrangement direction, obtains gradient information using the structural tensor, analyzes the directional differences of adjacent units, calculates the directional consistency index, and obtains the directional abnormality area;
[0042] The fiber breakage detection module detects the fiber direction mutation points within the abnormal area on the label surface according to the abnormal direction area, extracts the spatial distribution density of the mutation points and calculates the spatial density value of the mutation points, and screens the density of the mutation points according to the fracture density threshold to obtain the fiber breakage area;
[0043] The multi-scale anomaly recognition module recalculates the fiber direction consistency index and the fracture point density at each scale based on the fiber fracture area, obtains the direction change trend of each scale, calculates the difference value of the abnormal degree at each scale through cross-validation of the consistency fluctuation rate and the density change rate at each scale, marks the detection unit whose difference value exceeds the difference value threshold as an abnormal area, and screens the areas with abnormalities at each scale to obtain scale abnormal areas;
[0044] The defect classification and evaluation module calculates the cumulative amplitude of fluctuations and the directional concentration deviation of the abnormal area based on the scale abnormal area, classifies it according to the spatial distribution difference of the cumulative amplitude of fluctuations and the gradient distribution difference of the directional concentration deviation value, and identifies minor scratches, tears, drops and label misalignment defects to obtain the glass bottle label defect results.
[0045] The beneficial effects brought about by the technical solution provided by the embodiment of the present invention include at least:
[0046] High-resolution image acquisition combined with gradient enhancement filtering improves label region recognition accuracy. Local detection unit division and fiber alignment direction analysis enable more precise location of directional anomalies. Spatial density analysis of mutation point distribution effectively distinguishes the degree of fiber breakage and avoids misjudgment. Multi-scale calculation combined with consistency fluctuation rate and density change rate cross-validation enhances defect detection stability. Gradient analysis of the cumulative amplitude of fluctuations and the directional concentration deviation value improves defect classification accuracy, effectively distinguishing scratches, tears, drops, label misalignment, and other defects. Comprehensive multi-dimensional data analysis and optimization strategies enhance detection adaptability and reliability to meet complex quality assessment needs. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0048] Figure 1 is a flow chart of the method of the present invention;
[0049] Figure 2 This is a detailed flow chart of step S1 of the present invention;
[0050] Figure 3 This is a schematic diagram of a detailed process of step S2 of the present invention;
[0051] Figure 4 This is a detailed flow chart of step S3 of the present invention;
[0052] Figure 5 This is a detailed flow chart of step S4 of the present invention;
[0053] Figure 6 This is a detailed flow chart of step S5 of the present invention;
[0054] Figure 7 It is a system module diagram of the present invention. DETAILED DESCRIPTION
[0055] The technical solution of the present invention is described below in conjunction with the accompanying drawings.
[0056] In the embodiments of the present invention, words such as "exemplarily" and "for example" are used to indicate examples, illustrations, or explanations. Any embodiment or design described as an "exemplary" in the present invention should not be interpreted as being preferred or advantageous over other embodiments or designs. Rather, the use of the word "exemplary" is intended to present concepts in a concrete manner. Furthermore, in the embodiments of the present invention, "and / or" can mean both or either of the two.
[0057] In the embodiments of the present invention, the terms "image" and "picture" may be used interchangeably. It should be noted that, when the distinction between them is not emphasized, their intended meanings are the same. The terms "of," "corresponding," and "corresponding" may be used interchangeably. It should be noted that, when the distinction between them is not emphasized, their intended meanings are the same.
[0058] In the embodiments of the present invention, sometimes a subscript such as W1 may be written as a non-subscript such as W1. When the difference is not emphasized, the meanings to be expressed are the same.
[0059] In order to make the technical problems, technical solutions and advantages to be solved by the present invention clearer, a detailed description will be given below with reference to the accompanying drawings and specific embodiments.
[0060] See also Figure 1 The present invention provides a technical solution: a method for detecting defects in glass bottle labels based on image processing, comprising the following steps:
[0061] S1: Use fixed-angle light source and near-infrared irradiation to obtain high-resolution images, suppress noise through gradient enhancement filtering, detect label edges, identify label area boundaries, and obtain label area images;
[0062] S2: Divide the detection unit of 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 fiber arrangement abnormality, and obtain the direction abnormality area;
[0063] S3: Based on the abnormal direction area, detect the fiber direction mutation points in the abnormal area 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 to obtain the fiber fracture area;
[0064] S4: Based on the fiber fracture area, the fiber direction consistency index and fracture point density are obtained at each scale, the difference value of the abnormal degree at each scale is calculated, and the abnormal area with the difference value exceeding the difference value threshold is screened to obtain the scale abnormal area;
[0065] S5: Based on the scale abnormal area, analyze the cumulative amplitude of fluctuations and the directional concentrated deviation value of each abnormal area, classify and identify minor scratches, tears, drops, and label misalignment defects, and obtain the glass bottle label defect classification results.
[0066] The label area image includes edge gradient direction data, label area boundary information, and gradient enhancement filtering results. The direction anomaly area includes direction gradient change rate data, direction consistency index value, and direction consistency anomaly interval. The fiber breakage area includes mutation point spatial density value, breakage density threshold, and fiber breakage distribution area. The scale anomaly area includes consistency fluctuation rate calculation value, density change rate evaluation value, and anomaly detection difference threshold. The glass bottle label defect results include slight scratch defects, label tear defects, label drop defects, and label misalignment defects.
[0067] See also Figure 2 , using a fixed-angle light source and near-infrared irradiation to obtain a high-resolution image, performing noise suppression through gradient enhancement filtering, detecting label edges, identifying label area boundaries, and obtaining label area images. The specific steps are as follows:
[0068] S101: Acquire an image of a glass bottle label illuminated by a fixed-angle light source, call a near-infrared 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, select pixel areas that meet the set illumination intensity range, eliminate areas with uneven illumination, and obtain illumination uniformity data on the label surface;
[0069] When acquiring the image of the glass bottle label, first illuminate 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 between 30° and 45°, and use an optical angle measuring instrument to monitor the incident light angle in real time to control its error within 0.5°. Then, use high-resolution imaging equipment, such as a 50-megapixel industrial camera, to record the optical characteristics of the label surface, where the optical characteristics include pixel brightness, reflectivity, surface texture information, etc. In this process, the pixel brightness of the acquired image is analyzed to set the light intensity. The grayscale range is 120 to 180, and the pixel brightness calculation formula L = 0.299R + 0.587G + 0.114B is called 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. The pixel area that meets the light intensity range is screened by comparing with the set threshold range, and all pixels below 120 or above 180 are removed to ensure the uniformity of the label surface illumination. Then, the illumination uniformity calculation is performed based on the screened pixel area, and the local mean calculation method is used to obtain the brightness mean of each area. For example, the average brightness is calculated for a 10×10 pixel area. Among them L i For the brightness value of each pixel in the area, the data of the area where the uniformity exceeds the set deviation range (for example, the uniformity deviation exceeds 15%) is eliminated to ensure the reliability of the final obtained label surface illumination uniformity data.
[0070] S102: Based on the label surface illumination uniformity data, a gradient enhancement filter is invoked to calculate the grayscale gradient value of the image pixel, the local grayscale change rate is calculated for the high-frequency noise area, a local grayscale change rate threshold is set, noise areas exceeding the threshold are filtered out, and the grayscale value of the area is adjusted to obtain label image smoothness data;
[0071] Based on the obtained label surface illumination uniformity data, the image is gradient enhanced and filtered to calculate the grayscale gradient value of each pixel. First, the neighborhood difference calculation method is called to calculate the grayscale gradient difference of each pixel in the up and down, left and right, and diagonal directions respectively. The formula is used Calculate the gradient value, where I x,yThe gray value of the pixel point at (x, y) coordinates is represented, and after calculation, a threshold is set, for example, the gradient threshold is set to 15, if the gradient value of a certain pixel exceeds the threshold, it is marked as a high-frequency noise area, and then the local gray level change rate of the high-frequency noise area is calculated, a 5*5 pixel region centered on the pixel point is selected, the gray level mean M is calculated, and the gray level change rate of all pixels in the region is calculated If the gray level change rate is greater than 0.2, the pixel is determined to be an abnormal gray point and needs to be adjusted. The adjustment method uses local mean replacement, that is, the average gray value of the region is used to replace the original gray value of the pixel. The final 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 gray uniformity of the image, such as calculating the mean square error Wherein is the global gray mean of the image, N is the total number of pixels, and D value is used as the smoothness measurement index.
[0072] S103: According to the label image smoothness data, the edge pixels with prominent gray gradient change are detected, the gradient direction is calculated, the label region is analyzed and screened according to the connectivity, the non-connected regions are removed, the label region pixel information is extracted, and the label region image is obtained;
[0073] According to the calculated label image smoothness data, the edge pixels with prominent gray gradient change are further detected, the pixel points with gray gradient value greater than 20 are selected as candidate edge pixels, and the gradient direction is calculated. The gradient direction uses the formula Determination, after obtaining the gradient direction, the continuity of adjacent edge pixels is checked using the connectivity analysis method, and the analysis is performed in the 8-neighborhood mode, that is, if at least three of the eight adjacent pixels of a certain edge pixel are also edge pixels, it is determined that it belongs to the continuous edge, otherwise the pixel is removed. Finally, the connected regions are retained and screened, the pixel number of the connected regions is calculated using the area calculation method, if the pixel number of a certain connected region is less than 100, it is determined to be an isolated edge and is removed, only the label regions meeting the set area range are retained, and finally the label region pixel information is extracted to form a complete label region image.
[0074] Please refer to Figure 3 , according to the label region image, the detection unit of the label surface is divided, the fiber arrangement direction is extracted, the main direction angle of the label is calculated, the direction gradient change rate is analyzed, the fiber arrangement abnormality is judged, and the specific steps of the direction abnormal region are as follows:
[0075] S201: According to the label region image, a local detection unit is divided, the pixel data in each unit is extracted, the fiber arrangement direction in each unit is analyzed, and the fiber arrangement direction data is obtained;
[0076] Based on the label region image, the label region is first divided into multiple local detection units. The division method can be based on the image resolution and the actual size of the label region, setting the size of each detection unit to 50×50 pixels. Subsequently, the pixel data within each unit is extracted, including the grayscale values of all pixels in each unit. For each local unit, the main direction of the pixels within the area is calculated. First, the grayscale values of the pixels within each unit are calculated. Using the structure tensor method, the local grayscale changes are calculated to determine the fiber arrangement direction within the unit. The structure tensor is composed of local image gradient information. The gradient calculation formula is used during the calculation process. The neighborhood of each pixel in the unit is set to a 3×3 pixel block. The local gradient value is calculated as follows: The covariance matrix of the local gradient is then calculated to obtain the principal eigenvalue and eigenvector, thereby determining the fiber orientation of each unit. For example, when the eigenvector of a detection unit points to 45°, it means that the fibers in that area are mainly arranged along the 45° direction. Finally, by calculating the fiber orientation of all units, the overall data of the fiber orientation in the entire label area is obtained.
[0077] S202: Based on the fiber arrangement direction data, the structural tensor is called to calculate the local gradient information, the area where the gradient amplitude exceeds the set threshold is screened, the main direction angle within the detection unit is calculated, the direction angle is recorded as two-dimensional direction data, the direction change rate between adjacent units is calculated, the area with prominent changes is screened, and the local direction gradient change rate is obtained;
[0078] Based on the fiber arrangement direction data, the structural tensor is then called to calculate the local gradient information. For each detection unit, the gradient amplitude within the unit is calculated. The calculation method can use the gradient amplitude formula, which is: By calculating the gradient amplitude of each detection unit, the area where the gradient amplitude exceeds the set threshold is screened out. The gradient amplitude threshold is set to 0.5. When the gradient amplitude is greater than 0.5, the area is considered to be a gradient mutation area. Then the main direction angle of the area is calculated. The main direction angle is obtained by calculating the angle of the eigenvector. For example, when the direction of the main eigenvector is The main direction angle is recorded as two-dimensional direction data. The main direction angle recording value is between -180° and 180°. Then the direction change rate between adjacent units is calculated. The direction change rate can be calculated by calculating the main direction difference of adjacent units. The threshold is set to 10°. If the main direction difference between two adjacent units is greater than 10°, it is considered that the direction of the area has changed significantly. Finally, the area with prominent changes is screened out and the gradient change rate of the local direction is calculated. The calculation method is: Among them, θ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 more significant directional gradient change in the area, and finally the local directional gradient change rate data is obtained.
[0079] S203: Calculate the direction consistency index according to the local direction gradient change rate, screen the deviation area according to the consistency threshold, judge whether the fiber arrangement is abnormal, mark the abnormal area, and obtain the direction abnormal area;
[0080] According to the calculated local direction gradient change rate, the direction consistency index is calculated, which is used to measure the consistency of the fiber arrangement in each detection unit. The calculation method is to obtain the difference of the direction angle in each detection unit, and 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, and 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 more dispersed. According to the set consistency threshold, for example, if the consistency threshold is set to 0.8, if the consistency index C of a certain area is less than 0.8, it is considered that the fiber arrangement of the area is abnormal, and the abnormal area is marked, and the area is marked as a direction abnormal area. The data of the direction abnormal area is finally obtained. These abnormal areas may be caused by uneven fiber arrangement or defects. The marked area can be used for further analysis or quality control.
[0081] Please refer to Figure 4 , according to the direction abnormal area, detect the fiber direction mutation point in the label surface abnormal area, calculate the spatial density value of the mutation point, and screen the mutation point density according to the fracture density threshold, to obtain the specific steps of the fiber fracture area as follows:
[0082] S301: Based on the direction abnormal area, detect the fiber direction mutation point in the abnormal area, extract the mutation point pixel coordinates, calculate the Euclidean distance between adjacent mutation points, screen the mutation point aggregation area which does not exceed the Euclidean distance, and obtain the mutation point spatial density data;
[0083] For the Euclidean distance between adjacent mutation points, the formula is:
[0084]
[0085] Calculate the corrected Euclidean distance between the mutation points, screen the mutation point aggregation area which does not exceed the Euclidean distance, and obtain the mutation point spatial density data;
[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, and θk represents the fiber orientation 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 in the calculation area;
[0087] Detailed explanation of the formula and the process of formula calculation and derivation:
[0088] d ij Represents the modified Euclidean distance between adjacent mutation points i and j, indicating the spatial distance between the two mutation points, corrected for the deviation in their direction. This value is used to measure the degree of spatial clustering between mutation points.
[0089] x i ,x j is the horizontal coordinate of mutation points i and j in the image coordinate system, y i ,y j The coordinate data is obtained by obtaining the pixel position of the mutation point in the image.
[0090] θ k The fiber orientation angle at the kth mutation point is calculated based on the angle of each mutation point relative to the image coordinate system during the measurement process. The orientation angle is calculated from the intensity gradient or directional change at the corresponding point in the image. This is typically calculated using the grayscale value change of the image, typically using a gradient method or directional calculation.
[0091] θ mean is the average direction angle of all mutation points. This value is calculated by taking the average direction angle of all mutation points:
[0092]
[0093] Where N is the total number of mutation points.
[0094] N represents the total number of mutation points, which are usually identified by image processing programs based on criteria defined by threshold changes or directional deviations. Assume that 100 mutation points are detected in a certain area, then N = 100.
[0095] Calculation process:
[0096] Calculate the Euclidean distance: Assume that 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 means that the spatial distance between mutation points i and j is 5.83 pixels.
[0099] Calculate the direction deviation: Assume there are three 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, the directional deviation is:
[0102] |θ1-θ mean |=|45°-50°|=5°;
[0103] For other mutation points, calculate the directional deviation and sum it:
[0104] |θ2-θ mean |=|50°-50°|=0°;
[0105] |θ3-θ mean |=|55°-50°|=5°;
[0106] Sum the directional deviations and divide by the total number of mutation points N = 3:
[0107]
[0108] Corrected Euclidean distance: Substitute the above calculated results into the formula. Assuming the calculated spatial distance is 5.83 and the directional deviation is 3.33, we get:
[0109] d ij =5.83+3.33=9.16;
[0110] The results show that the modified Euclidean distance between mutation points i and j is 9.16, which takes into account both spatial distance and directional deviation. This value reflects the clustering of mutation points. If the distance between clustered areas is less than a certain threshold (for example, 10), the mutation points are considered to belong to the same cluster.
[0111] S302: Based on the spatial density data of the mutation points, the number of mutation points within the current spatial area is calculated, the density value is recorded and the regional distribution range is constructed, a fracture density threshold is set, areas where the density of mutation points exceeds the threshold are screened, the connectivity of high-density areas is determined, isolated high-density points are removed, continuous areas that meet the criteria are screened, their boundaries are marked, and the fiber fracture density distribution is obtained;
[0112] According to the spatial density data of mutation points, the number of mutation points in the current spatial area is first calculated. The spatial area of each detection area is set to 100×100 pixels. The calculation method is to count the total number N of all mutation points in the area, and then calculate the density value D. The formula is Where A is the total number of pixels in the detection area. The density values of all detection areas are recorded and the regional distribution range is constructed. The density values of each area are normalized. The normalization calculation method is Among them D min and D max The minimum and maximum density values in all areas are used to set the fracture density threshold, for example, the threshold is set to 0.7. When the normalized density value of a certain area is greater than 0.7, it is judged as a high-density area. Then the connectivity of the high-density area is judged. The connectivity judgment adopts the 8-neighborhood analysis method, that is, if at least 50% of the adjacent pixels in a high-density area belong to the high-density area, it is judged to be a connected area. Otherwise, the point is eliminated as an isolated high-density point. Finally, the continuous area that meets the standard is screened and its boundary is marked using the boundary tracking algorithm. The boundary tracking method adopts a clockwise search method, starting from the high-density point in the upper left corner, moving along the edge of the high-density area, marking the coordinates of all boundary points, and recording the final boundary data to finally obtain the fiber fracture density distribution.
[0113] S303: extracting density-exceeding regions based on fiber fracture density distribution, calculating regional connectivity, screening connected regions, establishing fiber fracture region boundaries, and obtaining fiber fracture regions;
[0114] According to the fiber breakage density distribution, the density-exceeding-limit area is first extracted. The screening method for the over-limit area 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 judged to be an over-limit area. Then the connectivity of the area is calculated. The connectivity calculation method adopts the depth-first search (DFS) method. Starting from each over-limit area, its adjacent over-limit areas are gradually searched. If a certain area is connected to at least three adjacent areas, it is judged to be a continuous area. Otherwise, the area is eliminated. Then all connected areas are screened and the boundary of the fiber breakage area is established. The boundary establishment method is to perform edge detection on the connected area, extract the coordinates of all boundary pixels, and record the boundary data to finally obtain the fiber breakage area.
[0115] See also Figure 5 Based on the fiber fracture area, the fiber direction consistency index and fracture point density are obtained at each scale, the difference value of the abnormal degree at each scale is calculated, and the abnormal area with the difference value exceeding the difference value threshold is screened. The specific steps for obtaining the scale abnormal area are as follows:
[0116] S401: Based on the fiber breakage area, obtain the fiber direction consistency index and breakage point density at each scale, extract the direction change trend of each scale, calculate the consistency fluctuation rate, and obtain the scale direction change data;
[0117] Based on the fiber breakage area, we first obtain the fiber direction consistency index at each scale. The consistency index can be obtained by calculating the standard deviation of the fiber direction in each detection unit. The detection unit of each scale is set to 50×50 pixels, and the fiber direction of all pixels in the unit is calculated. For example, the mean and standard deviation of the direction angle are used to measure the consistency of the fiber arrangement in the area. If the standard deviation is small, it means that the fiber arrangement in the area is relatively consistent, otherwise it is inconsistent. Then, the fracture point density at each scale is obtained. The density is calculated by counting the number of fracture points per unit area. The area is set to 100×100 pixels. If the number of fracture points in the area is 20, the density of the area is 0.2 fracture points / pixel. Then, the direction change trend at each scale is extracted. The direction change trend is measured by calculating the fiber direction change between adjacent scales. The calculation method is: Δθ=|θ scale -θ scale+1 |, where θ scale is the fiber orientation angle at the current scale, Δθ represents the change in fiber orientation. If the change exceeds the set threshold (for example, the threshold is set to 15°), it is considered that the fiber orientation in this area has changed significantly. Finally, the consistency fluctuation rate is calculated. The fluctuation rate can be determined by calculating the standard deviation of the orientation changes between multiple scales. If the standard deviation is large, it means that the orientation changes at multiple scales are more drastic, and finally the scale orientation change data is obtained.
[0118] S402: Calculate the difference value of the abnormality degree at each scale based on the scale direction change data, screen the detection units that exceed the preset difference value threshold, analyze the connectivity based on the spatial distribution of the detection units, eliminate isolated abnormal units, retain continuous abnormal areas, and record the scope of the abnormal areas to obtain the scale abnormality difference value distribution;
[0119] Calculate the difference value of the abnormality degree at each scale using the formula:
[0120]
[0121] Screen the detection units that exceed the preset difference value threshold, analyze the connectivity based on the spatial distribution of the detection units, eliminate isolated abnormal units, retain continuous abnormal areas, and record the scope of the abnormal areas to obtain the scale abnormal difference value distribution;
[0122] Among them, D scale represents the abnormal 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 abnormal area, θ i,scale is the fiber orientation 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 orientation angle of the i-th detection unit in the previous scale, θmean,scale-1 is the average direction angle of all detection units at the previous scale, δ j,scale is the directional deviation value of the j-th anomaly detection unit at the current scale, δ j,scale-1 is the directional deviation value of the j-th anomaly detection unit in the previous scale;
[0123] D scale Represents the abnormal difference value at the current scale, indicating the difference in directional change between the current scale and the previous scale. Its calculation is based on the directional deviation of each detection unit and the directional deviation of the abnormal 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 that there are 100 detection units at the current scale, then N = 100; θ i,scale is the fiber orientation angle of the i-th detection unit at the current scale, indicating the main direction of the detection unit. Assume that the orientation angle of the first detection unit at the current scale is θ 1,scale =45°, the second 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 that the direction angles of all detection units are 45°, 50°, 48°, and 52° respectively, then:
[0126]
[0127] θ i,scale-1 is the fiber orientation angle of the i-th detection unit at the previous scale. Assume that the orientation angle of the first detection unit at the previous scale is θ 1,scale-1 =47°, the second 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 that this value is θ mean,scale-1 =48°. j,scale is the directional deviation value of the jth abnormal detection unit at the current scale, which indicates the difference between the unit and the average directional angle of the current scale. Assume that the directional deviation of the first abnormal unit at the current scale is δ 1,scale =|45°-48.75°|=3.75°. δ j,scale-1 is the directional deviation value of the jth 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. Assume that this value is 10, which means 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 the differences of all detection units. Assume that the sum is 3. Calculate the sum of the directional deviation differences:
[0132]
[0133] 4. Substitute into the formula to calculate D scale :
[0134]
[0135] The results indicate that the anomaly difference value at the current scale is 1.575°, indicating significant directional deviation at this scale, indicating large directional fluctuations and inconsistencies. This value can be used to screen out abnormal areas and detect unstable directional characteristics within them, thereby supporting subsequent defect classification and treatment.
[0136] S403: Screening out abnormal areas at all scales based on the scale anomaly difference value distribution, analyzing the connectivity of the scale anomaly areas, removing isolated abnormal units, constructing the abnormal area boundaries, and obtaining the scale anomaly areas;
[0137] According to the distribution of scale anomaly difference values, we first screen out areas 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, it is considered to be an overall abnormal area. Then the connectivity of the scale abnormal area is analyzed. The connectivity is judged by the depth-first search (DFS) algorithm. If an abnormal area is connected to at least three adjacent areas, it is considered to be a connected abnormal area. Otherwise, the isolated abnormal units are eliminated and the boundaries of the abnormal area are further constructed. The boundary construction method is achieved through edge detection. The edge detection algorithm is used to extract the outer contour of the connected area. Finally, a complete scale abnormal area is obtained. By boundary calibration and recording of regional coordinates, a clear scale abnormal area is finally obtained, and the coordinate positions of all abnormal units are marked.
[0138] See also Figure 6Based on the scale abnormal area, the cumulative amplitude of fluctuations and the directional concentrated deviation value of each abnormal area are analyzed to classify and identify minor scratches, tears, drops, and label misalignment defects. The specific steps for obtaining the glass bottle label defect classification results are as follows:
[0139] S501: Based on the scale abnormal area, with reference to the fiber fracture area and the direction abnormal area, calculate the cumulative amplitude of the abnormal area fluctuation, extract the fluctuation change trend and analyze the spatial distribution characteristics to obtain the abnormal area fluctuation cumulative data;
[0140] Based on the scale anomaly area, first calculate the cumulative amplitude of fluctuations in the abnormal area according to the previously calculated fiber breakage area and direction anomaly area. The calculation of the cumulative amplitude of fluctuations is achieved by comparing the amplitude of changes in the area at each scale. The cumulative amplitude of fluctuations in the area is set as the sum of changes between multiple measurement scales, using the formula: Where W is the cumulative amplitude of fluctuation, ΔX i represents the amplitude of change at the i-th scale, n is the number of scales, and the amplitude of change is calculated as the difference in fiber direction at adjacent scales for each region. If the amplitude of change at a certain scale is greater than the set threshold (for example, the threshold is set to 10°), it is considered that the cumulative amplitude of fluctuations in this region is large. Then, the fluctuation trend at each scale is extracted. The fluctuation trend refers to the trend of the direction and amplitude of changes at multiple scales. The extraction method is to calculate the relative change rate of fluctuations at each scale using the formula: The volatility of each scale is calculated. If the volatility of a certain scale exceeds the set threshold (such as 0.3), it is considered that the fluctuation in this area is more severe. Finally, the cumulative fluctuation data of the abnormal area is obtained by analyzing the spatial distribution characteristics. The spatial distribution characteristics analysis is completed by comparing the cumulative amplitude of fluctuations in different areas, and finally the cumulative fluctuation data of each abnormal area is obtained.
[0141] S502: Calculate the directional concentration deviation value of the abnormal area based on the accumulated fluctuation data of the abnormal area, analyze the gradient change of the directional deviation value, compare the directional stability within the abnormal area based on the spatial distribution difference of the accumulated fluctuation amplitude and the gradient distribution of the directional concentration deviation value, screen areas with similar directional deviation characteristics, and obtain the directional deviation distribution of the abnormal area;
[0142] According to the accumulated data of abnormal area fluctuations, the directional concentration deviation value of each abnormal area is first calculated. The directional concentration deviation value is obtained by calculating the deviation degree of the direction of each detection unit in the area. The calculation method is: Among them, θ 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°), the direction of the area is considered to be relatively dispersed. Then, the gradient change of the direction deviation value is analyzed. The gradient change indicates the speed of change of the deviation value in space. The calculation method is: Among them, δ current and δ previous are the deviation values of 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 fluctuation in this area is large. Subsequently, the spatial distribution difference of the cumulative amplitude of the fluctuation is compared with the gradient distribution of the concentrated direction deviation value to screen out areas with similar direction deviation characteristics. The similar direction deviation characteristics in 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: Determine the defect type of the abnormal area based on the directional deviation distribution of the abnormal area, select the area that meets the defect characteristics, and classify it into minor scratches, tears, drops, and label misalignment to obtain the glass bottle label defect classification result;
[0144] According to the distribution of directional deviations in abnormal areas, the defect type of the abnormal area is judged. The basis for judging the defect type is the distribution of directional deviations in the area. If the deviation value in a certain area is large and changes dramatically, it may be a defect such as tearing or falling. If the deviation value is small and relatively uniform, it may be a slight scratch or label misalignment. When screening areas that meet the defect characteristics, the standard deviation of the deviation value distribution is used to assist in judgment. Areas with larger standard deviations are classified as larger defects such as tearing and falling, and areas with smaller standard deviations are classified as slight scratches or label misalignment. Then, classification is performed according to the characteristics of the deviation distribution. The classification is based on the fluctuation range of the deviation value and the change trend within the area. Finally, the classification results of glass bottle label defects are obtained. The classification results include several common defect types such as slight scratches, tearing, falling, and label misalignment. Each type of area has a corresponding standard value and interval in the defect type classification.
[0145] See also Figure 7 , a glass bottle label defect detection system based on image processing, the system includes:
[0146] The optical imaging module uses a fixed-angle light source and near-infrared band illumination to obtain high-resolution label images, and uses gradient enhancement filtering to suppress noise, detect edge features, identify label area boundaries, and generate label area images.
[0147] The directional feature analysis module divides the local detection unit according to the label area image, calculates the fiber arrangement direction, obtains the gradient information using the structural tensor, analyzes the directional differences between adjacent units, calculates the directional consistency index, and obtains the directional abnormality area;
[0148] The fiber breakage detection module detects fiber direction mutation points within the abnormal area on the label surface based on the abnormal direction area, extracts the spatial distribution density of the mutation points, calculates the spatial density value of the mutation points, and screens the density of the mutation points according to the fracture density threshold to obtain the fiber breakage area;
[0149] The multi-scale anomaly recognition module recalculates the fiber direction consistency index and fracture point density at each scale based on the fiber breakage area, obtains the directional change trend of each scale, and calculates the difference value of the abnormality degree at each scale through cross-validation of the consistency fluctuation rate and density change rate at each scale. Detection units with difference values exceeding the difference value threshold are marked as abnormal areas. The abnormal areas at each scale are screened to obtain scale abnormal areas.
[0150] The defect classification and assessment module calculates the cumulative amplitude of fluctuations and directional concentration deviations based on the scale abnormal area, classifies the area based on the spatial distribution difference of the cumulative amplitude of fluctuations and the gradient distribution difference of the directional concentration deviation value, and identifies minor scratches, tears, drops and label misalignment defects to obtain the glass bottle label defect results.
[0151] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any modifications or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in the present invention should be included in the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be based on the scope of protection of the claims.
Claims
1. A glass bottle label defect detection method based on image processing, characterized in that: The following steps are involved: S1: Use fixed-angle light source and near-infrared irradiation to obtain high-resolution images, suppress noise through gradient enhancement filtering, detect label edges, identify label area boundaries, and obtain label area images; S2: Dividing the detection unit of 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, judging the fiber arrangement abnormality, and obtaining the direction abnormality area; S3: detecting fiber direction mutation points within the abnormal region on the label surface according to the abnormal direction region, calculating the spatial density value of the mutation points, screening the density of the mutation points according to the fracture density threshold, and obtaining the fiber fracture region; S4: Based on the fiber fracture area, obtaining the fiber direction consistency index and fracture point density at each scale, calculating the difference value of the abnormality degree at each scale, screening the abnormal area whose difference value exceeds the difference value threshold, and obtaining the scale abnormal area; S5: Based on the scale abnormal area, analyze the fluctuation cumulative amplitude and directional concentrated deviation value of each abnormal area, classify and identify minor scratches, tears, drops, and label misalignment defects, and obtain the glass bottle label defect classification result; The specific steps of detecting fiber direction mutation points within the abnormal area on the label surface according to the abnormal direction area, 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 area are as follows: S301: Based on the direction abnormal area, detecting fiber direction mutation points in the abnormal area, extracting the pixel coordinates of the mutation points, calculating the Euclidean distance between adjacent mutation points, screening the mutation point clustering area that does not exceed the Euclidean distance, and obtaining the mutation point spatial density data; S302: Calculate the number of mutation points within the current spatial area based on the mutation point spatial density data, record the density value and construct a regional distribution range, set a fracture density threshold, filter areas where the mutation point density exceeds the threshold, determine the connectivity of high-density areas, remove isolated high-density points, filter continuous areas that meet the criteria, mark their boundaries, and obtain fiber fracture density distribution; S303: extracting density-exceeding regions according to the fiber breakage density distribution, calculating regional connectivity, screening connected regions, establishing fiber breakage region boundaries, and obtaining fiber breakage regions.
2. The method for detecting glass bottle label defects based on image processing according to claim 1, characterized in that: The label area image includes edge gradient direction data, label area boundary information, and gradient enhancement filtering results; the directional abnormality area includes directional gradient change rate data, directional consistency index value, and directional consistency abnormality interval; the fiber breakage area includes mutation point spatial density value, breakage density threshold, and fiber breakage distribution area; the scale abnormality area includes consistency fluctuation rate calculation value, density change rate evaluation value, and abnormality detection difference threshold; the glass bottle label defect classification results include slight scratch defects, label tear defects, label drop defects, and label misalignment defects.
3. The method for detecting glass bottle label defects based on image processing according to claim 1, characterized in that: The specific steps for obtaining a high-resolution image using a fixed-angle light source and near-infrared illumination, suppressing noise through gradient enhancement filtering, detecting label edges, and identifying label area boundaries are as follows: S101: Acquire an image of a glass bottle label illuminated by a fixed-angle light source, call a near-infrared 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, select pixel areas that meet the set illumination intensity range, eliminate areas with uneven illumination, and obtain illumination uniformity data on the label surface; S102: Based on the label surface illumination uniformity data, a gradient enhancement filter is invoked to calculate the grayscale gradient value of the image pixel, the local grayscale change rate is calculated for the high-frequency noise area, a local grayscale change rate threshold is set, noise areas exceeding the threshold are filtered out and the grayscale value of the area is adjusted to obtain label image smoothness data; S103: Detect edge pixels with prominent grayscale gradient changes based on the label image smoothness data, calculate the gradient direction, analyze and filter the label area based on connectivity, eliminate non-connected areas, extract label area pixel information, and obtain a label area image.
4. The method for detecting glass bottle label defects based on image processing according to claim 1, characterized in that: The specific steps of dividing the detection unit of 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, judging the fiber arrangement abnormality, and obtaining the direction abnormality area are as follows: S201: Divide the local detection unit according to the label area image, extract pixel data in the unit, calculate the pixel grayscale gradient value, screen the stable area and obtain the gradient direction to obtain fiber arrangement direction data; S202: Based on the fiber arrangement direction data, the structural tensor is called to calculate local gradient information, regions where the gradient amplitude exceeds a set threshold are screened, the main direction angle within the detection unit is calculated, the direction angle is recorded as two-dimensional direction data, the direction change rate between adjacent units is calculated, regions with prominent changes are screened, and the local direction gradient change rate is obtained; S203: Calculate the direction consistency index according to the local direction gradient change rate, screen the deviation area according to the consistency threshold, determine whether the fiber arrangement is abnormal, mark the abnormal area, and obtain the direction abnormal area.
5. The method for detecting glass bottle label defects based on image processing according to claim 1, characterized in that: For calculating the Euclidean distance between adjacent mutation points , using the formula: ; in, Represent mutation points and The horizontal coordinate in the image coordinate system, Represent mutation points and The vertical coordinate in the image coordinate system, Representative The fiber direction angle of the mutation point, Represents the average direction angle of all mutation points, Represents the total number of mutation points in the calculation area.
6. The method for detecting glass bottle label defects based on image processing according to claim 1, characterized in that: Based on the fiber breakage area, the fiber direction consistency index and the breakage point density are obtained at each scale, the difference value of the abnormality degree at each scale is calculated, and the abnormal area whose difference value exceeds the difference value threshold is screened. The specific steps for obtaining the scale abnormal area are as follows: S401: Based on the fiber breakage area, obtain the fiber direction consistency index and the breakage point density at each scale, extract the direction change trend of each scale, calculate the consistency fluctuation rate, and obtain scale direction change data; S402: Calculating the difference value of the abnormality degree at each scale based on the scale direction change data, screening the detection units that exceed the preset difference value threshold, analyzing the connectivity based on the spatial distribution of the detection units, eliminating isolated abnormal units, retaining continuous abnormal areas, and recording the range of the abnormal areas to obtain the scale abnormality difference value distribution; S403: According to the scale anomaly difference value distribution, screen out regions that are abnormal at all scales, analyze the connectivity of the scale anomaly regions, remove isolated abnormal units, construct the abnormal region boundary, and obtain the scale anomaly region.
7. The method for detecting glass bottle label defects based on image processing according to claim 6, characterized in that: For calculating the difference value of abnormality at each scale , using the formula: ; in, is the total number of detection units at the current scale, is the total number of detection units in the abnormal area, For the The fiber orientation angle of each detection unit at the current scale, is the average direction angle of all detection units at the current scale, For the The fiber orientation angle of each detection unit in the previous scale, is the average direction angle of all detection units in the previous scale, For the The directional deviation value of the anomaly detection unit at the current scale, For the The directional deviation value of an anomaly detection unit in the previous scale.
8. The method for detecting glass bottle label defects based on image processing according to claim 1, characterized in that: Based on the scale abnormal area, the cumulative amplitude of fluctuations and the directional concentrated deviation value of each abnormal area are analyzed to classify and identify minor scratches, tears, drops, and label misalignment defects. The specific steps for obtaining the glass bottle label defect classification results are as follows: S501: Based on the scale abnormal area, with reference to the fiber breakage area and the direction abnormal area, calculate the cumulative amplitude of the abnormal area fluctuation, extract the fluctuation change trend and analyze the spatial distribution characteristics to obtain the abnormal area fluctuation cumulative data; S502: Calculating the directional concentration deviation value of the abnormal area based on the accumulated fluctuation data of the abnormal area, analyzing the gradient change of the directional deviation value, comparing the directional stability within the abnormal area based on the spatial distribution difference of the accumulated fluctuation amplitude and the gradient distribution of the directional concentration deviation value, screening areas with similar directional deviation characteristics, and obtaining the directional deviation distribution of the abnormal area; S503: Determine the defect type of the abnormal area based on the directional deviation distribution of the abnormal area, screen the area that meets the defect characteristics, classify slight scratches, tears, drops, and label misalignment, and obtain a glass bottle label defect classification result.
9. A glass bottle label defect detection system based on image processing, characterized in that: The method for detecting defects in glass bottle labels based on image processing according to any one of claims 1 to 8 is implemented, wherein the system comprises: The optical imaging module uses a fixed-angle light source and near-infrared band illumination to obtain high-resolution label images, and uses gradient enhancement filtering to suppress noise, detect edge features, identify label area boundaries, and generate label area images. The directional feature analysis module divides the local detection unit according to the label area image, calculates the fiber arrangement direction, obtains gradient information using the structural tensor, analyzes the directional differences of adjacent units, calculates the directional consistency index, and obtains the directional abnormality area; The fiber breakage detection module detects the fiber direction mutation points within the abnormal area on the label surface according to the abnormal direction area, extracts the spatial distribution density of the mutation points and calculates the spatial density value of the mutation points, and screens the density of the mutation points according to the fracture density threshold to obtain the fiber breakage area; The multi-scale anomaly recognition module recalculates the fiber direction consistency index and the fracture point density at each scale based on the fiber fracture area, obtains the direction change trend of each scale, calculates the difference value of the abnormal degree at each scale through cross-validation of the consistency fluctuation rate and the density change rate at each scale, marks the detection unit whose difference value exceeds the difference value threshold as an abnormal area, and screens the areas with abnormalities at each scale to obtain the scale abnormal area; The defect classification and assessment module calculates the cumulative amplitude of fluctuations and the directional concentration deviation based on the scale abnormal area, classifies the abnormal area according to the spatial distribution difference of the cumulative amplitude of fluctuations and the gradient distribution difference of the directional concentration deviation value, and identifies minor scratches, tears, drops and label misalignment defects to obtain the glass bottle label defect classification 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