A method and system for visually detecting defects on packaging film surface

By using the division of grayscale images and the weighted fusion of light influence weight coefficients in packaging film surface inspection, the crease defect area can be accurately extracted, which solves the problem of smaller grayscale differences under the influence of light angle and improves detection accuracy.

CN118365635BActive Publication Date: 2024-09-03GUANGDONG ZHENGYI PACKAGING CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202410774026.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-06-17
Publication Date
2024-09-03
Estimated Expiration
2044-06-17

AI Technical Summary

Technical Problem

When the existing technology detects crease defects on the packaging film surface, the grayscale difference becomes smaller due to the influence of different illumination angles, making it impossible to accurately extract the crease defect area.

Method used

By obtaining the grayscale image of the packaging film surface, dividing the image blocks and determining the direction of the crease defect, each suspected crease is calculated based on the position distribution and grayscale difference between the suspected crease pixels and the surrounding pixels in the crease area sequence. The possibility of crease pixels under vertical illumination and non-vertical illumination is analyzed, and the crease defect area is extracted through weighted fusion using the illumination influence weight coefficient.

Benefits of technology

It improves the accuracy of packaging film surface defect detection, suppresses crease defect pixels that do not have a gray-scale symmetrical relationship, enhances normal pixels that have a gray-scale symmetrical relationship, and reduces the impact of illumination angles.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118365635B
    Figure CN118365635B
Patent Text Reader

Abstract

The present invention relates to the field of image processing technology, and in particular to a method and system for visually detecting surface defects of a packaging film, comprising: obtaining a grayscale image of the surface of the packaging film; obtaining all suspected crease pixels in the grayscale image, and dividing the grayscale image into a plurality of image blocks; obtaining the crease defect direction of each image block; dividing the image block into a plurality of crease region sequences according to the crease defect direction; obtaining the possibility that each suspected crease pixel in the crease region sequence belongs to a normal pixel under vertical illumination; obtaining the possibility that each suspected crease pixel in the crease region sequence belongs to a normal pixel under non-vertical illumination; obtaining an illumination influence weight coefficient; obtaining the possibility that each suspected crease pixel belongs to a normal pixel; and extracting a crease defect region in the grayscale image according to the possibility that the suspected crease pixel belongs to a normal pixel. The present invention improves the accuracy of detecting surface defects of packaging films.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of image processing, and in particular to a method and system for visually detecting surface defects of a packaging film. Background Art

[0002] Lamination is the process of applying transparent plastic film to the surface of packaged products through hot pressing to protect and increase the gloss. Due to external factors such as human or machine factors, the plastic film is not flattened and applied to the surface of the package during the lamination process, resulting in crease defects, which affects the appearance of the package. Since the crease defect area caused by the packaging lamination has a relatively obvious grayscale difference with the background area, threshold segmentation technology is often used to detect crease defects in the packaging lamination. However, due to the influence of different lighting angles, the grayscale difference between the normal area and the crease defect area becomes smaller, making it impossible to accurately extract the crease defect area. Summary of the invention

[0003] In order to solve the above problems, the present invention provides a method and system for visually detecting surface defects of packaging films.

[0004] An embodiment of the present invention provides a method for visually detecting surface defects of a packaging film, the method comprising the following steps:

[0005] Acquire a grayscale image of the packaging film surface;

[0006] Obtain all suspected crease pixel points in the grayscale image, and divide the grayscale image into a plurality of image blocks; obtain the crease defect direction of each image block;

[0007] The image block is divided into several crease region sequences according to the direction of the crease defect; according to the position distribution between each suspected crease pixel and the surrounding pixels in the crease region sequence, the possibility of each suspected crease pixel in the crease region sequence being a normal pixel under vertical illumination is obtained; according to the grayscale difference between each suspected crease pixel in the crease region sequence and the surrounding suspected pixels, the possibility of each suspected crease pixel in the crease region sequence being a normal pixel under non-vertical illumination is obtained; according to the difference in the number of suspected crease pixels in the image block, the illumination influence weight coefficient is obtained; the possibility of suspected crease pixels being normal pixels under non-vertical illumination and the possibility of suspected crease pixels being normal pixels under vertical illumination are weightedly fused by the illumination influence weight coefficient to obtain the possibility of each suspected crease pixel being a normal pixel;

[0008] The crease defect area in the grayscale image is extracted according to the possibility that the suspected crease pixels belong to normal pixels.

[0009] Preferably, the step of acquiring all suspected crease pixel points in the grayscale image and dividing the grayscale image into a plurality of image blocks; and acquiring the crease defect direction of each image block comprises the following specific methods:

[0010] Preset a block parameter , use the Otsu threshold segmentation algorithm to perform threshold segmentation on the grayscale image to obtain a segmentation result map of the grayscale image; correspond all pixel points in the segmentation result map to all pixel points in the grayscale image, and record them as suspected crease pixels; divide the grayscale image into several For any image block, the sum vector of the gradient vectors of all pixels in the image block is recorded as the first sum vector; the direction of the vector perpendicular to the first sum vector is taken as the fold defect direction of the image block.

[0011] Preferably, the method of dividing the image block into a plurality of fold area sequences according to the fold defect direction includes:

[0012] For any image block, the image block is divided into several straight line areas, which are perpendicular to the fold defect direction of the image block and there is no gap between adjacent straight line areas; a pixel point sequence composed of all pixel points on each straight line area is recorded as a fold area sequence.

[0013] Preferably, the method of obtaining the possibility that each suspected crease pixel in the crease region sequence is a normal pixel under vertical illumination according to the position distribution between each suspected crease pixel and surrounding pixels in the crease region sequence includes the following specific methods:

[0014] Preset a range parameter and a sequence parameter For any suspected crease pixel in any crease region sequence in any image block, the suspected crease pixel is pixels and A pixel point sequence consisting of pixels is used as the neighborhood range sequence of the suspected crease pixel point; a A sliding window is used to slide in the neighborhood range sequence of the suspected fold mark pixel point with a step length of 1, and each sliding window is used as a sequence segment to obtain a plurality of sequence segments in the neighborhood range sequence of the suspected fold mark pixel point;

[0015] Obtain the grayscale change rate of each sequence segment in the neighborhood range sequence of each suspected crease pixel in the crease region sequence;

[0016] According to the difference in grayscale change rate between the suspected crease pixel point in the crease region sequence and other suspected crease pixel points in the neighborhood range sequence, the symmetric center point of each suspected crease pixel point in the crease region sequence is obtained;

[0017] Preset a clustering parameter , using K value The K-means clustering algorithm is used to cluster the symmetrical center points of all suspected crease pixel points in the crease region sequence to obtain clusters; the cluster centers of the clusters are used as the reference points of the crease region sequence;

[0018] For any suspected crease pixel in the crease region sequence, the reciprocal of the Euclidean distance between the symmetry center point of the suspected crease pixel and the reference point of the crease region sequence is taken as the possibility that the suspected crease pixel is a normal pixel under vertical illumination.

[0019] Preferably, the grayscale change rate of each sequence segment in the neighborhood range sequence of each suspected crease pixel point in the crease region sequence is obtained, including the specific method of:

[0020] For the suspected crease pixel point in the neighborhood range sequence sequence segment, The sum of the grayscale values ​​of all pixels in the sequence segment is equal to the The absolute value of the difference between the sum of the grayscale values ​​of all pixels in the sequence segment is recorded as the first absolute value of the difference; the absolute value of the first difference is added to the The ratio of the sum of the grayscale values ​​of all pixels in the sequence segment is taken as the The grayscale change rate of a sequence segment.

[0021] Preferably, the specific method of obtaining the symmetric center point of each suspected crease pixel point in the crease region sequence includes:

[0022] For any crease region sequence The suspected crease pixels and suspected crease pixels, The first The grayscale change rate of the sequence segment is The first pixel in the neighborhood sequence of suspected crease pixels The reciprocal of the absolute value of the difference in the grayscale change rate of the sequence segment is taken as the The suspected crease pixel and the The first The grayscale change difference value of the sequence segment; The suspected crease pixels and The cumulative sum of the grayscale change difference values ​​of all sequence segments in the neighborhood range sequence between the suspected crease pixels is taken as the The suspected crease pixel and the Symmetry between suspected crease pixels;

[0023] In the Among the symmetries between the suspected crease pixels and all the suspected crease pixels, the suspected crease pixel with the largest symmetry is recorded as The target suspected crease pixel of the suspected crease pixel; The suspected crease pixel and the The pixel point at the center of the straight line connecting the target suspected crease pixel points is taken as the first The symmetric center point of the suspected crease pixels.

[0024] Preferably, the method of obtaining the possibility that each suspected crease pixel in the crease region sequence is a normal pixel under non-vertical illumination according to the grayscale difference between each suspected crease pixel and surrounding suspected pixels in the crease region sequence includes the following specific methods:

[0025] Preset a clustering parameter and neighborhood parameters For any suspected crease pixel in any crease region sequence in any image block, use the K value to calculate The K-means clustering algorithm is used to cluster all the pixels in the neighborhood sequence of the suspected crease pixel to obtain clusters; the suspected crease pixels are pixels and pixel points constitute the target neighborhood range of the suspected crease pixel point;

[0026] In the target neighborhood range of the suspected crease pixel point, the pixel point that belongs to the same cluster as the suspected crease pixel point is recorded as the first pixel point of the suspected crease pixel point; the ratio of the total number of the first pixel points to the total number of all the pixels in the target neighborhood range of the suspected crease pixel point is taken as the grayscale aggregation of the suspected crease pixel point;

[0027] For any first pixel of the suspected crease pixel points, the absolute value of the difference in grayscale value between the suspected crease pixel point and the first pixel point is recorded as the first grayscale difference value of the first pixel point; the reciprocal of the cumulative sum of the first grayscale difference values ​​of all the pixels of the suspected crease pixel points is recorded as the grayscale consistency of the suspected crease pixel points;

[0028] The product of the grayscale aggregation of the suspected crease pixel point and the grayscale consistency of the suspected crease pixel point is taken as the possibility that the suspected crease pixel point is a normal pixel point under non-vertical lighting.

[0029] Preferably, the method of obtaining the illumination influence weight coefficient according to the difference in the number of suspected fold pixel points in the image block includes the following specific methods:

[0030] The image block with the largest number of suspected crease pixels is recorded as the first image block; the image block with the smallest number of suspected crease pixels is recorded as the second image block; the reciprocal of the difference between the maximum grayscale value of all pixels in the first image block and the minimum grayscale value of all pixels in the second image block is used as the illumination influence weight coefficient.

[0031] Preferably, the method of weighted fusion of the possibility that the suspected crease pixel point belongs to a normal pixel point under non-vertical illumination and the possibility that the suspected crease pixel point belongs to a normal pixel point under vertical illumination by using the illumination influence weight coefficient to obtain the possibility that each suspected crease pixel point belongs to a normal pixel point includes the following specific methods:

[0032] For any suspected crease pixel, the product of the possibility that the suspected crease pixel is a normal pixel under vertical lighting and the lighting influence weight coefficient is recorded as the first product; the difference between 1 and the lighting influence weight coefficient is recorded as the second difference; the product of the second difference and the possibility that the suspected crease pixel is a normal pixel under non-vertical lighting is recorded as the second product; the sum of the first product and the second product is taken as the possibility that the suspected crease pixel is a normal pixel.

[0033] The present invention also proposes a system for visually inspecting surface defects of packaging films, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements any one of the steps of a method for visually inspecting surface defects of packaging films when executing the computer program.

[0034] The beneficial effects of the technical solution of the present invention are as follows: the present invention divides an image block into a plurality of crease area sequences according to the direction of the crease defect; obtains the possibility that each suspected crease pixel in the crease area sequence is a normal pixel under vertical illumination according to the position distribution between each suspected crease pixel and the surrounding pixels in the crease area sequence; by analyzing the grayscale symmetry relationship of the suspected crease pixels in the direction perpendicular to the crease defect when the illumination angle is perpendicular to the surface of the packaging film, and according to the symmetry relationship of the suspected crease pixels in the crease area sequence, obtains the possibility that the suspected crease pixels are normal pixels under vertical illumination, thereby suppressing the crease defect pixels that do not have a grayscale symmetry relationship and enhancing the grayscale symmetry relationship. Normal pixels improve the effect of defect detection; according to the grayscale difference between each suspected crease pixel and the surrounding suspected pixels in the crease area sequence, the possibility of each suspected crease pixel in the crease area sequence being a normal pixel under non-vertical lighting is obtained; thereby eliminating the influence of different lighting angles; through the lighting influence weight coefficient, the possibility of suspected crease pixels being normal pixels under non-vertical lighting and the possibility of suspected crease pixels being normal pixels under vertical lighting are weightedly fused to obtain the possibility of each suspected crease pixel being a normal pixel; according to the possibility that the suspected crease pixel is a normal pixel, the crease defect area in the grayscale image is extracted; thereby improving the accuracy of packaging film surface defect detection. BRIEF DESCRIPTION OF THE DRAWINGS

[0035] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. 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 paying creative work.

[0036] Figure 1 A flowchart of the steps of a method for visually detecting surface defects of a packaging film according to the present invention;

[0037] Figure 2 The present invention is a characteristic relationship flow chart of visual detection of surface defects of packaging films. DETAILED DESCRIPTION

[0038] In order to further explain the technical means and effects adopted by the present invention to achieve the predetermined invention purpose, the following is a detailed description of a packaging film surface defect visual detection method and system proposed by the present invention, its specific implementation, structure, features and effects, in conjunction 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.

[0039] 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 invention belongs.

[0040] The specific scheme of the visual detection method and system for surface defects of packaging films provided by the present invention is described in detail below with reference to the accompanying drawings.

[0041] See also Figure 1 , which shows a flowchart of a method for visually detecting surface defects of a packaging film provided by an embodiment of the present invention, the method comprising the following steps:

[0042] Step S001: Acquire a grayscale image of the packaging film surface.

[0043] It should be noted that in the grayscale image of the packaging film surface, normal pixels have different grayscale change relationships under different directions and lighting angles, and defective pixels usually cause irregularity or abnormality in the grayscale value change. Based on this irregularity or abnormality, the crease defect area in the grayscale image of the packaging film surface is extracted.

[0044] Specifically, we first need to collect the grayscale image of the packaging film surface. The specific process is as follows:

[0045] The packaging film sample to be tested is placed on the testing equipment, and the packaging film surface image is obtained through a high-definition camera, and the packaging film surface image is subjected to median filtering, denoising and grayscale operations to obtain a grayscale image of the packaging film surface. In this embodiment, the grayscale image of the packaging film surface obtained is described as having a size of 800×800; median filtering and grayscale operations are prior arts, and this embodiment will not be described in detail here.

[0046] So far, a grayscale image of the packaging film surface is obtained through the above method.

[0047] Step S002: Obtain all suspected crease pixel points in the grayscale image, and divide the grayscale image into a plurality of image blocks; obtain the crease defect direction of each image block.

[0048] It should be noted that since the crease defect appears as a raised part in the image, it has a large grayscale difference from the background area under lighting conditions, that is, the grayscale value of the pixel points in the crease defect area is high, so the Otsu method can be used to pre-segment the grayscale image to obtain all suspected crease pixels; when there is a crease defect in the grayscale image, since the crease will cause a raised area, the raised area is consistent with the crease direction and has the same high grayscale expression; however, the grayscale image may also have normal raised areas, and the grayscale changes of normal raised areas have a certain regularity under the influence of light, while the raised areas caused by crease defects usually lead to irregular or abnormal grayscale changes; due to the interference of other external factors, the direction of the crease defect is random; therefore, in order to determine the grayscale change pattern of the pixel points in different directions, it is necessary to first determine the direction of the crease defect; since there may be multiple crease defects in different directions in the grayscale image, the direction of the crease defect in each image block can be determined by dividing the grayscale image into blocks.

[0049] Preset a block parameter , wherein this embodiment is based on This example is described as an example, and this embodiment is not specifically limited. It depends on the specific implementation situation.

[0050] Specifically, the grayscale image is threshold segmented using the Otsu threshold segmentation algorithm to obtain a segmentation result map of the grayscale image; all pixels in the segmentation result map are matched to all pixels in the grayscale image, and all are recorded as suspected crease pixels; the grayscale image is divided into several For any image block, the sum vector of the gradient vectors of all pixels in the image block is recorded as the first sum vector; the direction of the vector perpendicular to the first sum vector is taken as the fold defect direction of the image block.

[0051] It should be noted that since the crease defect area is a convex area in the grayscale image, the grayscale value of the pixel points in the crease defect area will increase rapidly due to the influence of light. This phenomenon will cause the gradient of the pixel points perpendicular to the crease direction to change rapidly. Therefore, the overall gradient direction of the pixel points in the image block can be used to determine the direction of the crease defect; among them, the Otsu threshold segmentation algorithm is a prior art and will not be described in detail in this embodiment.

[0052] So far, the fold defect directions of all image blocks are obtained through the above method.

[0053] Step S003: Divide the image block into several crease area sequences according to the direction of the crease defect; obtain the possibility that each suspected crease pixel in the crease area sequence is a normal pixel under vertical illumination according to the position distribution between each suspected crease pixel and the surrounding pixels in the crease area sequence; obtain the possibility that each suspected crease pixel in the crease area sequence is a normal pixel under non-vertical illumination according to the grayscale difference between each suspected crease pixel and the surrounding suspected pixels; obtain the illumination influence weight coefficient according to the difference in the number of suspected crease pixels in the image block; perform weighted fusion of the possibility that the suspected crease pixel is a normal pixel under non-vertical illumination and the possibility that the suspected crease pixel is a normal pixel under vertical illumination through the illumination influence weight coefficient to obtain the possibility that each suspected crease pixel is a normal pixel.

[0054] It should be noted that since the grayscale values ​​of the pixels of the image block are variable in the direction perpendicular to the crease defect, and the grayscale change relationship is affected by the illumination angle; in the direction parallel to the crease defect, the grayscale change of the pixels is consistent and is not affected by the illumination angle; from the perspective of illumination direction, when the light shines vertically on the packaging film, the grayscale value of the pixels in the crease defect area is larger, while the grayscale value of the pixels in the background area is smaller; when the light shines on the object from the side, the grayscale value of the pixels on the side facing the light source is larger, and the grayscale value of the pixels on the side facing away from the light source is smaller; therefore, according to the relationship between the grayscale value change of the pixels in the crease defect direction at different illumination angles, all suspected crease pixels are distinguished into normal pixels and defective pixels, that is, the possibility of suspected crease pixels belonging to normal pixels under different illumination directions is calculated.

[0055] Specifically, for any image block, the image block is divided into a number of straight line areas, where the straight line areas are perpendicular to the fold defect direction of the image block and there is no gap between adjacent straight line areas; a pixel point sequence composed of all pixel points on each straight line area is recorded as a fold area sequence.

[0056] 1. Obtain the probability that each suspected crease pixel in each crease region sequence is a normal pixel under vertical illumination.

[0057] It should be noted that under vertical lighting conditions, the grayscale values ​​of pixels belonging to the crease area in the direction perpendicular to the crease defect are larger, and the grayscale values ​​of pixels on both sides of the crease area are getting smaller and smaller. At this time, the normal pixels will have a certain grayscale change, and this grayscale change will make the normal pixels symmetrical. The symmetry here is specifically manifested in that all arbitrary pixels in a sequence are consistent with the symmetry center of their corresponding points, and the crease defect pixels will destroy this symmetry relationship and change the symmetry center. In order to analyze the symmetry relationship of suspected crease pixels in the sequence, it is first necessary to obtain multiple sequences perpendicular to the crease defect direction, and calculate the symmetry relationship of the suspected crease pixels in each sequence.

[0058] Preferably, in some implementations of the embodiments of the present invention, according to the position distribution between each suspected crease pixel and surrounding pixels in the crease region sequence, a calculation method for obtaining the possibility that each suspected crease pixel in the crease region sequence is a normal pixel under vertical illumination is:

[0059] Preset a range parameter and a sequence parameter , wherein this embodiment is based on This example is described as an example, and this embodiment is not specifically limited. It depends on the specific implementation situation.

[0060] For any suspected crease pixel in any crease region sequence in any image block, pixels and A pixel point sequence consisting of pixels is used as the neighborhood range sequence of the suspected crease pixel point; a A sliding window is used to slide in the neighborhood range sequence of the suspected fold mark pixel point with a step length of 1, and each sliding window is used as a sequence segment to obtain a plurality of sequence segments in the neighborhood range sequence of the suspected fold mark pixel point;

[0061] Obtain the grayscale change rate of each sequence segment in the neighborhood range sequence of each suspected crease pixel in the crease region sequence;

[0062] According to the difference in grayscale change rate between the suspected crease pixel point in the crease region sequence and other suspected crease pixel points in the neighborhood range sequence, the symmetric center point of each suspected crease pixel point in the crease region sequence is obtained;

[0063] Preset a clustering parameter , wherein this embodiment is based on This example is described as an example, and this embodiment is not specifically limited. It depends on the specific implementation situation.

[0064] Using K value The K-means clustering algorithm is used to cluster the symmetrical center points of all suspected crease pixel points in the crease region sequence to obtain clusters; the cluster centers of the clusters are used as the reference points of the crease region sequence;

[0065] For any suspected crease pixel in the crease region sequence, the reciprocal of the Euclidean distance between the symmetry center point of the suspected crease pixel and the reference point of the crease region sequence is taken as the possibility that the suspected crease pixel is a normal pixel under vertical illumination.

[0066] The specific formula is:

[0067]

[0068] In the formula, Indicates the possibility that the suspected crease pixels in the crease region sequence are normal pixels under vertical illumination; The Euclidean distance between the symmetric center point of the suspected crease pixel and the reference point of the crease region sequence; Represents the preset hyperparameters. This implementation presets , used to prevent the denominator from being 0.

[0069] It should be noted that since the suspected crease pixels have an irregular distribution, the corresponding symmetry center points will be offset. In order to analyze the possibility that the suspected crease pixels are normal pixels under vertical illumination through the offset analysis, it is necessary to first determine the reference points of the crease area sequence; since the positional relationship between the symmetry center point of the suspected crease pixel and the reference point can reflect its symmetry, the possibility of the suspected crease pixel being a normal pixel under vertical illumination is determined by the offset of the symmetry center point of the suspected crease pixel; the K-means clustering algorithm is a prior art and will not be described in detail in this embodiment.

[0070] Preferably, in some implementations of the embodiments of the present invention, the calculation method for obtaining the grayscale change rate of each sequence segment in the neighborhood range sequence of each suspected crease pixel point in each crease region sequence is:

[0071] For the suspected crease pixel point in the neighborhood range sequence sequence segment, The sum of the grayscale values ​​of all pixels in the sequence segment is equal to the The absolute value of the difference between the sum of the grayscale values ​​of all pixels in the sequence segment is recorded as the first absolute value of the difference; the absolute value of the first difference is added to the The ratio of the sum of the grayscale values ​​of all pixels in the sequence segment is taken as the The grayscale change rate of a sequence segment.

[0072] The specific formula is:

[0073]

[0074] In the formula, Indicates the number of pixels in the neighborhood of the suspected crease point. Grayscale change rate of each sequence segment; Indicates the number of pixels in the neighborhood of the suspected crease point. The sum of the gray values ​​of all pixels in a sequence segment; Indicates the number of pixels in the neighborhood of the suspected crease point. The sum of the gray values ​​of all pixels in a sequence segment; Indicates taking the absolute value.

[0075] It should be noted that the grayscale of the pixels in the crease region sequence has a certain grayscale change relationship, so there will also be grayscale changes between adjacent sequence segments in the neighborhood range sequence.

[0076] Preferably, in some implementations of the embodiments of the present invention, according to the difference in grayscale change rate of the sequence segment in the neighborhood range sequence between the suspected crease pixel point in the crease area sequence and other suspected crease pixel points, the calculation method for obtaining the symmetric center point of each suspected crease pixel point in each crease area sequence is:

[0077] For any crease region sequence The suspected crease pixels and suspected crease pixels, The first The grayscale change rate of the sequence segment is The first pixel in the neighborhood sequence of suspected crease pixels The reciprocal of the absolute value of the difference in the grayscale change rate of the sequence segment is taken as the The suspected crease pixel and the The first The grayscale change difference value of the sequence segment; The suspected crease pixels and The cumulative sum of the grayscale change difference values ​​of all sequence segments in the neighborhood range sequence between the suspected crease pixels is taken as the The suspected crease pixel and the Symmetry between suspected crease pixels;

[0078] The specific formula is:

[0079]

[0080] In the formula, Indicates the first The suspected crease pixel and the Symmetry between suspected crease pixels; Indicates the first The first Grayscale change rate of each sequence segment; The first The first Grayscale change rate of each sequence segment; Indicates taking the absolute value; Represents the preset hyperparameters. This implementation presets , used to prevent the denominator from being 0.

[0081] In the Among the symmetries between the suspected crease pixels and all the suspected crease pixels, the suspected crease pixel with the largest symmetry is recorded as The target suspected crease pixel of the suspected crease pixel; The suspected crease pixel and the The pixel point at the center of the straight line connecting the target suspected crease pixel points is taken as the first The symmetric center point of the suspected crease pixels.

[0082] At this point, the possibility that each suspected crease pixel in each crease region sequence is a normal pixel under vertical illumination is obtained.

[0083] 2. Obtain the possibility that each suspected crease pixel in each crease region sequence is a normal pixel under non-vertical illumination.

[0084] It should be noted that when the illumination direction is not perpendicular to the surface of the packaging film, the grayscale values ​​of all pixels in the area facing the illumination direction are larger, and the grayscale values ​​of all pixels in the other area are smaller because they are facing away from the illumination direction. The grayscale changes in the crease defect area in the direction perpendicular to the crease are uneven, which manifests as a sudden change in grayscale. When there is a crease defect at the junction of the bright area and the dark area, the grayscale values ​​of normal pixels in the direction perpendicular to the crease defect do not change much, while the grayscale values ​​of crease defect pixels will change greatly. Therefore, multiple pixels adjacent to the suspected crease pixel can be selected in the direction perpendicular to the crease defect as the neighborhood range sequence of the suspected crease pixel, and the target neighborhood range is clustered according to the grayscale values ​​of the pixels in the target neighborhood range. By analyzing the grayscale aggregation and grayscale consistency of the pixels in the cluster, the possibility of the suspected crease pixel being a normal pixel under non-vertical illumination can be judged.

[0085] Preferably, in some implementations of the embodiments of the present invention, according to the grayscale difference between each suspected crease pixel in the crease region sequence and the surrounding suspected pixels, a calculation method for obtaining the possibility that each suspected crease pixel in the crease region sequence is a normal pixel under non-vertical illumination is:

[0086] Preset a clustering parameter and neighborhood parameters , wherein this embodiment is based on This example is described as an example, and this embodiment is not specifically limited. It depends on the specific implementation situation.

[0087] For any suspected crease pixel in any crease region sequence in any image block, use the K value to calculate the The K-means clustering algorithm is used to cluster all the pixels in the neighborhood sequence of the suspected crease pixel to obtain clusters; the suspected crease pixels are pixels and pixel points constitute the target neighborhood range of the suspected crease pixel point;

[0088] In the target neighborhood range of the suspected crease pixel point, the pixel point that belongs to the same cluster as the suspected crease pixel point is recorded as the first pixel point of the suspected crease pixel point; the ratio of the total number of the first pixel points to the total number of all the pixels in the target neighborhood range of the suspected crease pixel point is taken as the grayscale aggregation of the suspected crease pixel point;

[0089] For any first pixel of the suspected crease pixel points, the absolute value of the difference in grayscale value between the suspected crease pixel point and the first pixel point is recorded as the first grayscale difference value of the first pixel point; the reciprocal of the cumulative sum of the first grayscale difference values ​​of all the pixels of the suspected crease pixel points is recorded as the grayscale consistency of the suspected crease pixel points;

[0090] The product of the grayscale aggregation of the suspected crease pixel point and the grayscale consistency of the suspected crease pixel point is taken as the possibility that the suspected crease pixel point is a normal pixel point under non-vertical lighting.

[0091] At this point, the possibility that each suspected crease pixel in each crease region sequence is a normal pixel under non-vertical illumination is obtained.

[0092] 3. Obtain the possibility that each suspected crease pixel is a normal pixel.

[0093] It should be noted that when the illumination is perpendicular to the coating surface, the grayscale change amplitude of the pixels in the crease defect area is small; when the illumination is not perpendicular to the coating surface, the grayscale change amplitude of the pixels in the crease defect area is large; therefore, the influence of illumination can be determined by the magnitude of the grayscale difference; by weighting the two situations of illumination being perpendicular to the film surface and illumination being not perpendicular to the coating surface, the possibility that the overall suspected crease pixel points belong to normal pixels is obtained.

[0094] Preferably, in some implementations of the embodiments of the present invention, the calculation method for obtaining the illumination influence weight coefficient is as follows according to the difference in the number of suspected crease pixel points in the image block:

[0095] The image block with the largest number of suspected crease pixels is recorded as the first image block; the image block with the smallest number of suspected crease pixels is recorded as the second image block; the reciprocal of the difference between the maximum grayscale value of all pixels in the first image block and the minimum grayscale value of all pixels in the second image block is used as the illumination influence weight coefficient.

[0096] Preferably, in some implementations of the embodiments of the present invention, the probability that the suspected crease pixel point belongs to a normal pixel point under non-vertical illumination and the probability that the suspected crease pixel point belongs to a normal pixel point under vertical illumination are weightedly fused by the illumination influence weight coefficient, and the calculation method for obtaining the probability that each suspected crease pixel point belongs to a normal pixel point is:

[0097] For any suspected crease pixel, the product of the possibility that the suspected crease pixel is a normal pixel under vertical lighting and the lighting influence weight coefficient is recorded as the first product; the difference between 1 and the lighting influence weight coefficient is recorded as the second difference; the product of the second difference and the possibility that the suspected crease pixel is a normal pixel under non-vertical lighting is recorded as the second product; the sum of the first product and the second product is taken as the possibility that the suspected crease pixel is a normal pixel.

[0098] At this point, the possibility that each suspected crease pixel belongs to a normal pixel is obtained through the above method.

[0099] Step S004: extracting the crease defect area in the grayscale image according to the possibility that the suspected crease pixel point belongs to the normal pixel point.

[0100] Preset a threshold parameter , wherein this embodiment is based on This example is described as an example, and this embodiment is not specifically limited. It depends on the specific implementation situation.

[0101] Specifically, for any suspected crease pixel in the grayscale image, if the possibility that the suspected crease pixel belongs to a normal pixel is less than the threshold parameter , the suspected crease pixel points are recorded as crease defect pixel points; all closed areas formed by all crease defect pixel points in the grayscale image are recorded as crease defect areas.

[0102] See also Figure 2 , which shows a feature relationship flow chart for visual inspection of packaging film surface defects.

[0103] Through the above steps, a visual inspection of packaging film surface defects is completed.

[0104] The present invention also proposes a system for visual inspection of packaging film surface defects, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements steps S001 to S004 of a method for visual inspection of packaging film surface defects when executing the computer program.

[0105] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the principles of the present invention should be included in the protection scope of the present invention.

Claims

1. A method for visually detecting surface defects of packaging films, characterized in that: The method comprises the following steps: Acquire a grayscale image of the packaging film surface; Obtain all suspected crease pixel points in the grayscale image, and divide the grayscale image into a plurality of image blocks; obtain the crease defect direction of each image block; The image block is divided into several crease region sequences according to the direction of the crease defect; according to the position distribution between each suspected crease pixel and the surrounding pixels in the crease region sequence, the possibility of each suspected crease pixel in the crease region sequence being a normal pixel under vertical illumination is obtained; according to the grayscale difference between each suspected crease pixel in the crease region sequence and the surrounding suspected pixels, the possibility of each suspected crease pixel in the crease region sequence being a normal pixel under non-vertical illumination is obtained; according to the difference in the number of suspected crease pixels in the image block, the illumination influence weight coefficient is obtained; the possibility of suspected crease pixels being normal pixels under non-vertical illumination and the possibility of suspected crease pixels being normal pixels under vertical illumination are weightedly fused by the illumination influence weight coefficient to obtain the possibility of each suspected crease pixel being a normal pixel; Extract the crease defect area in the grayscale image according to the possibility that the suspected crease pixel point belongs to the normal pixel point; The specific method of dividing the image block into a plurality of fold area sequences according to the fold defect direction includes: For any image block, the image block is divided into a number of straight line regions, where the straight line regions are perpendicular to the fold defect direction of the image block and there is no gap between adjacent straight line regions; a pixel point sequence consisting of all pixel points on each straight line region is recorded as a fold area sequence; The method of obtaining the possibility that each suspected crease pixel in the crease region sequence is a normal pixel under vertical illumination according to the position distribution between each suspected crease pixel and surrounding pixels in the crease region sequence includes the following specific methods: Preset a range parameter and a sequence parameter For any suspected crease pixel in any crease region sequence in any image block, the suspected crease pixel is pixels and A pixel point sequence consisting of pixels is used as the neighborhood range sequence of the suspected crease pixel point; a A sliding window is used to slide in the neighborhood range sequence of the suspected fold mark pixel point with a step length of 1, and each sliding window is used as a sequence segment to obtain a plurality of sequence segments in the neighborhood range sequence of the suspected fold mark pixel point; Obtain the grayscale change rate of each sequence segment in the neighborhood range sequence of each suspected crease pixel in the crease region sequence; According to the difference in grayscale change rate between the suspected crease pixel point in the crease region sequence and other suspected crease pixel points in the neighborhood range sequence, the symmetric center point of each suspected crease pixel point in the crease region sequence is obtained; Preset a clustering parameter , using K value The K-means clustering algorithm is used to cluster the symmetrical center points of all suspected crease pixel points in the crease region sequence to obtain clusters; the cluster centers of the clusters are used as the reference points of the crease region sequence; For any suspected crease pixel in the crease region sequence, the reciprocal of the Euclidean distance between the symmetric center point of the suspected crease pixel and the reference point of the crease region sequence is used as the possibility that the suspected crease pixel is a normal pixel under vertical illumination; The method of obtaining the possibility that each suspected crease pixel in the crease region sequence is a normal pixel under non-vertical illumination according to the grayscale difference between each suspected crease pixel in the crease region sequence and surrounding suspected pixels includes: Preset a clustering parameter and neighborhood parameters For any suspected crease pixel in any crease region sequence in any image block, use the K value to calculate The K-means clustering algorithm is used to cluster all the pixels in the neighborhood sequence of the suspected crease pixel to obtain clusters; the suspected crease pixels are pixels and pixel points constitute the target neighborhood range of the suspected crease pixel point; In the target neighborhood range of the suspected crease pixel point, the pixel point that belongs to the same cluster as the suspected crease pixel point is recorded as the first pixel point of the suspected crease pixel point; the ratio of the total number of the first pixel points to the total number of all the pixels in the target neighborhood range of the suspected crease pixel point is taken as the grayscale aggregation of the suspected crease pixel point; For any first pixel of the suspected crease pixel points, the absolute value of the difference in grayscale value between the suspected crease pixel point and the first pixel point is recorded as the first grayscale difference value of the first pixel point; the reciprocal of the cumulative sum of the first grayscale difference values ​​of all the pixels of the suspected crease pixel points is recorded as the grayscale consistency of the suspected crease pixel points; The product of the grayscale aggregation of the suspected crease pixel point and the grayscale consistency of the suspected crease pixel point is taken as the possibility that the suspected crease pixel point is a normal pixel point under non-vertical lighting.

2. A method for visually inspecting surface defects of packaging films according to claim 1, characterized in that: The method of obtaining all suspected crease pixel points in the grayscale image and dividing the grayscale image into a plurality of image blocks and obtaining the crease defect direction of each image block includes: Preset a block parameter , use the Otsu threshold segmentation algorithm to perform threshold segmentation on the grayscale image to obtain a segmentation result map of the grayscale image; correspond all pixel points in the segmentation result map to all pixel points in the grayscale image, and record them as suspected crease pixels; divide the grayscale image into several For any image block, the sum vector of the gradient vectors of all pixels in the image block is recorded as the first sum vector; the direction of the vector perpendicular to the first sum vector is taken as the fold defect direction of the image block.

3. The method for visually detecting surface defects of packaging films according to claim 1, characterized in that: The specific method of obtaining the grayscale change rate of each sequence segment in the neighborhood range sequence of each suspected crease pixel point in the crease region sequence includes: For the suspected crease pixel point in the neighborhood range sequence sequence segment, The sum of the grayscale values ​​of all pixels in the sequence segment is equal to the The absolute value of the difference between the sum of the grayscale values ​​of all pixels in the sequence segment is recorded as the first absolute value of the difference; the absolute value of the first difference is added to the The ratio of the sum of the grayscale values ​​of all pixels in the sequence segment is taken as the The grayscale change rate of a sequence segment.

4. A method for visually inspecting surface defects of packaging films according to claim 1, characterized in that: The specific method of obtaining the symmetric center point of each suspected crease pixel point in the crease region sequence includes: For any crease region sequence The suspected crease pixels and suspected crease pixels, The first The grayscale change rate of the sequence segment is The first pixel in the neighborhood sequence of suspected crease pixels The reciprocal of the absolute value of the difference in the grayscale change rate of the sequence segment is taken as the The suspected crease pixel and the The first The grayscale change difference value of the sequence segment; The suspected crease pixels and The cumulative sum of the grayscale change difference values ​​of all sequence segments in the neighborhood range sequence between the suspected crease pixels is taken as the The suspected crease pixel and the Symmetry between suspected crease pixels; In the Among the symmetries between the suspected crease pixels and all the suspected crease pixels, the suspected crease pixel with the largest symmetry is recorded as The target suspected crease pixel of the suspected crease pixel; The suspected crease pixel and the The pixel point at the center of the straight line connecting the target suspected crease pixel points is taken as the first The symmetric center point of the suspected crease pixels.

5. The method for visually inspecting surface defects of packaging films according to claim 1, characterized in that: The specific method of obtaining the illumination influence weight coefficient according to the difference in the number of suspected crease pixels in the image block is as follows: The image block with the largest number of suspected crease pixels is recorded as the first image block; the image block with the smallest number of suspected crease pixels is recorded as the second image block; the reciprocal of the difference between the maximum grayscale value of all pixels in the first image block and the minimum grayscale value of all pixels in the second image block is used as the illumination influence weight coefficient.

6. A method for visually inspecting surface defects of packaging films according to claim 1, characterized in that: The method of weighting and fusing the possibility that the suspected crease pixel point belongs to a normal pixel point under non-vertical illumination and the possibility that the suspected crease pixel point belongs to a normal pixel point under vertical illumination by using the illumination influence weight coefficient to obtain the possibility that each suspected crease pixel point belongs to a normal pixel point includes the following specific methods: For any suspected crease pixel point, the product of the possibility that the suspected crease pixel point is a normal pixel point under vertical illumination and the illumination influence weight coefficient is recorded as the first product; The difference between 1 and the illumination influence weight coefficient is recorded as the second difference; The product of the second difference and the possibility that the suspected crease pixel is a normal pixel under non-vertical lighting is recorded as the second product; the sum of the first product and the second product is taken as the possibility that the suspected crease pixel is a normal pixel.

7. A packaging film surface defect visual inspection system, comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that: When the processor executes the computer program, the steps of the method for visually detecting surface defects of packaging films as described in any one of claims 1 to 6 are implemented.

Citation Information

Patent Citations

  • Flexible IC base plate linear circuit bubble and folding mark defect detection system and method

    CN108802051A

  • Machine vision detection method for instant noodle package defect

    CN109377485A

  • Steel pipe defect intelligent detection method

    CN114937039A

  • Method and device for detecting defective packaging

    JP2005047570A

  • Defective package inspection method and apparatus

    JP2011079564A