Corrugated cardboard defect detection method, medium, and equipment
Through the methods of multi-light source image acquisition and fusion, image segmentation and grayscale feature extraction, the problem of corrugated cardboard defect detection is solved, and efficient, precise positioning and type distinction of corrugated cardboard defects is achieved.
Patent Information
- Application Number
- CN202411765423.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-04
- Publication Date
- 2025-08-22
- Estimated Expiration
- 2044-12-04
AI Technical Summary
During the manufacturing process, indentation or depression defects caused by equipment failure or operating errors are difficult to detect effectively, especially when image detection is small and defective areas are small, which makes detection difficult.
The defect area is initially extracted through image segmentation and image segmentation and grayscale feature extraction and subpixel edge extraction, and closed operations and grayscale processing are performed, and defect type is finally fitted.
It improves the reliability and accuracy of defect detection, can effectively distinguish point-shaped and linear defects, and achieves efficient positioning of corrugated cardboard defects.
Smart Images

Figure CN119273677B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of corrugated paper defects, and in particular to a method, medium and equipment for detecting defects in corrugated paperboard. Background Art
[0002] Corrugated paper is made by gluing together liner paper and corrugated paper formed by corrugating rollers. With its low cost, lightweight, and strong compressive strength, it is widely used in various fields, including transportation and packaging. However, during the manufacturing process, various factors, such as equipment failure and operational errors, inevitably lead to indentations or dents on the corrugated board, seriously affecting its normal use.
[0003] When the above defects appear on corrugated cardboard, the contrast is low and the defective area is small during image detection, which makes detection difficult. Summary of the Invention
[0004] The purpose of the present invention is to provide a method, medium and equipment for detecting defects in corrugated cardboard to solve the above technical problems.
[0005] To achieve the above object, the present invention provides the following technical solutions:
[0006] A method for detecting defects in corrugated cardboard comprises the following steps:
[0007] S100, collecting front and back images of a corrugated cardboard, where the collected images are at least three images taken under at least three light source positions, and fusing the at least three images to obtain sample images I front and I back.
[0008] S200, preprocessing the sample images I positive and I negative, performing image segmentation on the preprocessed images, preliminarily extracting defect areas through image segmentation, performing a closing operation on the defect areas, and performing secondary feature extraction, and obtaining the final defect areas based on the grayscale feature histogram;
[0009] S300 , after extracting the defect area, grayscale processing is performed on it, converting it from an RGB image to a grayscale image, then performing sub-pixel edge extraction on the grayscale image, fitting the extracted defect edge contour, and locating the defect.
[0010] The present invention further provides that, in step S100, the at least three light sources are a vertical light source perpendicular to the corrugated cardboard and at least two light sources distributed on both sides of the vertical light source.
[0011] The present invention further provides that the image segmentation method adopts a region growing method for segmentation, comprising the following steps:
[0012] S201, dividing the image into several regions and obtaining the grayscale histogram of all regions;
[0013] S202, detecting the similarity of the grayscale histograms between adjacent regions; if the detection result is less than a set threshold, merging the two regions; wherein the detection formula is as follows:
[0014] <T; (1)
[0015] At the same time, smooth difference detection is performed on it, and the detection formula is as follows:
[0016] ; (2)
[0017] In formula (1) and formula (2): h1(z), h2(z) are the cumulative grayscale histograms of two adjacent regions; T is the given threshold;
[0018] S203, repeat the above steps until the adjacent regions do not meet the thresholds defined by equations (1) and (2), and the region growing ends.
[0019] The present invention further arranges that when setting the threshold T, the following method is adopted: setting the threshold T to divide all pixels of the image into two categories C1 and C2, the grayscale means of C1 and C2 are m1 and m2 respectively, the global average grayscale value of the image is m, and the probability of pixels being divided into C1 and C2 are p1 and p2 respectively, then
[0020] ;(3)
[0021] ;(4)
[0022] when When the value of T is the largest, the optimal threshold value T is obtained as the T value in formula (1) and formula (2).
[0023] The present invention further provides that, during the grayscale processing, the image is converted using a weighted method, and the conversion formula is as follows:
[0024] Gray=0.299R+0.587G+0.114B;
[0025] In the formula: Gray—the converted single color channel; R—one color channel; G—one color channel; B—another color channel.
[0026] The present invention further provides that, when performing edge extraction, the following method is adopted:
[0027] S1. Calculate the partial derivative matrices P and Q of the image in the X and Y directions, where the first-order difference convolution template is as follows: , ; Calculate the gradient amplitude in the X and Y directions based on the first-order difference convolution template;
[0028] S2. Calculate the gradient amplitude and azimuth according to the gradient amplitude in the X and Y directions;
[0029] S3: Thin the wide edge band, that is, only keep the area with the largest edge peak value, and set the remaining non-maximum points to zero.
[0030] S4. Double threshold algorithm detects edges and connected edges.
[0031] The present invention is further configured to adopt least squares circle fitting during fitting, and to judge the defect type according to the fitting result.
[0032] The present invention further provides that when judging the defect type, the coordinates of the center of the least squares circle after fitting are set to (M, K) and the radius is r. If the fitted radius r is too large, it is directly judged as a linear defect; otherwise, the difference di between each edge point on the contour and the fitted radius is calculated:
[0033] ;(5)
[0034] The average value of di of each edge point on the contour is taken as the roundness error. If the straightness error of the edge corresponding point is smaller, it is judged as a linear defect; if the roundness error is smaller, it is judged as a point defect.
[0035] The present invention also provides an electronic device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to execute the corrugated cardboard defect detection method.
[0036] The present invention also provides a readable storage medium on which a program is stored. When the program is executed by a processor, the method for detecting defects in corrugated cardboard is implemented.
[0037] The beneficial effects of the present invention are as follows: the present invention photographs corrugated cardboard from multiple light source positions and fuses the images from multiple light sources. By collecting different images of the target object under multiple light sources, the defect image can be obtained more completely. Secondly, the present invention performs image segmentation on the preprocessed image, initially extracts the defect area through image segmentation, performs a closing operation on the defect area, and then performs secondary feature extraction. The final defect area is obtained based on the grayscale feature histogram, which can ensure the display of defects. Finally, the reliability of defect positioning is greatly improved through sub-pixel edge extraction. Secondly, point defects such as depressions and linear defects such as indentations are distinguished based on the defect fitting circle. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0039] Figure 1 Flowchart of an embodiment of the present invention.
[0040] Figure 2 Schematic diagram of the position of the light source according to an embodiment of the present invention. DETAILED DESCRIPTION
[0041] The following will describe the implementation methods of the present application in detail with reference to the accompanying drawings and examples, so that the implementation process of how the present application applies technical means to solve technical problems and achieve technical effects can be fully understood and implemented accordingly.
[0042] like Figure 1 As shown, the present invention provides a method for detecting defects in corrugated cardboard, comprising the following steps:
[0043] S100, collecting front and back images of a corrugated cardboard, wherein the collected front and back images are at least three front images and at least three back images taken under at least three light source positions, and fusing the at least three front images and the at least three back images to obtain sample images I front and I back;
[0044] S200, preprocessing the sample images I positive and I negative, performing image segmentation on the preprocessed images, preliminarily extracting defect areas through image segmentation, performing a closing operation on the defect areas, and performing secondary feature extraction, and obtaining the final defect areas based on the grayscale feature histogram;
[0045] S300 , after extracting the defect area, grayscale processing is performed on it, converting it from an RGB image to a grayscale image, then performing sub-pixel edge extraction on the grayscale image, fitting the extracted defect edge contour, and locating the defect.
[0046] Preprocessing includes image enhancement and noise reduction. Specifically, linear grayscale transformation is used to increase the contrast of the original image, making the defect area more obvious and easier to process using the region growing segmentation method. In grayscale transformation, linear scaling of grayscale values is one of the most important steps. In this embodiment, the following operator is used: f(g)=ag+b;
[0047] In the formula: f(g) is the function for grayscale transformation; a is the slope of linear grayscale transformation; g is the grayscale value; b is the grayscale range to be transformed.
[0048] If g∈gb, the output grayscale value needs to be rounded to ensure that the output grayscale value is within the range of gb. The operator used here is:
[0049] f(g) =min (max(ag+b+0.5), 0), 2b-1);
[0050] Where: f(g)—the grayscale transformation function; a—the slope of the linear grayscale transformation; g—the grayscale value; b—the grayscale range to be transformed; min—the minimum grayscale value; max—the maximum grayscale value. From the above formula, we can see that: when |a| > 1, the contrast increases; when |a| < 1, the contrast decreases; when a < 1, the grayscale values are reversed; when b > 0, the brightness value increases; when b < 0, the brightness value decreases.
[0051] This embodiment further provides that, in step S100, the at least three light sources are a vertical light source perpendicular to the corrugated cardboard and at least two light sources distributed on both sides of the vertical light source.
[0052] In this embodiment, three light sources are used, one of which is located at position O2 and is vertical to the corrugated cardboard. The other two light sources are located on both sides of the vertical light source and are arranged at 45° to the vertical light source, namely O1 and O3. Figure 2 .
[0053] This embodiment uses the following method for segmentation:
[0054] The image segmentation method uses the region growing method for segmentation, which includes the following steps:
[0055] S201, dividing the image into several regions and obtaining the grayscale histogram of all regions;
[0056] S202, detecting the similarity of the grayscale histograms between adjacent regions; if the detection result is less than a set threshold, merging the two regions; wherein the detection formula is as follows:
[0057] <T; (1)
[0058] At the same time, smooth difference detection is performed on it, and the detection formula is as follows:
[0059] ; (2)
[0060] In formula (1) and formula (2): h1(z), h2(z) are the cumulative grayscale histograms of two adjacent regions; T is the given threshold; R is the image area; max is the maximum value of the image area;
[0061] S203, repeat the above steps until the adjacent regions do not meet the thresholds defined by equations (1) and (2), and the region growing ends.
[0062] Specifically, when the threshold value is determined by manual experience, it is easy to lose part of the image edge information during the edge extraction process, and pseudo edges may appear. Therefore, when setting the threshold value T in this embodiment, the following method is adopted: the threshold value T is set to divide all the pixels of the image into two categories, C1 and C2. The grayscale means of C1 and C2 are m1 and m2 respectively. The global average grayscale value of the image is m. The probability that the pixel is divided into C1 and C2 is p1 and p2 respectively. Then
[0063] ;(3)
[0064] ;(4)
[0065] when When the value of T is the largest, the optimal threshold value T is obtained as the T value in formula (1) and formula (2).
[0066] In order to accurately extract the target location of the corrugated cardboard defect, a ROI operation is performed on it to facilitate separate processing of the defect area. The extracted area is converted from RGB image to grayscale image. To effectively reduce the amount of image processing calculations and take into account the physiological characteristics of the human eye, a weighted method is used to convert the image when grayscale processing. The conversion formula is as follows:
[0067] Gray=0.299R+0.587G+0.114B;
[0068] In the formula: Gray—single color channel after conversion; R—one color channel; G—one color channel; B—another color channel,
[0069] When performing edge extraction, the following method is used:
[0070] S1. Calculate the partial derivative matrices P and Q of the image in the X and Y directions, where the first-order difference convolution template is as follows: , ;Calculate the gradient amplitude in the X and Y directions based on the first-order difference convolution template; the formula is as follows:
[0071] ;
[0072] ;
[0073] Where: S-image gray value; - Gradient amplitude in the y direction; - gradient magnitude in the x direction;
[0074] S2. Calculate the gradient amplitude and azimuth according to the gradient amplitude in the X and Y directions;
[0075] The calculation method is as follows: ;
[0076] Where: M[i,j]—the amplitude of the point; - Gradient amplitude in the y direction; - Gradient magnitude in the x-direction.
[0077] S3: Thin the wide edge band, that is, only keep the area with the largest edge peak value, and set the remaining non-maximum points to zero.
[0078] S4. Double threshold algorithm detects edges and connected edges.
[0079] In the present invention, since the defect types are depressions and indentations, the least squares circle fitting is adopted during fitting, and the defect type is determined based on the fitting results.
[0080] The specific judgment method is as follows: when judging the defect type, the coordinates of the center of the least squares circle after fitting are set to (M, K) and the radius is r. If the fitting radius r is too large, it is directly judged as a linear defect; otherwise, the difference di between each edge point on the contour and the fitting radius is calculated:
[0081] ;(5)
[0082] Where (xi,yi) is the pixel coordinate value of the edge contour.
[0083] The average value of di of each edge point on the contour is taken as the roundness error. If the straightness error of the edge corresponding point is smaller, it is judged as a linear defect; if the roundness error is smaller, it is judged as a point defect. Example
[0084] The present invention also provides an electronic device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to execute the corrugated cardboard defect detection method. Example
[0085] The present invention also provides a readable storage medium on which a program is stored. When the program is executed by a processor, the method for detecting defects in corrugated cardboard is implemented.
[0086] This method captures corrugated cardboard from multiple light sources and fuses these images. By capturing different images of the target object under multiple light sources, it can capture a more complete image of the defect. To address the low contrast and small defect areas in corrugated cardboard images, the sub-pixel edge extraction method proposed above achieves excellent defect location, achieving the desired detection objectives and significantly improving the applicability of the region growing method in complex environments.
[0087] For example, certain words are used in the specification and claims to refer to specific components. Those skilled in the art should understand that hardware manufacturers may use different terms to refer to the same component. This specification and claims do not use differences in names as a way to distinguish components, but use differences in the functions of the components as the criteria for distinction. For example, "including" mentioned throughout the specification and claims is an open term and should be interpreted as "including but not limited to". "Approximately" means that within an acceptable error range, those skilled in the art can solve technical problems within a certain error range and basically achieve technical effects.
[0088] It should be noted that the terms "include," "comprises," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a product or system comprising a series of elements includes not only those elements but also other elements not explicitly listed, or elements inherent to such product or system. In the absence of further limitations, an element defined by the phrase "comprising a..." does not exclude the presence of other identical elements in the product or system comprising the element.
[0089] The foregoing description shows and describes several preferred embodiments of the present invention. However, as previously mentioned, it should be understood that the present invention is not limited to the forms disclosed herein and should not be construed as excluding other embodiments. Rather, the present invention can be used in various other combinations, modifications, and environments and can be modified within the scope of the present invention through the above teachings or through technology or knowledge in the relevant field. Modifications and variations made by those skilled in the art that do not depart from the spirit and scope of the present invention are intended to be protected by the appended claims.
Claims
1. A method for detecting defects in corrugated cardboard, characterized in that: The steps include: S100, collecting front and back images of the corrugated cardboard, collecting at least three front images and at least three back images captured under at least three light source positions, and fusing the at least three front images and the at least three back images to obtain a sample image I 正 , I 反 ; S200, sample image I 正 , I 反 Perform preprocessing, perform image segmentation on the preprocessed image, preliminarily extract the defect area through image segmentation, perform secondary feature extraction on the defect area after closing operation, and obtain the final defect area based on the grayscale feature histogram; S300, after extracting the defect area, grayscale processing is performed on it, converting it from an RGB image to a grayscale image, then performing sub-pixel edge extraction on the grayscale image, fitting the extracted defect edge contour, and locating the defect; The preprocessing includes image enhancement and noise reduction. Specifically, linear grayscale transformation is used to increase the contrast of the original image, making the defect area more obvious and easier to process by region growing segmentation. In grayscale transformation, linear scaling of grayscale values is one of the most important steps. In this embodiment, the following operators are used: f(g) =min (max(ag+b+0.5),0),2 b -1); Where: f(g) - grayscale transformation function; a - slope of linear grayscale transformation; g - grayscale value; b - grayscale range to be transformed; min - minimum grayscale value; max - maximum grayscale value. From the above formula, we can see that: when |a|>1, the contrast increases; when |a|<1, the contrast decreases; when a<1, the grayscale value is reversed; when b>0, the brightness value increases; when b<0, the brightness value decreases. The image segmentation method uses the region growing method for segmentation, which includes the following steps: S201, dividing the image into several regions and obtaining the grayscale histogram of all regions; S202, detecting the similarity of the grayscale histograms between adjacent regions; if the detection result is less than a set threshold, merging the two regions; wherein the detection formula is as follows: <T;(1) At the same time, smooth difference detection is performed on it, and the detection formula is as follows: ;(2) In formula (1) and formula (2): h1(z), h2(z) are the cumulative grayscale histograms of two adjacent regions; T is the given threshold; R is the image area; max is the maximum value of the image area; S203, repeat the above steps until the adjacent region does not meet the thresholds defined by equations (1) and (2), then the region growing ends; when setting the threshold T, the following method is used: set the threshold T to divide all pixels of the image into two categories, C1 and C2, the grayscale means of C1 and C2 are m1 and m2 respectively, the global average grayscale value of the image is m, and the probability of pixels being divided into C1 and C2 are p1 and p2 respectively, then ;(3) ;(4) When it is the largest, the optimal threshold T is obtained as the T value in formula (1) and formula (2); When performing edge extraction, the following method is used: S1. Calculate the partial derivative matrices P and Q of the image in the X and Y directions, and calculate the gradient amplitude in the X and Y directions based on the first-order difference convolution template, where the first-order difference convolution template is as follows: , ; S2. Calculate the gradient amplitude and azimuth according to the gradient amplitude in the X and Y directions; S3, thinning the wide edge band, that is, only retaining the area with the largest edge peak, and setting all other non-maximum points to zero; S4, dual threshold algorithm detects edges and connects edges; When judging the defect type, the coordinates of the center of the least squares circle after fitting are set to (M, K) and the radius is r. If the fitted radius r is too large, it is directly judged as a linear defect.
2. A method for detecting defects in corrugated cardboard according to claim 1, characterized in that: In step S100, the at least three light sources are a vertical light source perpendicular to the corrugated cardboard and at least two light sources distributed on both sides of the vertical light source.
3. A method for detecting defects in corrugated cardboard according to claim 1, characterized in that: When graying, the image is converted using a weighted method. The conversion formula is as follows: Gray=0.299R+0.587G+0.114B; In the formula: Gray—the converted single color channel; R—one color channel; G—one color channel; B—another color channel.
4. An electronic device, characterized in that: The method comprises a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to execute the method for detecting defects in corrugated cardboard according to any one of claims 1 to 3.
5. A readable storage medium, characterized in that: A program is stored thereon, and when the program is executed by a processor, the method for detecting defects in corrugated cardboard according to any one of claims 1 to 3 is implemented.
Citation Information
Patent Citations
Corrugated carton pressing line defect detection optimization method based on artificial intelligence system
CN114782475A
Heat pipe orifice defect detection device and method based on machine vision
CN114894808A