Disclosure of Invention
In order to overcome the problems in the related art, the present disclosure provides a method and an apparatus for detecting defects at plastic packaged semiconductor pins.
According to a first aspect of the embodiments of the present disclosure, a method for detecting defects at a plastic package semiconductor pin is provided. The detection method comprises the following steps: acquiring an image at the plastic package semiconductor pin; selecting a gray value from the gray values of all pixels in the image as a binarization threshold value to binarize the image to obtain a binary image; determining a defect to be determined in the image according to the binary image; and determining the defects at the pins of the plastic packaged semiconductor according to the comparison between the gray value mean value of the defects to be determined and the gray value mean value of the adjacent area of the defects to be determined.
Optionally, the binarizing the image by selecting a gray value from the gray values of all the pixels in the image as a binarization threshold to obtain a binary image includes: sorting the gray values of all pixels in the image from large to small and forming a gray value array A { a }1,a2,a3...an-wherein n represents the total number of gray values of all pixels; determining the binarization threshold value according to the gray value array and the following formula:
wherein, aiRepresents the array A { a }1,a2,a3...anK is a positive integer and 1 ≦ k < n, Differ represents the ratio of the mean of the first k gray values in the gray value array a to the mean of the remaining gray values in the gray value array a.
Optionally, a first minimum threshold T1m and a first maximum threshold T1n of the total number of all defective pixels in the image are obtained, and k is set to: k is more than or equal to T1m and less than or equal to T1 n.
Optionally, the determining, according to the binary image, a defect to be determined in the image includes: extracting and storing the defect connected domain according to the binary image; and determining a region corresponding to the defect connected domain in the image, and determining the defect to be determined.
Optionally, the extracting and storing the defect connected domain according to the binary image includes: acquiring a second minimum threshold and a second maximum threshold of the number of pixels of a single defect in the image; extracting the defect connected domain, and saving the defect connected domain with the pixel number smaller than the second maximum threshold and larger than the second minimum threshold.
Optionally, the determining the defect at the plastic package semiconductor pin according to the comparison between the gray value mean of the defect to be determined and the gray value mean of the adjacent region of the defect to be determined includes: calculating the difference between the mean value of the gray values of the defects to be determined and the mean value of the gray values of the adjacent regions of the defects to be determined; and determining the defects at the plastic package semiconductor pins according to the comparison between the difference and a preset reference value.
Optionally, the calculating the difference between the mean gray value of the defect to be determined and the mean gray value of the adjacent region of the defect to be determined includes: and calculating the difference between the mean value of the gray values of the defects to be determined and the mean value of the gray values of the boundary area surrounding the defects to be determined.
Optionally, the boundary region is formed by extending a preset number of pixels outside the defect to be determined.
According to a second aspect of the embodiments of the present disclosure, there is provided a device for detecting defects at a plastic package semiconductor pin, wherein the device comprises: the acquisition unit is used for acquiring an image at the plastic package semiconductor pin; the binarization unit is used for selecting a gray value from the gray values of all pixels in the image as a binarization threshold value to binarize the image to obtain a binary image; the middle determining unit is used for determining the defects to be determined in the image according to the binary image; and the defect determining unit is used for determining the defects at the plastic package semiconductor pins according to the comparison between the gray value mean value of the defects to be determined and the gray value mean value of the adjacent area of the defects to be determined.
Optionally, the binarization unit is configured to select a gray value from gray values of all pixels in the image as a binarization threshold to binarize the image to obtain a binary image, where: sorting the gray values of all pixels in the image from large to small and forming a gray value array A { a }1,a2,a3...an-wherein n represents the total number of gray values of all pixels; determining the binarization threshold value according to the gray value array and the following formula:
wherein, aiRepresents the array A { a }1,a2,a3...anK is a positive integer and 1 ≦ k < n, Differ represents the ratio of the mean of the first k gray values in the gray value array a to the mean of the remaining gray values in the gray value array a.
Optionally, the binarization unit is configured to obtain a first minimum threshold T1m and a first maximum threshold T1n of the total number of all defective pixels in the image, and set k as: k is more than or equal to T1m and less than or equal to T1 n.
Optionally, the intermediate determination unit is configured to determine the defect to be determined in the image according to the binary image in the following manner: extracting and storing the defect connected domain according to the binary image; and determining a region corresponding to the defect connected domain in the image, and determining the defect to be determined.
Optionally, the intermediate determining unit is configured to extract and store the defect connected domain according to the binary map in the following manner: acquiring a second minimum threshold and a second maximum threshold of the number of pixels of a single defect in the image; extracting the defect connected domain, and saving the defect connected domain with the pixel number smaller than the second maximum threshold and larger than the second minimum threshold.
Optionally, the defect determining unit is configured to determine the defect at the plastic package semiconductor pin according to a comparison between the mean value of the gray-scale values of the defect to be determined and the mean value of the gray-scale values of the adjacent region of the defect to be determined by adopting the following method: calculating the difference between the mean value of the gray values of the defects to be determined and the mean value of the gray values of the adjacent regions of the defects to be determined; and determining the defects at the plastic package semiconductor pins according to the comparison between the difference and a preset reference value.
Optionally, the defect determining unit is configured to calculate a difference between the mean gray value of the defect to be determined and the mean gray value of the adjacent region of the defect to be determined by: and calculating the difference between the mean value of the gray values of the defects to be determined and the mean value of the gray values of the boundary area surrounding the defects to be determined.
Optionally, the boundary region is formed by extending a preset number of pixels outside the defect to be determined.
The technical scheme provided by the embodiment of the disclosure can have the following beneficial effects: the defect detection is carried out by utilizing the contrast of the defect gray value mean value and the adjacent area gray value mean value, whether the defect is really the defect at the plastic package semiconductor pin can be judged more accurately, and therefore the misjudgment caused by directly judging the defect by using a fixed gray threshold value is avoided.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.
Detailed Description
The technical solutions in the embodiments of the present disclosure will be clearly and completely described below with reference to the drawings in the embodiments of the present disclosure, and it is obvious that the described embodiments are some, but not all embodiments of the present disclosure. All other embodiments, which can be derived by a person skilled in the art from the embodiments disclosed herein without making any creative effort, shall fall within the protection scope of the present disclosure.
It should be understood that the terms "first," "second," "third," and "fourth," etc. in the claims, description, and drawings of the present disclosure are used to distinguish between different objects and are not used to describe a particular order. The terms "comprises" and "comprising," when used in the specification and claims of this disclosure, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof.
Specific embodiments of the present disclosure are described in detail below with reference to the accompanying drawings.
The present disclosure provides a method for detecting defects at plastic package semiconductor pins. Referring to fig. 1, fig. 1 is a flow chart illustrating a method for detecting defects at a plastic packaged semiconductor pin according to an exemplary embodiment. As shown in FIG. 1, the method for detecting defects at the pins of the plastic packaged semiconductor comprises the following steps S101-S104.
Step S101: and acquiring an image at the plastic package semiconductor pin.
Step S102: and selecting a gray value from the gray values of all pixels in the image as a binarization threshold value to binarize the image to obtain a binary image.
Step S103: and determining the defects to be determined in the image according to the binary image.
Step S104: and determining the defects at the pins of the plastic packaged semiconductor according to the comparison between the gray value mean value of the defects to be determined and the gray value mean value of the adjacent area of the defects to be determined.
The respective steps will be described in detail below.
In step S101, an image at the plastic packaged semiconductor pins is acquired.
According to the embodiment of the disclosure, in order to detect whether the plastic packaged semiconductor pin has a defect, the image at the plastic packaged semiconductor pin can be directly or indirectly acquired, for example, the plastic packaged semiconductor can be directly imaged by using an imaging device, or a pre-saved image of the plastic packaged semiconductor can be acquired from other components through transmission. The image at the pins of the plastic packaged semiconductor includes, but is not limited to, images of all pin positions, and may include images of other positions of the plastic packaged semiconductor. Defects at the plastic packaged semiconductor pins may appear as white patches (white spots) in the inspection image.
In step S102, a gray value is selected from the gray values of all the pixels in the image as a binarization threshold to binarize the image, so as to obtain a binary image.
This step is used to more reasonably binarize the image to obtain a subsequent binary image that is more accurate in identifying defects, according to embodiments of the present disclosure. The gray values of all pixels in the image can be extracted by any suitable method such as an at function of Opencv, and then a gray value can be selected from the gray values by any suitable binarization threshold selection algorithm to be used as a binarization threshold to binarize the image, so as to obtain a binary image of the image, and certainly, a gray value can be manually selected to be used as the binarization threshold.
Preferably, the binarizing the image by selecting a gray value from gray values of all pixels in the image as a binarization threshold to obtain a binary image includes: sorting the gray values of all pixels in the image from large to small and forming a gray value array A { a }1,a2,a3...an-wherein n represents the total number of gray values of all pixels; determining the binarization threshold value according to the gray value array and the following formula:
wherein, aiRepresents the array A { a }1,a2,a3...anK is a positive integer and 1 ≦ k < n, Differ represents the ratio of the mean of the first k gray values in the gray value array a to the mean of the remaining gray values in the gray value array a.
Specifically, after extracting the gray values of all pixels in the image as described above, all these gray values are sorted in order from large to small using any suitable means such as an interpolation sorting algorithm,and stored as a gray value array A { a }1,a2,a3...anWhere n represents the total number of pixels (grey values) in the image. Then, determining the binarization threshold according to the gray value array and the following formula:
wherein, aiRepresents the array A { a }1,a2,a3...anK is a positive integer and 1 ≦ k < n, Differ represents the ratio of the mean of the first k gray values in the gray value array a to the mean of the remaining gray values in the gray value array a. When all values of k are taken within the interval of k being more than or equal to 1 and less than n, n-1 Differs can be obtained through calculation, the Differs are compared to obtain the maximum Differ, the value of k corresponding to the maximum Differ can be obtained, and the kth gray value ak in the array A is used as the binarization threshold. Then, the image may be binarized according to the binarization threshold, for example, if the gray value of a pixel in the image is greater than the binarization threshold, the gray value of the pixel is assigned to 255, and if the gray value of the pixel in the image is less than the binarization threshold, the gray value of the pixel is assigned to 0, thereby obtaining a binary image of the image.
Further, a first minimum threshold T1m and a first maximum threshold T1n of the total number of all defective pixels in the image are obtained, and k is set to: k is more than or equal to T1m and less than or equal to T1 n.
The first minimum threshold and the first maximum threshold may be manually preset or manually directly input based on an estimated total number of pixels with all defects. For example, the number of defects in the image may be estimated in advance and the total number of pixels of all the defects may be estimated therefrom, and the first minimum threshold value T1m and the first maximum threshold value T1n may be set according to the estimated total number of pixels, and the binarization threshold value may be obtained using the above formula with the interval T1m ≦ k ≦ T1n between the first minimum threshold value and the first maximum threshold value as a search interval. The first minimum threshold T1m and the first maximum threshold T1n are set, and k is set to: t1m ≦ k ≦ T1n is to set the valid calculation interval, making the calculation more time-saving. Because the defect in the image is represented as a white spot and the gray value is large, the maximum Differ can be included by taking the first T1m gray values to the first T1n gray values according to the estimated total number of the defective pixels, so that the maximum Differ can be searched by calculating the Differ without taking all values of k in the interval of more than or equal to 1 and less than n.
In step S103, a defect to be determined in the image is determined according to the binary image.
According to an embodiment of the present disclosure, from the binary map, a defect (high grayscale region) in the binary map is determined, and the corresponding position and size of the defect in the image is determined.
Further, the determining the defect to be determined in the image according to the binary image comprises: extracting and storing the defect connected domain according to the binary image; and determining a region corresponding to the defect connected domain in the image, and determining the defect to be determined.
Specifically, all defect connected domains (high-gray regions) in the binary image can be extracted and stored through a connected domain extraction algorithm, and a region corresponding to the size and the position of the defect connected domain is determined in the image, wherein the region is the defect to be determined in the image.
Further, the extracting and storing the defect connected domain according to the binary image comprises: acquiring a second minimum threshold and a second maximum threshold of the number of pixels of a single defect in the image; extracting the defect connected domain, and saving the defect connected domain which is smaller than the second maximum threshold and larger than the second minimum threshold.
Specifically, in order to accurately obtain defects of a desired size, such as defects affecting quality, thereby excluding particularly small and non-affecting defects, the second minimum threshold value and the second maximum threshold value of the number of pixels of a single defect may be manually preset or manually directly input according to the estimated number of pixels of the single defect. And only the defect connected regions within the second minimum threshold and the second maximum threshold interval are saved. And determining corresponding defects to be determined in the image according to the defect connected regions.
In step S104, a final defect in the image is determined according to a comparison between the mean gray value of the defect to be determined and the mean gray value of the region adjacent to the defect to be determined.
According to the embodiment of the disclosure, whether the defect to be determined is really the defect at the plastic package semiconductor pin can be more accurately judged by comparing the defect to be determined in the image with the mean value of the gray values of the adjacent areas, so that the misjudgment caused by directly judging the defect by using a fixed gray threshold value is avoided.
Further, the determining the final defect in the image according to the comparison between the mean value of the gray values of the defect to be determined and the mean value of the gray values of the adjacent region of the defect to be determined includes: calculating the difference between the mean value of the gray values of the defects to be determined and the mean value of the gray values of the adjacent regions of the defects to be determined; and determining the final defect in the image according to the comparison of the difference and a preset reference value.
Specifically, the difference between the gray value mean of the defect to be determined and the adjacent area in the image is calculated, and then the difference is compared with a preset reference value to judge whether the contrast is obvious or not, namely whether the defect exists or not. For example, when the difference between the gray value averages is greater than a preset reference value, the defect to be determined is a defect at the plastic package semiconductor pin, and when the difference between the gray value averages is less than the preset reference value, the defect to be determined is not considered as a defect. The preset reference value may be a value defined in advance according to a requirement, for example, the preset reference value may be set to be larger if the defect to be determined is clearly recognized as a defect in comparison with its neighboring area, and may be set to be smaller if the defect to be determined is recognized as a defect in comparison with its neighboring area.
Further, the calculating the difference between the mean gray value of the defect to be determined and the mean gray value of the adjacent region of the defect to be determined includes: and calculating the difference between the mean value of the gray values of the defects to be determined and the mean value of the gray values of the boundary area surrounding the defects to be determined.
Specifically, in order to more accurately judge the defect, the difference of the mean gray value of the defect to be determined and the boundary region surrounding it may be calculated.
Further, the boundary region is formed by extending a preset number of pixels outside the defect to be determined. In particular, the defect to be determined may be flared out using any suitable means to form an annular boundary region around the defect to be determined. For example, the defect to be determined can be extended by 5 to 10 pixels, i.e. the width of the boundary zone is 5 to 10 pixels.
According to another embodiment of the present disclosure, when determining the defect to be determined in the image according to the binary map, the saved defect connected domain is subjected to an external expansion using any suitable algorithm such as a morphological expansion corrosion algorithm to form an annular boundary region of the defect connected domain according to the binary map, then a region corresponding to the defect connected domain and the annular boundary region is determined in the image, so as to form the defect to be determined in the image and the boundary region surrounding the defect, and finally, as described above, the defect at the plastic package semiconductor pin is determined according to the defect to be determined and the boundary region surrounding the defect.
The embodiment of the disclosure also provides a device for detecting the defects at the pins of the plastic package semiconductor. The detection device is used for executing the steps in the detection method embodiment.
Referring to fig. 2, fig. 2 is a block diagram illustrating an apparatus 100 for detecting defects at plastic packaged semiconductor pins according to an exemplary embodiment. As shown in fig. 2, the detection apparatus 100 includes an acquisition unit 101, a binarization unit 102, an intermediate determination unit 103, and a defect determination unit 104. The acquisition unit 101 is configured for acquiring an image at the plastic encapsulated semiconductor pins. The binarization unit 102 is configured to select a gray value from gray values of all pixels in the image as a binarization threshold to binarize the image, so as to obtain a binary image. The intermediate determination unit 103 is configured for determining a defect to be determined in the image from the binary image. The defect determining unit 104 is configured to determine the defect at the plastic package semiconductor pin according to a comparison between the gray value mean of the defect to be determined and the gray value mean of the adjacent region of the defect to be determined.
According to an embodiment of the present disclosure, the binarization unit is configured to select a gray value from gray values of all pixels in the image as a binarization threshold to binarize the image to obtain a binary image, in the following manner: sorting the gray values of all pixels in the image from large to small and forming a gray value array A { a }1,a2,a3...an-wherein n represents the total number of gray values of all pixels; determining the binarization threshold according to the following formula:
wherein, aiRepresents the array A { a }1,a2,a3...anK is a positive integer and 1 ≦ k < n, Differ represents the ratio of the mean of the first k gray values in the gray value array a to the mean of the remaining gray values in the gray value array a.
Preferably, the binarization unit is configured to acquire a first minimum threshold T1m and a first maximum threshold T1n of the total number of all defective pixels in the image, and set k as: k is more than or equal to T1m and less than or equal to T1 n.
According to an embodiment of the disclosure, the intermediate determination unit is configured to determine the defect to be determined in the image from the binary map in the following manner: extracting and storing the defect connected domain according to the binary image; and determining a region corresponding to the defect connected domain in the image, and determining the defect to be determined.
Preferably, the intermediate determination unit is configured to extract and store the defect connected domain according to the binary map in the following manner: acquiring a second minimum threshold and a second maximum threshold of the number of pixels of a single defect in the image; extracting the defect connected domain, and saving the defect connected domain with the pixel number smaller than the second maximum threshold and larger than the second minimum threshold.
According to an embodiment of the disclosure, the defect determining unit is configured to determine the defect at the plastic package semiconductor pin according to a comparison between the mean value of the gray values of the defect to be determined and the mean value of the gray values of the adjacent region of the defect to be determined in the following manner: calculating the difference between the mean value of the gray values of the defects to be determined and the mean value of the gray values of the adjacent regions of the defects to be determined; and determining the defects at the plastic package semiconductor pins according to the comparison between the difference and a preset reference value.
Further, the defect determining unit is configured to calculate a difference between the mean gray value of the defect to be determined and the mean gray value of the adjacent region of the defect to be determined by: and calculating the difference between the mean value of the gray values of the defects to be determined and the mean value of the gray values of the boundary area surrounding the defects to be determined.
Preferably, the boundary region is formed by extending a preset number of pixels outside the defect to be determined.
It will be appreciated that with respect to the apparatus in the above embodiments, the specific manner in which the respective units perform operations has been described in detail in relation to the embodiments of the method and will not be elaborated upon here.
The embodiments of the present disclosure are described in detail above, and the description of the embodiments is only used to help understanding the method and the core idea of the present disclosure. Meanwhile, a person skilled in the art should, based on the idea of the present disclosure, change or modify the specific embodiments and application scope of the present disclosure. In view of the above, the description is not intended to limit the present disclosure.