A method and system for detecting appearance defects of chemically formed foil

By using image processing technology, grayscale conversion and HSV color space conversion, combined with bilateral filters and Sobel operators, irregularity, edge and hue value evaluation indices are generated, solving the accuracy and cost problems of appearance defect detection of electrolytic foil, and realizing efficient and accurate appearance detection of electrolytic foil.

CN118501177BActive Publication Date: 2024-11-19NANTONG NANHUI ELECTRONIC MATERIALS CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410971321.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-19
Publication Date
2024-11-19
Estimated Expiration
2044-07-19

AI Technical Summary

Technical Problem

Existing methods for detecting defects in electrolytic foil suffer from low detection accuracy, high system complexity, and high cost. In particular, they cannot accurately identify defects such as color difference, uneven edges, and delamination, and may even damage the electrolytic foil.

Method used

Image processing techniques are employed, including grayscale conversion and HSV color space conversion, combined with bilateral filters, Sobel operators, and linear regression, to generate irregularity, edge evaluation, and hue value evaluation indices. These indices comprehensively evaluate the appearance defects of the electroforming foil, thus avoiding physical contact with the foil.

Benefits of technology

It enables accurate detection of major defects on the surface of electrolytic foil, improves detection accuracy, reduces system complexity and cost, and ensures the integrity of electrolytic foil.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118501177B_ABST
    Figure CN118501177B_ABST
Patent Text Reader

Abstract

The invention provides a method and system for detecting appearance defects of a chemically formed foil, and relates to the technical field of foil material detection. The invention divides the appearance defects of a chemically formed foil into whether there are pits and scratches on the surface, whether the edges are neat and whether the colors are uniform, performs threshold segmentation and edge detection on a grayscale image through image processing technology, generates an irregularity evaluation index and an edge evaluation index, generates a hue value evaluation index in an HSV color space image, corresponds to and evaluates the three appearance defects respectively, generates a comprehensive evaluation index from the three evaluation indexes, each comprehensive evaluation index value corresponds to a set of irregularity evaluation index, edge evaluation index and hue value evaluation index values, and judges whether defects occur at three detection levels according to the values ​​of the comprehensive evaluation indexes.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to the technical field of foil material detection, and in particular to a method and system for detecting appearance defects of chemically formed foil. Background Art

[0002] In modern industrial production, chemical foil is an important electronic material, and its surface quality directly affects the performance and reliability of the final product. The traditional method of detecting the appearance defects of chemical foil mainly relies on manual visual inspection, which is not only inefficient, but also prone to missed detection and false detection. With the development of machine vision and image processing technology, automated detection systems have gradually become a research hotspot. However, when dealing with complex surface defects of chemical foil, the existing automated detection technology often has problems such as low detection accuracy, high system complexity and high cost. Therefore, developing an efficient, accurate and cost-effective automated detection method for the appearance defects of chemical foil has become an important direction of current technological development.

[0003] In the prior art, the publication number CN117890301A discloses a system and method for detecting appearance defects of chemical foil, which detects and classifies appearance defects of chemical foil through machine vision and depth detection, including a detection platform, a conveying roller group, a tension adjustment module, a CCD image sensor, an image analysis server and a depth detection module, wherein the depth detection module includes a transverse linear module, a longitudinal linear module and an FP resonant cavity detection chip matrix. The specific steps include: moving the test sample on the conveying roller group, obtaining the surface images of both sides of the test sample through the CCD image sensor, obtaining the quality defect area and the suspected quality defect area on the surface of the test sample through the image analysis server and marking the position, using the depth detection method at the marked position to determine the pressure value of the marked position, performing full coverage pressure detection on the surface of the test sample, and screening the suspected quality area according to the depth value, discarding the suspected quality defect area without pressure value, and classifying the quality defect area according to the depth value and outputting the result.

[0004] The problem with the above method is that the defects detected by the above method are mainly shape defects of the chemical foil, and the defect area is judged by pressure analysis and depth analysis. There are many other factors that actually affect the quality of the chemical foil, such as color difference, uneven edges, delamination and other problems. The above method cannot accurately judge these defects, and it involves pressure detection, which will cause contact with the chemical foil. If the contact force cannot be accurately controlled, it will cause damage to the chemical foil, and it is necessary to use CCD image sensors and image analysis servers, and the equipment cost involved is relatively high.

[0005] The above information disclosed in this Background section is only for enhancement of understanding of the background of the present disclosure and therefore it may contain information that does not constitute the prior art that is already known to one of ordinary skill in the art. Summary of the invention

[0006] The object of the present invention is to provide a method and system for detecting appearance defects of chemically formed foils, so as to solve the problems raised in the above-mentioned background technology.

[0007] To achieve the above object, the present invention provides the following technical solutions:

[0008] A method for detecting appearance defects of a formed foil, the specific steps comprising:

[0009] Step 1: Collect the image of the foil to be inspected, scale the image size to 224×224, and then copy the image into two identical groups of images. One group is grayed to generate the first recognition image, and the other group is converted from the RGB color space to the HSV color space to generate the second recognition image. The column where the leftmost pixel of the first recognition image is located is used as the y-axis, and the row where the bottommost pixel is located is used as the x-axis. A plane rectangular coordinate system is established, and the pixel positions of the first recognition image and the second recognition image are mapped one by one in the coordinate system;

[0010] Step 2: Filter the first recognition image using a bilateral filter, count the grayscale histogram consisting of the frequency of occurrence of pixels at each level in 256 grayscale levels, calculate the inter-class variance of each threshold in the histogram, select the best segmentation threshold by the maximum inter-class variance, segment the first recognition image after filtering using the best segmentation threshold, identify the foreground part and the background part, extract the foreground part to generate the third recognition image;

[0011] Step 3: Process the third recognition image by using the Sobel operator to generate edge points of the third recognition image, divide the third recognition image into 64 8×8 regions at equal intervals, calculate the average gray value of pixels and the number of edge pixels in each region, combine all regions to generate the gray value variance of pixels and the total number of edge pixels, generate the irregularity of the formed foil according to the gray value variance of pixels and the total number of edge pixels, collect the gray value variance and the number of edge pixels of the surface of the formed foil without defects, preset the irregularity threshold, compare the actual irregularity of the formed foil with the irregularity threshold to generate the irregularity evaluation index;

[0012] Step 4: Map the coordinate system of the first recognition image to the third recognition image in which the edge points have been obtained, determine the coordinates of all edge pixel points, perform linear regression through the edge pixel point coordinates to generate a fitted edge straight line, calculate the variance of the distance between all edge pixel points and the fitted edge straight line, preset an edge variance threshold, and generate an edge evaluation index by comparing the actual variance with the edge variance threshold;

[0013] Step 5: Collect the hue value of each pixel in the second recognition image, generate the hue value variance of the second recognition image, collect the hue value of the chemical foil image whose color uniformity meets the color number standard in advance and calculate the variance, generate the hue value variance threshold, compare the hue value variance with the hue value variance threshold to generate the hue value evaluation index;

[0014] Step 6: The appearance defects of the chemical foil to be tested are divided into whether there are pits and scratches on the surface, whether the edges are neat and whether the color is uniform. The irregularity evaluation index, edge evaluation index and hue value evaluation index are combined to generate a comprehensive evaluation index to determine whether there are defects in the appearance of the chemical foil to be tested.

[0015] Furthermore, the formula for graying the image is:

[0016] Y=0.299*R+0.578*G+0.114*B

[0017] Among them, Y represents the grayscale value of the pixel, R represents the red channel value of the pixel, G represents the green channel value of the pixel, and B represents the blue channel value of the pixel.

[0018] Furthermore, the principle for converting an image from RGB color space to HSV color space is:

[0019] First, convert the value of the RGB space to between [0,1] according to the formula:

[0020]

[0021] Wherein, R represents the red channel value, G represents the green channel value, B represents the blue channel value, R0 represents the result of normalizing the red channel value, G0 represents the result of normalizing the green channel value, and B0 represents the result of normalizing the blue channel value;

[0022] H0, S0, and V0 between [0,1] are calculated through R0, G0, and B0. The specific formula is:

[0023] V0=max(R0,G0,B0)

[0024]

[0025] S=S0*255

[0026] V=V0*255

[0027] Among them, H represents the hue channel value, S represents the saturation channel value, V represents the brightness channel value, and H0, S0, and V0 represent the results of normalizing the hue channel value, the saturation channel value, and the brightness channel value, respectively.

[0028] Furthermore, the principle for selecting the optimal segmentation threshold by the maximum inter-class variance is:

[0029] Traversing all possible thresholds, dividing the first recognition image into a background part and a foreground part according to the value of each threshold, counting the number of pixels in the background part and the foreground part, calculating the mean of the grayscale values ​​of the pixels in the background part and the foreground part, and calculating the inter-class variance;

[0030] The formula for calculating the between-class variance is:

[0031] h(i) 2 =ω i0 ω i1 (μ i0 -μ i1 ) 2

[0032] Where: h(i) represents the inter-class variance when the threshold is i, ω i0 Indicates the proportion of the foreground part to the total image when the threshold is i, μ i0 represents the gray value of the foreground part when the threshold is i, ω i1 Indicates the proportion of the background part to the total image when the threshold is i, μ i1 Indicates the gray value of the background part when the threshold is i;

[0033] When h(i) takes the maximum value, the corresponding threshold i is the optimal segmentation threshold. The threshold i is used to perform threshold segmentation on the first recognition image, and the foreground part is extracted as the third recognition image.

[0034] Furthermore, the principle for generating the irregularity evaluation index is as follows:

[0035] First, the edge points of the third recognition image are generated based on the following principle:

[0036] The grayscale value of each pixel and the grayscale values ​​of its eight adjacent pixels are multiplied by the Sobel operator horizontal template, and all products are added to obtain the horizontal gradient value of the pixel; the grayscale value of the pixel and the grayscale values ​​of its eight adjacent pixels are multiplied by the Sobel operator vertical template, and all results are added to obtain the vertical gradient value; the horizontal gradient value calculation formula is:

[0037]

[0038] The vertical gradient value calculation formula is:

[0039]

[0040] Where: Gx(i, j) represents the horizontal gradient value of the pixel with coordinates (i, j), Gy(i, j) represents the vertical gradient value of the pixel with coordinates (i, j), and X(i, j) represents the grayscale value of the pixel with coordinates (i, j);

[0041] The formula for generating the gradient magnitude is:

[0042]

[0043] Where: G(i, j) represents the gradient amplitude of the pixel with coordinates (i, j);

[0044] Traverse all the gradient amplitudes, select a gradient amplitude that can most clearly reflect the edge features of the image and set it as the edge threshold. When the gradient amplitude of the pixel point with coordinates (i, j) is greater than the edge threshold, the pixel point is regarded as an edge pixel point;

[0045] The formula for generating the gray value variance of a pixel is:

[0046]

[0047] Among them, V g represents the gray value variance of all regions, n represents the number of divided regions, g i Represents the grayscale value of the ith region, which is the sum of the grayscale values ​​of all pixels in the region. represents the average gray value of all regions;

[0048] The formula for generating the irregularity of the formed foil is:

[0049]

[0050] Where P represents the irregularity of the formed foil, W V Represents the influence weight of gray value variance on irregularity, V g Represents the gray value variance of all regions, W K represents the influence weight of the number of edge pixels on the irregularity, and K represents the total number of edge pixels in all regions;

[0051] The formula for presetting the irregularity threshold is:

[0052]

[0053] Among them, P0 represents the irregularity threshold, W V Represents the influence weight of gray value variance on flattening, V g0 The gray value variance of the chemically formed foil without surface defects, W K represents the influence weight of the number of edge pixels on the irregularity, K0 represents the number of edge pixels of the formed foil without defects on the surface;

[0054] The formula for generating the irregularity evaluation index is:

[0055]

[0056] Wherein, μ represents the irregularity evaluation index, P represents the irregularity of the formed foil to be detected, and P0 represents the irregularity threshold.

[0057] Furthermore, the principle for generating a fitted edge line by performing linear regression on the edge pixel coordinates is as follows:

[0058] After image edge detection and coordinate system mapping, a series of edge coordinate points are obtained, and the mean values ​​of the horizontal and vertical coordinates of all edge coordinate points are calculated based on the following formula:

[0059]

[0060] in, Represents the mean of the horizontal coordinates of the edge points, x i represents the horizontal coordinate of the i-th edge pixel point, n represents the number of edge coordinate points, Represents the mean of the ordinates of the edge points, y i Represents the ordinate of the i-th edge pixel;

[0061] Generates the slope of the fitted edge line based on the formula:

[0062]

[0063] Among them, a represents the slope of the fitted edge line, x i Represents the horizontal coordinate of the i-th edge pixel, Represents the mean of the horizontal coordinates of the edge points, y i Represents the ordinate of the i-th edge pixel, Represents the mean of the vertical coordinates of the edge points;

[0064] Generates the intercept of the fitted marginal line based on the formula:

[0065]

[0066] Where b represents the intercept of the fitted edge line, represents the mean of the ordinates of the edge points, a represents the slope of the fitted edge line, Represents the mean of the horizontal coordinates of the edge points;

[0067] The resulting fitted edge line equation is:

[0068] y=ax+b

[0069] The formula for calculating the variance of the distance between all edge pixels and the fitted edge line is:

[0070]

[0071] Among them, d i represents the distance between the ith edge pixel and the fitted edge line, x i Indicates the horizontal coordinate of the i-th edge pixel, y i represents the ordinate of the i-th edge pixel, a and b represent the slope and intercept of the fitted edge line, respectively, and V d represents the variance of the distance between the edge pixel and the fitted edge line, N represents the number of edge pixels, Represents the average value of the distance between all edge pixels and the fitted edge straight line;

[0072] The principle of presetting the edge variance threshold is:

[0073] Analyze the historical foil edge data, calculate the variance of the distance between the edge pixel points and the fitted edge straight line in these data, collect all the variances, and statistically analyze the mean and standard deviation of these variances. According to the statistical mean and standard deviation results of the variance, the formula for presetting the edge variance threshold is:

[0074]

[0075] Among them, V d0 represents the edge variance threshold, represents the mean of the distance variance in historical data, σ represents the standard deviation of the distance variance in historical data, and k represents a constant that reflects the actual scenario requirements and risk tolerance;

[0076] The formula for generating the edge evaluation index is:

[0077]

[0078] in, represents the edge evaluation index, V d Represents the variance of the distance between the edge pixel and the fitted edge line, V d0 Represents the edge variance threshold.

[0079] Furthermore, the principle for generating the hue value evaluation index is as follows:

[0080] The formula for generating the variance of the tone value of the second recognition image is:

[0081]

[0082] Among them, V H represents the variance of the hue value of the second recognition image, m1 represents the number of pixels of the second recognition image, and H i represents the hue value of the i-th pixel, represents the average hue value of all pixels in the second recognition image;

[0083] The formula for generating the hue value variance threshold is:

[0084]

[0085] Among them, V H0 represents the hue value variance threshold, m2 represents the number of pixels of the foil image that meets the color standard, and H i0 Indicates the hue value of the i-th pixel in the foil image that meets the color standard. It represents the average hue value of all pixels in the foil image that meets the color number standard;

[0086] The formula for generating the hue value evaluation index is:

[0087]

[0088] Among them, ω represents the hue value evaluation index, V H represents the variance of the hue value of the second recognition image, V H0 Indicates the hue value variance threshold.

[0089] Furthermore, the principle for generating a comprehensive evaluation index to judge whether the appearance of the chemically formed foil to be tested has defects is as follows:

[0090] The formula for generating the comprehensive evaluation index is:

[0091]

[0092] Among them, λ represents the comprehensive evaluation index, μ represents the irregularity evaluation index, represents the edge evaluation index, ω represents the hue value evaluation index;

[0093] The comprehensive evaluation index under the influence of the three evaluation indexes has eight values: 0, 1, 2, 3, 4, 5, 6, and 7. Each value corresponds to a value of the irregularity evaluation index, the edge evaluation index, and the hue value evaluation index. The specific judgment principle is:

[0094] When λ=0, μ=0, ω=0, indicating that the irregularity, edge variance and hue value variance all exceed the threshold, and there are defects;

[0095] When λ=1, μ=0, ω = 1, indicating that the irregularity and edge variance exceed the threshold, there are defects, and the hue value has no defects;

[0096] When λ=2, μ=0, ω=0, indicating that the variance of irregularity and hue value exceeds the threshold, there are defects, and there are no defects on the edge;

[0097] When λ=3, μ=0, ω=1, indicating that the irregularity exceeds the threshold, there is a defect, and there is no defect in the hue value and edge;

[0098] When λ=4, μ=1, ω=0, indicating that the variance of hue value and edge variance exceeds the threshold, indicating a defect, while irregularity does not have a defect;

[0099] When λ=5, μ=1, ω = 1, indicating that the edge variance exceeds the threshold, there is a defect, and the irregularity and hue value do not have defects;

[0100] When λ=6, μ=1, ω=0, indicating that the variance of the hue value exceeds the threshold, there is a defect, and there is no defect in irregularity and edge;

[0101] When λ=7, μ=1, ω=1, indicating that the irregularity, edge variance, and hue value variance do not exceed the threshold value, and the formed foil has no defects at this time.

[0102] The present invention also provides a system for detecting appearance defects of chemically formed foil, the system being used to implement the above-mentioned method for detecting appearance defects of chemically formed foil, comprising:

[0103] An image acquisition module is used to acquire images of the foil to be detected, uniformly scale the size of the images to 224×224, and then copy the images into two identical groups of images, one group of which is grayed to generate a first recognition image, and the other group of which is converted from an RGB color space to an HSV color space to generate a second recognition image, and a plane rectangular coordinate system is established with the column where the leftmost pixel of the first recognition image is located as the y-axis and the row where the bottommost pixel is located as the x-axis, and the pixel positions of the first recognition image and the second recognition image are mapped one by one in the coordinate system;

[0104] A threshold segmentation module is used to filter the first recognition image using a bilateral filter, count the grayscale histogram composed of the frequency of occurrence of pixels at each level in 256 grayscale levels, calculate the inter-class variance of each threshold in the histogram, select the best segmentation threshold by the maximum inter-class variance, use the best segmentation threshold to segment the first recognition image after filtering, identify the foreground part and the background part, extract the foreground part to generate a third recognition image;

[0105] A surface processing module is used to process the third recognition image through a Sobel operator to generate edge points of the third recognition image, divide the third recognition image into 64 8×8 regions at equal intervals, calculate the average gray value of pixels in each region and the number of edge pixels, combine all regions to generate the gray value variance of pixels and the total number of edge pixels, generate the irregularity of the formed foil according to the gray value variance of pixels and the total number of edge pixels, collect the gray value variance and the number of edge pixels of the surface of the formed foil without defects, preset an irregularity threshold, compare the actual irregularity of the formed foil with the irregularity threshold to generate an irregularity evaluation index;

[0106] An edge processing module is used to map the coordinate system of the first recognition image to the third recognition image in which edge points have been obtained, determine the coordinates of all edge pixel points, generate a fitted edge line through linear regression of the edge pixel point coordinates, calculate the variance of the distance between all edge pixel points and the fitted edge line, preset an edge variance threshold, and generate an edge evaluation index by comparing the actual variance with the edge variance threshold;

[0107] A tone processing module is used to collect the tone value of each pixel in the second recognition image, generate the tone value variance of the second recognition image, collect the tone value of the chemical foil image whose color uniformity meets the color number standard in advance and calculate the variance, generate the tone value variance threshold, compare the tone value variance with the tone value variance threshold to generate the tone value evaluation index;

[0108] The comprehensive judgment module is used to classify the appearance defects of the chemical foil to be detected into whether there are pits and scratches on the surface, whether the edges are neat and whether the color is uniform, and to generate a comprehensive evaluation index by combining the irregularity evaluation index, the edge evaluation index and the hue value evaluation index to determine whether there are defects in the appearance of the chemical foil to be detected.

[0109] Compared with the prior art, the present invention has the following beneficial effects:

[0110] The present invention focuses on detecting the three most important and obvious defects on the surface of the chemical foil, including whether there are pits and scratches on the surface, whether the edges are neat and whether the color is uniform. Through image processing technology, the image of the surface of the chemical foil is processed into a grayscale image and an HSV color space image respectively, and the edge detection of the image is performed in the grayscale image to extract the edge points of the image. According to the principle that the grayscale value variance and the number of edge pixels of the image with pits and scratches will increase, an irregularity evaluation index is generated. The grayscale value variance reflects the uniformity and smoothness of the surface of the chemical foil, and the number of edge pixels reflects the complexity of the surface structure. The combination of these two parameters enables the evaluation of the irregularity to more comprehensively and accurately reflect the irregularity. The actual situation of the surface of the chemical foil is compared with the irregularity and the threshold of the irregularity to determine whether there are pits and scratches on the surface of the chemical foil; at the same time, a fitting straight line is generated according to the coordinates of the edge points, and an edge evaluation index is generated according to the variance of the distance between the actual edge pixel point and the fitting straight line. The neatness of the edge of the chemical foil is quantified into an edge evaluation index so that it can be quantitatively analyzed. If the distance between the edge pixel point and the fitting edge straight line is small, it means that the edge of the chemical foil is relatively neat, which ensures the accuracy of the detection; the hue value variance of each pixel point is calculated through the HSV color space image, and then the color uniformity is evaluated. According to the hue value evaluation index, the chemical foil with a large hue deviation can be detected in time. Finally, the comprehensive evaluation index is generated by combining the irregularity evaluation index, the edge evaluation index and the hue value evaluation index. According to the value of the comprehensive evaluation index, the corresponding values ​​of the other three evaluation indexes can be directly obtained, and then it can be determined which part has defects, which can intuitively and accurately reflect the defects of the appearance of the chemical foil. BRIEF DESCRIPTION OF THE DRAWINGS

[0111] Figure 1 This is a schematic diagram of a method flow chart of an embodiment of the present invention;

[0112] Figure 2 Schematic diagram of system modules according to an embodiment of the present invention. DETAILED DESCRIPTION

[0113] In order to make the objectives, technical solutions and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with specific embodiments.

[0114] It should be noted that, unless otherwise defined, the technical terms or scientific terms used in the present invention should be understood by people with ordinary skills in the field to which the present invention belongs. The words "first", "second" and similar words used in the present invention do not indicate any order, quantity or importance, but are only used to distinguish different components. "Include" or "comprise" and similar words mean that the elements or objects appearing before the word include the elements or objects listed after the word and their equivalents, without excluding other elements or objects. "Connect" or "connected" and similar words are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. "Up", "down", "left", "right" and the like are only used to indicate relative positional relationships. When the absolute position of the described object changes, the relative positional relationship may also change accordingly.

[0115] Example:

[0116] See also Figure 1 , the present invention provides a technical solution:

[0117] A method for detecting appearance defects of a formed foil, the specific steps comprising:

[0118] Step 1: Collect the image of the foil to be inspected, scale the image size to 224×224, and then copy the image into two identical groups of images. One group is grayed to generate the first recognition image, and the other group is converted from the RGB color space to the HSV color space to generate the second recognition image. The column where the leftmost pixel of the first recognition image is located is used as the y-axis, and the row where the bottommost pixel is located is used as the x-axis. A plane rectangular coordinate system is established, and the pixel positions of the first recognition image and the second recognition image are mapped one by one in the coordinate system;

[0119] In this embodiment, the formula for graying the image is as follows:

[0120] Y=0.299*R+0.578*G+0.114*B

[0121] Among them, Y represents the grayscale value of the pixel, R represents the red channel value of the pixel, G represents the green channel value of the pixel, and B represents the blue channel value of the pixel.

[0122] The principle of converting an image from RGB color space to HSV color space is:

[0123] First, convert the value of the RGB space to between [0,1] according to the formula:

[0124]

[0125] Wherein, R represents the red channel value, G represents the green channel value, B represents the blue channel value, R0 represents the result of normalizing the red channel value, G0 represents the result of normalizing the green channel value, and B0 represents the result of normalizing the blue channel value;

[0126] H0, S0, and V0 between [0,1] are calculated through R0, G0, and B0. The specific formula is:

[0127] V0=max(R0,G0,B0)

[0128]

[0129]

[0130] S=S0*255

[0131] V=V0*255

[0132] Among them, H represents the hue channel value, S represents the saturation channel value, V represents the brightness channel value, and H0, S0, and V0 represent the results of normalizing the hue channel value, the saturation channel value, and the brightness channel value, respectively.

[0133] In this embodiment, the pixel points after image scaling are marked with coordinates, the column where the leftmost pixel point of the image is located is taken as the y-axis, and the row where the bottommost pixel point is located is taken as the x-axis, a plane rectangular coordinate system is established, and the first recognized image and the second recognized image are mapped according to the coordinate system to ensure that each pixel point has unique coordinates.

[0134] Step 2: Filter the first recognition image using a bilateral filter, count the grayscale histogram consisting of the frequency of occurrence of pixels at each level in 256 grayscale levels, calculate the inter-class variance of each threshold in the histogram, select the best segmentation threshold by the maximum inter-class variance, segment the first recognition image after filtering using the best segmentation threshold, identify the foreground part and the background part, extract the foreground part to generate the third recognition image;

[0135] In this embodiment, the principle for selecting the optimal segmentation threshold by using the maximum inter-class variance is:

[0136] Traversing all possible thresholds, dividing the first recognition image into a background part and a foreground part according to the value of each threshold, counting the number of pixels in the background part and the foreground part, calculating the mean of the grayscale values ​​of the pixels in the background part and the foreground part, and calculating the inter-class variance;

[0137] The formula for calculating the between-class variance is:

[0138] h(i) 2 =ωi0 ω i1 (μ i0 -μ i1 ) 2

[0139] Where: h(i) represents the inter-class variance when the threshold is i, ω i0 Indicates the proportion of the foreground part to the total image when the threshold is i, μ i0 represents the gray value of the foreground part when the threshold is i, ω i1 Indicates the proportion of the background part to the total image when the threshold is i, μ i1 Indicates the gray value of the background part when the threshold is i;

[0140] When h(i) takes the maximum value, the corresponding threshold i is the optimal segmentation threshold. The threshold i is used to perform threshold segmentation on the first recognition image, and the foreground part is extracted as the third recognition image.

[0141] The calculation formula of the inter-class variance is the OTSU formula, where h(i) represents the inter-class variance when the threshold is i, and ω i0 Indicates the proportion of the foreground part to the total image, μ i0 represents the gray value of the target part when the threshold is i, ω i1 Indicates the proportion of the background part to the total image when the threshold is i, μ i1 It represents the gray value of the background part when the threshold is i. When h(i) is larger, it means that the difference between the two parts of the image is greater and the separation effect is better. At this time, the corresponding i is the optimal separation threshold.

[0142] Step 3: Process the third recognition image by using the Sobel operator to generate edge points of the third recognition image, divide the third recognition image into 64 8×8 regions at equal intervals, calculate the average gray value of pixels and the number of edge pixels in each region, combine all regions to generate the gray value variance of pixels and the total number of edge pixels, generate the irregularity of the formed foil according to the gray value variance of pixels and the total number of edge pixels, collect the gray value variance and the number of edge pixels of the surface of the formed foil without defects, preset the irregularity threshold, compare the actual irregularity of the formed foil with the irregularity threshold to generate the irregularity evaluation index;

[0143] In this embodiment, the principle for generating the irregularity evaluation index is:

[0144] First, the edge points of the third recognition image are generated based on the following principle:

[0145] The grayscale value of each pixel and the grayscale values ​​of its eight adjacent pixels are multiplied by the Sobel operator horizontal template, and all products are added to obtain the horizontal gradient value of the pixel; the grayscale value of the pixel and the grayscale values ​​of its eight adjacent pixels are multiplied by the Sobel operator vertical template, and all results are added to obtain the vertical gradient value; the horizontal gradient value calculation formula is:

[0146]

[0147] The vertical gradient value calculation formula is:

[0148]

[0149] Where: Gx(i, j) represents the horizontal gradient value of the pixel with coordinates (i, j), Gy(i, j) represents the vertical gradient value of the pixel with coordinates (i, j), and X(i, j) represents the grayscale value of the pixel with coordinates (i, j);

[0150] The formula for generating the gradient magnitude is:

[0151]

[0152] Where: G(i, j) represents the gradient amplitude of the pixel with coordinates (i, j);

[0153] Traverse all the gradient amplitudes, select a gradient amplitude that can most clearly reflect the edge features of the image and set it as the edge threshold. When the gradient amplitude of the pixel point with coordinates (i, j) is greater than the edge threshold, the pixel point is regarded as an edge pixel point;

[0154] The formula for generating the gray value variance of a pixel is:

[0155]

[0156] Among them, V g represents the gray value variance of all regions, n represents the number of divided regions, g i Represents the grayscale value of the ith region, which is the sum of the grayscale values ​​of all pixels in the region. represents the average gray value of all regions;

[0157] The formula for generating the irregularity of the formed foil is:

[0158]

[0159] Where P represents the irregularity of the formed foil, W V Represents the influence weight of gray value variance on irregularity, V gRepresents the gray value variance of all regions, W K represents the influence weight of the number of edge pixels on the irregularity, and K represents the total number of edge pixels in all regions;

[0160] Irregularity reflects the smoothness of the surface of the formed foil, which is determined by the grayscale value variance and the number of edge pixels on the surface of the formed foil. The grayscale value variance reflects the uniformity of the pixels on the surface of the formed foil. When pits or scratches appear, the grayscale value at the position of the pits and scratches increases, resulting in an increase in the overall grayscale value variance. Therefore, the irregularity is proportional to the grayscale value variance. Similarly, when pits or scratches appear, edge detection will additionally detect the pits or scratches, resulting in an increase in the number of edge pixels. Therefore, the irregularity is proportional to the number of edge pixels. The grayscale value variance has a greater impact on the smoothness. The weight can be set to 0.7, and the weight of the number of edge pixels can be set to 0.3.

[0161] The formula for presetting the irregularity threshold is:

[0162]

[0163] Among them, P0 represents the irregularity threshold, W V Represents the influence weight of gray value variance on flattening, V g0 The gray value variance of the chemically formed foil without surface defects, W K represents the influence weight of the number of edge pixels on the irregularity, K0 represents the number of edge pixels of the formed foil without defects on the surface;

[0164] The irregularity threshold formula uses the data of the formed foil without defects, except that the gray value variance and the number of edge pixels use the same proportion weight as the irregularity weight formula;

[0165] The formula for generating the irregularity evaluation index is:

[0166]

[0167] Wherein, μ represents the irregularity evaluation index, P represents the irregularity of the formed foil to be tested, and P0 represents the irregularity threshold;

[0168] The irregularity evaluation index reflects the relationship between the irregularity and the irregularity threshold. Logical judgment is made through the size relationship between the two, so that the irregularity evaluation index takes a value of 1 or 0. When the irregularity evaluation index takes a value of 1, it indicates that the irregularity of the chemical foil to be detected does not exceed the threshold, and there is no defect at this detection level. When the irregularity evaluation index takes a value of 0, it indicates that the irregularity of the chemical foil to be detected exceeds the threshold, and there is a defect at this detection level.

[0169] Step 4: Map the coordinate system of the first recognition image to the third recognition image in which the edge points have been obtained, determine the coordinates of all edge pixel points, perform linear regression through the edge pixel point coordinates to generate a fitted edge straight line, calculate the variance of the distance between all edge pixel points and the fitted edge straight line, preset an edge variance threshold, and generate an edge evaluation index by comparing the actual variance with the edge variance threshold;

[0170] In this embodiment, the principle for generating a fitted edge line by performing linear regression on the edge pixel coordinates is:

[0171] After image edge detection and coordinate system mapping, a series of edge coordinate points are obtained, and the mean values ​​of the horizontal and vertical coordinates of all edge coordinate points are calculated based on the following formula:

[0172]

[0173] in, Represents the mean of the horizontal coordinates of the edge points, x i represents the horizontal coordinate of the i-th edge pixel point, n represents the number of edge coordinate points, Represents the mean of the ordinates of the edge points, y i Represents the ordinate of the i-th edge pixel;

[0174] Generates the slope of the fitted edge line based on the formula:

[0175]

[0176] Among them, a represents the slope of the fitted edge line, x i Represents the horizontal coordinate of the i-th edge pixel, Represents the mean of the horizontal coordinates of the edge points, y i Represents the ordinate of the i-th edge pixel, Represents the mean of the vertical coordinates of the edge points;

[0177] Generates the intercept of the fitted marginal line based on the formula:

[0178]

[0179] Where b represents the intercept of the fitted edge line, represents the mean of the ordinates of the edge points, a represents the slope of the fitted edge line, Represents the mean of the horizontal coordinates of the edge points;

[0180] The resulting fitted edge line equation is:

[0181] y=ax+b

[0182] The formula for calculating the variance of the distance between all edge pixels and the fitted edge line is:

[0183]

[0184] Among them, d i represents the distance between the ith edge pixel and the fitted edge line, x i Indicates the horizontal coordinate of the i-th edge pixel, y i represents the ordinate of the i-th edge pixel, a and b represent the slope and intercept of the fitted edge line, respectively, and V d represents the variance of the distance between the edge pixel and the fitted edge line, N represents the number of edge pixels, Represents the average value of the distance between all edge pixels and the fitted edge straight line;

[0185] The variance of the distance between the edge pixel point and the fitted edge line reflects the fitting of the actual edge to the fitted edge line. When the variance is smaller, it means that the actual edge is closer to the fitted edge line, and the possibility that the edge has defects is smaller. When the variance is larger, it means that the actual edge is farther away from the fitted edge line, and the possibility that the edge has defects is greater.

[0186] The principle of presetting the edge variance threshold is:

[0187] Analyze the historical foil edge data, calculate the variance of the distance between the edge pixel points and the fitted edge straight line in these data, collect all the variances, and statistically analyze the mean and standard deviation of these variances. According to the statistical mean and standard deviation results of the variance, the formula for presetting the edge variance threshold is:

[0188]

[0189] Among them, V d0 represents the edge variance threshold, represents the mean of the distance variance in historical data, σ represents the standard deviation of the distance variance in historical data, and k represents a constant that reflects the actual scenario requirements and risk tolerance;

[0190] When there is enough historical data, the marginal variance is normally distributed, reflecting the actual scenario requirements and the risk tolerance constant k, which can be taken as 3, which is equivalent to covering 99.7% of defect-free samples and reducing the possibility of misjudgment.

[0191] The formula for generating the edge evaluation index is:

[0192]

[0193] in, represents the edge evaluation index, Vd Represents the variance of the distance between the edge pixel and the fitted edge line, V d0 represents the edge variance threshold;

[0194] The edge evaluation index reflects the relationship between the edge variance and the edge variance threshold. Logical judgment is made through the size relationship between the two, so that the edge evaluation index takes the value of 1 or 0. When the edge evaluation index takes the value of 1, it means that the edge variance of the chemical foil to be detected does not exceed the threshold, and there is no defect at this detection level. When the edge evaluation index takes the value of 0, it means that the edge variance of the chemical foil to be detected exceeds the threshold, and there is a defect at this detection level.

[0195] Step 5: Collect the hue value of each pixel in the second recognition image, generate the hue value variance of the second recognition image, collect the hue value of the chemical foil image whose color uniformity meets the color number standard in advance and calculate the variance, generate the hue value variance threshold, compare the hue value variance with the hue value variance threshold to generate the hue value evaluation index;

[0196] In this embodiment, the formula for generating the variance of the tone value of the second recognition image is:

[0197]

[0198] Among them, V H represents the variance of the hue value of the second recognition image, m1 represents the number of pixels of the second recognition image, and H i represents the hue value of the i-th pixel, represents the average hue value of all pixels in the second recognition image;

[0199] The hue value variance reflects the uniformity of the color of the chemical foil. The smaller the hue value variance, the closer the hue value on the surface of the chemical foil is, and the better the color consistency is, which means that the color variation on the entire surface is small, and there is no obvious color difference or spots.

[0200] The formula for generating the hue value variance threshold is:

[0201]

[0202] Among them, V H0 represents the hue value variance threshold, m2 represents the number of pixels of the foil image that meets the color standard, and H i0 Indicates the hue value of the i-th pixel in the foil image that meets the color standard. It represents the average hue value of all pixels in the foil image that meets the color number standard;

[0203] The color number of the chemical foil is a standard number used to identify and describe the color of the chemical foil. It can be determined according to the standard law or according to the actual situation. The historical chemical foil hue value data that meets the color number standard is collected to generate a hue value variance threshold that can meet the conditions.

[0204] The formula for generating the hue value evaluation index is:

[0205]

[0206] Among them, ω represents the hue value evaluation index, V H represents the variance of the hue value of the second recognition image, V H0 represents the hue value variance threshold;

[0207] The hue value evaluation index reflects the relationship between the hue value variance and the hue value variance threshold. Logical judgment is made through the size relationship between the two, so that the hue value evaluation index takes a value of 1 or 0. When the hue value evaluation index takes a value of 1, it means that the hue value variance of the chemical foil to be detected does not exceed the threshold, and there is no defect at this detection level. When the hue value evaluation index takes a value of 0, it means that the hue value variance of the chemical foil to be detected exceeds the threshold, and there is a defect at this detection level.

[0208] Step 6: The appearance defects of the chemical foil to be tested are divided into whether there are pits and scratches on the surface, whether the edges are neat and whether the color is uniform, and the irregularity evaluation index, edge evaluation index and hue value evaluation index are combined to generate a comprehensive evaluation index to determine whether there are defects in the appearance of the chemical foil to be tested;

[0209] In this embodiment, the formula for generating the comprehensive evaluation index is:

[0210]

[0211] Among them, λ represents the comprehensive evaluation index, μ represents the irregularity evaluation index, represents the edge evaluation index, ω represents the hue value evaluation index;

[0212] The comprehensive evaluation index under the influence of the three evaluation indexes has eight values: 0, 1, 2, 3, 4, 5, 6, and 7. Each value corresponds to a value of the irregularity evaluation index, the edge evaluation index, and the hue value evaluation index. The specific judgment principle is:

[0213] When λ=0, μ=0, ω=0, indicating that the irregularity, edge variance and hue value variance all exceed the threshold, and there are defects;

[0214] When λ=1, μ=0, ω = 1, indicating that the irregularity and edge variance exceed the threshold, there are defects, and the hue value has no defects;

[0215] When λ=2, μ=0, ω=0, indicating that the variance of irregularity and hue value exceeds the threshold, there are defects, and there are no defects on the edge;

[0216] When λ=3, μ=0, ω=1, indicating that the irregularity exceeds the threshold, there is a defect, and there is no defect in the hue value and edge;

[0217] When λ=4, μ=1, ω=0, indicating that the variance of hue value and edge variance exceeds the threshold, indicating a defect, while irregularity does not have a defect;

[0218] When λ=5, μ=1, ω = 1, indicating that the edge variance exceeds the threshold, there is a defect, and the irregularity and hue value do not have defects;

[0219] When λ=6, μ=1, ω=0, indicating that the variance of the hue value exceeds the threshold, there is a defect, and there is no defect in irregularity and edge;

[0220] When λ=7, μ=1, ω=1, indicating that the irregularity, edge variance, and hue value variance do not exceed the threshold value, and the formed foil has no defects at this time.

[0221] In the above judgment process, the value of each comprehensive judgment index corresponds to a set of values ​​of irregularity evaluation index, edge evaluation index and hue value evaluation index. The values ​​of irregularity evaluation index, edge evaluation index and hue value evaluation index can be directly deduced based on the comprehensive judgment index to avoid ambiguity.

[0222] See also Figure 2 The present invention also provides a system for detecting appearance defects of chemically formed foil, the system being used to implement the above-mentioned method for detecting appearance defects of chemically formed foil, comprising:

[0223] An image acquisition module is used to acquire images of the foil to be detected, uniformly scale the size of the images to 224×224, and then copy the images into two identical groups of images, one group of which is grayed to generate a first recognition image, and the other group of which is converted from an RGB color space to an HSV color space to generate a second recognition image, and a plane rectangular coordinate system is established with the column where the leftmost pixel of the first recognition image is located as the y-axis and the row where the bottommost pixel is located as the x-axis, and the pixel positions of the first recognition image and the second recognition image are mapped one by one in the coordinate system;

[0224] A threshold segmentation module is used to filter the first recognition image using a bilateral filter, count the grayscale histogram composed of the frequency of occurrence of pixels at each level in 256 grayscale levels, calculate the inter-class variance of each threshold in the histogram, select the best segmentation threshold by the maximum inter-class variance, use the best segmentation threshold to segment the first recognition image after filtering, identify the foreground part and the background part, extract the foreground part to generate a third recognition image;

[0225] A surface processing module is used to process the third recognition image through a Sobel operator to generate edge points of the third recognition image, divide the third recognition image into 64 8×8 regions at equal intervals, calculate the average gray value of pixels in each region and the number of edge pixels, combine all regions to generate the gray value variance of pixels and the total number of edge pixels, generate the irregularity of the formed foil according to the gray value variance of pixels and the total number of edge pixels, collect the gray value variance and the number of edge pixels of the surface of the formed foil without defects, preset an irregularity threshold, compare the actual irregularity of the formed foil with the irregularity threshold to generate an irregularity evaluation index;

[0226] An edge processing module is used to map the coordinate system of the first recognition image to the third recognition image in which edge points have been obtained, determine the coordinates of all edge pixel points, generate a fitted edge line through linear regression of the edge pixel point coordinates, calculate the variance of the distance between all edge pixel points and the fitted edge line, preset an edge variance threshold, and generate an edge evaluation index by comparing the actual variance with the edge variance threshold;

[0227] A tone processing module is used to collect the tone value of each pixel in the second recognition image, generate the tone value variance of the second recognition image, collect the tone value of the chemical foil image whose color uniformity meets the color number standard in advance and calculate the variance, generate the tone value variance threshold, compare the tone value variance with the tone value variance threshold to generate the tone value evaluation index;

[0228] The comprehensive judgment module is used to classify the appearance defects of the chemical foil to be detected into whether there are pits and scratches on the surface, whether the edges are neat and whether the color is uniform, and to generate a comprehensive evaluation index by combining the irregularity evaluation index, the edge evaluation index and the hue value evaluation index to determine whether there are defects in the appearance of the chemical foil to be detected.

[0229] The above formulas are all dimensionless and numerical calculations. The formula is a formula for the most recent real situation obtained by collecting a large amount of data and performing software simulation. The preset parameters in the formula are set by technicians in this field according to actual conditions.

[0230] The above embodiments may be implemented in whole or in part by software, hardware, firmware or any other combination thereof. When implemented by software, the above embodiments may be implemented in whole or in part in the form of a computer program product. Those skilled in the art may appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein may be implemented by electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed by hardware or software methods depends on the specific application and design constraints of the technical solution.

[0231] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, and may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0232] The above description is only a specific implementation manner of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application.

Claims

1. A method for detecting appearance defects of chemically formed foil, characterized in that: The specific steps include: Step 1: Collect the image of the foil to be inspected, scale the image size to 224×224, and then copy the image into two identical groups of images. One group is grayed to generate the first recognition image, and the other group is converted from the RGB color space to the HSV color space to generate the second recognition image. The column where the leftmost pixel of the first recognition image is located is used as the y-axis, and the row where the bottommost pixel is located is used as the x-axis. A plane rectangular coordinate system is established, and the pixel positions of the first recognition image and the second recognition image are mapped one by one in the coordinate system; Step 2: Filter the first recognition image using a bilateral filter, count the grayscale histogram consisting of the frequency of occurrence of pixels at each level in 256 grayscale levels, calculate the inter-class variance of each threshold in the histogram, select the best segmentation threshold by the maximum inter-class variance, segment the first recognition image after filtering using the best segmentation threshold, identify the foreground part and the background part, extract the foreground part to generate the third recognition image; Step 3: Process the third recognition image by using the Sobel operator to generate edge points of the third recognition image, divide the third recognition image into 64 8×8 regions at equal intervals, calculate the average gray value of pixels and the number of edge pixels in each region, combine all regions to generate the gray value variance of pixels and the total number of edge pixels, generate the irregularity of the formed foil according to the gray value variance of pixels and the total number of edge pixels, collect the gray value variance and the number of edge pixels of the surface of the formed foil without defects, preset the irregularity threshold, compare the actual irregularity of the formed foil with the irregularity threshold to generate the irregularity evaluation index; Step 4: Map the coordinate system of the first recognition image to the third recognition image in which the edge points have been obtained, determine the coordinates of all edge pixel points, perform linear regression through the edge pixel point coordinates to generate a fitted edge straight line, calculate the variance of the distance between all edge pixel points and the fitted edge straight line, preset an edge variance threshold, and generate an edge evaluation index by comparing the actual variance with the edge variance threshold; Step 5: Collect the hue value of each pixel in the second recognition image, generate the hue value variance of the second recognition image, collect the hue value of the chemical foil image whose color uniformity meets the color number standard in advance and calculate the variance, generate the hue value variance threshold, compare the hue value variance with the hue value variance threshold to generate the hue value evaluation index; Step 6: The appearance defects of the chemical foil to be tested are divided into whether there are pits and scratches on the surface, whether the edges are neat and whether the color is uniform, and the irregularity evaluation index, edge evaluation index and hue value evaluation index are combined to generate a comprehensive evaluation index to determine whether there are defects in the appearance of the chemical foil to be tested; The formula for graying an image is: Y=0.299*R+0.578*G+0.114*B Among them, Y represents the gray value of the pixel, R represents the red channel value of the pixel, G represents the green channel value of the pixel, and B represents the blue channel value of the pixel; The principle of converting an image from RGB color space to HSV color space is: First, convert the value of the RGB space to between [0,1] according to the formula: Wherein, R represents the red channel value, G represents the green channel value, B represents the blue channel value, R0 represents the result of normalizing the red channel value, G0 represents the result of normalizing the green channel value, and B0 represents the result of normalizing the blue channel value; H0, S0, and V0 between [0,1] are calculated through R0, G0, and B0. The specific formula is: V0=max(R0,G0,B0) S=S0*255 V=V0*255 Among them, H represents the hue channel value, S represents the saturation channel value, V represents the brightness channel value, H0, S0, and V0 represent the normalization results of the hue channel value, saturation channel value, and brightness channel value respectively; The principle for selecting the best segmentation threshold by maximizing the inter-class variance is: Traversing all possible thresholds, dividing the first recognition image into a background part and a foreground part according to the value of each threshold, counting the number of pixels in the background part and the foreground part, calculating the mean of the grayscale values ​​of the pixels in the background part and the foreground part, and calculating the inter-class variance; The formula for calculating the between-class variance is: h(i) 2 =ω i0 oh i1 (m i0 -m i1 ) 2 Where: h(i) represents the inter-class variance when the threshold is i, ω i0 Indicates the proportion of the foreground part to the total image when the threshold is i, μ i0 represents the gray value of the foreground part when the threshold is i, ω i1 Indicates the proportion of the background part to the total image when the threshold is i, μ i1 Indicates the gray value of the background part when the threshold is i; When h(i) takes the maximum value, the corresponding threshold i is the optimal segmentation threshold. The threshold i is used to perform threshold segmentation on the first recognition image, and the foreground part is extracted as the third recognition image. The principle for generating the irregularity evaluation index is: First, the edge points of the third recognition image are generated based on the following principle: The grayscale value of each pixel and the grayscale values ​​of its eight adjacent pixels are multiplied by the Sobel operator horizontal template, and all products are added to obtain the horizontal gradient value of the pixel; the grayscale value of the pixel and the grayscale values ​​of its eight adjacent pixels are multiplied by the Sobel operator vertical template, and all results are added to obtain the vertical gradient value; the horizontal gradient value calculation formula is: The vertical gradient value calculation formula is: Where: Gx(i, j) represents the horizontal gradient value of the pixel with coordinates (i, j), Gy(i, j) represents the vertical gradient value of the pixel with coordinates (i, j), and X(i, j) represents the grayscale value of the pixel with coordinates (i, j); The formula for generating the gradient magnitude is: Where: G(i, j) represents the gradient amplitude of the pixel with coordinates (i, j); Traverse all the gradient amplitudes, select a gradient amplitude that can most clearly reflect the edge features of the image and set it as the edge threshold. When the gradient amplitude of the pixel point with coordinates (i, j) is greater than the edge threshold, the pixel point is regarded as an edge pixel point; The formula for generating the gray value variance of a pixel is: Among them, V g represents the gray value variance of all regions, n represents the number of divided regions, g i Represents the grayscale value of the ith region, which is the sum of the grayscale values ​​of all pixels in the region. represents the average gray value of all regions; The formula for generating the irregularity of the formed foil is: Where P represents the irregularity of the formed foil, W V Represents the influence weight of gray value variance on irregularity, V g Represents the gray value variance of all regions, W K represents the influence weight of the number of edge pixels on the irregularity, and K represents the total number of edge pixels in all regions; The formula for presetting the irregularity threshold is: Among them, P0 represents the irregularity threshold, W V Represents the influence weight of gray value variance on flattening, V g0 The gray value variance of the chemically formed foil without surface defects, W K represents the influence weight of the number of edge pixels on the irregularity, K0 represents the number of edge pixels of the formed foil without defects on the surface; The formula for generating the irregularity evaluation index is: Wherein, μ represents the irregularity evaluation index, P represents the irregularity of the formed foil to be tested, and P0 represents the irregularity threshold; The principle of generating a fitted edge line through linear regression of edge pixel coordinates is: After image edge detection and coordinate system mapping, a series of edge coordinate points are obtained, and the mean values ​​of the horizontal and vertical coordinates of all edge coordinate points are calculated based on the following formula: in, Represents the mean of the horizontal coordinates of the edge points, x i represents the horizontal coordinate of the i-th edge pixel point, n represents the number of edge coordinate points, Represents the mean of the ordinates of the edge points, y i Represents the ordinate of the i-th edge pixel; Generates the slope of the fitted edge line based on the formula: Among them, a represents the slope of the fitted edge line, x i Represents the horizontal coordinate of the i-th edge pixel, Represents the mean of the horizontal coordinates of the edge points, y i Represents the ordinate of the i-th edge pixel, Represents the mean of the vertical coordinates of the edge points; Generates the intercept of the fitted marginal line based on the formula: Where b represents the intercept of the fitted edge line, represents the mean of the ordinates of the edge points, a represents the slope of the fitted edge line, Represents the mean of the horizontal coordinates of the edge points; The resulting fitted edge line equation is: y=ax+b The formula for calculating the variance of the distance between all edge pixels and the fitted edge line is: Among them, d i represents the distance between the ith edge pixel and the fitted edge line, x i Indicates the horizontal coordinate of the i-th edge pixel, y i represents the ordinate of the i-th edge pixel, a and b represent the slope and intercept of the fitted edge line, respectively, and V d represents the variance of the distance between the edge pixel and the fitted edge line, N represents the number of edge pixels, Represents the average value of the distance between all edge pixels and the fitted edge straight line; The principle of presetting the edge variance threshold is: Analyze the historical foil edge data, calculate the variance of the distance between the edge pixel points and the fitted edge straight line in these data, collect all the variances, and statistically analyze the mean and standard deviation of these variances. According to the statistical mean and standard deviation results of the variance, the formula for presetting the edge variance threshold is: Among them, V d0 represents the edge variance threshold, represents the mean of the distance variance in historical data, σ represents the standard deviation of the distance variance in historical data, and k represents a constant that reflects the actual scenario requirements and risk tolerance; The formula for generating the edge evaluation index is: in, represents the edge evaluation index, V d Represents the variance of the distance between the edge pixel and the fitted edge line, V d0 represents the edge variance threshold; The principle for generating the hue value evaluation index is: The formula for generating the variance of the tone value of the second recognition image is: Among them, V H represents the variance of the hue value of the second recognition image, m1 represents the number of pixels of the second recognition image, and H i represents the hue value of the i-th pixel, represents the average hue value of all pixels in the second recognition image; The formula for generating the hue value variance threshold is: Among them, V H0 represents the hue value variance threshold, m2 represents the number of pixels of the foil image that meets the color standard, and H i0 Indicates the hue value of the i-th pixel in the foil image that meets the color standard. It represents the average hue value of all pixels in the foil image that meets the color number standard; The formula for generating the hue value evaluation index is: Among them, ω represents the hue value evaluation index, V H represents the variance of the hue value of the second recognition image, V H0 represents the hue value variance threshold; The principle for generating a comprehensive evaluation index to determine whether the appearance of the chemically formed foil to be tested has defects is: The formula for generating the comprehensive evaluation index is: Among them, λ represents the comprehensive evaluation index, μ represents the irregularity evaluation index, represents the edge evaluation index, ω represents the hue value evaluation index; The comprehensive evaluation index under the influence of the three evaluation indexes has eight values: 0, 1, 2, 3, 4, 5, 6, and 7. Each value corresponds to a value of the irregularity evaluation index, the edge evaluation index, and the hue value evaluation index. The specific judgment principle is: When λ=0, μ=0, ω=0, indicating that the irregularity, edge variance and hue value variance all exceed the threshold, and there are defects; When λ=1, μ=0, ω = 1, indicating that the irregularity and edge variance exceed the threshold, there are defects, and the hue value has no defects; When λ=2, μ=0, ω=0, indicating that the variance of irregularity and hue value exceeds the threshold, there are defects, and there are no defects on the edge; When λ=3, μ=0, ω=1, indicating that the irregularity exceeds the threshold, there is a defect, and there is no defect in the hue value and edge; When λ=4, μ=1, ω=0, indicating that the variance of hue value and edge variance exceeds the threshold, indicating a defect, while irregularity does not have a defect; When λ=5, μ=1, ω = 1, indicating that the edge variance exceeds the threshold, there is a defect, and the irregularity and hue value do not have defects; When λ=6, μ=1, ω=0, indicating that the variance of the hue value exceeds the threshold, there is a defect, and there is no defect in irregularity and edge; When λ=7, μ=1, ω=1, indicating that the irregularity, edge variance, and hue value variance do not exceed the threshold value, and the formed foil has no defects at this time.

2. A system for detecting appearance defects of chemically formed foil, characterized in that: The system is used to implement the method for detecting appearance defects of chemically formed foil according to claim 1, comprising: An image acquisition module is used to acquire images of the foil to be detected, uniformly scale the size of the images to 224×224, and then copy the images into two identical groups of images, one group of which is grayed to generate a first recognition image, and the other group of which is converted from an RGB color space to an HSV color space to generate a second recognition image, and a plane rectangular coordinate system is established with the column where the leftmost pixel of the first recognition image is located as the y-axis and the row where the bottommost pixel is located as the x-axis, and the pixel positions of the first recognition image and the second recognition image are mapped one by one in the coordinate system; A threshold segmentation module is used to filter the first recognition image using a bilateral filter, count the grayscale histogram composed of the frequency of occurrence of pixels at each level in 256 grayscale levels, calculate the inter-class variance of each threshold in the histogram, select the best segmentation threshold by the maximum inter-class variance, use the best segmentation threshold to segment the first recognition image after filtering, identify the foreground part and the background part, extract the foreground part to generate a third recognition image; A surface processing module is used to process the third recognition image through a Sobel operator to generate edge points of the third recognition image, divide the third recognition image into 64 8×8 regions at equal intervals, calculate the average gray value of pixels in each region and the number of edge pixels, combine all regions to generate the gray value variance of pixels and the total number of edge pixels, generate the irregularity of the formed foil according to the gray value variance of pixels and the total number of edge pixels, collect the gray value variance and the number of edge pixels of the surface of the formed foil without defects, preset an irregularity threshold, compare the actual irregularity of the formed foil with the irregularity threshold to generate an irregularity evaluation index; An edge processing module is used to map the coordinate system of the first recognition image to the third recognition image in which edge points have been obtained, determine the coordinates of all edge pixel points, generate a fitted edge line through linear regression of the edge pixel point coordinates, calculate the variance of the distance between all edge pixel points and the fitted edge line, preset an edge variance threshold, and generate an edge evaluation index by comparing the actual variance with the edge variance threshold; A tone processing module is used to collect the tone value of each pixel in the second recognition image, generate the tone value variance of the second recognition image, collect the tone value of the chemical foil image whose color uniformity meets the color number standard in advance and calculate the variance, generate the tone value variance threshold, compare the tone value variance with the tone value variance threshold to generate the tone value evaluation index; The comprehensive judgment module is used to classify the appearance defects of the chemical foil to be detected into whether there are pits and scratches on the surface, whether the edges are neat and whether the color is uniform, and to generate a comprehensive evaluation index by combining the irregularity evaluation index, the edge evaluation index and the hue value evaluation index to determine whether there are defects in the appearance of the chemical foil to be detected.