Disclosure of Invention
In order to solve the above technical problems, an object of the present invention is to provide a method for detecting production quality of a chip circuit board, which adopts the following technical solutions:
the invention provides a production quality detection method suitable for a chip circuit board, which comprises the following steps:
obtaining a welding spot image of the chip circuit board; obtaining a gray level histogram of the welding spot image;
taking the gray level with continuity in the gray histogram as a classifiable gray level; obtaining a grouping index according to a first frequency difference between the classifiable gray level and an adjacent gray level, and if the grouping index is greater than a preset index threshold, classifying the classifiable gray level and the adjacent gray level into one class to obtain a plurality of gray level classes;
obtaining a gradient histogram of a pixel point corresponding to each gray level category; selecting a reference gradient according to the gradient value and the second frequency in the gradient histogram; taking pixel points corresponding to the reference gradients of the gray level categories as points to be detected; obtaining the gradient distribution of other pixel points in the neighborhood range of the point to be detected, which are in the same gray level category as the point to be detected, and screening out edge points from the point to be detected according to the gradient distribution, wherein the edge points form edge lines; acquiring a minimum external square of an area surrounded by each edge line in the welding spot image, and taking the size of the minimum external square as a reference size;
performing superpixel segmentation on the welding spot image according to the reference size to obtain a plurality of superpixel blocks; screening out a defective super pixel block according to the average pixel value in each super pixel block; and acquiring the defect position and the defect degree according to the position and the number of the defect super-pixel blocks.
Further, the obtaining of the solder joint image of the chip circuit board comprises:
the method comprises the steps of collecting a surface image of a chip circuit board, inputting the surface image into a pre-trained welding spot area segmentation network, and obtaining the welding spot image.
Further, the regarding the continuous gray level in the gray histogram as a classifiable gray level includes:
obtaining the number of other cylinders in a preset neighborhood range of the cylinder corresponding to each gray level in the gray level histogram; and if the number of the pillars is larger than a preset pillar number threshold value, the corresponding gray level is considered to have continuity.
Further, the obtaining a grouping indicator according to the first frequency difference between the classifiable gray level and the adjacent gray level comprises:
obtaining the grouping indicator according to a grouping indicator formula, the grouping indicator formula comprising:
wherein,
for the purpose of the grouping indicator,
is an exponential function with a natural constant as the base,
is as follows
A first frequency number corresponding to each gray level,
a first frequency count corresponding to said adjacent gray levels,
the number of the columns.
Further, the selecting a reference gradient according to the gradient value and the second frequency in the gradient histogram includes:
counting all gradient levels with the second frequency in the gradient histogram to obtain an average gradient; counting all the second frequency numbers in the gradient histogram to obtain an average frequency number; taking a gradient level that is greater than the average gradient and a second frequency that is less than the average frequency as the reference gradient.
Further, the obtaining of the gradient distribution of other pixel points in the neighborhood range of the point to be detected and in the same gray level category as the point to be detected, and the screening of the edge points in the point to be detected according to the gradient distribution includes:
counting all straight lines passing through the points to be detected in the neighborhood range of the points to be detected;
if the gradient difference between one point on the straight line and the point to be detected is smaller than a preset gradient threshold value and the point to be detected are in the same gray level category, the point is regarded as the gradient similar point of the point to be detected;
counting the number of the gradient similar points on each straight line, and if the number of the gradient similar points is greater than a preset number threshold, considering the corresponding straight line as a small segment edge line;
and if the small section of edge line exists in the neighborhood range of the point to be detected, the point to be detected is considered as the edge point.
Further, said screening out defective superpixel blocks based on the average pixel value within each superpixel block comprises:
and taking K superpixel blocks with the minimum average pixel value as the defect superpixel blocks, wherein K is a positive integer.
The invention has the following beneficial effects:
according to the embodiment of the invention, the gray level classes are obtained by performing rough classification according to the distribution of the gray levels in the gray level histogram. And further selecting a proper gradient value as a reference gradient according to the gradient histogram in the gray level class. And obtaining edge points according to the gradient distribution in the neighborhood range of the pixel points corresponding to the reference gradient, and further obtaining a plurality of edge areas. The reference size is selected through the edge area, the poor segmentation effect caused by the improper selection of the size during superpixel segmentation is avoided, the defect information can be rapidly and accurately screened out by utilizing the pixel value in the superpixel block, and the accurate and rapid production quality detection of the chip circuit board is realized.
Detailed Description
To further illustrate the technical means and effects of the present invention adopted to achieve the predetermined objects, the following detailed description of the method for detecting the production quality of a chip circuit board according to the present invention with reference to the accompanying drawings and preferred embodiments shows the following detailed descriptions of the specific implementation, structure, features and effects thereof. In the following description, different "one embodiment" or "another embodiment" refers to not necessarily the same embodiment. Furthermore, the particular features, structures, or characteristics may be combined in any suitable manner in one or more embodiments.
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 following describes a specific scheme of the production quality detection method for the chip circuit board provided by the invention in detail with reference to the accompanying drawings.
Referring to fig. 1, a flowchart of a method for detecting production quality of a chip circuit board according to an embodiment of the present invention is shown, where the method includes:
step S1: obtaining a welding spot image of the chip circuit board; and obtaining a gray level histogram of the welding spot image.
In the embodiment of the invention, the chip circuit board after being welded is horizontally placed on the detection table, the camera is deployed to collect the surface image of the chip circuit board from right above, and the surface image is subjected to noise reduction by using a Gaussian filtering algorithm in consideration of the influence of noise in the image collection and image transmission processes.
In the surface image, other image information than the solder points is present, for example, a plate material, an electronic component, and the like. In order to carry out targeted detection on the welding spot defects, after the surface image is obtained, the surface image is input into a welding spot area segmentation network trained in advance, and the welding spot image is obtained. It should be noted that the welding spot area segmentation network is a common semantic segmentation network, and the specific training method and implementation means are technical means well known to those skilled in the art, and only the network is briefly described here:
(1) the image containing the welding spot area is used as training data. And marking the pixels of the welding spot area as 1 and marking other pixels as 0 to obtain the label data.
(2) The semantic segmentation network adopts a coding-decoding structure, and the training data and the label data are input into the network after being normalized. The semantic segmentation coder is used for extracting the features of the input data to obtain a feature map. And the semantic segmentation decoder performs sampling transformation on the feature map and outputs a semantic segmentation result.
(3) And training the network by adopting a cross entropy loss function.
The abscissa of the gray level histogram is the gray level, and the ordinate is the frequency of occurrence of the corresponding gray level in the image. The gray level histogram can be used for representing the gray level distribution in the welding spot image. It should be noted that the method for obtaining the gray level histogram is a technical means well known to those skilled in the art, and is not described herein.
Step S2: taking the gray level with continuity in the gray histogram as a classifiable gray level; and obtaining a grouping index according to a first frequency difference between the classifiable gray level and the adjacent gray level, and classifying the classifiable gray level and the adjacent gray level into one class if the grouping index is greater than a preset index threshold value to obtain a plurality of gray level classes.
The gray histogram can represent gray distribution in an image, for superpixel segmentation, pixels with similar pixel values are essentially segmented into a region, and if the size of the superpixel block is too large, a defect region and a normal region in the image are not effectively segmented; if the size of the super pixel blocks is too small, the edge fitting degree between the super pixel blocks is poor, the boundaries are not clear, and the defect identification accuracy is influenced. Therefore, in step S2, the gray scale is subjected to initial coarse classification in consideration of the gray scale value and the distribution characteristics of the pixel points, and multiple gray scale categories are obtained for processing in the subsequent steps.
In the process of gray level classification, the gray levels with similar gray levels need to be considered as one class, if a certain gray level in a gray level histogram has continuity, that is, if a plurality of other gray level distributions exist in a neighborhood range, it is indicated that a gray level with a similar size to the gray level exists, and the gray level can be used for classification analysis. Therefore, the method for specifically judging the continuity of the gray levels by taking the gray levels with continuity in the gray histogram as classifiable gray levels comprises the following steps:
each cylinder in the gray level histogram corresponds to a gray level, and if no cylinder exists at a position corresponding to the gray level, it indicates that the pixel point distribution of the gray level does not exist in the image. And obtaining the number of the other cylinders in the preset neighborhood range of the cylinder corresponding to each gray level in the gray level histogram, wherein the larger the number of the cylinders is, the more the gray levels similar to the gray level are, and the better the continuity of the gray level is. And if the number of the cylinders is larger than a preset cylinder number threshold value, the corresponding gray level is considered to have continuity.
In the embodiment of the present invention, the radius of the neighborhood range of the gray scale is set to 5, i.e. the neighborhood range is (a-5, a +5), where a is the size of the target gray scale. The cylinder number threshold is set to 0, i.e. in the embodiment of the present invention, it is considered that only other gray levels exist in the neighborhood of the target gray level, which indicates that continuity exists in the target gray level.
The gradable gray level represents that the corresponding gray level can be combined with other adjacent gray levels, the frequency difference between the two gray levels is also required to be considered during combination, and the smaller the frequency difference is, the closer the information content of the pixel points corresponding to the two gray levels in the image is, the more the pixel points are classified into one type of pixels. Referring to fig. 2, a schematic diagram of a solder joint image according to an embodiment of the invention is shown, where the position pointed by the arrow in fig. 2 is the location of the tin cavity defect. As can be seen from fig. 2, a plurality of area distributions with the same pixel value exist in the welding spot image, and the purpose of classification is to consider that the pixels with similar gray levels and the same frequency are the same type of pixels. For example, the gray levels of different regions of normal categories in the welding spot image have similarity and a large amount of information, and the regions can be classified into one category by classification, and the defect regions are similar. The method for obtaining the grouping index according to the first frequency difference between the classifiable gray level and the adjacent gray level comprises the following steps:
obtaining a grouping index according to a grouping index formula, wherein the grouping index formula comprises the following components:
wherein,
as an index of the grouping,
is an exponential function with a natural constant as the base,
is as follows
A first frequency count corresponding to each gray level,
a first frequency count corresponding to adjacent gray levels,
is the number of columns.
According to the grouping index formula, if the continuity of the target gray level is strong and the frequency difference between the target gray level and the adjacent gray level is small, it indicates that the two gray levels are more likely to be pixels of the same type. If the grouping index is larger than the preset index threshold, the classifiable gray level and the adjacent gray level are classified into one class, and a plurality of gray level classes can be obtained through continuous classification.
Step S3: obtaining a gradient histogram of a pixel point corresponding to each gray level category; selecting a reference gradient according to the gradient value and the second frequency in the gradient histogram; taking pixel points corresponding to the reference gradients of the gray level categories as points to be detected; obtaining the gradient distribution of other pixel points which are in the same gray level category as the point to be detected in the neighborhood of the point to be detected, and screening out edge points from the point to be detected according to the gradient distribution, wherein the edge points form edge lines; and acquiring a minimum external square of an area surrounded by each edge line in the welding spot image, and taking the size of the minimum external square as a reference size.
Because the classification in step S2 is a coarse classification, the pixel point corresponding to each gray level category does not constitute a valid region in the image, and there may be sub-regions composed of different edges in the region. Since embodiments of the present invention aim to provide a method for adaptively obtaining the super-pixel block size in a solder joint image, all edges and their constituent regions in the image need to be obtained for subsequent screening of the super-pixel block size.
The most obvious characteristic of the edge is that the gradient is larger, in the welding spot image, the edge information is information with less information quantity and more obvious gradient amplitude, a gradient histogram of a pixel point corresponding to each gray level category is obtained, and the information in the gradient histogram can represent the size and distribution of the gradient, so that the reference gradient can be selected according to the gradient value in the gradient histogram and the corresponding second frequency. Considering the reference gradient as the gradient corresponding to the edge point, the edge analysis can be performed on the pixel point corresponding to the reference gradient to determine whether the pixel point is the edge point, wherein the specific method for acquiring the reference gradient includes:
and counting all gradient levels with the second frequency in the gradient histogram to obtain an average gradient. And counting all the second frequency numbers in the gradient histogram to obtain the average frequency number. The gradient level with the gradient level larger than the average gradient and the second frequency smaller than the average frequency is used as the reference gradient.
The pixel points corresponding to the reference gradients in the gray level categories are used as the points to be detected, and because the embodiment of the invention hopes to find the edge points capable of forming a complete edge, when the points to be detected are screened, the gradient distribution of other pixel points in the neighborhood range of the points to be detected needs to be considered, namely, the more similar the gradient distribution is to the points to be detected, the easier the edge line is formed, and the more the points to be detected are required edge points. Specifically, the method for obtaining the gradient distribution of other pixel points in the neighborhood range of the point to be detected and in the same gray level category as the point to be detected and screening out the edge point in the point to be detected according to the gradient distribution comprises the following steps:
and counting all straight lines passing through the points to be detected in the neighborhood range of the points to be detected. If the gradient difference between one point on the straight line and the point to be detected is smaller than the preset gradient threshold value and the point to be detected are in the same gray level class, the point is considered to be the gradient similar point of the point to be detected. And counting the number of the gradient similar points on each straight line, and if the number of the gradient similar points is greater than a preset number threshold, considering the corresponding straight line as a small section edge line. And if the small section of edge line exists in the neighborhood range of the point to be detected, the point to be detected is considered as an edge point.
In the embodiment of the present invention, the size of the neighborhood range to be detected is set to 5 × 5, that is, the length of each straight line is 5 pixels, the gradient threshold is set to 5, and the number threshold is set to 3.
The continuous edge points can form a complete edge line, the minimum external square of the area surrounded by each edge line in the welding spot image is obtained, and the size of the minimum external square is used as the reference size.
Step S4: performing superpixel segmentation on the welding spot image according to the reference size to obtain a plurality of superpixel blocks; screening out a defective super pixel block according to the average pixel value in each super pixel block; and acquiring the defect position and the defect degree according to the position and the number of the defect super pixel blocks.
The reference size is size information obtained by pixel distribution self-adaption in the welding spot image, and the defect of overlarge or undersize cannot exist when the welding spot image is subjected to superpixel segmentation according to the reference size. It should be noted that performing superpixel segmentation according to the reference size is a well-known technical means for those skilled in the art, and the detailed description of the segmentation process is omitted.
The solder joint image can obtain a plurality of superpixel blocks after superpixel segmentation is carried out, the pixel information in each superpixel block is similar, because the tin hole defect is obvious black in the image and has obvious pixel difference with other areas, the defect superpixel block can be screened out according to the average pixel value of each superpixel block, and the method specifically comprises the following steps: and taking K superpixel blocks with the minimum average pixel value as defect superpixel blocks, wherein K is a positive integer. In the present example, K is 5.
The defect can be positioned according to the position of the defect super-pixel block, and the number of the defect super-pixel blocks can obtain the defect degree, namely the larger the number is, the larger the defect degree is. Reference can be provided for workers in the production quality detection process through the defect positions and the defect degrees, the workers can check the process according to the defect information, and the yield of products is improved.
In summary, the embodiment of the present invention obtains the gray histogram of the welding spot image, and obtains a plurality of gray level categories according to the distribution of the gray levels in the gray histogram and the corresponding frequency. Obtaining a reference gradient according to a gradient histogram corresponding to the gray level category, screening out edge points from pixel points corresponding to the reference gradient, further obtaining a region surrounded by edge lines, obtaining a minimum external square of the region, performing superpixel segmentation on a welding spot image by taking the size of the minimum external square as a reference size, and detecting a defective superpixel block according to an average pixel value of the segmented superpixel block. The embodiment of the invention can segment the welding spot image in the chip circuit board by adaptively acquiring the size of the superpixel block, thereby realizing accurate quality detection.
It should be noted that: the sequence of the above embodiments of the present invention is only for description, and does not represent the advantages or disadvantages of the embodiments. The processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing may also be possible or may be advantageous.
All the embodiments in the present specification are described in a progressive manner, and the same and similar parts among the embodiments are referred to each other, and each embodiment focuses on the differences from other embodiments.
The above description is only for the purpose of illustrating the preferred embodiments of the present invention and should not be taken as limiting the scope of the present invention, which is intended to cover any modifications, equivalents, improvements, etc. within the spirit and scope of the present invention.