Method for detecting appearance defects of packaging cans

By performing edge detection and reflection possibility calculation on the multi-frame grayscale map of the packaging can, combined with gamma transformation technology, the defect detection inaccurate problem caused by reflection is solved, and higher detection accuracy and reliability are achieved.

CN119228800BActive Publication Date: 2025-03-11SHAANXI YATAI DAIRY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411749206.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-02
Publication Date
2025-03-11
Estimated Expiration
2044-12-02

AI Technical Summary

Technical Problem

In the prior art, when enhancing the image of the packaging can surface, the defect detection results are inaccurate due to reflection problems.

Method used

By obtaining the multi-frame grayscale map of the packaging can, edge detection is performed and the reflective possibility of the target area is calculated, and the image contrast is adjusted in combination with gamma transformation technology to enhance image details, thereby improving the accuracy of defect detection.

Benefits of technology

It reduces misjudgment caused by reflection, improves the accuracy and reliability of defect detection, and makes defect characteristics more obvious.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119228800B_ABST
    Figure CN119228800B_ABST
Patent Text Reader

Abstract

The present invention relates to the field of image processing, and in particular to a method for detecting defects in the shape of packaging cans, the method comprising: obtaining multiple grayscale images of packaging cans, performing edge detection on the grayscale images, and using the area formed by the detected closed edges as a target area; calculating the possibility that the target area is a reflective area; calculating a gamma coefficient, the gamma coefficient being positively correlated with the possibility, and for each pixel point in the target area, the corresponding original grayscale value is transformed by gamma to obtain the latest grayscale value to obtain an enhanced grayscale image of the packaging can; the enhanced grayscale image is input into a pre-trained model, and the position of the defect is output. The present invention further evaluates the reflective characteristics of the target area by combining the comprehensive reflective characteristics of the target area, determines the gamma coefficient according to the evaluation results, adjusts the contrast of the image by gamma transformation, enhances the details in the image, makes the defect features more obvious, and thus improves the accuracy of defect detection.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of image processing, and more particularly to a method for detecting shape defects of packaging cans. Background Art

[0002] As an important packaging container, packaging cans play an important role in protecting the contents, facilitating consumers' use, and improving the aesthetics of products. In order to ensure the quality and safety of packaging cans, a series of quality inspections are usually required. These inspections include surface quality inspection (check whether the surface of the can is flat and smooth, without scratches, bumps, deformation, rust spots and other defects), printing quality inspection, sealing quality inspection, and thickness, shape deviation, compressive strength and other aspects. Among them, the integrity of the packaging can is crucial to maintaining the shelf life of the product. Any minor defects may cause product deterioration or contamination. With the advancement of technology, machine vision and automated inspection technology can achieve fast and accurate inspection of the appearance of packaging cans through high-precision image acquisition, processing and analysis.

[0003] At present, the existing technology, such as the patent application document with publication number CN118115484A, discloses a can body defect detection method, system, equipment and storage medium. The can body defect detection method includes: performing image enhancement processing on the surface image of the can to obtain an enhanced surface image of the can; performing grayscale processing on the enhanced surface image of the can to obtain a grayscale surface image of the can; performing edge detection processing on the grayscale surface image of the can to obtain a sharpened contour image of the can; performing grayscale value detection processing on the grayscale surface image of the can to construct a suspected defect target frame; based on the suspected defect target frame, performing comprehensive detection on the sharpened contour image of the can in terms of defect shape regularity, defect scale and defect edge roughness to obtain a defect detection result.

[0004] However, when performing image enhancement processing on the surface image of the can, the reflection problem on the surface of the can causes the defects originally existing in the image to be covered by the reflection, resulting in inaccurate defect detection results. Summary of the invention

[0005] In order to solve the problem of inaccurate defect detection results, the present invention provides the following solution.

[0006] The method for detecting the appearance defects of packaging cans includes:

[0007] Obtain multiple frames of grayscale images of the packaging can, perform edge detection on the grayscale images, and use the area formed by the detected closed edges as the target area;

[0008] Calculate the probability that the target area is a reflective area, the probability is:

[0009] ; In the formula, is the probability that the target area is a reflective area, is the grayscale mean of all pixels in the target area, is the maximum grayscale value of all pixels in the target area, The comprehensive reflective characteristics of the target area;

[0010] Calculating a gamma coefficient, wherein the gamma coefficient is positively correlated with the possibility, and for each pixel point in the target area, obtaining a latest grayscale value from a corresponding original grayscale value through a gamma transformation to obtain an enhanced grayscale image of the packaging can;

[0011] The enhanced grayscale image is fed into a pre-trained model and the location of the defect is output.

[0012] Due to the false identification and real defects caused by reflection, the present invention first obtains multiple frames of grayscale images of the packaging can and performs edge detection, preliminarily identifies the target area formed by the closed edge, and further evaluates the reflective characteristics of the target area by calculating the ratio of the grayscale mean and the maximum grayscale value, combined with the comprehensive reflective characteristics of the target area, to reduce misjudgment, and determines the gamma coefficient based on the evaluation results. The gamma transform can adjust the contrast of the image, enhance the details in the image, make the defect features more obvious, and thus improve the accuracy of defect detection.

[0013] Preferably, the latest grayscale value is:

[0014] ; In the formula, is the latest grayscale value, is the original grayscale value, is the gamma coefficient, The possibility that the target area is a reflective area.

[0015] Since the gamma coefficient is related to the possibility of reflective areas, this transformation can adapt to different lighting and reflective conditions. In areas with strong reflectiveness, the gamma coefficient will be adjusted accordingly to reduce the impact of reflection on defect detection. Through this enhancement, the defect detection model can more easily identify defects in the image, thereby improving the accuracy and reliability of defect detection.

[0016] Preferably, the comprehensive reflective characteristics of the target area satisfy the relationship:

[0017] ; In the formula, is the comprehensive reflective characteristics of the target area, is the first indicator of the target area. is the second indicator of the target area, is the multi-frame similarity of the target area.

[0018] Preferably, the step of obtaining the first indicator includes:

[0019] Shrink the target area layer by layer from the outermost boundary to the innermost boundary. During each shrinkage, if the eight neighborhoods of the pixel point belong to the target area, the pixel point will be retained. Otherwise, the pixel point will be removed. During each shrinkage, the removed pixel point will be used as a layer boundary. Shrinkage will stop when the distance from the boundary of the target area to its center point after shrinkage is reduced to half of the distance from the boundary of the target area to its center point before shrinkage begins.

[0020] Calculate the sum of the differences in the grayscale mean values ​​of the pixels corresponding to each two adjacent layers of boundaries from the second layer boundary to the last layer boundary from the outside to the inside, divide the sum by the layer number difference and normalize it to obtain the average grayscale change, and use the average grayscale change as the first indicator.

[0021] By shrinking each layer and retaining the boundary pixels of each layer, the hierarchical structure of the target area can be analyzed, and the sum of the grayscale mean differences of the pixels corresponding to the boundaries of two adjacent layers can be calculated to quantify the grayscale changes from the outside to the inside of the target area. This change can reflect the grayscale distribution and possible reflective characteristics inside the target area.

[0022] Preferably, the second indicator satisfies the relationship:

[0023] ; In the formula, is the second indicator, is the standard deviation of the grayscale values ​​of all pixels in the target area, For the The standard deviation of the grayscale values ​​of pixels on the layer boundary, For the The first The angle between the gradient direction of a pixel and the unit vector pointing from the center point of the target area to the pixel. is the number of all layers after the target area is shrunk, is the total number of pixels corresponding to each layer boundary, Indicates normalization processing.

[0024] By comprehensively considering the influence of grayscale distribution uniformity and gradient direction, the reflective properties and structural characteristics of the target area can be more comprehensively described.

[0025] Preferably, the multi-frame similarity satisfies the relationship:

[0026] ; In the formula, is the multi-frame similarity, is the area of ​​the target area in the current grayscale image, To intercept the current grayscale image from the left to the right In the frame grayscale image, The area of ​​the region closest to the target region in the frame grayscale image, is the center point of the target area and The distance from the center point of the nearest area in the frame grayscale image, is the maximum value of the distance between the center point of the target area and the center point of the nearest area in all frame grayscale images. It is an exponential function with the natural constant e as its base.

[0027] Calculating the multi-frame similarity of the target area can quantify the similarity between different frames. In defect detection, multi-frame similarity can help identify anomalies that appear consistently in multiple frames, thereby locating defects more accurately.

[0028] Preferably, the model is a convolutional neural network model or a YOLOv8 model.

[0029] Preferably, the comprehensive reflective characteristics of the target area satisfy the relationship:

[0030] ; In the formula, is the comprehensive reflective characteristics of the target area, is the first indicator of the target area. is the second indicator of the target area, is the multi-frame similarity of the target area, , , All are weights.

[0031] The beneficial effects of the present invention are:

[0032] The present invention calculates the comprehensive reflective characteristics of the target area by analyzing the grayscale distribution characteristics of the target area, the gradient influence and the similarity between the target areas of adjacent frame images, and further evaluates the possibility that the target area is a reflective area to reduce the misjudgment caused by reflection. The gamma coefficient is determined according to the evaluation result. The gamma transformation can adjust the contrast of the image, enhance the details in the image, make the defect features more obvious, and thus improve the accuracy of defect detection. BRIEF DESCRIPTION OF THE DRAWINGS

[0033] By reading the following detailed description with reference to the accompanying drawings, the above and other objects, features and advantages of the exemplary embodiments of the present invention will become readily understood. In the accompanying drawings, several embodiments of the present invention are shown in an exemplary and non-limiting manner, and the same or corresponding reference numerals represent the same or corresponding parts, wherein:

[0034] Figure 1It is a method flow chart of steps S1 to S4 in the method for detecting shape defects of packaging cans according to an embodiment of the present invention.

[0035] Figure 2 It is a flow chart of a method for calculating the comprehensive reflective characteristics of a target area in a packaging can shape defect detection method according to an embodiment of the present invention. DETAILED DESCRIPTION

[0036] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.

[0037] The present invention is aimed at the scenario of performing appearance defect detection on packaging cans of the same batch and the same model.

[0038] The specific embodiments of the present invention are described in detail below with reference to the accompanying drawings.

[0039] Reference Figure 1 The packaging can shape defect detection method includes steps S1 to S4, which are as follows:

[0040] S1: Obtain multiple frames of grayscale images of the packaging can, perform edge detection on the grayscale images, and use the area formed by the detected closed edges as the target area.

[0041] Use an image acquisition device (such as a camera or scanner) to capture images of packaging cans and obtain continuous image frames from them. Convert the captured multiple color image frames into grayscale images, enhance the grayscale images to highlight the features in the image or improve the image quality, and further process the multiple grayscale images, such as filtering, edge detection, etc., so as to extract the features of the packaging cans or detect defects.

[0042] Apply the Canny edge detection algorithm to the grayscale image. In the obtained edge image, the edge is composed of a series of connected pixels. These edges form a closed boundary, and the area enclosed by the closed edge is the closed area. The closed area is then analyzed as the target area.

[0043] S2: Calculate the possibility that the target area is a reflective area.

[0044] Reflective areas usually have specific visual characteristics, such as high brightness, low saturation, etc., which make them visually distinguishable from other types of areas (such as shadow areas, ordinary areas, etc.).

[0045] Specifically, reflective areas usually show a gradient characteristic of grayscale values, because light reflection causes grayscale values ​​to change at different locations. In addition, in multiple frames of images taken continuously, if a region shows a similar grayscale change pattern under multiple different lighting conditions, then this region is likely to be a reflective region. Therefore, by detecting these grayscale gradients and similarities in multiple frames of images and comprehensively analyzing the grayscale stability of the target region, the probability of each region being a reflective region can be calculated.

[0046] For the convenience of analysis, taking any target area as an example, we first calculate the average grayscale value of all pixels in the target area, and use this average value as the grayscale feature of the area. Then we perform the following analysis.

[0047] Reference Figure 2 , Figure 2 1 is a flow chart of a method for calculating the comprehensive reflective characteristics of a target area in a method for detecting shape defects of packaging cans according to an embodiment of the present invention, including steps S20 to S22, which are specifically as follows:

[0048] S20: Calculate a first index of the target area.

[0049] Shrink inward from the outermost boundary of the target area layer by layer. During each shrinkage, if the eight neighborhoods of the pixel point belong to the target area, the pixel point will be retained, otherwise, the pixel point will be removed. During each shrinkage, the removed pixel points will be recorded. According to the number of shrinkages, multiple layers of boundaries can be formed (for example, the pixel point part deleted after the first shrinkage is called the first layer boundary, the pixel point part deleted after the second shrinkage is called the second layer boundary, and so on).

[0050] The shrinking stops when the distance from the boundary of the target area after shrinking to its center point is reduced to half of the distance from the boundary of the target area to its center point before shrinking begins;

[0051] For each layer of boundary, calculate the mean grayscale value of the pixels it contains, calculate the sum of the differences in the grayscale means of the pixels corresponding to each two adjacent layers of boundaries from the second layer of boundary to the last layer of boundary, divide the sum by the layer number difference and normalize it to obtain the average grayscale change, and use the average grayscale change as the first indicator of the target area.

[0052] Exemplarily, the first indicator of the target area satisfies the following relationship:

[0053]

[0054] In the formula, is the first indicator of the target area. is the number of all layers after the target area is shrunk, For the The grayscale mean of the pixels in the layer, For the The grayscale mean of the pixels in the layer, It is an exponential function with the natural constant e as its base.

[0055] in, The sum of the differences in the grayscale means of all adjacent layers from the second layer to the last layer is calculated. This sum reflects the overall change in the grayscale of the target area, and then divided by , the sum of grayscale changes is normalized to the range of the number of layers, which reflects the grayscale change rate relative to the number of layers. Then an exponential function is used to convert the normalized grayscale change into a positive, possibly very large number, so that small grayscale change differences can also be reflected.

[0056] For example, if the grayscale value of the target area varies little between layers, then the value of the first indicator of the target area will be close to 1 (because the input of the exponential function is close to 0), indicating that the area is relatively uniform in grayscale. On the contrary, if the grayscale value varies greatly between layers, then the value of the first indicator of the target area will be much greater than 1, indicating that the area has a large change or complexity in grayscale.

[0057] It should be noted that the distinction between "inside and outside" only begins after the first boundary contraction, that is, the first layer of boundary and the internal area. In the initial state (before contraction), the entire target area is regarded as a whole, without a clear distinction between the inside and outside boundaries. Therefore, it is necessary to calculate the grayscale change from the second contraction (i.e., the formation of the second layer of boundary).

[0058] In another embodiment, the grayscale gradient trend of each layer is also considered.

[0059] For example, if >0, indicating that Layer to layer At the boundary, the grayscale mean value increases, that is, there is a trend of grayscale gradient, which is similar to the reflection phenomenon. At this time, a variable is assigned to 1 and added to the first index of the target area calculated above;

[0060] if ≤0, indicating that the mean gray value is decreasing or unchanged. Although the gray value has changed, it is inconsistent with the reflection phenomenon. At this time, a variable is assigned to 0, and it is also added to the first indicator of the target area calculated above.

[0061] Then the first index of the target area of ​​the inserted variable satisfies the relationship:

[0062]

[0063] In the formula, is the first indicator of the target area. is the number of all layers after the target area is shrunk, is a variable, For the The grayscale mean of the pixels in the layer, For the The grayscale mean of the pixels in the layer, It is an exponential function with the natural constant e as its base.

[0064] This formula comprehensively considers the boundary ratio and the possibility of grayscale gradient that conforms to the reflective grayscale change trend, thus providing an indicator for quantitatively evaluating the grayscale gradient characteristics of the target area.

[0065] when The larger it is, the more boundaries there are in the target area's multi-layer boundaries that conform to the grayscale change trend of reflection, and the stronger the grayscale gradient of the target area is. The smaller it is, the fewer boundaries that conform to the grayscale change trend of reflection in the multi-layer boundaries of the target area are, and the weaker the grayscale gradient of the target area is.

[0066] S21: Calculate the second index of the target area.

[0067] In the grayscale gradient area formed by reflection, the gradient direction is from the center of the area to the boundary, with a divergent gradient direction. This gradient distribution pattern reflects the visual effect of the gradual change of brightness formed on the image after the light starts from the light source and is reflected on the surface of the object.

[0068] The gradient direction of the grayscale gradient area caused by reflection is the same as the grayscale change trend of the reflection (that is, the gradient trend of the grayscale value gradually increasing from the region boundary to the center). This is in sharp contrast to the gradient direction of the flat area and the edge texture area.

[0069] Therefore, the second index of the target area is calculated according to the gradient direction of the pixel points on the multi-layer boundary and the standard deviation of the pixel points on the boundary of each layer.

[0070] Exemplarily, the second index of the target area satisfies the following relationship:

[0071]

[0072] In the formula, is the second indicator, is the standard deviation of the grayscale values ​​of all pixels in the target area, For the The standard deviation of the grayscale values ​​of pixels on the layer boundary, For the The first The angle between the gradient direction of a pixel and the unit vector pointing from the center point of the target area to the pixel. is the number of all layers after the target area is shrunk, is the total number of pixels corresponding to each layer boundary, Indicates normalization processing.

[0073] in, It represents the sum of the standard deviation of the grayscale values ​​on all layer boundaries and the standard deviation of the entire region. This accumulated value reflects the difference between the grayscale values ​​of the multi-layer boundary pixels and the grayscale values ​​of the entire region. Small), but the grayscale values ​​of the pixels at the multi-layer boundary have a gradual trend (i.e. is larger), the accumulated value will be larger, indicating that the grayscale gradient of the target area is stronger.

[0074] Indicates the accumulation of the consistency between the gradient direction of all pixels and the center direction. This accumulated value reflects the divergence of the gradient direction of the target area. The closer the gradient direction of the pixel point to the boundary is, the more divergent it is (that is, the smaller the angle with the center direction is), the larger the accumulated value will be, indicating that the grayscale gradient of the target area is stronger.

[0075] In summary, the second index combines the grayscale value standard deviation difference and the angle between the gradient direction and the center direction to quantify the grayscale gradient characteristics of the target area. When the grayscale value of the target area has a gradient trend on the multi-layer boundary, and the gradient direction is more divergent as it approaches the boundary, the value of the second index will be larger, indicating that the grayscale gradient of the target area is stronger. On the contrary, it indicates that the grayscale gradient is weaker.

[0076] S22: Calculate the multi-frame similarity of the target area.

[0077] Since the shooting conditions are consistent, if there is a reflective area in the continuous frame images, then its position and size are similar. Therefore, the characteristics of the target area in the continuous frames are further analyzed to calculate the multi-frame similarity of the target area.

[0078] Exemplarily, the multi-frame similarity of the target area satisfies the following relationship:

[0079]

[0080] In the formula, is the multi-frame similarity, is the area of ​​the target area in the current grayscale image, To intercept the current grayscale image from the left to the right In the frame grayscale image, The area of ​​the region closest to the target region in the frame grayscale image, is the center point of the target area and The distance from the center point of the nearest area in the frame grayscale image, is the maximum value of the distance between the center point of the target area and the center point of the nearest area in all frame grayscale images. It is an exponential function with the natural constant e as its base.

[0081] This formula combines the area difference and distance difference The two factors are converted into a comprehensive similarity index through an exponential function. When the area difference and distance difference are both small, the greater the multi-frame similarity of the target area, the greater the possibility that the target area is reflective.

[0082] After the first index, the second index and the multi-frame similarity of the target area are obtained through the above calculations, a comprehensive reflective feature of the target area is comprehensively calculated.

[0083] Exemplarily, the comprehensive reflective characteristics of the target area satisfy the following relationship:

[0084]

[0085] In the formula, is the comprehensive reflective characteristics of the target area, is the first indicator of the target area. is the second indicator of the target area, is the multi-frame similarity of the target area.

[0086] The larger the comprehensive reflective feature value is, the stronger the reflective features of the target area are in terms of grayscale gradient and multi-frame similarity.

[0087] In another embodiment, the comprehensive reflective characteristics of the target area satisfy the relationship:

[0088]

[0089] In the formula, is the comprehensive reflective characteristics of the target area, is the first indicator of the target area. is the second indicator of the target area, is the multi-frame similarity of the target area, , , are all weights. Among them, weight , , The settings can be adjusted based on multiple experiments.

[0090] After the comprehensive reflective features of the target area are calculated, the possibility that the target area is a reflective area is further calculated.

[0091] The probability that the target area is a reflective area satisfies the following relationship:

[0092]

[0093] In the formula, is the probability that the target area is a reflective area, is the grayscale mean of all pixels in the target area, is the maximum grayscale value of all pixels in the target area, It is the comprehensive reflective characteristics of the target area.

[0094] in, It reflects the ratio of the gray value of the target area to the gray value range of the entire image. The larger the ratio, the higher the gray value of the target area, which may be closer to the gray characteristics of the reflective area. and Multiply them together to get a more comprehensive assessment of the likelihood of reflection.

[0095] S3: Calculate a gamma coefficient, which is positively correlated with the possibility. For each pixel point in the target area, the corresponding original grayscale value is transformed by gamma to obtain the latest grayscale value, so as to obtain an enhanced grayscale image of the packaging can.

[0096] Based on the evaluation result of the possibility of reflection, a suitable gamma coefficient is selected. Generally speaking, the greater the possibility of reflection, the smaller the gamma coefficient may be selected to enhance the contrast of low grayscale areas and make the reflection area brighter and more prominent. Conversely, if the possibility of reflection is small, a gamma coefficient close to 1 or slightly greater than 1 may be selected to maintain or slightly enhance the contrast of the image.

[0097] Apply the gamma transform formula to the grayscale value of each pixel in the target area.

[0098] The gamma transform formula is generally: ,in, is the grayscale value of the output image, is a constant, is the grayscale value of the input image, is the gamma coefficient.

[0099] In the embodiment of the present invention, the gamma transform formula is:

[0100]

[0101] In the formula, is the latest grayscale value of the pixel in the target area obtained by gamma transformation. is the original grayscale value of the pixel in the target area, is the gamma coefficient, where The possibility that the target area is a reflective area.

[0102] After gamma transformation, an enhanced grayscale image of the packaging can is obtained. Similarly, the enhanced grayscale images of the packaging cans of all frames can be obtained.

[0103] S4: Input the enhanced grayscale image into the pre-trained model and output the location of the defect.

[0104] In an embodiment of the present invention, a trained YOLOv8 model is selected (a convolutional neural network model may also be selected), the enhanced multi-frame grayscale image is input into the trained YOLOv8 model, and the defect position of the packaging can shape is output.

[0105] In the description of this specification, "plurality" or "several" means at least two, such as two, three or more, etc., unless otherwise clearly and specifically defined.

[0106] Although this specification has shown and described a number of embodiments of the present invention, it will be apparent to those skilled in the art that such embodiments are provided by way of example only. Those skilled in the art will conceive of many modifications, changes and alternatives without departing from the ideas and spirit of the present invention. It should be understood that in the practice of the present invention, various alternatives to the embodiments of the present invention described herein may be employed.

Claims

1. A method for detecting packaging can appearance defects, characterized in that: include: Obtain multiple frames of grayscale images of the packaging can, perform edge detection on the grayscale images, and use the area formed by the detected closed edges as the target area; Calculate the probability that the target area is a reflective area, the probability is: ; In the formula, is the probability that the target area is a reflective area, is the grayscale mean of all pixels in the target area, is the maximum grayscale value of all pixels in the target area, is the comprehensive reflective feature of the target area, satisfying the relationship: ; In the formula, is the comprehensive reflective characteristics of the target area, is the first indicator of the target area. is the multi-frame similarity of the target area, is the second indicator of the target area, satisfying the relationship: ; In the formula, is the standard deviation of the grayscale values ​​of all pixels in the target area, For the The standard deviation of the grayscale values ​​of pixels on the layer boundary, For the The first The angle between the gradient direction of a pixel and the unit vector pointing from the center point of the target area to the pixel. is the number of all layers after the target area is shrunk, is the total number of pixels corresponding to each layer boundary, Indicates normalization processing; The step of obtaining the first indicator includes: Shrink the target area layer by layer from the outermost boundary to the innermost boundary. Each time the pixel is shrunk, if the eight neighborhoods of the pixel point belong to the target area, the pixel point is retained. Otherwise, the pixel point is removed. Each time the pixel is shrunk, the removed pixel point is used as a layer boundary. Shrinkage stops when the distance from the boundary of the target area to its center point after shrinkage is reduced to half of the distance from the boundary of the target area to its center point before shrinkage begins. Calculate the sum of the grayscale mean differences of the pixel points corresponding to each two adjacent layers of boundaries from the second layer boundary to the last layer boundary from the outside to the inside, divide the sum by the layer number difference and normalize it to obtain an average grayscale change, and use the average grayscale change as the first indicator; Calculating a gamma coefficient, wherein the gamma coefficient is positively correlated with the possibility, and for each pixel point in the target area, obtaining a latest grayscale value from a corresponding original grayscale value through a gamma transformation to obtain an enhanced grayscale image of the packaging can; The enhanced grayscale image is fed into a pre-trained model and the location of the defect is output.

2. The method for detecting packaging can shape defects according to claim 1, characterized in that: The latest grayscale value is: ; In the formula, is the latest grayscale value, is the original grayscale value, is the gamma coefficient, The possibility that the target area is a reflective area.

3. The method for detecting packaging can shape defects according to claim 2, characterized in that: The multi-frame similarity satisfies the relationship: ; In the formula, is the multi-frame similarity, is the area of ​​the target area in the current grayscale image, To intercept the current grayscale image from the left to the right In the frame grayscale image, The area of ​​the region closest to the target region in the frame grayscale image, is the center point of the target area and The distance from the center point of the nearest area in the frame grayscale image, is the maximum value of the distance between the center point of the target area and the center point of the nearest area in all frame grayscale images. It is an exponential function with the natural constant e as its base.

4. The method for detecting packaging can shape defects according to claim 3, characterized in that: The model is a convolutional neural network model or a YOLOv8 model.

5. The method for detecting packaging can shape defects according to claim 1, characterized in that: The comprehensive reflective characteristics of the target area satisfy the relationship: ; In the formula, is the comprehensive reflective characteristics of the target area, is the first indicator of the target area. is the second indicator of the target area, is the multi-frame similarity of the target area, , , All are weights.

Citation Information

Patent Citations

  • Pop can body defect detection method, system and equipment and storage medium

    CN118115484A

  • Printed circuit board quality intelligent detection method based on vision assistance

    CN117115153A