CN118501177B - Appearance defect detection method and system for formed foil - Google Patents
Appearance defect detection method and system for formed foil Download PDFInfo
- Publication number
- CN118501177B CN118501177B CN202410971321.XA CN202410971321A CN118501177B CN 118501177 B CN118501177 B CN 118501177B CN 202410971321 A CN202410971321 A CN 202410971321A CN 118501177 B CN118501177 B CN 118501177B
- Authority
- CN
- China
- Prior art keywords
- edge
- value
- variance
- threshold
- irregularity
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
- 239000011888 foil Substances 0.000 title claims abstract description 125
- 230000007547 defect Effects 0.000 title claims abstract description 99
- 238000001514 detection method Methods 0.000 title claims abstract description 32
- 238000011156 evaluation Methods 0.000 claims abstract description 137
- 230000011218 segmentation Effects 0.000 claims abstract description 25
- 238000012545 processing Methods 0.000 claims abstract description 24
- 238000000034 method Methods 0.000 claims abstract description 21
- 239000003086 colorant Substances 0.000 claims abstract description 8
- 238000003708 edge detection Methods 0.000 claims abstract description 6
- 230000015572 biosynthetic process Effects 0.000 claims description 73
- 238000013507 mapping Methods 0.000 claims description 15
- 230000002950 deficient Effects 0.000 claims description 12
- 238000001914 filtration Methods 0.000 claims description 9
- 238000012417 linear regression Methods 0.000 claims description 9
- 238000004364 calculation method Methods 0.000 claims description 7
- 230000002146 bilateral effect Effects 0.000 claims description 6
- 238000006243 chemical reaction Methods 0.000 claims description 3
- 238000005516 engineering process Methods 0.000 abstract description 4
- 238000010191 image analysis Methods 0.000 description 3
- 238000004458 analytical method Methods 0.000 description 2
- 238000011161 development Methods 0.000 description 2
- 230000018109 developmental process Effects 0.000 description 2
- 239000000047 product Substances 0.000 description 2
- 238000000926 separation method Methods 0.000 description 2
- 230000004075 alteration Effects 0.000 description 1
- 230000009286 beneficial effect Effects 0.000 description 1
- 238000004422 calculation algorithm Methods 0.000 description 1
- 238000004590 computer program Methods 0.000 description 1
- 230000032798 delamination Effects 0.000 description 1
- 238000013461 design Methods 0.000 description 1
- 238000010586 diagram Methods 0.000 description 1
- 230000000694 effects Effects 0.000 description 1
- 239000012776 electronic material Substances 0.000 description 1
- 239000012467 final product Substances 0.000 description 1
- 238000009776 industrial production Methods 0.000 description 1
- 238000007689 inspection Methods 0.000 description 1
- 239000011159 matrix material Substances 0.000 description 1
- 238000004445 quantitative analysis Methods 0.000 description 1
- 238000011160 research Methods 0.000 description 1
- 238000012216 screening Methods 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
- 238000011179 visual inspection Methods 0.000 description 1
Abstract
The invention provides a method and a system for detecting appearance defects of a formed foil, which relate to the technical field of foil detection, the invention divides the appearance defects of the formed foil into whether pit scratches exist on the surface, whether edges are neat and whether colors are uniform, respectively carries out threshold segmentation and edge detection on a gray map through an image processing technology to generate an irregularity evaluation index and an edge evaluation index, generating tone value evaluation indexes in the HSV color space image, correspondingly evaluating the three appearance defects respectively, generating comprehensive evaluation indexes by the three evaluation indexes, wherein the value of each comprehensive evaluation index corresponds to the value of a group of irregularity evaluation indexes, edge evaluation indexes and tone value evaluation indexes, and judging whether the defects appear on the three detection layers according to the value of the comprehensive evaluation indexes.
Description
Technical Field
The invention relates to the technical field of foil detection, in particular to an appearance defect detection method and system for a formed foil.
Background
In modern industrial production, the surface quality of the formed foil as an important electronic material directly influences the performance and reliability of the final product. The traditional detection method of the appearance defects of the formed foil mainly depends on manual visual inspection, and the method is low in efficiency and easy to cause the conditions of missed detection and false detection. With the development of machine vision and image processing technology, automated inspection systems are becoming a hotspot for research. However, when the existing automatic detection technology is used for processing complex surface defects of the formed foil, the problems of low detection precision, high system complexity, high cost and the like often exist. Therefore, developing an efficient, accurate and cost-effective automatic detection method for appearance defects of formed foil becomes an important direction of current technical development.
In the prior art, publication number CN117890301a discloses an appearance defect detection system and a detection method of a formed foil, the method detects and classifies appearance defects of the formed foil through machine vision and depth detection, and the detection system comprises a detection table, a transport roller set, a tension adjusting module, a CCD image sensor, an image analysis server and a depth detection module, wherein the depth detection module comprises a transverse linear module, a longitudinal linear module and an F-P resonant cavity detection chip matrix. The method comprises the following specific steps: the method comprises the steps of moving a sample to be tested on a transport roller set, acquiring surface images of two sides of the sample to be tested through CCD image sensors, obtaining a quality defect area and a suspected quality defect area on the surface of the sample to be tested through an image analysis server, marking the positions, determining pressure values of marking positions by using a depth detection mode at the marked positions, carrying out full-coverage pressure detection on the surface of the sample to be tested, screening the suspected quality area according to the depth values, discarding the suspected quality defect area without the pressure values, classifying the quality defect area according to the depth values, and outputting results.
The problems with the above method are: the defects detected by the method are mainly shape defects of the formed foil, the defective areas are judged through pressure analysis, depth analysis and the like, and other factors such as chromatic aberration, uneven edges, delamination and the like are also affected in practice, the defects cannot be accurately judged by the method, the pressure detection is involved, contact is caused on the formed foil, the formed foil is damaged if the contact force cannot be accurately controlled, a CCD image sensor and an image analysis server are needed, and the involved equipment cost is high.
The above information disclosed in the background section is only for enhancement of understanding of the background of the disclosure and therefore it may include information that does not form the prior art that is already known to a person of ordinary skill in the art.
Disclosure of Invention
The present invention is directed to a method and a system for detecting appearance defects of a formed foil, so as to solve the problems set forth in the background art.
In order to achieve the above purpose, the present invention provides the following technical solutions:
The method for detecting the appearance defects of the formed foil comprises the following specific steps:
step 1: collecting images to be detected into foil, uniformly scaling the sizes of the images into 224 multiplied by 224, copying the images into two groups of identical images, generating a first identification image after one group of images are subjected to gray scale treatment, generating a second identification image after the other group of images are converted into HSV (hue, saturation and saturation) color space from RGB (red, green, blue) color space, taking the column of the leftmost pixel point of the first identification image as a y axis and the row of the bottommost pixel point as an x axis, establishing a plane rectangular coordinate system, and mapping the pixel point positions of the first identification image and the second identification image in the coordinate system one by one;
Step 2: filtering the first identification image by using a bilateral filter, counting a gray level histogram formed by occurrence frequencies of pixel points of each level in 256 gray levels, calculating inter-class variances of all thresholds in the histogram, selecting an optimal segmentation threshold value through the maximum inter-class variance, segmenting the first identification image after filtering by using the optimal segmentation threshold value, identifying a foreground part and a background part, and extracting the foreground part to generate a third identification image;
Step 3: processing a third identification image through a sobel operator to generate edge points of the third identification image, equally dividing the third identification image into 64 areas with the granularity of 8 multiplied by 8, calculating the average gray value of pixel points in each area and the number of edge pixel points, combining the gray value variance of the pixel points and the total number of the edge pixel points generated by all the areas, generating formation foil irregularities according to the gray value variance of the pixel points and the total number of the edge pixel points, collecting the gray value variance of the formation foil surface and the number of the edge pixel points, which have no defects on the surface, presetting an irregularity threshold, and comparing the actual formation foil irregularities with the irregularity threshold to generate an irregularity evaluation index;
Step 4: mapping the coordinate system of the first identification image into a third identification image with edge points, determining the coordinates of all edge pixel points, generating a fitting edge straight line through linear regression of the coordinates of the edge pixel points, calculating the variance of the distances between all edge pixel points and the fitting edge straight line, presetting an edge variance threshold, and generating an edge evaluation index through comparing the actual variance with the edge variance threshold;
Step 5: collecting the tone value of each pixel point in the second identification image, generating a tone value variance of the second identification image, collecting the tone value of the formation foil image with the color uniformity conforming to the color number standard in advance, calculating the variance, generating a tone value variance threshold, and comparing the tone value variance with the tone value variance threshold to generate a tone value evaluation index;
step 6: dividing the appearance defects of the formation foil to be detected into whether pit scratches exist on the surface, whether edges are neat and whether colors are uniform, and generating comprehensive evaluation indexes by combining the irregularity evaluation indexes, the edge evaluation indexes and the tone value evaluation indexes to judge whether the appearance of the formation foil to be detected has defects.
Further, the formula according to which the image is subjected to the graying process is:
Y=0.299*R+0.578*G+0.114*B
wherein 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.
Further, the principle underlying the conversion of an image from RGB color space to HSV color space is:
firstly, converting the value of RGB space into the value between [0,1], wherein the formula is as follows:
Wherein R represents a red channel value, G represents a green channel value, B represents a blue channel value, R 0 represents a result of normalizing the red channel value, G 0 represents a result of normalizing the green channel value, and B 0 represents a result of normalizing the blue channel value;
H 0、S0、V0 with a value between [0,1] is calculated through R 0、G0、B0, and the specific formula is as follows:
V0=max(R0,G0,B0)
S=S0*255
V=V0*255
Wherein H represents a hue channel value, S represents a saturation channel value, V represents a luminance channel value, and H 0、S0、V0 represents the result of normalizing the hue channel value, the saturation channel value, and the luminance channel value, respectively.
Further, the principle on which the optimal segmentation threshold is selected by the maximum inter-class variance is as follows:
Traversing all possible thresholds, dividing the first identification image into a background part and a foreground part according to the value of each threshold, counting the number of pixels of the background part and the foreground part, calculating the average value of gray values of the pixels of the background part and the foreground part, and calculating the inter-class variance;
the formula from which the inter-class variance is calculated is:
h(i)2=ωi0ωi1(μi0-μi1)2
Wherein: h (i) represents the inter-class variance when the threshold is i, ω i0 represents the proportion of the foreground portion to the total image when the threshold is i, μ i0 represents the foreground portion gray value when the threshold is i, ω i1 represents the proportion of the background portion to the total image when the threshold is i, and μ i1 represents the background portion gray value 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 for carrying out threshold segmentation on the first identification image, and the foreground part is extracted as a third identification image.
Further, the principle on which the irregularity evaluation index is generated is:
firstly, generating edge points of a third identification image according to the following principle:
The gray value of each pixel point and the gray values of eight adjacent pixel points are multiplied by a sobel operator horizontal direction template, and all the products are added to obtain a pixel point horizontal direction gradient value; multiplying the gray value of the pixel point and the gray values of eight adjacent pixel points with a template in the vertical direction of a sobel operator, and adding all the results to obtain a gradient value in the vertical direction; the calculation formula of the gradient value in the horizontal direction is as follows:
the calculation formula of the gradient value in the vertical direction is as follows:
Wherein: gx (i, j) represents a horizontal gradient value of a pixel point with coordinates (i, j), gy (i, j) represents a vertical gradient value of a pixel point with coordinates (i, j), and X (i, j) represents a gray value of a pixel point with coordinates (i, j);
The formula for generating the gradient amplitude basis is as follows:
wherein: g (i, j) represents the gradient magnitude of the pixel point with coordinates (i, j);
Traversing all gradient amplitude values, selecting one gradient amplitude value which can clearly show the image edge characteristic as an edge threshold value, and when the gradient amplitude value of a pixel point with coordinates (i, j) is larger than the edge threshold value, taking the pixel point as an edge pixel point;
The formula according to which the gray value variance of the pixel point is generated is as follows:
wherein V g represents the gray value variance of all the regions, n represents the number of divided regions, g i represents the gray value of the ith region, which is the sum of the gray values of all the pixel points in the region, Representing the average gray value of all regions;
the formula according to which the formation foil irregularities are generated is:
wherein, P represents the formation foil irregularity, W V represents the influence weight of gray value variance on the irregularity, V g represents the gray value variance of all areas, W K represents the influence weight of the number of edge pixel points on the irregularity, K represents the total number of edge pixel points in all areas;
The formula according to which the threshold value of irregularity is preset is:
Wherein, P 0 represents an irregularity threshold value, W V represents an influence weight of a gray value variance on flatness, V g0 represents a gray value variance of a formation foil with no surface defect, W K represents an influence weight of the number of edge pixel points on irregularity, and K 0 represents the number of edge pixel points of the formation foil with no surface defect;
The formula according to which the irregularity evaluation index is generated is:
wherein μ represents an irregularity evaluation index, P represents an irregularity of the formation foil to be detected, and P 0 represents an irregularity threshold.
Further, the principle on which the fitting edge straight line is generated by linear regression of the coordinates of the edge pixel points is as follows:
Obtaining a series of edge coordinate points through image edge detection and coordinate system mapping, and calculating the average value of the horizontal coordinates and the vertical coordinates of all the edge coordinate points according to the following formula:
wherein, Represents the mean value of the abscissa of the edge points, x i represents the abscissa of the ith edge pixel point, n represents the number of edge coordinate points,Representing the mean value of the ordinate of the edge points, and y i represents the ordinate of the ith edge pixel point;
Generating the slope of the fitting edge straight line according to the following formula:
Where a represents the slope of the fitted edge line, x i represents the abscissa of the ith edge pixel point, Representing the mean of the abscissa of the edge points, y i representing the ordinate of the ith edge pixel point,Representing the mean value of the ordinate of the edge point;
generating the intercept of the fitting edge straight line according to the following formula:
Wherein b represents the intercept of the fitted edge line, Represents the mean value of the ordinate of the edge points, a represents the slope of the fitted edge line,Representing the mean value of the abscissa of the edge points;
the generated fitting edge linear equation is:
y=ax+b
the formula according to which the variance of the distances between all edge pixel points and the fitted edge straight line is calculated is as follows:
Wherein d i represents the distance between the ith edge pixel point and the fitted edge straight line, x i represents the abscissa of the ith edge pixel point, y i represents the ordinate of the ith edge pixel point, a and b represent the slope and intercept of the fitted edge straight line, V d represents the variance of the distance between the edge pixel point and the fitted edge straight line, N represents the number of edge pixel points, Representing the average value of the distances between all edge pixel points and the fitting edge straight line;
the principle on which the edge variance threshold is preset is as follows:
Analyzing the historical foil edge data, calculating variances of distances between edge pixel points and fitting edge straight lines in the data, collecting all variances, statistically analyzing the mean value and standard deviation of the variances, and presetting an edge variance threshold according to the mean value and standard deviation result of the statistical variances, wherein the formula on which the edge variance threshold is based is as follows:
where V d0 represents the edge variance threshold, The average value of the distance variance in the historical data is represented, sigma represents the standard deviation of the distance variance in the historical data, and k represents a constant reflecting the actual scene requirement and the risk tolerance;
the formula according to which the edge evaluation index is generated is:
wherein, Representing the edge evaluation index, V d represents the variance of the distance between the edge pixel point and the fitted edge line, and V d0 represents the edge variance threshold.
Further, the principle on which the tone value evaluation index is generated is as follows:
the formula from which the variance of the hue value of the second identification image is generated is:
Where V H represents the variance of the tone value of the second recognition image, m 1 represents the number of pixels of the second recognition image, H i represents the tone value of the i-th pixel, Representing an average hue value for all pixel points in the second identification image;
the formula according to which the hue value variance threshold is generated is:
Wherein V H0 represents a tone value variance threshold value, m 2 represents the number of pixels of the formation foil image conforming to the color number standard, H i0 represents the tone value of the ith pixel in the formation foil image conforming to the color number standard, Representing the average tone value of all pixel points in the formation foil image which accords with the color number standard;
The formula from which the tone value evaluation index is generated is:
Where ω represents the hue value evaluation index, V H represents the hue value variance of the second identification image, and V H0 represents the hue value variance threshold.
Further, the principle on which the comprehensive evaluation index is generated to judge whether the appearance of the formation foil to be detected has defects is as follows:
The formula according to which the comprehensive evaluation index is generated is as follows:
wherein lambda represents the comprehensive evaluation index, mu represents the irregularity evaluation index, Represents an edge evaluation index, ω represents a tone value evaluation index;
the comprehensive evaluation indexes under the influence of the three evaluation indexes have eight values of 0, 1,2, 3, 4, 5, 6 and 7, and each value corresponds to one value of the irregularity evaluation index, the edge evaluation index and the tone value evaluation index, and the specific judgment principle is as follows:
when λ=0, at which time μ=0, Ω=0, indicating that the irregularity, edge variance, and hue value variance all exceed the threshold, all with defects;
when λ=1, at which time μ=0, Ω=1, indicating that the irregularity, edge variance exceeds the threshold, there is a defect, and the hue value is not defective;
When λ=2, at which time μ=0, Ω=0, indicating that the irregularity, hue value variance exceeds the threshold, there are defects, and no defects at the edges;
When λ=3, at which time μ=0, Ω=1, indicating that the irregularity exceeds the threshold, that there is a defect, that the hue value and the edge are not defective;
when λ=4, at which time μ=1, Ω=0, indicating that the hue value variance and the edge variance exceed the threshold, that there is a defect, and that the irregularity does not have a defect;
when λ=5, at which time μ=1, Ω=1, indicating that the edge variance exceeds the threshold, there are defects, and no defects in the irregularity and hue values;
when λ=6, at which time μ=1, Ω=0, indicating that the hue value variance exceeds the threshold, there are defects, irregularities and edges are not defective;
When λ=7, at which time μ=1, Ω=1, indicating that the irregularities, edge variance and hue value variance do not exceed the threshold, and the formed foil is free of defects.
The invention also provides an appearance defect detection system of the formed foil, which is used for realizing the method for detecting the appearance defect of the formed foil, and comprises the following steps:
The image acquisition module is used for acquiring an image to be detected into foil, uniformly scaling the size of the image into 224 multiplied by 224, copying the image into two groups of identical images, generating a first identification image after one group of images are subjected to gray level processing, generating a second identification image after the other group of images are converted into HSV color space from RGB color space, taking the column of the leftmost pixel point of the first identification image as a y axis and the row of the bottommost pixel point as an x axis, establishing a plane rectangular coordinate system, and mapping the pixel point positions of the first identification image and the second identification image in the coordinate system one by one;
The threshold segmentation module is used for filtering the first identification image by using a bilateral filter, counting a gray level histogram formed by occurrence frequencies of pixel points of each level in 256 gray levels, calculating an inter-class variance of each threshold in the histogram, selecting an optimal segmentation threshold by the maximum inter-class variance, segmenting the filtered first identification image by using the optimal segmentation threshold, identifying a foreground part and a background part, and extracting the foreground part to generate a third identification image;
The surface processing module is used for processing the third identification image through a sobel operator, generating edge points of the third identification image, equally dividing the third identification image into 64 areas of 8 multiplied by 8, calculating the average gray value of pixel points in each area and the number of edge pixel points, combining the gray value variance of the pixel points and the total number of the edge pixel points generated by all the areas, generating formation foil irregularities according to the gray value variance of the pixel points and the total number of the edge pixel points, collecting the gray value variance of the formation foil surface and the number of the edge pixel points, which are free of defects on the surface, presetting an irregularity threshold, and comparing the actual formation foil irregularities with the irregularity threshold to generate an irregularity evaluation index;
The edge processing module is used for mapping the coordinate system of the first identification image into a third identification image with the edge points, determining the coordinates of all the edge pixel points, generating a fitting edge straight line through linear regression of the coordinates of the edge pixel points, calculating the variance of the distances between all the edge pixel points and the fitting edge straight line, presetting an edge variance threshold, and generating an edge evaluation index through comparing the actual variance with the edge variance threshold;
the tone processing module is used for collecting the tone value of each pixel point in the second identification image, generating a tone value variance of the second identification image, collecting the tone value of the formation foil image with the color uniformity conforming to the color number standard in advance, calculating the variance, generating a tone value variance threshold value, and comparing the tone value variance with the tone value variance threshold value to generate a tone value evaluation index;
The comprehensive judging module is used for dividing the appearance defects of the formation foil to be detected into whether pit scratches exist on the surface, whether edges are neat and whether colors are uniform, and generating comprehensive evaluation indexes by comprehensive irregularity evaluation indexes, edge evaluation indexes and tone value evaluation indexes to judge whether the appearance of the formation foil to be detected has defects.
Compared with the prior art, the invention has the beneficial effects that:
The method mainly and most obviously detects three defects of the formed foil surface, including whether the formed foil surface has pit scratches, whether edges are neat and whether colors are uniform, respectively processing the image of the formed foil surface into a gray level image and an HSV color space image through an image processing technology, carrying out edge detection on the image in the gray level image, extracting edge points of the image, generating an irregularity evaluation index according to the principle that both the gray level value variance of the image with the pit scratches and the number of the edge pixel points are increased, wherein the gray level value variance reflects the uniformity and the smoothness of the formed foil surface, the number of the edge pixel points reflects the complexity of a surface structure, and the combination of the two parameters enables the evaluation of the irregularity to more comprehensively and accurately reflect the actual condition of the formed foil surface and judges whether the pit scratches exist on the formed foil surface by comparing the irregularity with an irregularity threshold; meanwhile, a fitting straight line is generated according to the coordinates of the edge points, an edge evaluation index is generated according to the variance of the distance between the actual edge pixel points and the fitting straight line, the uniformity of the edges of the formed foil is measured as the edge evaluation index, so that quantitative analysis can be performed, if the distance between the edge pixel points and the fitting straight line is smaller, the edges of the formed foil are tidier, and the detection accuracy is ensured; the variance of the tone value of each pixel point is calculated through the HSV color space image, the uniformity of the color is further evaluated, and the formation foil with larger tone deviation can be timely detected according to the tone value evaluation index. And finally, generating a comprehensive evaluation index by combining the irregularity evaluation index, the edge evaluation index and the tone value evaluation index, and directly obtaining the values of the other three corresponding evaluation indexes according to the value of the comprehensive evaluation index, so as to judge which part is defective, and intuitively and accurately reflect the defect condition of the appearance of the formed foil.
Drawings
FIG. 1 is a schematic flow chart of a method according to an embodiment of the present invention;
fig. 2 is a schematic diagram of a system module according to an embodiment of the invention.
Detailed Description
The present invention will be further described in detail with reference to specific embodiments in order to make the objects, technical solutions and advantages of the present invention more apparent.
It is to be noted that unless otherwise defined, technical or scientific terms used herein should be taken in a general sense as understood by one of ordinary skill in the art to which the present invention belongs. The terms "first," "second," and the like, as used herein, do not denote any order, quantity, or importance, but rather are used to distinguish one element from another. The word "comprising" or "comprises", and the like, means that elements or items preceding the word are included in the element or item listed after the word and equivalents thereof, but does not exclude other elements or items. The terms "connected" or "connected," and the like, 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 used only to indicate a relative positional relationship, and when the absolute position of the object to be described is changed, the relative positional relationship may be changed accordingly.
Examples:
referring to fig. 1, the present invention provides a technical solution:
The method for detecting the appearance defects of the formed foil comprises the following specific steps:
step 1: collecting images to be detected into foil, uniformly scaling the sizes of the images into 224 multiplied by 224, copying the images into two groups of identical images, generating a first identification image after one group of images are subjected to gray scale treatment, generating a second identification image after the other group of images are converted into HSV (hue, saturation and saturation) color space from RGB (red, green, blue) color space, taking the column of the leftmost pixel point of the first identification image as a y axis and the row of the bottommost pixel point as an x axis, establishing a plane rectangular coordinate system, and mapping the pixel point positions of the first identification image and the second identification image in the coordinate system one by one;
in this embodiment, the formula according to which the image is subjected to graying processing is:
Y=0.299*R+0.578*G+0.114*B
wherein 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 underlying the conversion of an image from RGB color space to HSV color space is:
firstly, converting the value of RGB space into the value between [0,1], wherein the formula is as follows:
Wherein R represents a red channel value, G represents a green channel value, B represents a blue channel value, R 0 represents a result of normalizing the red channel value, G 0 represents a result of normalizing the green channel value, and B 0 represents a result of normalizing the blue channel value;
H 0、S0、V0 with a value between [0,1] is calculated through R 0、G0、B0, and the specific formula is as follows:
V0=max(R0,G0,B0)
S=S0*255
V=V0*255
Wherein H represents a hue channel value, S represents a saturation channel value, V represents a luminance channel value, and H 0、S0、V0 represents the result of normalizing the hue channel value, the saturation channel value, and the luminance channel value, respectively.
In this embodiment, coordinates are used to mark the pixel points after image scaling, the column where the leftmost pixel point of the image is located is taken as the y-axis, the row where the bottommost pixel point is located is taken as the x-axis, a plane rectangular coordinate system is established, a coordinate system is established, and the first identification image and the second identification image are mapped according to the coordinate system, so that each pixel point is guaranteed to have unique coordinates.
Step 2: filtering the first identification image by using a bilateral filter, counting a gray level histogram formed by occurrence frequencies of pixel points of each level in 256 gray levels, calculating inter-class variances of all thresholds in the histogram, selecting an optimal segmentation threshold value through the maximum inter-class variance, segmenting the first identification image after filtering by using the optimal segmentation threshold value, identifying a foreground part and a background part, and extracting the foreground part to generate a third identification image;
In this embodiment, the principle on which the optimal segmentation threshold is selected by the maximum inter-class variance is as follows:
Traversing all possible thresholds, dividing the first identification image into a background part and a foreground part according to the value of each threshold, counting the number of pixels of the background part and the foreground part, calculating the average value of gray values of the pixels of the background part and the foreground part, and calculating the inter-class variance;
the formula from which the inter-class variance is calculated is:
h(i)2=ωi0ωi1(μi0-μi1)2
Wherein: h (i) represents the inter-class variance when the threshold is i, ω i0 represents the proportion of the foreground portion to the total image when the threshold is i, μ i0 represents the foreground portion gray value when the threshold is i, ω i1 represents the proportion of the background portion to the total image when the threshold is i, and μ i1 represents the background portion gray value 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 for carrying out threshold segmentation on the first identification image, and the foreground part is extracted as a third identification image.
The calculation formula of the inter-class variance is an formula of OTSU by the Ojin method, h (i) represents the inter-class variance when the threshold value is i, omega i0 represents the proportion of the foreground part to the total image, mu i0 represents the gray value of the target part when the threshold value is i, omega i1 represents the proportion of the background part to the total image when the threshold value is i, and mu i1 represents the gray value of the background part when the threshold value is i; when h (i) is larger, the difference between the two images is larger, the separation effect is better, and the corresponding i is the optimal separation threshold.
Step 3: processing a third identification image through a sobel operator to generate edge points of the third identification image, equally dividing the third identification image into 64 areas with the granularity of 8 multiplied by 8, calculating the average gray value of pixel points in each area and the number of edge pixel points, combining the gray value variance of the pixel points and the total number of the edge pixel points generated by all the areas, generating formation foil irregularities according to the gray value variance of the pixel points and the total number of the edge pixel points, collecting the gray value variance of the formation foil surface and the number of the edge pixel points, which have no defects on the surface, presetting an irregularity threshold, and comparing the actual formation foil irregularities with the irregularity threshold to generate an irregularity evaluation index;
in this embodiment, the principle on which the irregularity evaluation index is generated is as follows:
firstly, generating edge points of a third identification image according to the following principle:
The gray value of each pixel point and the gray values of eight adjacent pixel points are multiplied by a sobel operator horizontal direction template, and all the products are added to obtain a pixel point horizontal direction gradient value; multiplying the gray value of the pixel point and the gray values of eight adjacent pixel points with a template in the vertical direction of a sobel operator, and adding all the results to obtain a gradient value in the vertical direction; the calculation formula of the gradient value in the horizontal direction is as follows:
the calculation formula of the gradient value in the vertical direction is as follows:
Wherein: gx (i, j) represents a horizontal gradient value of a pixel point with coordinates (i, j), gy (i, j) represents a vertical gradient value of a pixel point with coordinates (i, j), and X (i, j) represents a gray value of a pixel point with coordinates (i, j);
The formula for generating the gradient amplitude basis is as follows:
wherein: g (i, j) represents the gradient magnitude of the pixel point with coordinates (i, j);
Traversing all gradient amplitude values, selecting one gradient amplitude value which can clearly show the image edge characteristic as an edge threshold value, and when the gradient amplitude value of a pixel point with coordinates (i, j) is larger than the edge threshold value, taking the pixel point as an edge pixel point;
The formula according to which the gray value variance of the pixel point is generated is as follows:
wherein V g represents the gray value variance of all the regions, n represents the number of divided regions, g i represents the gray value of the ith region, which is the sum of the gray values of all the pixel points in the region, Representing the average gray value of all regions;
the formula according to which the formation foil irregularities are generated is:
wherein, P represents the formation foil irregularity, W V represents the influence weight of gray value variance on the irregularity, V g represents the gray value variance of all areas, W K represents the influence weight of the number of edge pixel points on the irregularity, K represents the total number of edge pixel points in all areas;
The irregularity reflects the smoothness of the surface of the formation foil, and is determined by the gray value variance of the surface of the formation foil and the number of edge pixels, the gray value variance reflects the uniformity of the pixels on the surface of the formation foil, when pits or scratches occur, the gray value of the scratch position of the pits increases, so that the integral gray value variance increases, and the irregularity is proportional to the gray value variance; similarly, when pits or scratches appear, the edge detection can additionally detect the parts of the pits or scratches, so that the number of edge pixel points is increased, the irregularity is in direct proportion to the number of the edge pixel points, the influence of the gray value variance on the flatness is larger, the weight can be set to be 0.7, and the influence weight of the number of the edge pixel points is set to be 0.3;
The formula according to which the threshold value of irregularity is preset is:
Wherein, P 0 represents an irregularity threshold value, W V represents an influence weight of a gray value variance on flatness, V g0 represents a gray value variance of a formation foil with no surface defect, W K represents an influence weight of the number of edge pixel points on irregularity, and K 0 represents the number of edge pixel points of the formation foil with no surface defect;
The irregularity threshold value formula is consistent with the irregularity weight formula except that the gray value variance and the number of edge pixel points adopt formation foil data without defects;
The formula according to which the irregularity evaluation index is generated is:
wherein μ represents an irregularity evaluation index, P represents an irregularity of the formation foil to be detected, and P 0 represents an irregularity threshold;
the irregularity evaluation index reflects the relation between the irregularity and the irregularity threshold, logic judgment is carried out through the size relation between the irregularity and the irregularity threshold, the irregularity evaluation index is enabled to be 1 or 0, when the irregularity evaluation index is 1, the fact that the irregularity of the formation foil to be detected does not exceed the threshold is indicated, no defect exists on the detection layer, when the irregularity evaluation index is 0, the fact that the irregularity of the formation foil to be detected exceeds the threshold is indicated, and the defect exists on the detection layer.
Step 4: mapping the coordinate system of the first identification image into a third identification image with edge points, determining the coordinates of all edge pixel points, generating a fitting edge straight line through linear regression of the coordinates of the edge pixel points, calculating the variance of the distances between all edge pixel points and the fitting edge straight line, presetting an edge variance threshold, and generating an edge evaluation index through comparing the actual variance with the edge variance threshold;
in this embodiment, the principle on which the fitted edge straight line is generated by performing linear regression on the coordinates of the edge pixel points is as follows:
Obtaining a series of edge coordinate points through image edge detection and coordinate system mapping, and calculating the average value of the horizontal coordinates and the vertical coordinates of all the edge coordinate points according to the following formula:
wherein, Represents the mean value of the abscissa of the edge points, x i represents the abscissa of the ith edge pixel point, n represents the number of edge coordinate points,Representing the mean value of the ordinate of the edge points, and y i represents the ordinate of the ith edge pixel point;
Generating the slope of the fitting edge straight line according to the following formula:
Where a represents the slope of the fitted edge line, x i represents the abscissa of the ith edge pixel point, Representing the mean of the abscissa of the edge points, y i representing the ordinate of the ith edge pixel point,Representing the mean value of the ordinate of the edge point;
generating the intercept of the fitting edge straight line according to the following formula:
Wherein b represents the intercept of the fitted edge line, Represents the mean value of the ordinate of the edge points, a represents the slope of the fitted edge line,Representing the mean value of the abscissa of the edge points;
the generated fitting edge linear equation is:
y=ax+b
the formula according to which the variance of the distances between all edge pixel points and the fitted edge straight line is calculated is as follows:
Wherein d i represents the distance between the ith edge pixel point and the fitted edge straight line, x i represents the abscissa of the ith edge pixel point, y i represents the ordinate of the ith edge pixel point, a and b represent the slope and intercept of the fitted edge straight line, V d represents the variance of the distance between the edge pixel point and the fitted edge straight line, N represents the number of edge pixel points, Representing the average value of the distances between all edge pixel points and the fitting edge straight line;
The variance of the distance between the edge pixel point and the fitting edge straight line reflects the fitting condition of the actual edge to the fitting edge straight line, when the variance is smaller, the actual edge is closer to the fitting edge straight line, the probability of having defects on the edge is smaller, and when the variance is larger, the actual edge is farther from the fitting edge straight line, the probability of having defects on the edge is larger;
the principle on which the edge variance threshold is preset is as follows:
Analyzing the historical foil edge data, calculating variances of distances between edge pixel points and fitting edge straight lines in the data, collecting all variances, statistically analyzing the mean value and standard deviation of the variances, and presetting an edge variance threshold according to the mean value and standard deviation result of the statistical variances, wherein the formula on which the edge variance threshold is based is as follows:
where V d0 represents the edge variance threshold, The average value of the distance variance in the historical data is represented, sigma represents the standard deviation of the distance variance in the historical data, and k represents a constant reflecting the actual scene requirement and the risk tolerance;
When the historical data is enough, the edge variance is normally distributed, the k-value of the constant reflecting the actual scene demand and the risk tolerance is 3, which is equivalent to covering 99.7% of non-defective samples, and reducing the possibility of erroneous judgment
The formula according to which the edge evaluation index is generated is:
wherein, Representing an edge evaluation index, V d representing the variance of the distance between the edge pixel point and the fitted edge straight line, V d0 representing an edge variance threshold;
The edge evaluation index reflects the relation between the edge variance and the edge variance threshold, the magnitude relation between the edge variance and the edge variance threshold is used for carrying out logic judgment, the value of the edge evaluation index is 1 or 0, when the value of the edge evaluation index is 1, the edge variance of the formation foil to be detected does not exceed the threshold, no defect exists on the detection layer, and when the value of the edge evaluation index is 0, the edge variance of the formation foil to be detected exceeds the threshold, and the defect exists on the detection layer.
Step 5: collecting the tone value of each pixel point in the second identification image, generating a tone value variance of the second identification image, collecting the tone value of the formation foil image with the color uniformity conforming to the color number standard in advance, calculating the variance, generating a tone value variance threshold, and comparing the tone value variance with the tone value variance threshold to generate a tone value evaluation index;
In this embodiment, the formula according to which the variance of the hue value of the second identification image is generated is:
Where V H represents the variance of the tone value of the second recognition image, m 1 represents the number of pixels of the second recognition image, H i represents the tone value of the i-th pixel, Representing an average hue value for all pixel points in the second identification image;
The color tone value variance reflects the uniformity of the color of the formed foil, and the smaller the color tone value variance is, the closer the color tone value of the formed foil surface is, the better the color uniformity is, which means that the color change on the whole surface is small and no obvious color difference or spot exists;
the formula according to which the hue value variance threshold is generated is:
Wherein V H0 represents a tone value variance threshold value, m 2 represents the number of pixels of the formation foil image conforming to the color number standard, H i0 represents the tone value of the ith pixel in the formation foil image conforming to the color number standard, Representing the average tone value of all pixel points in the formation foil image which accords with the color number standard;
The color number of the formed foil is used for identifying and describing the standard number of the formed foil color, the color number can be determined according to a standard act or according to actual conditions, historical formed foil tone value data reaching the color number standard is collected, and a tone value variance threshold capable of meeting the conditions is generated.
The formula from which the tone value evaluation index is generated is:
Wherein ω represents the tone value evaluation index, V H represents the tone value variance of the second recognition image, and V H0 represents the tone value variance threshold;
The tone value evaluation index reflects the relation between the tone value variance and the tone value variance threshold, the relation between the tone value variance and the tone value variance threshold is logically judged through the magnitude relation between the tone value evaluation index and the tone value variance threshold, the tone value evaluation index takes the value of 1 or 0, when the tone value evaluation index takes the value of 1, the tone value variance of the formation foil to be detected does not exceed the threshold, no defect exists on the detection layer, when the tone value evaluation index takes the value of 0, the tone value variance of the formation foil to be detected exceeds the threshold, and the defect exists on the detection layer.
Step 6: dividing the appearance defects of the formation foil to be detected into whether pit scratches exist on the surface, whether edges are neat and whether colors are uniform, and generating comprehensive evaluation indexes by combining the irregularity evaluation indexes, the edge evaluation indexes and the tone value evaluation indexes to judge whether the appearance of the formation foil to be detected has defects;
in this embodiment, the formula according to which the comprehensive evaluation index is generated is:
wherein lambda represents the comprehensive evaluation index, mu represents the irregularity evaluation index, Represents an edge evaluation index, ω represents a tone value evaluation index;
the comprehensive evaluation indexes under the influence of the three evaluation indexes have eight values of 0, 1,2, 3, 4, 5, 6 and 7, and each value corresponds to one value of the irregularity evaluation index, the edge evaluation index and the tone value evaluation index, and the specific judgment principle is as follows:
when λ=0, at which time μ=0, Ω=0, indicating that the irregularity, edge variance, and hue value variance all exceed the threshold, all with defects;
when λ=1, at which time μ=0, Ω=1, indicating that the irregularity, edge variance exceeds the threshold, there is a defect, and the hue value is not defective;
When λ=2, at which time μ=0, Ω=0, indicating that the irregularity, hue value variance exceeds the threshold, there are defects, and no defects at the edges;
When λ=3, at which time μ=0, Ω=1, indicating that the irregularity exceeds the threshold, that there is a defect, that the hue value and the edge are not defective;
when λ=4, at which time μ=1, Ω=0, indicating that the hue value variance and the edge variance exceed the threshold, that there is a defect, and that the irregularity does not have a defect;
when λ=5, at which time μ=1, Ω=1, indicating that the edge variance exceeds the threshold, there are defects, and no defects in the irregularity and hue values;
when λ=6, at which time μ=1, Ω=0, indicating that the hue value variance exceeds the threshold, there are defects, irregularities and edges are not defective;
When λ=7, at which time μ=1, Ω=1, indicating that the irregularities, edge variance and hue value variance do not exceed the threshold, and the formed foil is free of defects.
In the judging process, the values of each comprehensive judging index correspond to the values of a group of irregularity evaluation index, edge evaluation index and tone value evaluation index, and the values of the irregularity evaluation index, the edge evaluation index and the tone value evaluation index can be directly reversely deduced according to the comprehensive judging indexes, so that ambiguity is avoided.
Referring to fig. 2, the present invention further provides a system for detecting an appearance defect of a formed foil, where the system is configured to implement the method for detecting an appearance defect of a formed foil, and the method includes:
The image acquisition module is used for acquiring an image to be detected into foil, uniformly scaling the size of the image into 224 multiplied by 224, copying the image into two groups of identical images, generating a first identification image after one group of images are subjected to gray level processing, generating a second identification image after the other group of images are converted into HSV color space from RGB color space, taking the column of the leftmost pixel point of the first identification image as a y axis and the row of the bottommost pixel point as an x axis, establishing a plane rectangular coordinate system, and mapping the pixel point positions of the first identification image and the second identification image in the coordinate system one by one;
The threshold segmentation module is used for filtering the first identification image by using a bilateral filter, counting a gray level histogram formed by occurrence frequencies of pixel points of each level in 256 gray levels, calculating an inter-class variance of each threshold in the histogram, selecting an optimal segmentation threshold by the maximum inter-class variance, segmenting the filtered first identification image by using the optimal segmentation threshold, identifying a foreground part and a background part, and extracting the foreground part to generate a third identification image;
The surface processing module is used for processing the third identification image through a sobel operator, generating edge points of the third identification image, equally dividing the third identification image into 64 areas of 8 multiplied by 8, calculating the average gray value of pixel points in each area and the number of edge pixel points, combining the gray value variance of the pixel points and the total number of the edge pixel points generated by all the areas, generating formation foil irregularities according to the gray value variance of the pixel points and the total number of the edge pixel points, collecting the gray value variance of the formation foil surface and the number of the edge pixel points, which are free of defects on the surface, presetting an irregularity threshold, and comparing the actual formation foil irregularities with the irregularity threshold to generate an irregularity evaluation index;
The edge processing module is used for mapping the coordinate system of the first identification image into a third identification image with the edge points, determining the coordinates of all the edge pixel points, generating a fitting edge straight line through linear regression of the coordinates of the edge pixel points, calculating the variance of the distances between all the edge pixel points and the fitting edge straight line, presetting an edge variance threshold, and generating an edge evaluation index through comparing the actual variance with the edge variance threshold;
the tone processing module is used for collecting the tone value of each pixel point in the second identification image, generating a tone value variance of the second identification image, collecting the tone value of the formation foil image with the color uniformity conforming to the color number standard in advance, calculating the variance, generating a tone value variance threshold value, and comparing the tone value variance with the tone value variance threshold value to generate a tone value evaluation index;
The comprehensive judging module is used for dividing the appearance defects of the formation foil to be detected into whether pit scratches exist on the surface, whether edges are neat and whether colors are uniform, and generating comprehensive evaluation indexes by comprehensive irregularity evaluation indexes, edge evaluation indexes and tone value evaluation indexes to judge whether the appearance of the formation foil to be detected has defects.
The above formulas are all formulas with dimensions removed and numerical values calculated, the formulas are formulas with a large amount of data collected for software simulation to obtain the latest real situation, and preset parameters in the formulas are set by those skilled in the art according to the actual situation.
The above embodiments may be implemented in whole or in part by software, hardware, firmware, or any other combination. When implemented in software, the above-described embodiments may be implemented in whole or in part in the form of a computer program product. Those of skill in the art will appreciate that the elements and algorithm steps described in connection with the embodiments disclosed herein can be implemented as electronic hardware, or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the solution.
The units described as separate units may or may not be physically separate, and units shown as units may or may not be physical units, may be located in one place, or may be distributed over a plurality of 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.
The foregoing is merely illustrative of the present application, and the present application is not limited thereto, and any person skilled in the art will readily recognize that variations or substitutions are within the scope of the present application.
Claims (2)
1. The method for detecting the appearance defects of the formed foil is characterized by comprising the following specific steps:
step 1: collecting images to be detected into foil, uniformly scaling the sizes of the images into 224 multiplied by 224, copying the images into two groups of identical images, generating a first identification image after one group of images are subjected to gray scale treatment, generating a second identification image after the other group of images are converted into HSV (hue, saturation and saturation) color space from RGB (red, green, blue) color space, taking the column of the leftmost pixel point of the first identification image as a y axis and the row of the bottommost pixel point as an x axis, establishing a plane rectangular coordinate system, and mapping the pixel point positions of the first identification image and the second identification image in the coordinate system one by one;
Step 2: filtering the first identification image by using a bilateral filter, counting a gray level histogram formed by occurrence frequencies of pixel points of each level in 256 gray levels, calculating inter-class variances of all thresholds in the histogram, selecting an optimal segmentation threshold value through the maximum inter-class variance, segmenting the first identification image after filtering by using the optimal segmentation threshold value, identifying a foreground part and a background part, and extracting the foreground part to generate a third identification image;
Step 3: processing a third identification image through a sobel operator to generate edge points of the third identification image, equally dividing the third identification image into 64 areas with the granularity of 8 multiplied by 8, calculating the average gray value of pixel points in each area and the number of edge pixel points, combining the gray value variance of the pixel points and the total number of the edge pixel points generated by all the areas, generating formation foil irregularities according to the gray value variance of the pixel points and the total number of the edge pixel points, collecting the gray value variance of the formation foil surface and the number of the edge pixel points, which have no defects on the surface, presetting an irregularity threshold, and comparing the actual formation foil irregularities with the irregularity threshold to generate an irregularity evaluation index;
Step 4: mapping the coordinate system of the first identification image into a third identification image with edge points, determining the coordinates of all edge pixel points, generating a fitting edge straight line through linear regression of the coordinates of the edge pixel points, calculating the variance of the distances between all edge pixel points and the fitting edge straight line, presetting an edge variance threshold, and generating an edge evaluation index through comparing the actual variance with the edge variance threshold;
Step 5: collecting the tone value of each pixel point in the second identification image, generating a tone value variance of the second identification image, collecting the tone value of the formation foil image with the color uniformity conforming to the color number standard in advance, calculating the variance, generating a tone value variance threshold, and comparing the tone value variance with the tone value variance threshold to generate a tone value evaluation index;
step 6: dividing the appearance defects of the formation foil to be detected into whether pit scratches exist on the surface, whether edges are neat and whether colors are uniform, and generating comprehensive evaluation indexes by combining the irregularity evaluation indexes, the edge evaluation indexes and the tone value evaluation indexes to judge whether the appearance of the formation foil to be detected has defects;
The formula according to which the image is subjected to graying treatment is as follows:
Y=0.299*R+0.578*G+0.114*B
wherein Y represents the gray value of the pixel point, R represents the red channel value of the pixel point, G represents the green channel value of the pixel point, and B represents the blue channel value of the pixel point;
the principle underlying the conversion of an image from RGB color space to HSV color space is:
firstly, converting the value of RGB space into the value between [0,1], wherein the formula is as follows:
Wherein R represents a red channel value, G represents a green channel value, B represents a blue channel value, R 0 represents a result of normalizing the red channel value, G 0 represents a result of normalizing the green channel value, and B 0 represents a result of normalizing the blue channel value;
H 0、S0、V0 with a value between [0,1] is calculated through R 0、G0、B0, and the specific formula is as follows:
V0=max(R0,G0,B0)
S=S0*255
V=V0*255
wherein H represents a hue channel value, S represents a saturation channel value, V represents a luminance channel value, and H 0、S0、V0 represents the results of normalizing the hue channel value, the saturation channel value, and the luminance channel value, respectively;
The principle on which the optimal segmentation threshold is selected by the maximum inter-class variance is as follows:
Traversing all possible thresholds, dividing the first identification image into a background part and a foreground part according to the value of each threshold, counting the number of pixels of the background part and the foreground part, calculating the average value of gray values of the pixels of the background part and the foreground part, and calculating the inter-class variance;
the formula from which the inter-class variance is calculated is:
h(i)2=ωi0ωi1(μi0-μi1)2
Wherein: h (i) represents the inter-class variance when the threshold is i, ω i0 represents the proportion of the foreground portion to the total image when the threshold is i, μ i0 represents the foreground portion gray value when the threshold is i, ω i1 represents the proportion of the background portion to the total image when the threshold is i, and μ i1 represents the background portion gray value when the threshold is i;
When h (i) takes the maximum value, the corresponding threshold i is the optimal segmentation threshold, threshold segmentation is carried out on the first identification image by using the threshold i, and the foreground part is extracted as a third identification image;
the principle on which the irregularity evaluation index is generated is as follows:
firstly, generating edge points of a third identification image according to the following principle:
The gray value of each pixel point and the gray values of eight adjacent pixel points are multiplied by a sobel operator horizontal direction template, and all the products are added to obtain a pixel point horizontal direction gradient value; multiplying the gray value of the pixel point and the gray values of eight adjacent pixel points with a template in the vertical direction of a sobel operator, and adding all the results to obtain a gradient value in the vertical direction; the calculation formula of the gradient value in the horizontal direction is as follows:
the calculation formula of the gradient value in the vertical direction is as follows:
Wherein: gx (i, j) represents a horizontal gradient value of a pixel point with coordinates (i, j), gy (i, j) represents a vertical gradient value of a pixel point with coordinates (i, j), and X (i, j) represents a gray value of a pixel point with coordinates (i, j);
The formula for generating the gradient amplitude basis is as follows:
wherein: g (i, j) represents the gradient magnitude of the pixel point with coordinates (i, j);
Traversing all gradient amplitude values, selecting one gradient amplitude value which can clearly show the image edge characteristic as an edge threshold value, and when the gradient amplitude value of a pixel point with coordinates (i, j) is larger than the edge threshold value, taking the pixel point as an edge pixel point;
The formula according to which the gray value variance of the pixel point is generated is as follows:
wherein V g represents the gray value variance of all the regions, n represents the number of divided regions, g i represents the gray value of the ith region, which is the sum of the gray values of all the pixel points in the region, Representing the average gray value of all regions;
the formula according to which the formation foil irregularities are generated is:
wherein, P represents the formation foil irregularity, W V represents the influence weight of gray value variance on the irregularity, V g represents the gray value variance of all areas, W K represents the influence weight of the number of edge pixel points on the irregularity, K represents the total number of edge pixel points in all areas;
The formula according to which the threshold value of irregularity is preset is:
Wherein, P 0 represents an irregularity threshold value, W V represents an influence weight of a gray value variance on flatness, V g0 represents a gray value variance of a formation foil with no surface defect, W K represents an influence weight of the number of edge pixel points on irregularity, and K 0 represents the number of edge pixel points of the formation foil with no surface defect;
The formula according to which the irregularity evaluation index is generated is:
wherein μ represents an irregularity evaluation index, P represents an irregularity of the formation foil to be detected, and P 0 represents an irregularity threshold;
The principle on which the fitting edge straight line is generated by linear regression through the coordinates of the edge pixel points is as follows:
Obtaining a series of edge coordinate points through image edge detection and coordinate system mapping, and calculating the average value of the horizontal coordinates and the vertical coordinates of all the edge coordinate points according to the following formula:
wherein, Represents the mean value of the abscissa of the edge points, x i represents the abscissa of the ith edge pixel point, n represents the number of edge coordinate points,Representing the mean value of the ordinate of the edge points, and y i represents the ordinate of the ith edge pixel point;
Generating the slope of the fitting edge straight line according to the following formula:
Where a represents the slope of the fitted edge line, x i represents the abscissa of the ith edge pixel point, Representing the mean of the abscissa of the edge points, y i representing the ordinate of the ith edge pixel point,Representing the mean value of the ordinate of the edge point;
generating the intercept of the fitting edge straight line according to the following formula:
Wherein b represents the intercept of the fitted edge line, Represents the mean value of the ordinate of the edge points, a represents the slope of the fitted edge line,Representing the mean value of the abscissa of the edge points;
the generated fitting edge linear equation is:
y=ax+b
the formula according to which the variance of the distances between all edge pixel points and the fitted edge straight line is calculated is as follows:
Wherein d i represents the distance between the ith edge pixel point and the fitted edge straight line, x i represents the abscissa of the ith edge pixel point, y i represents the ordinate of the ith edge pixel point, a and b represent the slope and intercept of the fitted edge straight line, V d represents the variance of the distance between the edge pixel point and the fitted edge straight line, N represents the number of edge pixel points, Representing the average value of the distances between all edge pixel points and the fitting edge straight line;
the principle on which the edge variance threshold is preset is as follows:
Analyzing the historical foil edge data, calculating variances of distances between edge pixel points and fitting edge straight lines in the data, collecting all variances, statistically analyzing the mean value and standard deviation of the variances, and presetting an edge variance threshold according to the mean value and standard deviation result of the statistical variances, wherein the formula on which the edge variance threshold is based is as follows:
where V d0 represents the edge variance threshold, The average value of the distance variance in the historical data is represented, sigma represents the standard deviation of the distance variance in the historical data, and k represents a constant reflecting the actual scene requirement and the risk tolerance;
the formula according to which the edge evaluation index is generated is:
wherein, Representing an edge evaluation index, V d representing the variance of the distance between the edge pixel point and the fitted edge straight line, V d0 representing an edge variance threshold;
The principle on which the tone value evaluation index is generated is as follows:
the formula from which the variance of the hue value of the second identification image is generated is:
Where V H represents the variance of the tone value of the second recognition image, m 1 represents the number of pixels of the second recognition image, H i represents the tone value of the i-th pixel, Representing an average hue value for all pixel points in the second identification image;
the formula according to which the hue value variance threshold is generated is:
Wherein V H0 represents a tone value variance threshold value, m 2 represents the number of pixels of the formation foil image conforming to the color number standard, H i0 represents the tone value of the ith pixel in the formation foil image conforming to the color number standard, Representing the average tone value of all pixel points in the formation foil image which accords with the color number standard;
The formula from which the tone value evaluation index is generated is:
Wherein ω represents the tone value evaluation index, V H represents the tone value variance of the second recognition image, and V H0 represents the tone value variance threshold;
the principle on which the comprehensive evaluation index is generated to judge whether the appearance of the formation foil to be detected has defects is as follows:
The formula according to which the comprehensive evaluation index is generated is as follows:
wherein lambda represents the comprehensive evaluation index, mu represents the irregularity evaluation index, Represents an edge evaluation index, ω represents a tone value evaluation index;
the comprehensive evaluation indexes under the influence of the three evaluation indexes have eight values of 0, 1,2, 3, 4, 5, 6 and 7, and each value corresponds to one value of the irregularity evaluation index, the edge evaluation index and the tone value evaluation index, and the specific judgment principle is as follows:
when λ=0, at which time μ=0, Ω=0, indicating that the irregularity, edge variance, and hue value variance all exceed the threshold, all with defects;
when λ=1, at which time μ=0, Ω=1, indicating that the irregularity, edge variance exceeds the threshold, there is a defect, and the hue value is not defective;
When λ=2, at which time μ=0, Ω=0, indicating that the irregularity, hue value variance exceeds the threshold, there are defects, and no defects at the edges;
When λ=3, at which time μ=0, Ω=1, indicating that the irregularity exceeds the threshold, that there is a defect, that the hue value and the edge are not defective;
when λ=4, at which time μ=1, Ω=0, indicating that the hue value variance and the edge variance exceed the threshold, that there is a defect, and that the irregularity does not have a defect;
when λ=5, at which time μ=1, Ω=1, indicating that the edge variance exceeds the threshold, there are defects, and no defects in the irregularity and hue values;
when λ=6, at which time μ=1, Ω=0, indicating that the hue value variance exceeds the threshold, there are defects, irregularities and edges are not defective;
When λ=7, at which time μ=1, Ω=1, indicating that the irregularities, edge variance and hue value variance do not exceed the threshold, and the formed foil is free of defects.
2. An appearance defect detection system of a formed foil, characterized in that: the system is used for realizing the method for detecting the appearance defects of the formed foil, which comprises the following steps:
The image acquisition module is used for acquiring an image to be detected into foil, uniformly scaling the size of the image into 224 multiplied by 224, copying the image into two groups of identical images, generating a first identification image after one group of images are subjected to gray level processing, generating a second identification image after the other group of images are converted into HSV color space from RGB color space, taking the column of the leftmost pixel point of the first identification image as a y axis and the row of the bottommost pixel point as an x axis, establishing a plane rectangular coordinate system, and mapping the pixel point positions of the first identification image and the second identification image in the coordinate system one by one;
The threshold segmentation module is used for filtering the first identification image by using a bilateral filter, counting a gray level histogram formed by occurrence frequencies of pixel points of each level in 256 gray levels, calculating an inter-class variance of each threshold in the histogram, selecting an optimal segmentation threshold by the maximum inter-class variance, segmenting the filtered first identification image by using the optimal segmentation threshold, identifying a foreground part and a background part, and extracting the foreground part to generate a third identification image;
The surface processing module is used for processing the third identification image through a sobel operator, generating edge points of the third identification image, equally dividing the third identification image into 64 areas of 8 multiplied by 8, calculating the average gray value of pixel points in each area and the number of edge pixel points, combining the gray value variance of the pixel points and the total number of the edge pixel points generated by all the areas, generating formation foil irregularities according to the gray value variance of the pixel points and the total number of the edge pixel points, collecting the gray value variance of the formation foil surface and the number of the edge pixel points, which are free of defects on the surface, presetting an irregularity threshold, and comparing the actual formation foil irregularities with the irregularity threshold to generate an irregularity evaluation index;
The edge processing module is used for mapping the coordinate system of the first identification image into a third identification image with the edge points, determining the coordinates of all the edge pixel points, generating a fitting edge straight line through linear regression of the coordinates of the edge pixel points, calculating the variance of the distances between all the edge pixel points and the fitting edge straight line, presetting an edge variance threshold, and generating an edge evaluation index through comparing the actual variance with the edge variance threshold;
the tone processing module is used for collecting the tone value of each pixel point in the second identification image, generating a tone value variance of the second identification image, collecting the tone value of the formation foil image with the color uniformity conforming to the color number standard in advance, calculating the variance, generating a tone value variance threshold value, and comparing the tone value variance with the tone value variance threshold value to generate a tone value evaluation index;
The comprehensive judging module is used for dividing the appearance defects of the formation foil to be detected into whether pit scratches exist on the surface, whether edges are neat and whether colors are uniform, and generating comprehensive evaluation indexes by comprehensive irregularity evaluation indexes, edge evaluation indexes and tone value evaluation indexes to judge whether the appearance of the formation foil to be detected has defects.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202410971321.XA CN118501177B (en) | 2024-07-19 | Appearance defect detection method and system for formed foil |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202410971321.XA CN118501177B (en) | 2024-07-19 | Appearance defect detection method and system for formed foil |
Publications (2)
Publication Number | Publication Date |
---|---|
CN118501177A CN118501177A (en) | 2024-08-16 |
CN118501177B true CN118501177B (en) | 2024-11-19 |
Family
ID=
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109684905A (en) * | 2017-12-19 | 2019-04-26 | 云南电网有限责任公司昭通供电局 | The method of the icing quality testing of aerial condutor based on image identification |
CN110186945A (en) * | 2019-05-21 | 2019-08-30 | 东莞东阳光科研发有限公司 | A kind of three-dimensional appearance testing method of electrolytic capacitor electrode foil |
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109684905A (en) * | 2017-12-19 | 2019-04-26 | 云南电网有限责任公司昭通供电局 | The method of the icing quality testing of aerial condutor based on image identification |
CN110186945A (en) * | 2019-05-21 | 2019-08-30 | 东莞东阳光科研发有限公司 | A kind of three-dimensional appearance testing method of electrolytic capacitor electrode foil |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN115294113B (en) | Quality detection method for wood veneer | |
CN107437243B (en) | Tire impurity detection method and device based on X-ray image | |
CN113724231A (en) | Industrial defect detection method based on semantic segmentation and target detection fusion model | |
WO2021168733A1 (en) | Defect detection method and apparatus for defect image, and computer-readable storage medium | |
CN116559183B (en) | Method and system for improving defect judging efficiency | |
CN108960237B (en) | Reading identification method for pointer type oil level indicator | |
CN113096130B (en) | Method and device for detecting object defects | |
CN115100206B (en) | Printing defect identification method for textile with periodic pattern | |
CN109472261B (en) | Computer vision-based automatic monitoring method for grain storage quantity change of granary | |
CN116645367B (en) | Steel plate cutting quality detection method for high-end manufacturing | |
CN114140669B (en) | Welding defect recognition model training method and device and computer terminal | |
CN114820625B (en) | Automobile top block defect detection method | |
CN115018844A (en) | Plastic film quality evaluation method based on artificial intelligence | |
CN116152242B (en) | Visual detection system of natural leather defect for basketball | |
CN115100191A (en) | Metal casting defect identification method based on industrial detection | |
CN116883408B (en) | Integrating instrument shell defect detection method based on artificial intelligence | |
CN116109577A (en) | Printing label defect detection system and method | |
CN117664991A (en) | Defect detection system | |
CN112561875A (en) | Photovoltaic cell panel coarse grid detection method based on artificial intelligence | |
JPH08189904A (en) | Surface defect detector | |
CN115272350A (en) | Method for detecting production quality of computer PCB mainboard | |
CN117237747B (en) | Hardware defect classification and identification method based on artificial intelligence | |
CN118501177B (en) | Appearance defect detection method and system for formed foil | |
CN118037730A (en) | Crack length detection system based on computer image processing | |
CN114677428B (en) | Power transmission line icing thickness detection method based on unmanned aerial vehicle image processing |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant |