A method for removing edge reflection spots in visual inspection of surface defects of electroplated workpieces
Through image gray value and gradient feature analysis, combined with Gaussian function and clustering loss function, the light spot interference area on the surface of the electroplated workpiece is repaired layer by layer, which solves the impact of light spot interference on defect detection in machine vision and improves detection accuracy and detection. Rate.
Patent Information
- Application Number
- CN202110120681.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-01-28
- Publication Date
- 2024-09-06
- Estimated Expiration
- 2041-01-28
AI Technical Summary
In machine vision, the light source reflection spot interference at the edge of the electroplated workpiece surface affects the accuracy of defect detection, leading to problems such as misjudgment and missed detection. The existing methods are complex and difficult to effectively eliminate the spot interference area.
Through the changes in image gray value and the gradient characteristics of adjacent background areas, the transition area and defect area of the light spot are determined. Gaussian function convolution and clustering loss functions are used to iteratively calculate the membership degree and cluster center, generate a mask image, and repair the light spot layer by layer. Interference area to achieve the elimination of light spot interference.
It effectively solves the impact of light spot interference on defect detection, improves the detection rate of workpiece surface defects, and simplifies equipment design and algorithm complexity.
Smart Images

Figure CN112927189B
Abstract
Description
Technical Field
[0001] The invention relates to the field of nondestructive detection of surface defects, and in particular to a method for removing edge reflection spots in visual detection of surface defects of electroplated workpieces. Background Art
[0002] Surface treatment technology is usually used on workpieces to prevent surface wear and improve their aesthetics and corrosion resistance. However, the surface treatment technology makes the workpiece very smooth. When the incident light is irradiated on the surface of the workpiece, almost all of the reflected light is reflected, forming a light source reflection spot interference area. When processing some workpieces, burrs are prone to occur at the edges of the contours. The use of arc-shaped transitions can not only remove burrs, but also facilitate the use of the workpiece and prevent the corners from scratching the user. However, when the light source is irradiated at the chamfered structure, reflection occurs, and it is easy to form a reflection spot. When the surface defects of the workpiece are detected by an industrial camera, the collected image contains a light spot interference area, and the interference generated by the interference area mainly includes misjudgment of the light spot, and missed detection caused by complete and partial coverage of the defect image. The influencing factor of light spot interference brings great difficulties to the subsequent identification and detection of defects.
[0003] At present, in the field of machine vision image processing, the method of eliminating the interference area of the light spot reflected by the light source often adopts a reasonable light source lighting method and designs a uniform light source, such as illumination methods at different angles, which have a strong expression of surface bumps and can enhance the surface defect information, but the light source will produce a light spot interference area at the contour of the workpiece surface. The design of the machine vision light source needs to consider the characteristics of the light source such as the illumination direction, spectrum, intensity, and uniformity. An unreasonable design affects the detection rate of defects. The method of partially eliminating the interference of the light spot reflected by the light source cannot well express the edge texture information of the light spot interference area, and the designed device is complex. Fu Fangfa et al. decomposed and compared the three channels of the RGB image of the road surface with reflections, obtained the grayscale image with the smallest grayscale value and compared it with the standard threshold, determined the reflective part, and made a difference with the filtered road surface mirror reflection image to obtain the road surface de-reflection image, but the edge texture distribution of the obtained mirror reflection image was inaccurate (Fu Fangfa, Wang Yao, Wang Jinxiang, Shi Jinjin, Xu Weizhe, Han Min. An image processing method for road de-reflection [P]. Heilongjiang Province: CN105678240B, 2019-01-18.). Guo Jianting et al. designed an image de-reflection method and device, which requires at least two images taken from different directions, one of which is a reference image, and generates an estimated image from the overlapping image area of the reference image and the image to be de-reflected, which increases the complexity of the device and algorithm (Guo Jianting, Sun Hang. Image de-reflection method and device [P]. Guangdong Province CN110930323A, 2020-03-27.). Summary of the invention
[0004] The present invention aims at the interference area of the light spot reflected by the light source at the edge of the electroplated workpiece in the image collected by machine vision. The interference area affects the subsequent image processing and the detection rate of defects. A method for eliminating the interference of the light spot reflected by the light source at the edge on the defect detection in the visual detection of surface defects of reflective workpieces is proposed. This method determines the light spot transition area and the defect area through the characteristic law of the gray value change of the image and the gray value change gradient of the adjacent background area according to the three situations of complete separation, partial coverage or complete coverage of the light spot and the defect image, repairs the light spot area, and retains the defect area, thereby achieving the purpose of eliminating the light spot interference. The technical scheme of the present invention is as follows:
[0005] Step S1, obtaining a visual image of the workpiece surface;
[0006] Step S2, extracting the gray value of the original image of the workpiece, and then convolving and weighting it with Gaussian functions of different scales to extract the illumination component in the image;
[0007] Step S3, obtain the distribution law of its illumination grayscale, establish a clustering loss function, iteratively calculate the membership degree and cluster center, and make them meet the convergence condition. Then, classify the grayscale information, roughly locate the light spot interference area, and then use the light spot interference area as the initial mask image;
[0008] Step S4, judging whether the light spot interference area partially covers the defective image or is completely separated from or completely covers the defective image based on the characteristic law of the gray value change of the image and the gray value change gradient of the adjacent background area and the size of the gradient value and the threshold;
[0009] Step S41, when the light spot interference area partially covers the defective image, the defective area is determined by the characteristic law of the gray value change of the image and the gray value change gradient of its adjacent background area, and its gray value is set to the average gray value of the background image;
[0010] Step S42: When the light spot interference area is completely separated from the defect image, proceed to step S5; when the light spot interference area completely covers the defect image, the defect is moved away from the light spot interference area by moving the workpiece, thereby achieving complete separation;
[0011] Step S5, by comparing the grayscale difference between the edge pixel point and other pixel points in the surrounding n×n area, the n×n area with a large difference value is determined as the light spot interference transition area, and a complete mask image is obtained;
[0012] Step S6: Based on the obtained complete mask image, a small neighborhood is selected with the pixel to be repaired as the center, and the pixel is repaired with the known pixel value in the neighborhood, and the repair is carried out layer by layer from the outer edge of the complete mask image to the inside until all the pixels in the area are repaired;
[0013] Step S7, obtaining an image after removing the light spot interference.
[0014] In the present invention, the above step S1 is specifically as follows:
[0015] An LED light source is used to illuminate the workpiece at a low angle, and an industrial polarization camera is used to obtain a grayscale image of the workpiece. The industrial polarization camera can reduce the reflection intensity of the light spot on the workpiece surface.
[0016] The above step S2 is specifically as follows:
[0017] The grayscale value of the workpiece is extracted from the grayscale image obtained, and convolved with Gaussian functions of different scales for weighting to obtain the grayscale image illumination component L(x, y) at any point (x, y) on the workpiece surface, that is:
[0018]
[0019] In formula (1), F(x, y) is the grayscale value distribution of the collected grayscale image; I is the scale number, I∈Z + ; G i (x,y) is the Gaussian function at different scales, And satisfy ∫∫G i (x,y)dxdy=1,σ i is the scale value; M i is the weight coefficient corresponding to the i-th scale and satisfies * is the convolution symbol.
[0020] The above step S3 is specifically as follows:
[0021] According to the illumination component L(x,y), establish the clustering loss function J FCM ,
[0022]
[0023] In formula (2), N is the number of all pixels in the illumination component L(x, y); C is the number of clusters; u ij is the membership degree of the i-th pixel to class j, m is the membership degree u ij Factor, 1≤m<∞, and is an integer. Let the clustering loss function J FCM To u ij and C j The partial derivative is 0, and the membership degree u is obtained ij and cluster center C j , iteratively calculate the membership u ij and cluster center C j , until it meets the convergence condition Stop calculation, k is the number of iterations; ε is the error threshold.
[0024] According to the cluster center C j The grayscale values in the image are classified into j+1 categories when the minimum grayscale value in the region of the grayscale image is greater than the cluster center C. j The maximum value of is determined, and the area is determined as the light spot interference area.
[0025] The above step S4 is specifically as follows:
[0026] Get the edge coordinates and grayscale value of the spot interference area, and determine a threshold T based on the gradient M(x, y) between the defect edge and the spot interference transition area. 1 ,in,
[0027]
[0028] According to the characteristic law of the gray value change of the edge and the gray value change gradient M(x, y) of the adjacent background area, the gradient M(x, y) of the edge and background area of the spot interference area and the threshold T 1 The size of the spot interference area is used to determine whether the spot interference area partially covers the defective image or is completely separated from or completely covers the defective image.
[0029] The above step S41 is specifically as follows:
[0030] When the gradient M(x,y) between the edge of the light spot interference area and the background area is greater than or equal to the threshold T 1 When the light spot interference area partially covers the defect image, the gray value of the defect image is set to the average gray value of the background image.
[0031] The above step S42 is specifically as follows:
[0032] When the gradient M(x,y) between the edge of the light spot interference area and the background area is less than the threshold T 1 When the light spot interference area completely covers the defect image or is completely separated from the defect image, the light spot interference area is completely separated from the defect image by moving the workpiece to move the defect away from the light spot interference area.
[0033] The step S5 is specifically:
[0034] According to the background area of the normal illumination area, in the n×n pixel area, n≥3 and is an odd number, (e, f) is the center of the n×n pixel area, and the deviation H, V, D between the grayscale value F(e, f) of the center point (e, f) and the grayscale values of other pixels in the n×n area 1 , D 2 , a threshold T can be determined 2 , where the deviation H, V, D 1 , D 2 for:
[0035]
[0036] According to the image obtained in step S41 or step S42, the deviations H, V, D between the gray values of all edge pixels in the n×n area and other pixels are calculated. 1 , D 2 , when H, V, D 1 , D 2 There is a value greater than or equal to the threshold T 2 When , the area is the light spot interference transition area, and its gray value is set to 255, which is the initial mask image to be repaired; then the edge pixel coordinates and gray value of the initial mask image are obtained, and the deviations H, V, and D are recalculated. 1 , D 2 , until the deviation H, V, D 1 , D 2 are all less than the threshold T 2 When , the calculation is stopped and finally a complete mask image is obtained.
[0037] The step S6 is specifically:
[0038] According to the complete mask image, a small neighborhood B is selected with the pixel p to be repaired as the center. ε (p), and use the grayscale value of the known pixel q in the neighborhood to repair the pixel. The repair value I(p) for each pixel p to be repaired is:
[0039]
[0040] In formula (8), the weight function Q p From point p to the neighborhood B ε (p) Distance to edge, Q q From point q to neighborhood B ε (p) is the distance to the edge; F(q) is the grayscale value at point q; M(q) is the brightness gradient value at point q.
[0041] First, all the pixels at the outer edge of the transition area of the light spot interference are repaired, and then they are advanced inward layer by layer until all the pixels in the area are repaired to obtain the repaired image, thus finally achieving the purpose of eliminating the light spot interference.
[0042] The beneficial effect of the present invention is that: for the image collected by machine vision, the edge of the electroplated workpiece contains a light spot interference area reflected by the light source, and a method for eliminating the light spot interference is proposed in the present invention. The interference caused by the light spot reflected by the light source to the defect detection mainly includes the misjudgment of the light spot, and the missed detection caused by the light spot completely or partially covering the defect image. The present invention can effectively solve the influence caused by these three interferences and improve the detection rate of the surface defect detection of the workpiece. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] Figure 1 It is a flow chart of the present invention;
[0044] Figure 2 It is a hardware system diagram of the present invention;
[0045] Figure 3 A photo of an electroplated part in an embodiment of the present invention;
[0046] Figure 4 The schematic diagram of the principle of extracting illumination components of the present invention is as follows;
[0047] Figure 5 This is an embodiment of the reflected light spot removal of the present invention; wherein (a) is a grayscale image with a light spot interference area and a defect area, (b) is an extracted illumination component image, (c) is a determined complete mask image, and (d) is a result image after removing the light spot interference. DETAILED DESCRIPTION
[0048] The technical solution of the present invention is further described below in conjunction with the accompanying drawings and embodiments. The detection object is an automobile electroplated decorative part. It should be noted that the present invention can also be applied through other equivalent implementations. The method for removing reflected light spots in the visual detection of surface defects of electroplated workpieces described in this implementation is Figure 1 The flow chart of the present invention comprises the following steps:
[0049] S1. Obtaining a visual image of the workpiece surface;
[0050] S2, extracting the gray value of the original image of the workpiece to obtain a gray image, and then convolving and weighting it with Gaussian functions of different scales to extract the illumination component in the image;
[0051] S3, obtain the distribution law of its illumination grayscale, establish a clustering loss function, iteratively calculate the membership degree and cluster center, and make them meet the convergence condition; then classify the grayscale information, roughly locate the light spot interference area, and then use the light spot interference area as the initial mask image;
[0052] S4, judging whether the light spot interference area partially covers the defective image or is completely separated from or completely covers the defective image based on the characteristic law of the gray value change of the image and the gray value change gradient of the adjacent background area according to the gradient value and the threshold;
[0053] S4.1. If the light spot interference area partially covers the defective image, the defective area is determined by the characteristic law of the gray value change of the image and the gray value change gradient of the adjacent background area, and its gray value is set to the average gray value of the background image;
[0054] S4.2, when the light spot interference area is completely separated from the defective image, proceed to step S5;
[0055] If the light spot interference area completely covers the defect image, the defect image can be moved away from the light spot interference area by moving the workpiece to achieve complete separation;
[0056] S5. By comparing the grayscale difference between the edge pixel point and other pixel points in the surrounding n×n area, the n×n pixel area with a large difference value is determined as the light spot interference transition area to obtain a complete mask image, where n≥3 and is an odd number;
[0057] S6, based on the obtained complete mask image, a small neighborhood is selected with the pixel to be repaired as the center, and the pixel is repaired with the known pixel value in the neighborhood, and the process is advanced layer by layer from the outer edge of the complete mask image to the inside until all the pixels in the area are repaired;
[0058] S7, obtaining an image after removing the light spot interference.
[0059] The above step S1 is specifically as follows:
[0060] An LED light source is used to illuminate the workpiece at a low angle, and an industrial polarization camera is used to obtain a grayscale image of the workpiece. The industrial polarization camera can reduce the reflection intensity of the light spot on the workpiece surface.
[0061] The above step S2 is specifically as follows:
[0062] The grayscale value of the workpiece is extracted from the grayscale image obtained, and convolved with Gaussian functions of different scales for weighting to obtain the grayscale image illumination component L(x, y) at any point (x, y) on the workpiece surface, that is:
[0063]
[0064] In formula (1), F(x, y) is the grayscale value distribution of the collected grayscale image; I is the scale number, I∈Z + ; G i (x,y) is the Gaussian function at different scales, And satisfy ∫∫G i (x,y)dxdy=1,σ i is the scale value; M i is the weight coefficient corresponding to the i-th scale and satisfies * is the convolution symbol.
[0065] The above step S3 is specifically as follows:
[0066] According to the illumination component L(x,y), establish the clustering loss function J FCM ,
[0067]
[0068] In formula (2), N is the number of all pixels in the illumination component L(x, y); C is the number of clusters; u ij is the membership degree of the i-th pixel to class j, m is the membership degree u ij Factor, 1≤m<∞, and is an integer. Let the clustering loss function J FCM To u ij and C j The partial derivative is 0, and the membership degree u is obtained ij and cluster center C j , iteratively calculate the membership u ij and cluster center C j , until it meets the convergence condition Stop calculation, k is the number of iterations; ε is the error threshold.
[0069] According to the cluster center C j The grayscale values in the image are classified into j+1 categories when the minimum grayscale value in the region of the grayscale image is greater than the cluster center C. j The maximum value of is determined, and the area is determined as the light spot interference area.
[0070] The above step S4 is specifically as follows:
[0071] Get the edge coordinates and grayscale value of the spot interference area, and determine a threshold T based on the gradient M(x, y) between the defect edge and the spot interference transition area. 1 ,in,
[0072]
[0073] According to the characteristic law of the gray value change of the edge and the gray value change gradient M(x, y) of the adjacent background area, the gradient M(x, y) of the edge and background area of the spot interference area and the threshold T 1 The size of the spot interference area is used to determine whether the spot interference area partially covers the defective image or is completely separated from or completely covers the defective image.
[0074] The above step S41 is specifically as follows:
[0075] When the gradient M(x,y) between the edge of the light spot interference area and the background area is greater than or equal to the threshold T 1When the light spot interference area partially covers the defect image, the gray value of the defect image is set to the average gray value of the background image.
[0076] The above step S42 is specifically as follows:
[0077] When the gradient M(x,y) between the edge of the light spot interference area and the background area is less than the threshold T 1 When the light spot interference area completely covers the defect image or is completely separated from the defect image, the light spot interference area is completely separated from the defect image by moving the workpiece to move the defect away from the light spot interference area.
[0078] The step S5 is specifically:
[0079] According to the background area of the normal illumination area, in the n×n pixel area, n≥3 and is an odd number, (e, f) is the center of the n×n pixel area, and the deviation H, V, D between the grayscale value F(e, f) of the center point (e, f) and the grayscale values of other pixels in the n×n area 1 , D 2 , a threshold T can be determined 2 , where the deviation H, V, D 1 , D 2 for:
[0080]
[0081] According to the image obtained in step S41 or step S42, the deviations H, V, D between the gray values of all edge pixels in the n×n area and other pixels are calculated. 1 , D 2 , when H, V, D 1 , D 2 There is a value greater than or equal to the threshold T 2 When , the area is the light spot interference transition area, and its gray value is set to 255, which is the initial mask image to be repaired; then the edge pixel coordinates and gray value of the initial mask image are obtained, and the deviation H, v, D are recalculated. 1 , D 2 , until the deviation H,v,D 1 , D 2 are all less than the threshold T 2 When , the calculation is stopped and finally a complete mask image is obtained.
[0082] The step S6 is specifically:
[0083] According to the complete mask image, a small neighborhood B is selected with the pixel p to be repaired as the center. ε(p), and use the grayscale value of the known pixel q in the neighborhood to repair the pixel. The repair value I(p) for each pixel p to be repaired is:
[0084]
[0085] In formula (8), the weight function Q p From point p to the neighborhood B ε (p) Distance to edge, Q q From point q to neighborhood B ε (p) is the distance to the edge; F(q) is the grayscale value at point q; M(q) is the brightness gradient value at point q.
[0086] First, all the pixels at the outer edge of the transition area of the light spot interference are repaired, and then they are advanced inward layer by layer until all the pixels in the area are repaired to obtain the repaired image, thus finally achieving the purpose of eliminating the light spot interference.
[0087] like Figure 2-3 As shown, a polarization camera is used to weaken the reflective intensity of the light spot on the workpiece surface. The LED strip light source illuminates the test workpiece at a low angle, and the image is collected by the MER-502-79U3M POL polarization camera of Daheng Image. Figure 5 (a) is a grayscale image with spot interference area and defect area collected by the visual inspection system for surface defects of electroplated decorative parts. The grayscale value of the workpiece is extracted based on the acquired grayscale image, and convolved with Gaussian functions of different scales for weighting to obtain the grayscale image illumination component L(x, y) at any point (x, y) on the workpiece surface. The calculation method is shown in formula (1). In the embodiment of the present invention, I=3; σ adopts three scales of 50, 125 and 250 respectively; the weight coefficient Figure 4 The schematic diagram of the method for extracting illumination components is shown in FIG. Figure 5 (b) is the illumination component image in an embodiment of the present invention.
[0088] According to the illumination component L(x,y), establish the clustering loss function J FCM , loss function J FCM See formula (2). In the embodiment of the present invention, C = 2, m = 2. Let the clustering loss function J FCM To u ij and C j The partial derivative is 0, and the membership degree u is obtained ij and cluster center C j , iteratively calculate the membership u ij and cluster center C j , until it meets the convergence condition Stop calculation, k is the number of iteration steps; ε is the error threshold, in the embodiment of the present invention, ε=0.000001.
[0089] According to the cluster center C 1 , C 2 The grayscale values in the image are classified into three categories. When the minimum grayscale value in a certain area of the grayscale image is greater than the cluster center C 1 , C 2 The maximum value of C is determined as the light spot interference area. In the embodiment of the present invention, C 1 and C 2 The maximum value is 129.
[0090] Get the edge coordinates and grayscale value of the spot interference area, and determine a threshold T based on the gradient M(x,y) between the defect edge and the spot interference transition area. 1 , the gradient M(x, y) is shown in formula (3). In the embodiment of the present invention, T 1 = 8. Based on the characteristic law of the gray value change of the edge and the gray value change gradient M(x, y) of the adjacent background area, according to the gradient M(x, y) of the edge and background area of the spot interference area and the threshold T 1 The size of the spot interference area is used to determine whether the spot interference area partially covers the defective image or is completely separated from or completely covers the defective image.
[0091] When the gradient M(x,y) between the edge of the spot interference area and the background area is greater than or equal to the threshold T 1 When the light spot interference area partially covers the defect image, the gray value of the defect image is set to the average gray value of the background image.
[0092] When the gradient M(x,y) between the edge of the spot interference area and the background area is less than the threshold T 1 When the light spot interference area completely covers the defect image or is completely separated from the defect image, the light spot interference area is completely separated from the defect image by moving the workpiece to move the defect away from the light spot interference area.
[0093] According to the background area of the normal lighting area, in the 3×3 pixel area, (e, f) is the center of the 3×3 pixel area, and the deviation H, V, D between the grayscale value F(e, f) of the center point (e, f) and the grayscale values of other pixels in the 3×3 area 1 , D 2 , a threshold T can be determined 2 In the embodiment of the present invention, T 2 =4, where the deviations H, V, and D 1 , D 2 for:
[0094]
[0095]
[0096] H, V, and D can be obtained from formulas (9) to (12) respectively. 1 , D 2 , when H, V, D 1 , D 2 As long as there is a value greater than the threshold T 2 When , the area of the 3×3 window is determined as the spot interference transition area, and the grayscale of all pixels in the area is set to 255. If all of them are less than the threshold T 2 When the illumination is normal, it is determined as an area with normal illumination. After all edge information is detected, edge algorithm detection is performed to obtain its contour information and detect it until H, V, D 1 , D 2 The values are all less than the threshold T 2 The final image mask is completed. Figure 5 (c) is the final complete mask image determined in the embodiment of the present invention.
[0097] Finally, based on the complete mask image, a small neighborhood B is selected with the pixel p to be repaired as the center. ε (p), in the embodiment of the present invention, the neighborhood B ε (p) A 5×5 pixel area is selected, and the pixel is repaired with the grayscale value of the known pixel q in the 5×5 pixel area, wherein the repair value I(p) of each pixel p to be repaired is as shown in formula (8).
[0098] The pixels on the edge are repaired in a small area outside the mask image, and then the process is advanced inward layer by layer until all pixels in the area are repaired to obtain the repaired image, which can ultimately achieve the purpose of eliminating light spot interference.
[0099] The invention can remove the light spot interference area in the image and can well repair the area. Figure 5 (d) as shown.
[0100] The detailed description in the embodiments is only a specific demonstration of the feasibility of the present invention and is not intended to limit the protection scope of the present invention. Any equivalent implementation or modification that does not deviate from the technical spirit of the present invention should be included in the protection scope of the present invention.
[0101] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "illustrative embodiments", "examples", "specific examples", or "some examples" means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner.
[0102] Although the embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present invention, and that the scope of the present invention is defined by the claims and their equivalents.
Claims
1. A method for removing edge reflection spots in visual inspection of surface defects of electroplated workpieces, characterized in that: The following steps are involved: S1. Obtaining a visual image of the workpiece surface; S2, extracting the gray value of the original image of the workpiece to obtain a gray image, and then convolving and weighting it with Gaussian functions of different scales to extract the illumination component in the image; S3, obtain the distribution law of its illumination grayscale, establish a clustering loss function, iteratively calculate the membership degree and cluster center, and make them meet the convergence condition; then classify the grayscale information, roughly locate the light spot interference area, and then use the light spot interference area as the initial mask image; S4, judging whether the light spot interference area partially covers the defective image or is completely separated from or completely covers the defective image based on the characteristic law of the gray value change of the image and the gray value change gradient of the adjacent background area according to the gradient value and the threshold; S4.
1. If the light spot interference area partially covers the defective image, the defective area is determined by the characteristic law of the gray value change of the image and the gray value change gradient of the adjacent background area, and its gray value is set to the average gray value of the background image; S4.2, when the light spot interference area is completely separated from the defective image, proceed to step S5; If the light spot interference area completely covers the defect image, the defect image can be moved away from the light spot interference area by moving the workpiece to achieve complete separation; S5. By comparing the grayscale difference between the edge pixel point and other pixel points in the surrounding n×n area, the n×n pixel area with a large difference value is determined as the light spot interference transition area to obtain a complete mask image, where n≥3 and is an odd number; S6, based on the obtained complete mask image, a small neighborhood is selected with the pixel to be repaired as the center, and the pixel is repaired with the known pixel value in the neighborhood, and the process is advanced layer by layer from the outer edge of the complete mask image to the inside until all the pixels in the area are repaired; S7, obtaining an image after removing the light spot interference.
2. The method for removing edge reflection spots in visual inspection of surface defects of electroplated workpieces according to claim 1 is characterized in that: The step S1 comprises: An LED light source is used to illuminate the workpiece at a low angle, and an industrial polarization camera is used to obtain a grayscale image of the workpiece. The industrial polarization camera can reduce the reflection intensity of the light spot on the workpiece surface.
3. The method for removing edge reflection spots in visual inspection of surface defects of electroplated workpieces according to claim 1, characterized in that: The step S2 comprises: The grayscale value is extracted from the acquired grayscale image and convolved with Gaussian functions of different scales to obtain the illumination component L(x, y) of the grayscale image at any point (x, y) on the workpiece surface, that is: Among them, F(x, y) is the gray value distribution of the collected gray image; I is the scale number, I∈Z + ; G i (x, y) is a Gaussian function at different scales, And satisfy ∫∫G i (x, y)dxdy=1,σ i is the scale value; M i is the weight coefficient corresponding to the i-th scale and satisfies * is the convolution symbol.
4. The method for removing edge reflection spots in visual inspection of surface defects of electroplated workpieces according to claim 3 is characterized in that: The step S3 comprises: According to the illumination component L(x, y), the clustering loss function J is established FCM , Where N is the number of all pixels in the illumination component L(x, y); C is the number of clusters; u ij is the membership degree of the i-th pixel to class j, m is the membership degree u ij Factor, 1≤m<∞, m is an integer; let the clustering loss function J FCM To u ij and C j The partial derivative is 0, and the membership degree u is obtained ij and cluster center C j , iteratively calculate the membership u ij and cluster center C j , until it meets the convergence condition Stop calculation, k is the number of iterations; ε is the error threshold; According to the cluster center C j The grayscale values in the image are classified into j+1 categories when the minimum grayscale value in the region of the grayscale image is greater than the cluster center C. j The maximum value of is determined, and the area is determined as the light spot interference area.
5. The method for removing edge reflection spots in visual inspection of electroplated workpiece surface defects according to claim 4, characterized in that: The step S4 comprises: Obtain the edge coordinates and grayscale value of the spot interference area, and determine a threshold T1 based on the gradient M(x, y) between the edge of the defect image and the spot interference transition area, where: Through the characteristic law of the gray value change of the edge and the gray value change gradient M(x, y) of the adjacent background area, and according to the gradient M(x, y) between the edge of the light spot interference area and the background area and the size of the threshold T1, it is judged whether the light spot interference area partially covers the defective image or is completely separated from or completely covers the defective image.
6. The method for removing edge reflection spots in visual inspection of surface defects of electroplated workpieces according to claim 5, characterized in that: The step S4.1 comprises: When the gradient M(x, y) between the edge of the light spot interference area and the background area is greater than or equal to the threshold T1, it is determined that the light spot interference area partially covers the defective image, and the grayscale value of the defective image is set to the average grayscale value of the background image.
7. The method for removing edge reflection spots in visual inspection of electroplated workpiece surface defects according to claim 5, characterized in that: The step S4.2 comprises: When the gradient M(x, y) between the edge of the light spot interference area and the background area is less than the threshold T1, it is determined that the light spot interference area completely covers the defective image or is completely separated from the defective image. When the light spot interference area completely covers the defective image, the defective image is moved away from the light spot interference area by moving the workpiece, so that the light spot interference area and the defective image are completely separated.
8. The method for removing edge reflection spots in visual inspection of electroplated workpiece surface defects according to claim 1, characterized in that: The step S5 comprises: According to the background area of the normal illumination area, in the n×n pixel area, n≥3 and is an odd number, (e, f) is the center of the n×n pixel area, and the deviation between the gray value F(e, f) of the center point (e, f) and the gray value of other pixels in the n×n area is H, V, D1, D2, and a threshold T2 is determined, where the deviation H, V, D1, D2 is: According to the image obtained in step S4.1 or step S4.2, calculate the deviations H, V, D1, D2 between the grayscale values of all edge pixels in the n×n area and other pixels. When one of H, V, D1, D2 is greater than or equal to the threshold T2, the area is a light spot interference transition area, and its grayscale value is set to 255, which is the repaired initial mask image. Then obtain the edge pixel coordinates and grayscale values of the initial mask image, recalculate the deviations H, V, D1, D2, and stop calculating until the deviations H, V, D1, D2 are all less than the threshold T2, and finally obtain a complete mask image.
9. The method for removing edge reflection spots in visual inspection of surface defects of electroplated workpieces according to claim 1, characterized in that: The step S6 further comprises: According to the complete mask image, a small neighborhood B is selected with the pixel p to be repaired as the center. ε (p), and use the grayscale value of the known pixel q in the neighborhood to repair the pixel. The repair value I(p) for each pixel p to be repaired is: Among them, the weight function Q p From point p to the neighborhood B ε (p) Distance to edge, Q q From point q to neighborhood B ε (p) is the distance to the edge; F(q) is the grayscale value of point q; M(q) is the brightness gradient value of point q; first repair all the pixels at the outer edge of the transition area of the light spot interference, and then advance inward layer by layer until all the pixels in the area are repaired to obtain the repaired image, and finally achieve the purpose of eliminating the light spot interference.
Citation Information
Patent Citations
An image processing method for road de-reflection
CN105678240B
Image de-reflection method and device
CN110930323A
Method and equipment for monitoring defects of target object
CN102842131A
Magneto-optic imaging defect detection method based on automatic search of binary threshold
CN105427324A
Optical measuring system and method for detecting surface roughness and surface damage
CN108332689A
