Disclosure of Invention
The invention provides a quality detection method for a surface coating of a flexible circuit board, which aims to solve the existing problems.
The invention discloses a quality detection method for a surface coating of a flexible circuit board, which adopts the following technical scheme:
the embodiment of the invention provides a method for detecting the quality of a surface coating of a flexible circuit board, which comprises the following steps:
acquiring a circuit board gray level image and a binarized circuit board gray level image;
obtaining a circuit board gray level image without a circuit area according to the circuit board gray level image and the binarized circuit board gray level image, and carrying out gray level stretching on gray level values of pixel points in the circuit board gray level image without the circuit area to obtain new gray level values after gray level stretching;
according to the new gray value after gray stretching and the gray value of the pixel point in the circuit board gray image of the removed circuit area, the stretching rate of the pixel point in the circuit board gray image of the removed circuit area;
obtaining a low gray scale region according to the gray scale value of the pixel point with the stretching ratio closest to 0 and the new gray scale value after gray scale stretching, obtaining the gradient value of the boundary pixel point of the low gray scale region, and obtaining a high-low gradient region in the low gray scale region according to the gradient value of the boundary pixel point in the low gray scale region;
presetting a base number in logarithmic transformation, and constructing a logarithmic transformation function according to the stretching ratio of pixel points in the gray level image of the circuit board without the circuit area, a new gray level value after gray level stretching and the base number in logarithmic transformation;
acquiring the number ratio of the pixels in the high and low gradient areas in the low gray areas under the results of different logarithmic transformation functions, constructing a two-dimensional curve with the gradient ratio changing along with the base number according to the number ratio of the pixels in the high and low gradient areas and different base numbers, wherein the gradient ratio is the number ratio of the pixels in the high and low gradient areas in the low gray areas, and taking the maximum value in the two-dimensional curve as the optimal base number;
and carrying out image enhancement on the stretched circuit board gray level image with the circuit area removed according to the logarithmic transformation function determined by the optimal base number, obtaining an enhanced image, and identifying defects on the enhanced image by utilizing edge detection.
Further, the circuit board gray level image of which the circuit area is removed is obtained according to the circuit board gray level image and the binarized circuit board gray level image, and the method comprises the following specific steps:
and subtracting the circuit board gray level image from the binarized circuit board gray level image, and removing the circuit area to obtain the circuit board gray level image with the circuit area removed.
Further, the step of performing gray stretching on the gray value of the pixel point in the circuit board gray image with the circuit area removed to obtain a new gray value after gray stretching comprises the following specific steps:
in the method, in the process of the invention,new gray value after gray stretching of pixel point in gray image of circuit board with circuit area removed is represented,Gray value of pixel point in gray image of circuit board for representing removed circuit area, +.>Representing coordinates of the corresponding pixel points; b represents the maximum gray value of the pixel point in the gray image of the circuit board without the circuit area; a represents the minimum gray value of the pixel point in the gray image of the circuit board except the circuit area.
Further, the step of removing the stretching ratio of the pixel points in the circuit board gray image of the circuit area according to the new gray value after gray stretching and the gray value of the pixel points in the circuit board gray image of the circuit area comprises the following specific steps:
in the method, in the process of the invention,new gray value after gray stretching of pixel point in gray image of circuit board with circuit area removed is represented,Gray value of pixel point in gray image of circuit board for representing removed circuit area, +.>Representing coordinates of the corresponding pixel points;Stretching ratio of pixel point in gray scale image of circuit board for removing circuit area>The representation takes absolute value.
Further, the method for obtaining the low gray scale region according to the pixel gray scale value closest to 0 in the stretching ratio and the new gray scale value after gray scale stretching comprises the following specific steps:
firstly, the gray value of the pixel point with the stretching rate nearest to 0 in the gray image of the circuit board with the circuit area removed is obtained and is recorded as,Representing the pixel point coordinates of the nearest 0 of the stretching ratio;
in the method, in the process of the invention,gray value of pixel point with nearest 0 of stretching ratio in gray image of circuit board with circuit area removed>Representing the pixel point coordinates of the nearest 0 of the stretching ratio;Representing a new gray value after pixel point gray stretching in the circuit board gray image of the removed circuit area; the region formed by the gray value points satisfying the above expression is regarded as a low gray region, otherwise, a high gray region.
Further, the step of obtaining the high-low gradient region in the low gray region according to the gradient value of the boundary pixel point in the low gray region comprises the following specific steps:
in the method, in the process of the invention,representing the +.>Gradient values of the individual boundary pixels, +.>Represents the total number, +.>The average gradient value of boundary pixels in the low gray scale region is represented, the region composed of pixels higher than the tie gradient value is marked as a high gradient region, and the region composed of pixels lower than the average gradient value is marked as a low gradient region.
Further, the construction of the logarithmic transformation function according to the stretching ratio of the pixel points in the gray level image of the circuit board without the circuit area, the new gray level value after gray level stretching and the base number during logarithmic transformation comprises the following specific steps:
in the method, in the process of the invention,new gray values representing pixel points after logarithmic transformation,/and method for generating the same>Coordinates of corresponding pixel points;Representing new gray values after pixel gray stretching in the line board gray image with the line area removed,representing coordinates of the corresponding pixel points;Representing the base number when performing a logarithmic transformation;Representing the stretching ratio of pixel points in the gray level image of the circuit board with the circuit area removed;Representing natural constants.
The technical scheme of the invention has the beneficial effects that: the method can amplify the characteristics of the region to be detected by using image processing means such as image cutting, stretching and the like as far as possible, reduces the influence of similar regions on the detection result, and improves the detection efficiency and accuracy after the image is processed.
Detailed Description
In order to further describe the technical means and effects adopted by the invention to achieve the preset aim, the following detailed description is given below of a flexible circuit board surface coating quality detection method according to the invention, which is specific to the implementation, structure, characteristics and effects thereof, with reference to the accompanying drawings and the preferred embodiment. In the following description, different "one embodiment" or "another embodiment" means that the embodiments are not necessarily the same. Furthermore, the particular features, structures, or characteristics of one or more embodiments may be combined in any suitable manner.
Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs.
The invention provides a specific scheme of a flexible circuit board surface coating quality detection method, which is specifically described below with reference to the accompanying drawings.
Referring to fig. 1, a flowchart of steps of a method for detecting quality of a plating layer on a surface of a flexible circuit board according to an embodiment of the invention is shown, the method includes the following steps:
and S001, acquiring a surface image of the flexible circuit board and preprocessing.
Specifically, an industrial camera is used to collect an image of the surface of the flexible circuit board to be detected, the image of the surface of the flexible circuit board is subjected to graying to obtain a gray image of the circuit board, and Gaussian filtering denoising treatment is performed on the gray image of the circuit board, and it is to be noted that the model of the industrial camera in the embodiment is not particularly limited.
And obtaining the gray level image of the circuit board by carrying out graying and Gaussian filtering on the surface image of the flexible circuit board.
And S002, removing the circuit area in the gray scale image on the surface of the circuit board.
It should be noted that the scratched area of the circuit board exists in the non-circuit area basically, but the gray scale characteristics of the circuit area are obvious and are easy to interfere with the subsequent defect judgment, so that the circuit area needs to be removed. After the pure non-line area is obtained, the gray value distribution is relatively concentrated, so that the contrast of the defect area is not obvious and is unfavorable for subsequent identification, and the gray value stretching is needed to be carried out on the image so that the image is uniformly distributed in the gray interval. Because the gray value of the defect area is lower than that of the normal area, in order to further enhance the contrast of the defect area, the stretched image is subjected to logarithmic transformation, so that the characteristics of the low gray area are more obvious, and a necessary environment is provided for subsequent defect detection.
It should be further noted that the scratched area of the circuit board mainly exists in the non-circuit area, so in order to make the circuit area not affect the detection result, some technical means are needed to cut the circuit area. Through the observation of the circuit board image and the combination of the prior characteristics, the circuit area has clear gray scale characteristics and the gray scale characteristics of the non-circuit area are greatly different, so that the circuit area can be easily cut by the existing Otsu algorithm.
Specifically, the circuit area can be removed by subtracting the circuit board gray level image from the binarized circuit board gray level image obtained by using the Otsu threshold segmentation algorithm, so as to obtain the circuit board gray level image with the circuit area removed.
It should be noted that, the circuit board gray-scale image and the binarized circuit board gray-scale image are subtracted, and the corresponding positions on the image are directly subtracted and removed instead of subtracting the gray-scale values of the corresponding positions, so as to remove the circuit area.
And performing Otsu threshold segmentation and subtraction on the circuit board gray level image to obtain the circuit board gray level image with the circuit area removed.
And step S003, carrying out gray stretching and calculating the stretching rate on the gray image of the circuit board with the circuit area removed.
It should be noted that, because the image after the circuit is removed has a relatively concentrated gray value distribution due to its own characteristics, the scratch defect is hardly reflected from the image, and in order to make the defect characteristics have some prominent differences from the normal area, the gray value of the image is subjected to gray stretching so as to uniformly distribute in the [0,255] gray interval.
Specifically, gray stretching is performed according to the maximum and minimum gray values of pixel points in the gray image of the circuit board with the circuit area removed to obtain a new gray value after gray stretching, and the specific calculation method is as follows:
in the method, in the process of the invention,new gray value after gray stretching of pixel point in gray image of circuit board with circuit area removed is represented,Gray value of pixel point in gray image of circuit board for representing removed circuit area, +.>Representing coordinates of the corresponding pixel points; b represents the maximum gray value of the pixel point in the gray image of the circuit board without the circuit area; a represents the minimum gray value of the pixel point in the gray image of the circuit board except the circuit area.
Further, according to the new gray value of the line board gray image with the line area removed after the pixel points are stretched and the gray value of the line board gray image with the line area removed, the stretching rate of the pixel points in the line board gray image with the line area removed is calculated as follows:
in the method, in the process of the invention,new gray value after gray stretching of pixel point in gray image of circuit board with circuit area removed is represented,Representing coordinates of the corresponding pixel points;Representing gray values of pixel points in the gray image of the circuit board without the circuit area;The stretching ratio of the pixel points in the gray level image of the circuit board with the circuit area removed is shown, and the stretching ratio is larger as the stretching ratio is larger, so that the stretching degree is larger;Representation pair->Taking the absolute value.
Further, the circuit board gray scale image of the removed circuit area can be obtained by carrying out (1) gray scale stretching on all the pixel points in the circuit board gray scale image of the removed circuit area, and the stretching rate of all the pixel points in the circuit board gray scale image of the removed circuit area can be obtained by carrying out (2) stretching rate calculation on all the pixel points in the circuit board gray scale image of the removed circuit area.
The new gray value after the gray stretching of the pixel point in the circuit board gray image of the circuit area is obtained by calculating the gray value of the pixel point in the circuit board gray image of the circuit area, and the stretching rate of the pixel point in the circuit board gray image of the circuit area is obtained.
And S004, carrying out region division on the circuit board gray level image with the circuit regions removed after gray level stretching, and calculating the high-low gradient regions in the low gray level regions.
Although the image having a certain defect contrast is obtained by stretching the whole image in the previous step, since the gray-scale value distribution of the original image is too concentrated, the gray-scale stretching performed using the original gray-scale value as a parameter makes the defective region more noticeable, but also causes the occurrence of an excessive disturbance region due to an excessive number of gray-scale values similar to the defective region. Therefore, in order to further distinguish the gray scale characteristics of the defective region from the similar regions, the gray scale characteristics of the detection region are quantized, then the gray scale value of the low gray scale region is reduced in combination with the logarithmic transformation, and the gray scale value of the high gray scale region is increased, so that the defective region is further highlighted.
It should be further noted that, because the defect area is mainly distributed in the low gray scale area of the stretched image, but because the gray scale value of the original image is too concentrated, the defect area cannot be accurately identified only by the gray scale characteristics of the stretched image, and therefore, the low gray scale area needs to be further processed.
Specifically, a low gray scale region is obtained according to a pixel gray scale value closest to 0 in the stretching ratio and a new gray scale value after the pixel gray scale stretching of the pixel point in the circuit board gray scale image of the removed circuit region, and the specific method is as follows:
firstly, the gray value of the pixel point with the stretching rate nearest to 0 in the gray image of the circuit board with the circuit area removed is obtained and is recorded as,The pixel coordinates of the nearest 0 stretch ratio are shown.
In the method, in the process of the invention,gray value of pixel point with nearest 0 of stretching ratio in gray image of circuit board with circuit area removed>Representing the pixel point coordinates of the nearest 0 of the stretching ratio;New gray value after gray stretching of pixel point in gray image of circuit board with circuit area removed is represented,Representing coordinates of the corresponding pixel points; the region formed by the gray value points satisfying the above formula (3) is regarded as a low gray region, otherwise, a high gray region.
It should be noted that, after global gray-scale stretching, some normal regions may be caused to have gradients due to the surrounding gray-scale variations. The defect area has a remarkable gradient characteristic, because the gradient generated after stretching can cause a certain influence when the gradient is used for defect judgment. It is therefore necessary to determine the high-low gradient region in the low gray region.
Specifically, a sobel algorithm is used to obtain gradient values of boundary pixel points, and a high-low gradient region in a low gray region is obtained according to the gradient values of the boundary pixel points in the low gray region. The specific calculation method is as follows:
in the method, in the process of the invention,representing the +.>Gradient values of the individual boundary pixels, +.>Represents the total number, +.>Representing the average gradient value of the boundary pixel points in the low gray scale region. The regions of pixels above the tie gradient value are marked as high gradient regions and the regions of pixels below the average gradient value are marked as low gradient regions.
Thus, a high-low gradient region in the low gray scale region is obtained.
And S005, carrying out logarithmic transformation on the circuit board gray level image with the circuit area removed after gray level stretching to determine the optimal base number, and further obtaining the gray level image with obvious defect area contrast.
When the image contrast is enhanced by logarithmic transformation, the difference in the base number greatly affects the result after the processing, and the larger the base number is, the stronger the emphasis on the low-gradation region is, and the stronger the compression on the high-gradation portion is. However, too small a base number results in poor results after processing, and defective areas cannot be well highlighted, and too large a base number results in some normal areas being integrated with defective areas due to too much suppression, so that it is necessary to find a suitable base number.
Specifically, a logarithmic transformation function is constructed according to the stretching ratio of pixel points in the gray level image of the circuit board without the circuit area, a new gray level value after gray level stretching and a base number in logarithmic transformation.
Each numerical value is subjected to logarithmic transformation in the [0,255] base range, and the specific method of logarithmic transformation is as follows:
in the method, in the process of the invention,new gray values representing pixel points after logarithmic transformation,/and method for generating the same>Coordinates of corresponding pixel points;Representing new gray values after pixel gray stretching in the line board gray image with the line area removed,representing coordinates of the corresponding pixel points;Represents the base of the logarithmic transformation, +.>The value of (2) is [0,255]]The base number is within the range;Representing the stretching ratio of pixel points in the gray level image of the circuit board with the circuit area removed;Representing natural constants.
The new gray value of the pixel is calculated according to the gray value after stretching,the larger the value of (2), the stronger the emphasis on the low gray area, the stronger the compression on the high gray part, and +.>Is to normalize the pixel point and prevent the updated gray value from exceeding [0,255]]Interval.
Further, the number of the pixels in the high gradient area and the number of the pixels in the low gradient area under the logarithmic transformation result of different bases are compared, the ratio is Q, and the specific steps are as follows:
in the method, in the process of the invention,representing the number of pixels in the high gradient region, +.>Representing the number of pixels in the low gradient region, +.>And the ratio of the number of the pixels in the high gradient region to the number of the pixels in the low gradient region is represented.
When the base is too low, the low gray scale region is too dark, which results in too few gradient regions, and as the base increases, the high gradient region increases at a greater rate than the low gradient region. When the value exceeds a certain value, the increasing speed of the high gradient area is smaller than that of the low gradient area, the ratio of the high gradient area to the low gradient area is reduced, and the finding of the changing middle point of the high gradient area and the low gradient area is the optimal bottom value to be found.
Specifically, a two-dimensional curve with the gradient ratio changing along with the base number is constructed according to the ratio Q of the pixel points of the high and low gradient areas in the low gray areas and the different base numbers under the logarithmic transformation results of different base numbers, the gradient ratio is the ratio Q of the pixel points of the high and low gradient areas in the low gray areas, the base number corresponding to the maximum value point in the two-dimensional curve with the gradient ratio changing along with the base numbers is the optimal base number, and the image enhancement is carried out on the stretched circuit board gray image of the circuit board removed area according to the determined optimal base number, so that the contrast ratio of the circuit board gray image of the circuit board removed area is further increased.
So far, the gray level image with obvious defect area contrast is obtained through logarithmic transformation processing of the stretched image.
And step S006, performing edge detection on the gray level image with obvious defect area contrast to identify defects.
The line part is already segmented through an Otsu algorithm, and the contrast between the scratch defect area and the surrounding area in the image is obvious through a series of processing of the steps, so that the edge detection is carried out on the processed image through a canny operator, and the scratch defect area is obtained and marked. After the scratch defect is identified, the scratch defect is required to be visually displayed on a corresponding display, so that a user can more intuitively check the abnormity of the surface coating of the circuit board.
The foregoing description of the preferred embodiments of the invention is not intended to be limiting, but rather is intended to cover all modifications, equivalents, alternatives, and improvements that fall within the spirit and scope of the invention.