Printing pattern defect detection method and system for plastic packaging

By adaptively determining the window side length, combined with the ACE image enhancement algorithm, the problem of poor detection results of traditional algorithms under different regional feature differences is solved, and more accurate printing pattern defect detection and detail retention are achieved.

CN118411367BActive Publication Date: 2024-09-10浙江一鸣包装印刷有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410881440.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-03
Publication Date
2024-09-10
Estimated Expiration
2044-07-03

AI Technical Summary

Technical Problem

In the printing process of plastic packaging, the traditional contrast enhancement algorithm (ACE image enhancement algorithm) has a fixed window size and cannot adapt to the local feature differences in different areas of the image, resulting in poor detection of printed pattern defects.

Method used

The connected domain is obtained through the region segmentation algorithm, and the window side length is adaptively determined based on the scratch influence degree of edge pixels and the length of the connected path. The image is enhanced with the ACE image enhancement algorithm, and region segmentation is performed to detect defective areas.

Benefits of technology

It improves the accuracy and detail retention of printing pattern defect detection, enables more accurate assessment of local features, enhances the image enhancement effect, and facilitates the detection of printing pattern defects.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118411367B
    Figure CN118411367B
Patent Text Reader

Abstract

The present application relates to the field of image processing technology, and specifically to a method and system for detecting defects in printed patterns for plastic packaging, the method comprising: obtaining a grayscale image of printed plastic packaging and its connected domains; determining the degree of scratch influence based on the number of edge pixels in the connected domain and the grayscale value difference; determining a scratch index based on the connectivity of the connected domain and the difference in the width of the connected domain; determining the window length of any edge pixel based on the degree of scratch influence and the scratch index, optimizing the window size in the ACE image enhancement algorithm, obtaining an enhanced image, performing regional segmentation on the enhanced image and detecting defective areas. The present application aims to more accurately evaluate the local features of pixels, improve the image enhancement effect, and facilitate the detection of printed pattern defects.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of image processing technology, and in particular to a method and system for detecting printed pattern defects for plastic packaging. Background Art

[0002] Plastic packaging is widely used in our daily life. During the printing process of plastic packaging products, defects such as color difference, position deviation, missing printing, ink spots, scratches and blurred patterns may occur. These defects will directly affect the appearance and quality of the product. Therefore, it is necessary to inspect and remove unqualified products in time before the products enter the subsequent production, and find out the cause of the machine failure to avoid greater losses.

[0003] Since the color and shape of the pattern are relatively complex during the printing process, the scratches in the pattern are easily blurred or covered, and the image needs to be enhanced. The window size selection of the traditional contrast enhancement algorithm (ACE image enhancement algorithm) is generally a fixed value, but the local features of different areas in the image may vary greatly. Selecting the same size window will result in poor image enhancement effect, thereby affecting the defect detection results in the printed pattern. Summary of the invention

[0004] In order to solve the above technical problems, the present application provides a method and system for detecting printed pattern defects in plastic packaging. The technical solutions adopted are as follows:

[0005] In a first aspect, an embodiment of the present application provides a method for detecting printed pattern defects in plastic packaging, the method comprising the following steps:

[0006] Obtaining a grayscale image of plastic packaging printing; using a region segmentation algorithm to obtain each connected domain of the grayscale image of plastic packaging printing;

[0007] Determine the degree of influence of the scratch on the connected domain based on the increase of edge pixels of the connected domain relative to the location of the corresponding area of ​​the defect-free printed grayscale image, and the grayscale value difference between the edge pixels on the connected domain and its neighboring pixels; wherein the neighboring pixels are not in the connected domain;

[0008] Based on the length and number of connected paths between edge pixels in the connected domain and the difference in connected domain widths between adjacent edge pixels on the connected domain, the scratch index of any edge pixel on the connected domain is determined;

[0009] Based on the difference between the maximum scratch influence degree of the connected domain and the scratch influence degree of any edge pixel point on the connected domain, combined with the scratch index of any edge pixel point on the connected domain, the window side length of any edge pixel point is determined; based on the window side length combined with the ACE image enhancement algorithm, the enhanced image is obtained, and the enhanced image is segmented and the defect area is detected.

[0010] Preferably, the method for determining the degree of impact of the scratches includes:

[0011] Determine the suspicious weight of the connected domain based on the difference in the number of edge pixels between the connected domain and the corresponding region in the grayscale image of defect-free printing;

[0012] Based on the gray value difference between the edge pixel point on the connected domain and the pixel point closest to it, the color destruction coefficient of the connected domain is determined;

[0013] Based on the suspicious weight and the color destruction coefficient, the scratch influence degree of the connected domain is determined; wherein the suspicious weight and the color destruction coefficient are both positively correlated with the scratch influence degree.

[0014] Preferably, the method for determining the suspicious weight includes:

[0015] The number of edge pixels in the connected domain is calculated, and the difference between the number of edge pixels at the corresponding area in the non-defective printed grayscale image is used as the numerator; the total number of edge pixels in the non-defective printed grayscale image is calculated as the denominator;

[0016] The ratio of the numerator to the denominator is taken as the suspicious weight of the connected domain.

[0017] Preferably, the method for determining the color destruction coefficient includes:

[0018] Calculate the cumulative sum of the absolute values ​​of the differences between the grayscale values ​​of all edge pixels in the connected domain and the pixels closest to them that are not in the connected domain; calculate the distribution variance of the grayscale values ​​of the pixels in the connected domain;

[0019] The ratio of the cumulative sum to the distribution variance is taken as the color destruction coefficient of the connected domain.

[0020] Preferably, the deterministic method of the scratch index comprises:

[0021] Based on the connectivity between any two edge pixels in the connected domain, the connectivity strength between any two edge pixels is determined;

[0022] Determine the scratch possibility index of any edge pixel point based on the difference in connected domain width between any edge pixel point on the connected domain and the position of its adjacent edge pixel point;

[0023] Based on the connectivity strength and the possibility index, the scratch index of any edge pixel point is determined; wherein the scratch index is positively correlated with the scratch possibility index, and is positively correlated with the average connectivity strength between any edge pixel point and all other edge pixels in its connected domain.

[0024] Preferably, the method for determining the connectivity strength includes:

[0025] The depth-first search algorithm is used to calculate the number of connected paths between any two edge pixels and the length of each connected path;

[0026] Determine the maximum number of connected paths theoretically possible between any two edge pixels;

[0027] Obtain the maximum Manhattan distance between any two edge pixels, calculate the cumulative result of all connected path lengths between any two edge pixels; and use the ratio of the cumulative result to the maximum Manhattan distance as the first ratio;

[0028] Obtain the number of connected paths between any two edge pixels; and use the ratio of the number of connected paths to the maximum number of connected paths theoretically possible between any two edge pixels as a second ratio;

[0029] The first and second weight coefficients are set respectively, and the weighted sums of the first and second ratios corresponding to the first and second weight coefficients are calculated respectively as the connectivity strength between any two edge pixels.

[0030] Preferably, the method for determining the scratch possibility index includes:

[0031] The curve obtained after the connected domain is corroded is used as the skeleton line of the corresponding connected domain, and the line between the two endpoints where the skeleton line intersects with the connected domain is used as the main direction of the connected domain;

[0032] For any edge pixel point on the connected domain, draw a straight line perpendicular to the main direction of the connected domain through any edge pixel point, and take the number of pixels in the connected domain where the straight line passes through any edge pixel point as the width of the connected domain of any edge pixel point;

[0033] The cumulative sum of the absolute values ​​of the differences in the widths of the connected domains between any edge pixel and all its adjacent edge pixels is calculated; the ratio of the cumulative sum to the width of the connected domain of any edge pixel is used as the scratch possibility index of any edge pixel.

[0034] Preferably, the method for determining the window side length includes:

[0035] Obtain the maximum value of the scratch influence degree in all connected domains of the grayscale image of plastic packaging printing;

[0036] Calculate the ratio of the scratch influence degree of any edge pixel point to the maximum value, and record it as the normalized scratch influence value;

[0037] An integer value of the product of the scratch index of any edge pixel point and the normalized value of the scratch influence is used as the side length of the window of any edge pixel point.

[0038] Preferably, the process of acquiring the enhanced image and the process of detecting the defective area include:

[0039] The window side length of each pixel point except the edge pixels in the grayscale image of plastic packaging printing is set to the average window side length of all edge pixels;

[0040] The window side length of each pixel in the grayscale image of plastic packaging printing is used as the window side length of each pixel in the improved ACE algorithm to obtain the enhanced image;

[0041] For the enhanced image, a region segmentation algorithm is used to perform region segmentation, and the similarity between each segmented region and the corresponding position region in the defect-free printing grayscale image is calculated;

[0042] When the similarity is greater than the similarity threshold, the region is judged to be a defective region; otherwise, the region is judged to be a normal region.

[0043] In a second aspect, an embodiment of the present application also provides a printed pattern defect detection system for plastic packaging, comprising a memory, a processor, and a computer program stored in the memory and running on the processor, wherein when the processor executes the computer program, the steps of any one of the above-mentioned printed pattern defect detection methods for plastic packaging are implemented.

[0044] In the above scheme, the present application calculates the degree of scratch influence of the connected domain according to the increase in the number of connected domains and the change characteristics of the gray value difference, and considers the difference or consistency of the color of the printed pattern through the degree of scratch influence; its beneficial effect is that it can more accurately evaluate the area where the scratch defect is located by comparing with the original color distribution of the corresponding area of ​​the defect-free printed grayscale image, and better extract the visual characteristics of the scratch. The present application calculates the connectivity strength according to the connected path between two edge pixels, calculates the scratch possibility index of the edge pixel point by the width of the connected domain between adjacent edge pixels, and obtains the scratch index of each edge pixel point. Its beneficial effect is that the connected path and the width of the connected domain are comprehensively considered to better extract the distribution characteristics when the scratch occurs. The present application determines the window side length according to the scratch influence degree and scratch index of each edge pixel point, and its beneficial effect is that it can adaptively determine the window size according to the characteristics of the edge pixel point, and better reflect the local changes of the image. Compared with the traditional ACE image enhancement algorithm, the present application selects windows of different sizes for different pixel points, and its beneficial effect is that it can more accurately evaluate the local characteristics of each pixel point, while retaining more detail information in the image, so that the image enhancement effect is better, which is convenient for detecting printed pattern defects. BRIEF DESCRIPTION OF THE DRAWINGS

[0045] In order to more clearly illustrate the technical solutions and advantages in the embodiments of the present application or the prior art, the drawings required for use in the embodiments or the prior art descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0046] Figure 1 A flow chart of a method for detecting printed pattern defects for plastic packaging provided in one embodiment of the present application;

[0047] Figure 2 A printed image of a plastic package without scratch defects provided by one embodiment of the present application;

[0048] Figure 3 A printed image of a plastic package with scratch defects provided in one embodiment of the present application;

[0049] Figure 4 A flowchart for constructing an indicator of the window side length of the improved ACE algorithm provided in one embodiment of the present application. DETAILED DESCRIPTION

[0050] In order to further explain the technical means and effects adopted by the present application to achieve the predetermined invention purpose, the following is a detailed description of the printing pattern defect detection method and system for plastic packaging proposed in the present application, its specific implementation, structure, features and effects, in combination with the accompanying drawings and preferred embodiments. In the following description, different "one embodiment" or "another embodiment" does not necessarily refer to the same embodiment. In addition, specific features, structures or characteristics in one or more embodiments may be combined in any suitable form.

[0051] Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs.

[0052] The specific scheme of the printed pattern defect detection method and system for plastic packaging provided by the present application is described in detail below with reference to the accompanying drawings.

[0053] An embodiment of the present application provides a method and system for detecting printed pattern defects in plastic packaging.

[0054] Specifically, the following printing pattern defect detection method for plastic packaging is provided, please refer to Figure 1 , the method comprises the following steps:

[0055] The first step is to obtain a grayscale image of plastic packaging printing; and use a region segmentation algorithm to obtain each connected domain of the grayscale image of plastic packaging printing.

[0056] In this embodiment, a CCD camera is used to collect a plastic packaging printing image, and the plastic packaging printing image is an RGB space image. Among them, a CCD camera is a camera that uses a charge coupled device as a photosensitive element, and RGB refers to a color mode or color space composed of three basic color lights: red, green, and blue.

[0057] First, the obtained plastic packaging printing image is preprocessed to eliminate the influence of noise and some external interference, and enhance the accuracy of subsequent analysis. In order to remove noise while retaining boundary information, this embodiment uses median filtering to process the plastic packaging printing image. Median filtering is a well-known technology and will not be described in detail. The implementer can also use other denoising methods to denoise the plastic packaging printing image. The obtained plastic packaging printing image is converted into a grayscale image, which is recorded as a plastic packaging printing grayscale image.

[0058] Then, the obtained grayscale image of plastic packaging printing is segmented using a region segmentation algorithm to obtain a plurality of connected domains. In this embodiment, a region growing algorithm is used for region segmentation, and the region growing algorithm is a well-known technology and will not be described in detail.

[0059] At this point, the plastic packaging printing grayscale image and its connected domains can be obtained according to the above method.

[0060] The second step is to determine the degree of influence of the scratch on the connected domain based on the increase of edge pixels in the connected domain relative to the corresponding area of ​​the defect-free printed grayscale image, and the difference in grayscale values ​​between the edge pixels on the connected domain and their neighboring pixels; wherein the neighboring pixels are not in the connected domain.

[0061] When scratches appear on the printed pattern of plastic packaging, the scratches may cause the originally continuous pattern area to be divided into two or more discontinuous parts, that is, cause the connected domain separation phenomenon. Therefore, after the scratches appear, the number of connected domains on the pattern increases, and the area of ​​some connected domains may decrease. In addition, after the scratch divides the image into two parts, its edge pixels are still connected, because these two edge pixels belong to the same image, and due to the increase in connected paths, the connectivity of the edge pixels is also strong. Secondly, the width distribution in the scratches is uneven, and some areas may become wider or narrower. Therefore, the width of the connected domain corresponding to the left and right adjacent edge pixels of some edge pixels will have a changing trend.

[0062] Accordingly, the present application conducts analysis on printed images of plastic packaging with scratch defects.

[0063] In one embodiment of the present application, a plastic packaging printed image without scratch defects is shown in the attached Figure 2 As shown in the attached figure, there are scratch defects in the printed image of plastic packaging Figure 3 shown.

[0064] In this embodiment, any connected domain that may have a scratch defect is analyzed, and any connected domain is recorded as a connected domain C in this embodiment. The same analysis method as the connected domain C is used to analyze other connected domains in the plastic packaging printing image. The specific process of scratch defect analysis on the connected domain C is as follows:

[0065] Since the printed pattern has a certain color distribution, if the connected domain C is a scratch defect, the original color distribution of the connected domain C will be destroyed, that is, the colors of the pixels inside the scratch defect are consistent, and the edge pixels will have obvious differences from the original colors of the adjacent printed pattern.

[0066] The same shooting conditions as the grayscale image of the plastic packaging printing are used to obtain a defect-free plastic packaging printing image, and the defect-free plastic packaging printing image is grayscaled to obtain a defect-free printing grayscale image.

[0067] According to the above analysis, the impact degree of the scratch on the connected domain C can be determined based on the increase in the number of edge pixels of the connected domain C and the change characteristics of the gray value difference of the pixel closest to it, specifically:

[0068] Based on the difference in the number of edge pixels between the connected domain C and the corresponding area in the grayscale image of defect-free printing, the suspicious weight of the connected domain C is determined; specifically:

[0069] First, the number of edge pixels in the connected domain C is calculated, and the difference between the number of edge pixels in the corresponding area of ​​the non-defective printed grayscale image is used as the numerator; the total number of edge pixels in the non-defective printed grayscale image is calculated as the denominator;

[0070] Then, the ratio of the numerator to the denominator is taken as the suspicious weight of the connected domain C.

[0071] Based on the gray value difference between the edge pixel point on the connected domain C and the pixel point closest to it, the color destruction coefficient of the connected domain C is determined; specifically:

[0072] First, the sum of the absolute values ​​of the differences between the grayscale values ​​of all edge pixels in the connected domain C and the pixels in the nearest non-connected domain C is calculated; the distribution variance of the grayscale values ​​of the pixels in the connected domain C is calculated;

[0073] Then, the ratio of the accumulated sum to the distribution variance is taken as the color destruction coefficient of the connected domain C.

[0074] In this embodiment, in order to prevent the denominator from being 0 when calculating the color destruction coefficient, a very small positive number greater than 0 is added to the distribution variance. In this embodiment, the value is 0.001, and the implementer can set it according to the actual situation.

[0075] Furthermore, based on the suspicious weight of the connected domain C and the color destruction coefficient of the connected domain C, the scratch influence degree of the connected domain C is determined. Among them, the suspicious weight of the connected domain C and the color destruction coefficient of the connected domain C are both positively correlated with the scratch influence degree of the connected domain C.

[0076] Preferably, in this embodiment, the product of the suspicious weight of the connected domain C and the color destruction coefficient is used as the scratch influence degree of the connected domain C.

[0077] In other embodiments of the present application, the influence degree of the scratches on the connected domain C may be obtained by using other appropriate positive correlations such as the suspicious weight of the connected domain C and the sum of the color destruction coefficients.

[0078] It should be understood that when the degree of influence of the scratch on the connected domain C is greater, it means that the original color distribution difference relative to the corresponding area of ​​the defect-free printed grayscale image is larger, then the connected domain C is more likely to divide the defective area and better extract the visual features of the scratch.

[0079] The third step is to determine the scratch index of any edge pixel point on the connected domain based on the length and number of connected paths between edge pixels in the connected domain and the difference in connected domain width between adjacent edge pixels on the connected domain.

[0080] Furthermore, if a scratch separates two edge pixels that were originally connected, the edge pixels on both sides of the scratch are still connected, and because the number of connected paths increases, the connectivity strength of the edge pixels in the connected domain will also increase. Taking any edge pixel on the connected domain as the center, obtain the eight-connected domain of each edge pixel, analyze the eight-connected domain of any two edge pixels in the connected domain, and determine the connectivity strength between any two edge pixels based on the connectivity between any two edge pixels in the connected domain; specifically:

[0081] First, the depth-first search algorithm is used to calculate the number of connected paths between any two edge pixels and the length of each connected path. The specific method is as follows: determine the 8-connected domain of each edge pixel, first determine the starting pixel and the target pixel, and use the depth-first search algorithm in the connected domain to traverse each edge pixel, and count the number of connected paths between the two edge pixels and the length of each path. Among them, the depth-first search algorithm is a well-known technology and will not be repeated.

[0082] Then, determine the maximum number of connected paths that are theoretically possible between any two edge pixels. Specifically, suppose there is an 8-connected image and you want to calculate the maximum number of connected paths from point A to point B. If the Manhattan distance between point A and point B is d, then the maximum number of connected paths that are theoretically possible will be the number of combinations of directions chosen in any of the d steps. In an 8-connected graph, there are 8 choices for each step, so the number of paths will be .

[0083] Finally, obtain the maximum Manhattan distance between any two edge pixels, calculate the cumulative result of the length of all connected paths between any two edge pixels; take the ratio of the cumulative result to the maximum Manhattan distance as the first ratio; obtain the number of connected paths between any two edge pixels; take the ratio of the number of connected paths to the maximum number of connected paths theoretically possible between any two edge pixels as the second ratio; set the first and second weight coefficients respectively, and use the first and second weight coefficients as weights to calculate the weighted sum of the corresponding first and second ratios as the connectivity strength between any two edge pixels.

[0084] In this embodiment, the first weight coefficient and the second weight coefficient are respectively set to 0.3 and 0.7, which can be set by the implementer according to actual conditions.

[0085] Furthermore, the width of the scratch may be unevenly distributed, so the width of the connected domain corresponding to the other adjacent edge pixels on the left and right of a certain edge pixel on the scratch will change to a certain extent, that is, it will become wider or narrower. The curve obtained after the connected domain is corroded is used as the skeleton line of the connected domain, and the line between the two endpoints where the skeleton line intersects with the connected domain is used as the main direction of the connected domain. For any edge pixel on the connected domain, a straight line perpendicular to the main direction of the connected domain is drawn through any edge pixel, and the number of pixels that the straight line passes through the connected domain is used as the width of the connected domain of any edge pixel. From the above analysis, based on this feature, it can be judged that the edge pixel in the connected domain is likely to be a pixel in the scratch area.

[0086] Accordingly, based on the difference in the width of the connected domain between any edge pixel point and its adjacent edge pixel point on the connected domain, the scratch possibility index of any edge pixel point is determined; specifically:

[0087] First, the cumulative sum of the absolute values ​​of the differences in the widths of the connected domains between any edge pixel and all its adjacent edge pixels is calculated;

[0088] Then, the ratio of the accumulated sum value to the width of the connected domain of any edge pixel point is used as the scratch possibility index of any edge pixel point.

[0089] Based on the above steps, the scratch influence degree of all connected domains, the scratch possibility index of any edge pixel point on the connected domain, and the connectivity strength between any two edge pixels in the connected domain are obtained respectively. When the scratch influence degree of the connected domain where the edge pixel point is located is greater, and the difference in the connected domain width between the edge pixel point and its adjacent edge pixel point is greater, it means that the connected domain is more likely to be a scratch area, and the edge pixel point should obtain a larger window for enhancement; when the scratch influence degree of the connected domain where the edge pixel point is located is smaller, and the connected domain width between the edge pixel point and its adjacent edge pixel point is closer, it means that the probability of this connected domain being a scratch area is smaller, and when enhancing, a smaller window should be selected for enhancement.

[0090] Accordingly, based on the connectivity between edge pixels in the connected domain and the difference in connected domain width between adjacent edge pixels on the connected domain, the scratch index of any edge pixel on the connected domain is determined; specifically:

[0091] The scratch index is positively correlated with the scratch possibility index, and is positively correlated with the mean value of the connectivity strength between any edge pixel point and all other edge pixel points in the connected domain where the edge pixel point is located.

[0092] In this embodiment, the product of the average value of the connectivity strength between any edge pixel point and all other edge pixel points in the connected domain where the edge pixel point is located and the scratch possibility index is used as the scratch index.

[0093] In other embodiments of the present application, the mean value of the connectivity strength between any edge pixel point and all other edge pixel points in its connected domain and the sum of the scratch possibility index may be used as the scratch index.

[0094] It can be understood that a positive correlation means that the dependent variable will increase as the independent variable increases, and the dependent variable will decrease as the independent variable decreases. The specific relationship can be a multiplication relationship, an addition relationship, or the idempotence of an exponential function, which is determined by actual application and is not specifically limited in this application.

[0095] The fourth step is to determine the window side length of any edge pixel point based on the difference between the maximum value of the scratch influence of the connected domain and the scratch influence of any edge pixel point on the connected domain, combined with the scratch index of any edge pixel point on the connected domain; based on the window side length combined with the ACE image enhancement algorithm, the enhanced image is obtained, and the enhanced image is segmented and the defective area is detected.

[0096] According to the scratch influence degree of the connected domain obtained in the second and third steps and the scratch index of any pixel point on the connected domain, the window size in the ACE image enhancement algorithm is corrected, so that the image is locally enhanced according to the distribution characteristics of the scratch defect area in the actual image, ensuring that the image detail information is retained while enhancing, making the defect area more prominent, and the optimized image enhancement effect is better.

[0097] First, the maximum value of the scratch influence degree in all connected domains of the grayscale image of plastic packaging printing is obtained; the ratio of the scratch influence degree of any edge pixel point to the maximum value is calculated, and recorded as the normalized scratch influence value;

[0098] Then, an integer value of the product of the scratch index of any edge pixel point and the normalized value of the scratch influence is taken as the side length of the window of any edge pixel point.

[0099] The window side length of each pixel except the edge pixels in the grayscale image of plastic packaging printing is set to the average window side length of all edge pixels, and the window side length of each pixel in the grayscale image of plastic packaging printing is used as the window side length of each pixel in the improved ACE algorithm to obtain the enhanced image.

[0100] In this embodiment, the indicator construction flow chart of the window side length of the improved ACE algorithm is as follows: Figure 4 shown.

[0101] For the enhanced image, the region segmentation algorithm is used to perform region segmentation, and the similarity between each segmented region and the corresponding position region in the defect-free printing grayscale image is calculated. When the similarity is greater than the similarity threshold, the region is judged as a defective region; otherwise, the region is judged as a normal region.

[0102] Among them, this embodiment uses the watershed algorithm to segment the enhanced image, and uses the cosine similarity calculation method to calculate the similarity between corresponding position areas. The calculation process of the watershed algorithm and the cosine similarity is a well-known technology and will not be repeated. At the same time, this embodiment sets the similarity threshold to 0.95, and the implementer can set it according to the actual situation.

[0103] Based on the same inventive concept as the above method, an embodiment of the present application also provides a printed pattern defect detection system for plastic packaging, including a memory, a processor, and a computer program stored in the memory and running on the processor, and when the processor executes the computer program, the steps of any one of the above-mentioned printed pattern defect detection methods for plastic packaging are implemented.

[0104] The various embodiments in this specification are described in a progressive manner, and the same or similar parts between the various embodiments can be referenced to each other, and each embodiment focuses on the differences from other embodiments.

[0105] It should be noted that, unless otherwise specified and limited, terms such as "include", "comprises" or any other variants thereof are intended to cover non-exclusive inclusion, so that a circuit structure, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such article or device. In the absence of further restrictions, an element defined by the sentence "including one..." does not exclude the existence of other identical elements in the article or device including the element. In addition, the term "and\or" used herein includes any and all combinations of one or more related listed items.

[0106] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the invention invented herein. The present application is intended to cover any variations, uses or adaptations of the present application, which follow the general principles of the present application and include common knowledge or customary technical means in the art not invented by the present application.

[0107] It should be understood that the present application is not limited to the exact construction that has been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof.

Claims

1. Printing pattern defect detection method for plastic packaging, It is characterized in that The method comprises the following steps: Obtaining a grayscale image of plastic packaging printing; using a region segmentation algorithm to obtain each connected domain of the grayscale image of plastic packaging printing; Based on the increase of edge pixels of the connected domain relative to the location of the corresponding area of ​​the non-defective printed grayscale image, and the grayscale value difference between the edge pixels on the connected domain and its neighboring pixels, the degree of scratch influence of the connected domain is determined; wherein the neighboring pixels are not in the connected domain; the difference between the number of edge pixels in the connected domain and the number of edge pixels at the location of the corresponding area of ​​the non-defective printed grayscale image is used as the numerator, and the total number of edge pixels in the non-defective printed grayscale image is used as the denominator to obtain the suspicious weight of the connected domain; the cumulative sum of the absolute values ​​of the differences between the grayscale values ​​of all edge pixels in the connected domain and the pixels that are closest to them and not in the connected domain is used as the numerator, and the distribution variance of the grayscale values ​​of the pixels in the connected domain is used as the denominator to obtain the color destruction coefficient of the connected domain; based on the suspicious weight and the color destruction coefficient, the degree of scratch influence of the connected domain is determined; wherein the suspicious weight and the color destruction coefficient are both positively correlated with the degree of scratch influence; Based on the length and number of connected paths between edge pixels in the connected domain, and the difference in connected domain widths between adjacent edge pixels on the connected domain, the scratch index of any edge pixel on the connected domain is determined; the number of connected paths between two edge pixels, the length of each connected path, the theoretically possible maximum number of connected paths, and the Manhattan distance are obtained; the ratio of the cumulative value of the length of all connected paths between the two edge pixels and the Manhattan distance is recorded as the first ratio; the ratio of the number of connected paths to the theoretically possible maximum number of connected paths is recorded as the second ratio, and the first ratio and the second ratio are weighted to obtain the connectivity strength of the two edge pixels; the connected domain is corroded. The curve obtained after erosion is used as the skeleton line of the corresponding connected domain, the line between the two endpoints where the skeleton line intersects the connected domain is recorded as the main direction of the connected domain, and the number of pixel points in the connected domain of the straight line perpendicular to the main direction of the edge pixel point is recorded as the connected domain width; the scratch possibility index is obtained according to the difference between the connected domain widths of the edge pixel point and all its adjacent edge pixel points and the connected domain width of the edge pixel point; the scratch index of the edge pixel point is determined based on the connectivity strength and the scratch possibility index; the scratch index is positively correlated with the scratch possibility index, and is positively correlated with the mean value of the connectivity strength between any edge pixel point and all other edge pixels in its connected domain; Based on the difference between the maximum scratch influence degree of the connected domain and the scratch influence degree of any edge pixel point on the connected domain, combined with the scratch index of any edge pixel point on the connected domain, the window side length of any edge pixel point is determined; based on the window side length combined with the ACE image enhancement algorithm, the enhanced image is obtained, and the enhanced image is segmented and the defect area is detected.

2. The method for detecting printed pattern defects in plastic packaging according to claim 1, It is characterized in that The method for determining the degree of impact of the scratches includes: Determine the suspicious weight of the connected domain based on the difference in the number of edge pixels between the connected domain and the corresponding area in the grayscale image of defect-free printing; Based on the gray value difference between the edge pixel point on the connected domain and the pixel point closest to it, the color destruction coefficient of the connected domain is determined; Based on the suspicious weight and the color destruction coefficient, the scratch influence degree of the connected domain is determined; wherein the suspicious weight and the color destruction coefficient are both positively correlated with the scratch influence degree.

3. The method for detecting printed pattern defects for plastic packaging according to claim 2, It is characterized in that The method for determining the suspicious weight includes: The number of edge pixels in the connected domain is calculated, and the difference between the number of edge pixels at the corresponding area in the non-defective printed grayscale image is used as the numerator; the total number of edge pixels in the non-defective printed grayscale image is calculated as the denominator; The ratio of the numerator to the denominator is taken as the suspicious weight of the connected domain.

4. The method for detecting printed pattern defects for plastic packaging according to claim 2, It is characterized in that The method for determining the color destruction coefficient includes: Calculate the cumulative sum of the absolute values ​​of the differences between the grayscale values ​​of all edge pixels in the connected domain and the pixels closest to them that are not in the connected domain; calculate the distribution variance of the grayscale values ​​of the pixels in the connected domain; The ratio of the cumulative sum to the distribution variance is taken as the color destruction coefficient of the connected domain.

5. The method for detecting printed pattern defects for plastic packaging according to claim 1, It is characterized in that The deterministic method of the scratch index includes: Based on the connectivity between any two edge pixels in the connected domain, the connectivity strength between any two edge pixels is determined; Determine the scratch possibility index of any edge pixel point based on the difference in connected domain width between any edge pixel point on the connected domain and the position of its adjacent edge pixel point; Based on the connectivity strength and the scratch possibility index, the scratch index of any edge pixel point is determined; wherein the scratch index is positively correlated with the scratch possibility index, and is positively correlated with the average connectivity strength between any edge pixel point and all other edge pixel points in its connected domain.

6. The method for detecting printed pattern defects for plastic packaging as claimed in claim 5, It is characterized in that The method for determining the connectivity strength includes: The depth-first search algorithm is used to calculate the number of connected paths between any two edge pixels and the length of each connected path; Determine the maximum number of connected paths theoretically possible between any two edge pixels; Obtain the maximum Manhattan distance between any two edge pixels, calculate the cumulative result of all connected path lengths between any two edge pixels; and use the ratio of the cumulative result to the maximum Manhattan distance as the first ratio; Obtain the number of connected paths between any two edge pixels; and use the ratio of the number of connected paths to the maximum number of connected paths theoretically possible between any two edge pixels as a second ratio; The first and second weight coefficients are set respectively, and the weighted sums of the first and second ratios corresponding to the first and second weight coefficients are calculated respectively as the connectivity strength between any two edge pixels.

7. The method for detecting printed pattern defects for plastic packaging according to claim 5, It is characterized in that The method for determining the scratch possibility index includes: For any edge pixel point on the connected domain, draw a straight line perpendicular to the main direction of the connected domain through any edge pixel point, and take the number of pixels in the connected domain where the straight line passes through any edge pixel point as the width of the connected domain of any edge pixel point; The cumulative sum of the absolute values ​​of the differences in the widths of the connected domains between any edge pixel and all its adjacent edge pixels is calculated; the ratio of the cumulative sum to the width of the connected domain of any edge pixel is used as the scratch possibility index of any edge pixel.

8. The method for detecting printed pattern defects for plastic packaging according to claim 1, It is characterized in that The method for determining the window side length comprises: Obtain the maximum value of the scratch influence degree in all connected domains of the grayscale image of plastic packaging printing; Calculate the ratio of the scratch influence degree of any edge pixel point to the maximum value, and record it as the normalized scratch influence value; An integer value of the product of the scratch index of any edge pixel point and the normalized value of the scratch influence is used as the side length of the window of any edge pixel point.

9. The method for detecting printed pattern defects for plastic packaging according to claim 1, It is characterized in that The process of acquiring the enhanced image and detecting the defective area includes: The window side length of each pixel point except the edge pixels in the grayscale image of plastic packaging printing is set to the average window side length of all edge pixels; The window side length of each pixel in the grayscale image of plastic packaging printing is used as the window side length of each pixel in the improved ACE algorithm to obtain the enhanced image; For the enhanced image, a region segmentation algorithm is used to perform region segmentation, and the similarity between each segmented region and the corresponding position region in the defect-free printing grayscale image is calculated; When the similarity is greater than the similarity threshold, the region is judged to be a defect region; otherwise, the region is judged to be a normal region.

10. A printed pattern defect detection system for plastic packaging, comprising a memory, a processor, and a computer program stored in the memory and running on the processor, It is characterized in that When the processor executes the computer program, the steps of the printed pattern defect detection method for plastic packaging as described in any one of claims 1 to 9 are implemented.