[0039] like figure 1 As shown, an image extraction device such as a CCD camera is electrically connected to an image acquisition card interfaced with a computer, and the CCD camera transmits and converts image data to be read by the computer through image acquisition. The image information obtained by the computer is expressed in the unit of pixel. If the actual measurement result value is to be given, the corresponding relationship between the digital image pixel and the actual size must be established. It is necessary to convert the CCD image coordinates to the table coordinates, so before measuring, the conversion coefficient K from the CCD coordinate system to the table coordinate system needs to be calibrated first. Calibration is actually to determine the actual physical size represented by each pixel. Whether the calibration is accurate or not will directly affect the measurement accuracy of the image measurement system.
[0040] figure 2 A flow chart of the embodiment of the present invention is given. It can be seen from the flow chart that: after the program starts from step 200, it enters step 201 to extract the image information of the antenna panel, that is, the computer reads the antenna captured by the ccd camera through the image acquisition card Panel image binary data; then the program enters step 202 to perform histogram correction processing on the second-order data of the antenna panel image and step 203 image edge retention filtering and noise reduction; after the above steps, the program undergoes step 204 Canny operator edge detection Step 205 and step 205 perform sub-pixel processing on the edge points, and then enter into step 206 to store the processed edge points. After completing the initialization of the program, the program enters real-time detection. Steps 207 , 208 , 209 , 210 and 211 of real-time detection are exactly the same as the above-mentioned steps 201 , 202 , 203 , 204 and 205 . The initialized and stored edge point is compared with the corresponding edge point detected later. When the allowable error or set value is exceeded, the program goes to step 214 to give a prompt message, otherwise, it goes to step 207 again.
[0041] Histogram correction in the process is a method to enhance the contrast of the part image by redistributing the gray values evenly, which can improve the subjective quality of the image. Assuming that the original image gray value is distributed in the interval [a, b], and the overall gray value distribution is [z 1 ,z k ], if the original interval [a, b] is [z 1 ,z k ] subspace, the pixel point z in the original interval can be mapped to the point z' of the new interval, specifically z ′ = z k - z 1 b - a ( z - a ) + z 1 , If only most of the image pixel values are distributed in the interval [a, b], the following mapping function can be used
[0042] z ′ = z k - z 1 b - a ( z - a ) + z 1 , a ≤ z ≤ b z 1 , z a z k , z b - - - ( 1 )
[0043] A mean filter or a Gaussian filter is used to achieve smoothing by using the weighted sum of pixels in a continuous window function to achieve the purpose of noise reduction. However, while removing high-frequency components in the image, this smoothing filter also makes the sharpened details in the image, such as edges, change asymptotically, thus sacrificing the precise positioning ability of the part image. For the impulse noise and salt and pepper noise in the image, the median filter algorithm can be used to filter out. The basic idea is to use the median value of the gray value of the pixel field to represent the gray value of the pixel, which reduces the influence of those points in the field that are very different from the typical value on filtering, and can better remove pulse interference. Equal noise, preserve the edge details of the image, but also filter out line details such as spires in the image. Therefore, the present invention performs preservation filtering on the crack edge information.
[0044] The edge preserving filter is a filter developed on the basis of mean filtering and median filtering. While effectively filtering out noise, it can basically maintain the step characteristics of the edge. The basic algorithm is as follows:
[0045] ① For the pixel point [i, j], its gray value is f[i, j], select a field of appropriate size, such as a 3 × 3 field;
[0046] ②According to the formula V=∑f 2 [i,j]-(∑f[i,j]) 2 /N, where N is the number of pixels in each field, calculate the gray distribution uniformity V of the upper left subfield, upper right subfield, and lower right subfield respectively;
[0047] ③ Take the mean value of the area corresponding to the minimum grayscale uniformity as the new grayscale value of the pixel point [i, j].
[0048](4) Coarse positioning and fine positioning of antenna panel crack images
[0049] Canny operator edge detection
[0050] The most basic feature of an image is the edge of the object. The edge of the image refers to the set of pixels in the image that have a step-like or cusp-like change in grayscale. The edge widely exists between objects and objects, objects and backgrounds, and regions. The purpose of edge detection is to highlight the edge of the image in order to extract image features. The Canny operator is the first derivative of the Gaussian function, which is optimal for step-like edges affected by white noise. This operator transforms the edge detection problem into the problem of detecting the maximum value of the unit function
[0051] The Canny edge detection algorithm is as follows:
[0052] ① Combine the image with the Gaussian function G σ ( x , y ) = ( 1 2 π σ 2 ) e ( - x 2 + y 2 2 σ 2 ) Do convolution to get a smooth image.
[0053] ② Determine the normal direction of the local edge of the image by the method based on the smooth gradient direction.
[0054] ③ Solve the edge position according to the normal direction of the local edge.
[0055] ④ Calculate the edge strength and perform non-maximum suppression on the gradient amplitude.
[0056] ⑤Use the double threshold algorithm to detect and connect edges.
[0057] Canny operators of different scales are represented by different standard deviations σ of the Gaussian. If the operators of several scales have outstanding responses to the edge (the signal-to-noise ratio exceeds the threshold), the initial position of the edge is first found at a larger filtering scale, and then σ is continuously reduced for tracking to obtain the most accurate positioning.
[0058] The present invention divides the crack edge into straight lines and circles, and performs different sub-pixel subdivision (positioning) on the straight lines and circles. For the straight line sub-pixel subdivision method based on the least squares method, it is based on the vertical distance between the measured point (xi, yi) and the straight line. For inclined straight lines, since the vertical distance between the point and the straight line is greater than the vertical distance, this method is not the best fitting method, and its positioning error is relatively large. Let the equation of the straight line be y=a 0 +a 1 x, the inclination angle of the line relative to the x-axis is θ, and the positional relationship between the point and the line is as follows image 3 As shown in a, the following two coordinate transformations are implemented: (1) Translate the line and the observation point (xi, yi) to move it along the vertical direction (y-axis) -a 0 , at this time the straight line passes through the origin, and the positional relationship is as follows image 3 b shown. (2) Rotate and translate the straight line around the origin and the observation point (xi, yi) θ angle (the counterclockwise direction is specified as positive, and the clockwise direction is negative), so that the straight line coincides with the x-axis. After the above coordinate transformation, the straight line and observation point (xi, yi) on the original xoy plane are transformed into the x' axis and observation point (x' on the new coordinate plane x'oy' i ', y i '),like image 3 c shown. The vertical distance between the measured point and the axis in the transformed x'oy' plane is equivalent to the vertical distance between the measured point (xi, yi) and the straight line in the original coordinate plane. image 3 The transformation of straight lines in two coordinate systems is illustrated.
[0059] The transformation matrix for translation is T 1 = 1 0 0 0 1 0 0 - a 0 1 , The transformation matrix for the rotation is T 2 = cos θ sin θ 0 - sin θ cos θ 0 0 0 1 , Then the relationship between the old and new coordinates can be expressed by the following formula:
[0060] ( x ′ y ′ 1 ) = ( xy 1 ) T 1 T 2 = ( xy 1 ) cos θ - sin θ 0 sin θ cos θ 0 - a 0 sin θ - a 0 cos θ 1 - - - ( 2 )
[0061] = x cos θ + y sin θ - a 0 sin θ y cos θ - a 0 cos θ - x sin θ 1
[0062] The improved least squares straight line fitting is fitted by measuring the vertical distance from the point to the straight line, and the mathematical model is
[0063] min 1 n Σ i = 1 n [ ( y i - a 0 ) cos θ - x i sin θ ] 2 - - - ( 3 )
[0064] Let u=sinθ, w=cosθ, then u 2 +w 2 =1, using the Lagrangian factor, the above formula can be expressed as:
[0065] L ( a 0 , u , w ) = { Σ i = 1 n [ ( y i - a 0 ) w - x i u ] 2 } - λ ( u 2 + w 2 - 1 ) n - - - ( 4 )
[0066] According to the least squares condition, we have ∂ L / ∂ a 0 = 0 , ∂ L / ∂ u = 0 , ∂ L / ∂ w = 0 , Use the following formula:
[0067] ∂ L ∂ a 0 = 2 Σ i = 1 n [ ( y i - a 0 ) w - x i u ] ( - w ) = 0 - - - ( 5 )
[0068] have to: a 0 = 1 w [ - uμ + wμ ]
[0069] in: μ = 1 n Σ i = 1 n x i , μ y = 1 n Σ i = 1 n y i , put a 0 Bring it into formula (4), and get:
[0070] L ′ ( μ , w ) = { Σ i = 1 n [ - u ( x i - μ x ) + w ( y i - μ y ) ] 2 } - λ ( u 2 + w 2 - 1 ) n - - - ( 6 )
[0071] make ∂ L ′ / ∂ u = 0 , ∂ L ′ / ∂ w = 0 , The following equations are obtained:
[0072] Σ i = 1 n [ u ( x i - μ x ) 2 - w ( x i - μ x ) ( y i - μ y ) ] - λun = 0
[0073] (7)
[0074] Σ i = 0 n [ - u ( x i - μ x ) ( y i - μ y ) + w ( y i - μ y ) 2 ] - λwn = 0
[0075] Written in vector form as:
[0076] M = u w = λ u w
[0077] in: M = μ xx - μ xy - μ xy μ yy , μ xx = 1 n Σ i = 1 n ( x i - μ x ) 2 , μ yy = 1 n Σ i = 1 n ( y i - μ y ) 2 , μ xy = Σ i = 1 n ( x i - μ x ) ( y i - μ y ) , λ is exactly the eigenvalue of M, it can be seen that the value of λ is
[0078] λ = 1 2 { ( μ xx + μ yy ) ± [ ( μ xx - μ xy ) 2 + 4 μ xy 2 ] 1 2 } - - - ( 8 )
[0079] Solving the system of equations (4-59), we get:
[0080] u = a 1 ( 1 + a 1 2 ) 1 2 = sin θ
[0081] (9)
[0082] w = 1 ( 1 + a 1 2 ) 1 2 = cos θ
[0083] In the above formula, a 1 = μ yy - λ μ xy is the slope of the straight line before coordinate transformation, and θ=arctana 1. Thus, the improved linear sub-pixel positioning equation y=a can be obtained 0 +a 1 x.
[0084] When the eigenvalue λ of the matrix M has two different values, a satisfactory λ value should be found to determine the optimal result, so that
[0085] f ( u , w ) = Σ i = 1 n [ - u ( x i - μ ) + w ( y i - μ y ) ] 2 - - - ( 10 )
[0086] Minimum, this formula is the first term in L'(μ, w), which represents the sum of the squares of the distance errors, which can be written as the following formula:
[0087] f ( u , w ) = n [ u , w ] · M · u w
[0088] (11)
[0089] = n [ u , w ] · λ u w = nλ
[0090] It can be seen that, for a certain number of measured points, the sum of squares of distance errors is defined by the value of λ. Assuming λ>0, the smaller the eigenvalue is, the smaller the sum of squared distance errors is. Therefore, the fit line parameters are defined with smaller eigenvalues.
[0091] The invention uses the least squares circle method to obtain the center and radius of the circle, and the calculation accuracy is within one pixel. The sub-pixel positioning is based on the one-dimensional gray moment method, and the two-dimensional sub-pixel of the circle is decomposed into two one-dimensional vectors, so as to achieve precise positioning and improve the operation speed.
[0092] The sub-pixel (dimension reduction gray moment method) positioning algorithm of the arc is as follows:
[0093] ① Calculate the center and radius of the circle by the least square method, and use the results as rough positioning.
[0094] ②If Figure 4 As shown, the squares in the figure are the pixel coordinates of the image, and the circles are the least squares circles. The pixel coordinate system is established with the center of the circle (rounded to the nearest integer) as the coordinate center, and the coordinates of the seven points in the gradient direction of each point on the edge of the circle are calculated within the range of θ=2π and rounded, that is, calculate [(r i -k)cosθ, (r i -k) sinθ], k = -3, -2, -1, 0, 1, 2, 3, r i is the distance from each edge point of the circle to the center of the circle. Obtain the values of the corresponding coordinate points in the original image, and arrange these values into a one-dimensional edge vector as follows:
[0095] I[int(x c +(r i -k)cosθ+0.5), int(y c +(r i -k)sinθ+0.5)] (12)
[0096] i=-3,-2,-1,0,1,2,3
[0097] In the formula: x c , y c Coarse positioning circle center coordinates, int is the rounding operation symbol.
[0098] ③ Calculate the edge position of the one-dimensional pixel, and set the one-dimensional edge position as k, then the corresponding two-dimensional edge position is:
[0099] [x′=x c +(r i -3+k)cosθ, y′=y c +(r i -3+k)sinθ] (13)
[0100] ④ Calculate the final characteristic parameters x', y', r' by the least squares fitting method.
[0101] (5) Size calculation
[0102] Using the initial calibration of the system, the sub-pixel precision measurement of cracks in the antenna panel is realized.
[0103] In order to have a clearer understanding of the present invention, a partial image processing process is given below for description: Figure 5 is a partial image of the crack of the intact flat-panel antenna; the circled P in the figure is a crack of the flat-panel antenna, from Figure 5 It can be seen that the ccd camera can obtain many images including cracks in one imaging, and the processing of the entire image includes a crack processing process described below, so the overall method of the present invention can be understood only by describing one crack processing process.
[0104] when Figure 5 The P circled in the middle is deformed later, such as Image 6 given, the present invention will be obtained at the beginning Figure 5 until later Image 6 , the processing includes the following whole process:
[0105] A. Initialize
[0106] 1) Build Figure 5 The corresponding relationship between the digital image pixels and the actual size in the Figure 5 The actual physical size represented by each pixel of the ccd camera (the image extraction device mentioned in the technical solution);
[0107] 2) The computer with the image acquisition card (the computing unit mentioned in the technical solution) extracts the flat crack antenna through the CCD camera Figure 5 image information, including Figure 7a;
[0108] 3) yes Figure 5 The crack edge information in the image information is extracted, such as Figure 7b;
[0109] 4) Yes Figure 5 include Figure 7b The edge points of the image information are sub-pixel processed, such as Figure 7c in a, b, c, d, e, f, g, h;
[0110] 5) Yes Figure 5 Edge points for subpixel processing include Figure 7c A, b, c, d, e, f, g, h are stored;
[0111] After the above process is completed, Figure 5 All the edge point information of the crack edge is stored, that is, the information database of the collected image information is established. The corresponding edge points of . Next, we combine this process Figure 8a , Figure 8b , Figure 8c Be explained.
[0112] B. Real-time detection
[0113] 1) The computer with the frame grabber regularly extracts the flat crack antenna through the ccd camera Figure 5 image information, including Figure 7a;
[0114] 2 pairs Figure 5 The crack edge information in the image information is extracted, such as Figure 7b;
[0115] 3) yes Figure 5 include Figure 7b The edge points of the image information are sub-pixel processed, such as Figure 7c in a, b, c, d, e, f, g, h;
[0116] 4) Compare with a, b, c, d, e, f, g, h stored in item 5) of initialization A;
[0117] 5) When it is less than the change amount, repeat item 1) in real-time detection B;
[0118] 6) When it is greater than the amount of change, that is, the newly detected graph changes locally, such as Figure 5 The p-crack edge information in Figure 7a changes, so from Figure 7a get Figure 7b , again Figure 7b If the edge points a, b, c, d, e, f, g, and h of the subpixel processing are compared with the corresponding points in storage, the difference is greater than the amount of change, and the computer will give a prompt message at this time.
[0119] Of course, in Figure 5 , Image 6 7. The processing of the crack edge information in the image information at least includes using the frequency domain method for image processing, and inversely transforming the calculation result into the spatial domain, such as denoising the image through histogram correction and edge preserving filtering algorithm. . The processing of the crack edge information in the image information further includes performing sub-pixel positioning processing on the edge points, such as a straight line edge positioning method and a circular arc positioning method. The linear edge positioning method includes the least squares linear regression method, and the original target that requires the smallest sum of squares of errors in the vertical direction is changed to require the smallest sum of squares of errors in the normal vertical direction. The arc positioning method is through the dimensionality reduction gray moment method and quadratic polynomial interpolation method.