A high-precision measurement method for lead frame pin spacing

Through machine vision image processing technology, X-ray imaging and multi-angle template matching are used to achieve high-precision measurement of the pin spacing of semiconductor lead frames, solving the problems of low efficiency and insufficient accuracy in existing technologies and improving detection efficiency and accuracy.

CN115527049BActive Publication Date: 2025-09-09SOUTHEAST UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202211256870.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-10-14
Publication Date
2025-09-09
Estimated Expiration
2042-10-14

AI Technical Summary

Technical Problem

Existing technologies make it difficult to achieve high-precision measurement of the pin spacing of semiconductor lead frames, resulting in inaccurate metal lead positioning and poor conductivity between the chip and the frame. Manual inspection is also inefficient and costly, and prone to false detection and missed detection.

Method used

Using machine vision image processing technology, the reference and test images are acquired through X-ray imaging, and image preprocessing and pyramid downsampling are performed. The pin spacing is calculated by combining multi-angle rotation template matching and sub-pixel edge detection.

Benefits of technology

It achieves sub-pixel high-precision measurement of lead frame pin spacing, improves detection efficiency, reduces labor costs, and reduces false detections and missed detections.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115527049B_ABST
    Figure CN115527049B_ABST
Patent Text Reader

Abstract

The present invention discloses a high-precision measurement method for lead frame pin spacing, which belongs to the field of machine vision. The method includes: after obtaining a reference image and an image to be measured, processing and rotating the reference image to obtain a multi-angle high-level pyramid rotation template image and a corresponding mask; performing template matching to achieve coarse matching, processing the matching result to obtain a pin image containing only the lead frame pin area; detecting the pin image contours and processing each contour to obtain a pin mask image, which is fused with the image to be measured to obtain a pin coarse positioning image; performing sub-pixel edge detection on the pin coarse positioning image to obtain a sub-pixel edge point set; calculating the minimum distance between the edge point sets of adjacent contours to obtain the spacing between adjacent lead frame pins. The method improves speed through template matching and coarse matching; achieves spacing measurement through images, reducing labor costs; and introduces sub-pixel edge detection to improve accuracy, which has the characteristics of high calculation accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the field of machine vision, and in particular relates to a high-precision measurement method for lead frame pin spacing. Background Art

[0002] Semiconductor chips are currently widely used in computer equipment, network communications, automotive electronics, aerospace, and other fields, and are the foundation of all modern life. With the large-scale development of integrated circuits, chip packaging processes are also gaining increasing attention. The semiconductor lead frame is the framework that connects the contact points of the semiconductor core chip to the metal leads. Currently, two processes are used: etching and stamping. Due to production process limitations, lead frames may have defects such as pin deformation and too small spacing between adjacent pins. These defects can lead to inaccurate metal lead positioning during bonding and poor conductivity between the chip and the frame. Product quality inspection of lead frames is a critical part of chip packaging technology.

[0003] In recent years, machine vision has been increasingly used in manufacturing and automated inspection technologies. While traditional optical and dimensional inspection methods cannot be used directly on chip packaging, ultra-high-resolution structural imaging can be easily obtained by leveraging the penetrating properties of X-rays and the differences in X-ray absorption rates among the various materials within the chip package. Although some professional software has dimensional measurement capabilities, manual labeling is still required. Furthermore, due to the large number of lead frame pins and the high precision requirements, traditional manual methods typically involve spot checks or full inspections. This, coupled with complex production environments, increases labor costs, low labor efficiency, and the risk of false detections and missed inspections. Furthermore, due to the small size of the pins themselves, current pixel-level dimensional inspections exhibit large errors, failing to meet high-precision measurement requirements and making it difficult to guarantee lead frame pin quality. Summary of the Invention

[0004] To solve the above problems, the present invention discloses a high-precision measurement method for lead frame pin spacing, which realizes lead frame pin spacing measurement through machine vision image processing technology, replacing manual spot inspection or full inspection, improving efficiency, and meeting the requirements of high-precision measurement at the sub-pixel level.

[0005] To achieve the above object, the technical solution of the present invention is as follows:

[0006] A high-precision measurement method for lead frame pin spacing, comprising the following steps:

[0007] Step 1: Obtain a reference image and a test image containing a lead frame and a chip core by X-ray imaging;

[0008] Step 2: Perform image preprocessing on the reference image in step 1 to obtain a kernel template image at the center of the reference image. Downsample the kernel template image 2 to 4 times to obtain a high-level pyramid template image.

[0009] Step 3: Perform image preprocessing and continuous downsampling 2 to 4 times on the image to be tested in step 1 to obtain a bottom pyramid image to be tested and a high pyramid image to be tested;

[0010] Step 4: Create a mask of the high-level pyramid template image in step 2, and rotate it with the high-level pyramid template image in the range of [-20° to -10°, 10° to 20°] to obtain a multi-angle high-level pyramid rotated template image and a corresponding multi-angle high-level pyramid rotated mask image;

[0011] Step 5: Coarse matching: template matching is performed on the multi-angle high-level pyramid rotated template image in step 4 and the high-level pyramid image to be tested in step 3. The best matching result is fused with the bottom-level pyramid image to be tested in step 3 to obtain a pin image containing only the lead frame pins.

[0012] Step 6: Perform image processing on the pin image in step 5, and then extract its contours to obtain a contour set containing all pin contours in the pin image. Process each contour in the contour set in turn to obtain a contour mask image of each contour.

[0013] Step 7: Combined with the contour mask image, perform edge detection on the image to be tested in step 1 using a sub-pixel edge detection method that combines adaptive thresholding and polynomial interpolation to obtain a set of sub-pixel coordinate points of each pin edge;

[0014] Step 8: Based on the sub-pixel coordinate point set in step 7, the spacing between adjacent pins is calculated using the Euclidean distance method in two-dimensional space.

[0015] Furthermore, the reference image and the image to be measured in step 1 are high-resolution grayscale images.

[0016] Furthermore, the specific method of step 2 is:

[0017] Step 2-1: Threshold segmentation of the reference image in step 1 is performed. The grayscale threshold of the reference image is obtained using the maximum inter-class variance method. The grayscale values ​​of pixels above the grayscale threshold are changed to 255, and the grayscale values ​​of pixels above the grayscale threshold are changed to 0, thereby obtaining the reference threshold segmentation image.

[0018] Step 2-2: Crop the center of the baseline threshold segmentation image in step 2-1, with the cropping range being 200 to 300 pixels away from the periphery of the chip core to obtain a core template image;

[0019] Step 2-3: The kernel template image in step 2-2 is continuously downsampled 2 to 4 times, specifically: using the kernel template image as the bottom pyramid template image, extracting odd rows and odd columns from the bottom pyramid template image to obtain a first-layer pyramid template image with an image size of 1 / 2 the rows and columns of the bottom pyramid template image; extracting odd rows and odd columns from the first-layer pyramid template image to obtain a second-layer pyramid template image with an image size of 1 / 2 the rows and columns of the first-layer pyramid template image; repeating the above operation 2 to 4 times to obtain a high-layer pyramid template image.

[0020] Furthermore, in step 3, the image to be tested in step 1 is subjected to image preprocessing and downsampling processing, wherein the image preprocessing method is consistent with the threshold segmentation step in step 2-1, and the processed image is used as the bottom pyramid image to be tested. The downsampling processing method is consistent with the specific steps of the downsampling processing in step 2-3, thereby obtaining a high-level pyramid image to be tested.

[0021] Furthermore, in step 4, the mask is created and the high-level pyramid template image is rotated, and the specific method is as follows:

[0022] Step 4-1: Create a mask of the high-level pyramid template image in step 2, define the area where the template image is located as the region of interest, and set the grayscale value of the region of interest in the mask to 1, and the grayscale value of the non-region of interest to 0;

[0023] Step 4-2: In the image rotation of step 4, the rotation range is [-20° to -10°, 10° to 20°]; the rotation target is the high-level pyramid template image and the mask mask produced in step 4-1 corresponding to the rotation angle thereof; the grayscale value of the non-interested region in the rotated mask mask is 0 and does not participate in the template matching calculation; the step size of each rotation angle is (layer+1), where layer refers to the layer number of the current rotation target; the high-level pyramid template image before rotation is used as the high-level pyramid rotated template image when the rotation angle is 0°.

[0024] Furthermore, the specific steps of the rough matching in step 5 are:

[0025] Step 5-1: Match the high-level pyramid rotated template image in step 4 with the high-level pyramid image template in step 3 in the rotation range of [-20° to -10°, 10° to 20°] in sequence. The rotation angle step size is (layer+1). The high-level pyramid rotated template image slides on the high-level pyramid image in a window-like manner. The matching degree at each position is calculated to obtain the best high-level matching position (x0, y0) and rotation angle theta.

[0026] The matching degree is calculated using the normalized correlation coefficient method, and the formula is:

[0027]

[0028] Where R represents the matching degree, which ranges from [-1, 1], T represents the template image, S represents the image to be tested, m represents the grayscale average value of the subscript corresponding to the image, and (u, v) represents each coordinate point in the ROI area;

[0029] Step 5-2: According to the best matching position (x0, y0) and the rotation angle theta in step 5-1, the best matching position (2 L *x0,2 L *y0) and the rotation angle theta, where L refers to the specific layer of the high-level pyramid template image;

[0030] Step 5-3: According to the bottom best matching position (2 L *x0,2 L *y0) and the rotation angle theta, the rectangular area of ​​the matching result on the bottom pyramid image to be tested can be obtained, and the image grayscale of the rectangular area is set to 255 to obtain the pin image containing only the lead frame pins.

[0031] Furthermore, the image processing and contour processing operations in step 6 are specifically performed as follows:

[0032] Step 6-1: The image processing in step 6 is to perform a morphological erosion operation on the pin image in step 5-3, so that the white area in the pin image becomes narrower and the black area becomes wider. The kernel matrix size of the erosion operation is 5*5. Then, the grayscale value at the four edges of the eroded image is changed to 255, and the edge size is one pixel. Then, the contour of the image after image processing is extracted to obtain a contour set containing all the pin contours in the pin image.

[0033] Step 6-2: The processing of the contour set in step 6-1 is to set the grayscale inside the contour to 0 and the grayscale outside the contour to between 220 and 240, so that the grayscale distribution of the outer part of the contour is uniform and avoid grayscale step changes, and obtain the contour mask image of each contour; sort all pin contours in a clockwise order according to the center position of each contour.

[0034] Furthermore, in step 7, each pin region of the image to be tested in step 1 is extracted separately in combination with the contour mask image, and then sub-pixel edge detection is performed on the pin region. The sub-pixel edge detection specifically comprises the following steps:

[0035] Step 7-1: Construct Sobel partial derivative operator templates in four directions: horizontal, vertical, 45 degrees, and 135 degrees. Compare the templates with the pin area to obtain gradient images in these four directions. Then, search for the maximum gradient and the corresponding gradient direction pixel by pixel in these four gradient images to obtain a pseudo-edge image.

[0036] The Sobel partial derivative operator template is as follows:

[0037]

[0038] P(x, y) represents the grayscale value of a pixel at a certain point (x, y). The calculation formulas for the gradients in each direction are as follows:

[0039] g1(x,y)=[P(x+1,y-1)+2*P(x+1,y)+P(x+1,y+1)]-[P(x-1,y-1)+2*P(x-1,y)+P(x-1,y+1)]

[0040] g2(x,y)=[P(x-1,y-1)+2*P(x,y-1)+P(x+1,y-1)]-[P(x-1,y+1)+2*P(x,y+1)+P(x+1,y+1)]

[0041] g3(x,y)=[P(x,y-1)+2*P(x+1,y-1)+P(x+1,y)]-[P(x-1,y)+2*P(x-1,y+1)+P(x,y+1)]

[0042] g4(x,y)=[P(x,y-1)+2*P(x-1,y-1)+P(x-1,y)]-[P(x,y+1)+2*P(x+1,y+1)+P(x+1,y)]

[0043] Among them, g i (x, y) represents the gradient at a point (x, y) after calculation by the i-th partial derivative operator template;

[0044] Step 7-2: In step 7-1, the maximum gradient and the corresponding gradient direction are calculated. Since the Sobel partial derivative operator template in four directions is used, the edge in the pseudo-edge image is not a single pixel point. If sub-pixel edge detection is required, only a single pixel edge is required. The pixel point (x, y) is judged to be the best edge point to obtain the best edge point set of the pseudo-edge image. The specific judgment method is as follows:

[0045] g(x0,y0)>=g(x1,y1)and g(x0,y0)>=g(x2,y2)

[0046] Among them, point (x0, y0) is the best edge point, point (x1, y1) and point (x2, y2) are two adjacent points along the gradient direction of point (x0, y0);

[0047] In step 7-2, before determining whether it is the best edge point, the pseudo-edge image in step 7-1 should be screened using the adaptive threshold method and the non-maximum suppression method, and certain sudden interference points and weak edges should be filtered out using the minimum threshold and maximum threshold. The maximum threshold is adaptively determined by using the maximum inter-class variance method on the pseudo-edge image, and the minimum threshold is between 0.4 and 0.6 times the maximum threshold. The adaptive threshold makes the screening and filtering process of the edge points of each contour more targeted, and local pin areas with different brightness and contrast will have corresponding local thresholds.

[0048] Step 7-3: The optimal edge point set obtained in step 7-2 is fitted using a Lagrange polynomial interpolation method to obtain a sub-pixel edge point set, where the interpolation function is:

[0049]

[0050] Among them, x k is the interpolation point, y k is the discrete function value, (x i ,y i ) is an edge point;

[0051] The formula for solving sub-pixel coordinates is:

[0052]

[0053]

[0054] Among them, (x, y) is the sub-pixel edge point, R0 is the point (x i ,y i ), R1 and R2 are the grayscale amplitudes at point (x i ,y i ) The grayscale amplitude of the adjacent points along the gradient direction, where the grayscale amplitude is approximated by the gradient amplitude.

[0055] Furthermore, the Euclidean distance method in the two-dimensional space in step 8 is:

[0056] D=min{d1,d2,d3,…},

[0057] Among them, d i It refers to the distance between two edge points from adjacent contour point sets;

[0058] In step 8, when calculating the shortest distance between two edge point sets, since the number of pins is large and the sub-pixel edge point set of each pin contains a large number of points, a divide-and-conquer method is used to calculate the shortest distance between the two sub-pixel edge point sets, and the shortest distance is calculated for the sub-pixel edge point sets of adjacent pins in turn.

[0059] The beneficial effects of the present invention are:

[0060] The present application provides a high-precision measurement method for lead frame pin spacing. After acquiring a reference image and an image to be measured, the reference image is processed and rotated to obtain a multi-angle high-level pyramid rotated template image and a corresponding mask. The template is then matched with the high-level pyramid image to be measured using a normalized cross-correlation matching method. The matching result is fused with the bottom-level pyramid image to be measured to obtain a pin image containing only the lead frame pin area. The pin image contours are detected and the edges of each contour are expanded to obtain a pin mask image. The pin mask image is fused with the image to be measured to obtain a coarse pin positioning image. Sub-pixel edge detection is performed on the coarse pin positioning image using a combination of adaptive thresholding and polynomial interpolation to obtain a set of sub-pixel edge points. The minimum distance between the edge point sets of adjacent contours is calculated to obtain the spacing between adjacent lead frame pins. Since the purpose of template matching is only to determine the area of ​​interest, using a high-level pyramid image for template matching can improve matching speed. Lead frame pin spacing measurement is achieved through machine vision image processing technology, replacing manual spot checks or full inspections, thereby improving efficiency. Sub-pixel edge detection is introduced to improve accuracy, which has the characteristic of high computational accuracy. BRIEF DESCRIPTION OF THE DRAWINGS

[0061] Figure 1 A flow chart of a high-precision measurement method for lead frame pin spacing provided by the present invention;

[0062] Figure 2 This is a partially enlarged schematic diagram of a pin image containing only lead frame pins;

[0063] Figure 3 It is a schematic diagram of a local magnification of the contour mask image, and Figure 2 Selected from the same region;

[0064] Figure 4 For use Figure 3 The result obtained by extracting the image to be tested from the mask area in ;

[0065] Figure 5 Schematic diagram of the enlarged image of the pin's sub-pixel coordinate point location. DETAILED DESCRIPTION

[0066] The present invention will be further described below with reference to the accompanying drawings and specific embodiments. It should be understood that the following specific embodiments are only used to illustrate the present invention and are not used to limit the scope of the present invention.

[0067] like Figure 1 The present invention provides a high-precision measurement method for lead frame pin spacing. The method uses machine vision image processing technology to achieve lead frame pin spacing measurement, replacing manual sampling or full inspection, improving efficiency, and meeting the requirements of high-precision measurement at the sub-pixel level. The specific steps are as follows:

[0068] Step 1: Obtain a reference image and a test image containing the lead frame and chip core by X-ray imaging. Both images are 8-bit grayscale images with a resolution of 1536*1536.

[0069] Step 2: Perform image preprocessing on the reference image in step 1 to obtain a kernel template image at the center of the reference image, and downsample the kernel template image twice to obtain a high-level pyramid template image;

[0070] Step 3: Perform image preprocessing and two consecutive downsampling processes on the image to be tested in step 1 to obtain a bottom pyramid image to be tested and a high pyramid image to be tested;

[0071] Step 4: Create a mask of the high-level pyramid template image in step 2, and rotate it with the high-level pyramid template image in the range of [-15°, 15°] to obtain a multi-angle high-level pyramid rotated template image and a corresponding multi-angle high-level pyramid rotated mask image;

[0072] Step 5: Coarse matching, the multi-angle high-level pyramid rotated template image in step 4 is matched with the high-level pyramid image to be tested in step 3 in sequence, and the bottom-level pyramid image to be tested in step 3 is processed according to the position coordinates and rotation angle of the maximum matching similarity to obtain a pin image containing only the lead frame pins, such as Figure 2 Here is a partial enlarged view;

[0073] Step 6: Process the pin image in step 5, and then extract its contours to obtain a contour set containing all pin contours in the pin image. Process each contour in the contour set in turn, including contour edge expansion, to obtain a contour mask image of each contour. Figure 2 The schematic diagram of the area is as follows Figure 3 ;

[0074] Step 7: Combined with the contour mask image, each pin in the image to be tested in step 1 is extracted separately, and its edge is detected using a sub-pixel edge detection method that combines adaptive thresholding and polynomial interpolation to obtain a set of sub-pixel coordinate points of each pin edge;

[0075] Step 8: Based on the sub-pixel coordinate point set in step 7, the spacing between adjacent pins is calculated using the Euclidean distance method in two-dimensional space.

[0076] Furthermore, the specific method of step 2 is:

[0077] Step 2-1: Threshold segmentation of the reference image in step 1 is performed. The grayscale threshold of the reference image is obtained using the maximum inter-class variance method. In this embodiment, the grayscale threshold is 128. The grayscale values ​​of pixels above the grayscale threshold are changed to 255, and the grayscale values ​​of pixels below the grayscale threshold are changed to 0, thereby obtaining a reference threshold segmented image.

[0078] Step 2-2: In this embodiment, the center of the reference threshold segmentation image in step 2-1 is cropped, and the cropping range is 230 pixels away from the periphery of the chip core to obtain a core template image;

[0079] Step 2-3: In step 2-2, the kernel template image is downsampled twice continuously. Specifically, the kernel template image is used as a bottom pyramid template image, odd rows and odd columns are extracted from the bottom pyramid template image to obtain a first-layer pyramid template image whose image size is 1 / 2 of the rows and columns of the bottom pyramid template image; odd rows and odd columns are extracted from the first-layer pyramid template image to obtain a second-layer pyramid template image whose image size is 1 / 2 of the rows and columns of the first-layer pyramid template image. The second-layer pyramid template image is the high-layer pyramid template image in this embodiment.

[0080] Furthermore, in step 3, the image to be tested in step 1 is subjected to image preprocessing and downsampling processing, wherein the image preprocessing method is consistent with the threshold segmentation step in step 2-1, and the processed image is used as the bottom pyramid image to be tested, wherein the grayscale threshold is calculated as 120 by the maximum inter-class variance method, and the downsampling processing method is consistent with the specific steps of the downsampling processing in step 2-3, to obtain the high-level pyramid image to be tested.

[0081] Furthermore, in step 4, the mask is created and the high-level pyramid template image is rotated, and the specific method is as follows:

[0082] Step 4-1: Create a mask of the high-level pyramid template image in step 2, define the area where the template image is located as the region of interest, and set the grayscale value of the region of interest in the mask to 1, and the grayscale value of the non-region of interest to 0. The non-region of interest does not participate in the matching calculation process;

[0083] Step 4-2: In this embodiment, in the image rotation of step 4, the rotation range is [-15°, 15°]; the rotation target is the high-level pyramid template image and the mask mask generated in step 4-1 corresponding to the rotation angle thereof. The grayscale value of the non-interested region in the rotated mask mask is 0 and does not participate in the template matching calculation; the step size of each rotation angle is (layer+1), where layer refers to the layer number of the current rotation target. For example, in the first layer, the step size of the rotation angle is 2; the high-level pyramid template image before rotation is used as the high-level pyramid rotated template image when the rotation angle is 0°, to obtain multi-angle high-level pyramid rotated template images and multi-angle high-level pyramid rotated mask images.

[0084] Furthermore, the specific steps of the rough matching in step 5 are:

[0085] Step 5-1: Match the high-level pyramid rotated template image in step 4 with the high-level pyramid image template in step 3 in the rotation range of [-15°, 15°], with a rotation angle step of 3°. Slide the high-level pyramid rotated template image on the high-level pyramid image in a window-like manner, calculate the matching degree at each position, and obtain the high-level best matching position (x0, y0) and rotation angle theta;

[0086] The matching degree is calculated using the normalized correlation coefficient method, and the formula is:

[0087]

[0088] Where R represents the matching degree, which ranges from [-1, 1], T represents the template image, S represents the image to be tested, m represents the grayscale average value of the subscript corresponding to the image, and (u, v) represents each coordinate point in the ROI area;

[0089] Step 5-2: Based on the best matching position (x0, y0) and rotation angle theta of the upper layer in step 5-1, and the number of downsampling times 2, the best matching position (4*x0, 4*y0) and rotation angle theta of the lower layer on the image to be tested in the lower pyramid in step 3 are obtained;

[0090] Step 5-3: Based on the bottom-level best matching position (4*x0, 4*y0) and the rotation angle theta obtained in step 5-2, the rectangular area of ​​the matching result on the bottom-level pyramid image to be tested can be obtained. The grayscale of the image within the rectangular area is set to 255, and the grayscale value of the rest of the image is set to 0. This will obtain a pin image containing only the lead frame pins, as shown in the figure below. Figure 2 As shown, it is a partial enlarged schematic diagram of the pin image, and the grayscale value of the blank area is 255.

[0091] Furthermore, in step 6, the contours of the pin image are extracted to obtain the number of contours in the image and the set of coordinate points of each contour. In this embodiment, the number of contours is 104. These 104 contours are edge-expanded in turn to obtain 104 contour mask images, which are then fused with the image to be tested in step 1 to obtain 104 pin regions of interest.

[0092] Furthermore, the image processing and contour processing operations in step 6 are specifically performed as follows:

[0093] Step 6-1: The image processing in step 6 is to perform a morphological erosion operation on the pin image in step 5-3, so that the white area in the pin image becomes narrower and the black area becomes wider. The kernel matrix size of the erosion operation is 5*5. Then, the grayscale value at the four edges of the eroded image is changed to 255, and the edge size is one pixel. Then, the contours of the processed image are extracted to obtain a set of 104 contours containing all the pin contours in the pin image.

[0094] Step 6-2: For each contour set in step 6-1, the grayscale inside the contour is set to 0 and the grayscale outside the contour is set to 230, so that the grayscale distribution outside the contour is uniform and grayscale step changes are avoided. The contour mask image of 104 contours is obtained. Figure 2 The schematic diagram of the area is as follows Figure 3 , the grayscale value of the blank area is 230;

[0095] In this embodiment, in order to ensure that two adjacent contours can be accurately positioned subsequently, all pin contours of the 104 contours should be sorted clockwise according to the center position of each contour.

[0096] Furthermore, in step 7, each pin region of the image to be tested in step 1 is extracted separately in combination with the contour mask image. Figure 4 Therefore Figure 3 This is the result of mask extraction. The grayscale value of the white area is 230. Then, sub-pixel edge detection is performed on the pin area. The specific steps of sub-pixel edge detection are as follows:

[0097] Step 7-1: Construct Sobel partial derivative operator templates in four directions: horizontal, vertical, 45 degrees, and 135 degrees. Compare the templates with the pin area to obtain gradient images in these four directions. Then, search for the maximum gradient and the corresponding gradient direction pixel by pixel in these four gradient images to obtain a pseudo-edge image.

[0098] The Sobel partial derivative operator template is as follows:

[0099]

[0100] P(x, y) represents the grayscale value of a pixel at a certain point (x, y). The calculation formulas for the gradients in each direction are as follows:

[0101] g1(x,y)=[P(x+1,y-1)+2*P(x+1,y)+P(x+1,y+1)]-[P(x-1,y-1)+2*P(x-1,y)+P(x-1,y+1)]

[0102] g2(x,y)=[P(x-1,y-1)+2*P(x,y-1)+P(x+1,y-1)]-[P(x-1,y+1)+2*P(x,y+1)+P(x+1,y+1)]

[0103] g3(x,y)=[P(x,y-1)+2*P(x+1,y-1)+P(x+1,y)]-[P(x-1,y)+2*P(x-1,y+1)+P(x,y+1)]

[0104] g4(x,y)=[P(x,y-1)+2*P(x-1,y-1)+P(x-1,y)]-[P(x,y+1)+2*P(x+1,y+1)+P(x+1,y)]

[0105] Among them, g i (x, y) represents the gradient at a point (x, y) after calculation by the i-th partial derivative operator template;

[0106] Step 7-2: In step 7-1, the maximum gradient and the corresponding gradient direction are calculated. Since the Sobel partial derivative operator template in four directions is used, the edge in the pseudo-edge image is not a single pixel point. If sub-pixel edge detection is required, only a single pixel edge is required. The pixel point (x, y) is judged to be the best edge point to obtain the best edge point set of the pseudo-edge image. The specific judgment method is as follows:

[0107] g(x0,y0)>=g(x1,y1)and g(x0,y0)>=g(x2,y2)

[0108] Among them, point (x0, y0) is the best edge point, point (x1, y1) and point (x2, y2) are two adjacent points along the gradient direction of point (x0, y0);

[0109] In this embodiment, in step 7-2, before determining whether it is the best edge point, the pseudo-edge image in step 7-1 should be screened using the adaptive threshold method and the non-maximum suppression method, and certain sudden interference points and weak edges should be filtered out using the minimum threshold and maximum threshold. The maximum threshold is adaptively determined to be 161 by using the maximum inter-class variance method on the pseudo-edge image, and the minimum threshold is 0.5 times the maximum threshold. The adaptive threshold makes the screening and filtering process of the edge points of each contour more targeted, and local pin areas with different brightness and contrast will have corresponding local thresholds.

[0110] Step 7-3: The optimal edge point set obtained in step 7-2 is fitted using a Lagrange polynomial interpolation method to obtain a sub-pixel edge point set, where the interpolation function is:

[0111]

[0112] Among them, x k is the interpolation point, y k is the discrete function value, (x i ,y i ) is an edge point;

[0113] The formula for solving sub-pixel coordinates is:

[0114]

[0115]

[0116] Among them, (x, y) is the sub-pixel edge point, R0 is the point (x i ,y i ), R1 and R2 are the grayscale amplitudes at point (x i ,y i ) The grayscale amplitude of the adjacent points along the gradient direction, where the grayscale amplitude is approximated by the gradient amplitude.

[0117] In this embodiment, Figure 4 For the pin area shown, the comparison table of the calculated sub-pixel coordinate point set and the coordinate point set obtained without using sub-pixel edge detection is as follows, taking the y-axis coordinate as an example:

[0118] P1 P2 P3 P4 P5 P6 P7 X-axis 1311 1312 1313 1314 1319 1327 1336 (Y-axis) pixel level 820 819 819 819 820 821 822 (Y axis) sub-pixel level 819.146 818.833 818.899 818.967 819.655 820.455 821.674

[0119] In this high-resolution image, the sub-pixel edge detection method can be used to obtain more accurate coordinate point positions. For easier observation, the image is magnified 10 times. The schematic diagram of the pin sub-pixel coordinate point position is shown in the figure below. Figure 5 shown.

[0120] Furthermore, the Euclidean distance method in the two-dimensional space in step 8 is:

[0121] D=min{d1,d2,d3,…},

[0122] Among them, d i It refers to the distance between two edge points from adjacent contour point sets;

[0123] In this embodiment, in step 8, when calculating the shortest distance between two edge point sets, since there are a large number of pins and the sub-pixel edge point set of each pin contains a large number of points, a divide-and-conquer method is used to calculate the shortest distance between the two sub-pixel edge point sets. The shortest distance is calculated for the sub-pixel edge point sets of adjacent pins in sequence.

[0124] The divide-and-conquer approach involves breaking a complex problem into two or more identical or similar subproblems, and then breaking each subproblem down into even smaller subproblems until the final subproblem can be solved directly. In this embodiment, each point from different contour point sets is first labeled and assigned a contour index. The divide-and-conquer approach is then applied to adjacent contour point sets, calculating the shortest distance and recording the point pairs that achieve the shortest distance.

[0125] It should be noted that the above content merely illustrates the technical idea of ​​the present invention and cannot be used to limit the scope of protection of the present invention. For ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present invention. These improvements and modifications all fall within the scope of protection of the claims of the present invention.

Claims

1. A high-precision measurement method for lead frame pin spacing, characterized in that: The following steps are involved: Step 1: Obtain a reference image and a test image containing a lead frame and a chip core by X-ray imaging; Step 2: Perform image preprocessing on the reference image in step 1 to obtain a kernel template image at the center of the reference image. Downsample the kernel template image 2 to 4 times to obtain a high-level pyramid template image. The specific method is as follows; Step 2-1: Threshold segmentation of the reference image in step 1 is performed. The grayscale threshold of the reference image is obtained using the maximum inter-class variance method. The grayscale values ​​of pixels above the grayscale threshold are changed to 255, and the grayscale values ​​of pixels above the grayscale threshold are changed to 0, thereby obtaining the reference threshold segmentation image. Step 2-2: Crop the center of the baseline threshold segmentation image in step 2-1, with the cropping range being 200 to 300 pixels away from the periphery of the chip core to obtain a core template image; Step 2-3: performing a downsampling process on the kernel template image in step 2-2 for 2 to 4 times continuously, specifically: using the kernel template image as the bottom pyramid template image, extracting odd rows and odd columns from the bottom pyramid template image to obtain a first-layer pyramid template image with an image size of 1 / 2 the rows and columns of the bottom pyramid template image; Extract odd rows and odd columns from the first-layer pyramid template image to obtain a second-layer pyramid template image with an image size of 1 / 2 the rows and columns of the first-layer pyramid template image; repeat the above operation 2-4 times to obtain a high-layer pyramid template image; Step 3: performing image preprocessing and continuous downsampling processing 2 to 4 times on the image to be tested in step 1 to obtain a bottom pyramid image to be tested and a high pyramid image to be tested; Perform image preprocessing and downsampling on the image to be tested in step 1, wherein the image preprocessing method is consistent with the threshold segmentation step in step 2-1, and the processed image is used as the bottom pyramid image to be tested. The downsampling method is consistent with the specific steps of the downsampling processing in step 2-3, to obtain a high-level pyramid image to be tested; Step 4: Create a mask of the high-level pyramid template image in step 2, and rotate it with the high-level pyramid template image in the range of [-20° to -10°, 10° to 20°] to obtain a multi-angle high-level pyramid rotated template image and a corresponding multi-angle high-level pyramid rotated mask image; Step 5: Coarse matching: template matching is performed on the multi-angle high-level pyramid rotated template image in step 4 and the high-level pyramid image to be tested in step 3. The best matching result is fused with the bottom-level pyramid image to be tested in step 3 to obtain a pin image containing only the lead frame pins. Step 6: Perform image processing on the pin image in step 5, and then extract its contours to obtain a contour set containing all pin contours in the pin image. Process each contour in the contour set in turn to obtain a contour mask image of each contour. Step 7: Combined with the contour mask image, perform edge detection on the image to be tested in step 1 using a sub-pixel edge detection method that combines adaptive thresholding and polynomial interpolation to obtain a set of sub-pixel coordinate points of each pin edge; Step 8: Based on the sub-pixel coordinate point set in step 7, the spacing between adjacent pins is calculated using the Euclidean distance method in two-dimensional space.

2. The high-precision measurement method for lead frame pin spacing according to claim 1, wherein: The reference image and the image to be measured in step 1 are high-resolution grayscale images of the lead frame and the chip core obtained by X-ray imaging.

3. The high-precision measurement method for lead frame pin spacing according to claim 1, wherein: In step 4, the mask is made and the high-level pyramid template image is rotated. The specific method is: Step 4-1: Create a mask of the high-level pyramid template image in step 2, define the area where the template image is located as the region of interest, and set the grayscale value of the region of interest in the mask to 1, and the grayscale value of the non-region of interest to 0; Step 4-2: In the image rotation of step 4, the rotation range is [-20° to -10°, 10° to 20°]; the rotation target is the high-level pyramid template image and the mask mask produced in step 4-1 corresponding to the rotation angle thereof; the grayscale value of the non-interested region in the rotated mask mask is 0 and does not participate in the template matching calculation; the step size of each rotation angle is (layer+1), where layer refers to the layer number of the current rotation target; the high-level pyramid template image before rotation is used as the high-level pyramid rotated template image when the rotation angle is 0°.

4. The high-precision measurement method for lead frame pin spacing according to claim 1, wherein: The specific steps of the rough matching in step 5 are: Step 5-1: Match the high-level pyramid rotated template image in step 4 with the high-level pyramid image template in step 3 in the rotation range of [-20° to -10°, 10° to 20°] in sequence. The rotation angle step size is (layer+1). The high-level pyramid rotated template image slides on the high-level pyramid image in a window-like manner. The matching degree at each position is calculated to obtain the high-level best matching position (x0, y0) and rotation angle theta. The matching degree is calculated using the normalized correlation coefficient method, and the formula is: Where R represents the matching degree, which ranges from [-1, 1], T represents the template image, S represents the image to be tested, m represents the grayscale average value of the subscript corresponding to the image, and (u, v) represents each coordinate point in the ROI area; Step 5-2: According to the best matching position (x0, y0) and the rotation angle theta in step 5-1, the best matching position (2 L *x0,2 L *y0) and the rotation angle theta, where L refers to the specific layer of the high-level pyramid template image; Step 5-3: According to the bottom best matching position (2 L *x0,2 L *y0) and the rotation angle theta, obtain the rectangular area of ​​the matching result on the bottom pyramid image to be tested, set the image grayscale of the rectangular area to 255, and obtain the pin image containing only the lead frame pins.

5. The high-precision measurement method for lead frame pin spacing according to claim 4, characterized in that: The image processing and contour processing operations in step 6 are specifically performed as follows: Step 6-1: The image processing in step 6 is to perform a morphological erosion operation on the pin image in step 5-3, so that the white area in the pin image becomes narrower and the black area becomes wider. The kernel matrix size of the erosion operation is 5*5. Then, the grayscale value at the four edges of the eroded image is changed to 255, and the edge size is one pixel. Then, the contour of the image after image processing is extracted to obtain a contour set containing all the pin contours in the pin image. Step 6-2: The processing of the contour set in step 6-1 is to set the grayscale inside the contour to 0 and the grayscale outside the contour to between 220 and 240, so that the grayscale distribution of the outer part of the contour is uniform and avoid grayscale step changes, and obtain the contour mask image of each contour; sort all pin contours in a clockwise order according to the center position of each contour.

6. The high-precision measurement method for lead frame pin spacing according to claim 1, wherein: In step 7, each pin region of the image to be tested in step 1 is extracted separately in combination with the contour mask image, and then sub-pixel edge detection is performed on the pin region. The sub-pixel edge detection specifically comprises the following steps: Step 7-1: Construct Sobel partial derivative operator templates in four directions: horizontal, vertical, 45 degrees, and 135 degrees. Compare the templates with the pin area to obtain gradient images in these four directions. Then, search for the maximum gradient and the corresponding gradient direction pixel by pixel in these four gradient images to obtain a pseudo-edge image. The Sobel partial derivative operator template is as follows: P(x, y) represents the grayscale value of a pixel at a certain point (x, y). The calculation formulas for the gradients in each direction are as follows: g1(x,y)=[P(x+1,y-1)+2*P(x+1,y)+P(x+1,y+1)]-[P(x-1,y-1)+2*P(x-1,y)+P(x-1,y+1)] g2(x,y)=[P(x-1,y-1)+2*P(x,y-1)+P(x+1,y-1)]-[P(x-1,y+1)+2*P(x,y+1)+P(x+1,y+1)] g3(x,y)=[P(x,y-1)+2*P(x+1,y-1)+P(x+1,y)]-[P(x-1,y)+2*P(x-1,y+1)+P(x,y+1)] g4(x,y)=[P(x,y-1)+2*P(x-1,y-1)+P(x-1,y)]-[P(x,y+1)+2*P(x+1,y+1)+P(x+1,y)] Among them, g i (x, y) represents the gradient at a point (x, y) after calculation by the i-th partial derivative operator template; Step 7-2: In step 7-1, the maximum gradient and the corresponding gradient direction are calculated. Since the Sobel partial derivative operator template in four directions is used, the edge in the pseudo-edge image is not a single pixel point. If sub-pixel edge detection is required, only a single pixel edge is required. The pixel point (x, y) is judged to be the best edge point to obtain the best edge point set of the pseudo-edge image. The specific judgment method is as follows: g(x0,y0)>=g(x1,y1)and g(x0,y0)>=g(x2,y2) Among them, point (x0, y0) is the best edge point, point (x1, y1) and point (x2, y2) are two adjacent points along the gradient direction of point (x0, y0); In step 7-2, before determining whether it is the best edge point, the pseudo-edge image in step 7-1 should be screened using the adaptive threshold method and the non-maximum suppression method, and certain sudden interference points and weak edges should be filtered out using the minimum threshold and maximum threshold. The maximum threshold is adaptively determined by using the maximum inter-class variance method on the pseudo-edge image, and the minimum threshold is between 0.4 and 0.6 times the maximum threshold. The adaptive threshold makes the screening and filtering process of the edge points of each contour more targeted, and local pin areas with different brightness and contrast will have corresponding local thresholds. Step 7-3: The optimal edge point set obtained in step 7-2 is fitted using a Lagrange polynomial interpolation method to obtain a sub-pixel edge point set, where the interpolation function is: Among them, x k is the interpolation point, y k is the discrete function value, (x i ,y i ) is an edge point; The formula for solving sub-pixel coordinates is: Among them, (x, y) is the sub-pixel edge point, R0 is the point (x i ,y i ), R1 and R2 are the grayscale amplitudes at point (x i ,y i ) The grayscale amplitude of the adjacent points along the gradient direction, where the grayscale amplitude is approximated by the gradient amplitude.

7. The high-precision measurement method for lead frame pin spacing according to claim 1, wherein: The Euclidean distance method in the two-dimensional space in step 8 is: Among them, d i It refers to the distance between two edge points from adjacent contour point sets; In step 8, when calculating the shortest distance between two edge point sets, since the number of pins is large and the sub-pixel edge point set of each pin contains a large number of points, a divide-and-conquer method is used to calculate the shortest distance between the two sub-pixel edge point sets, and the shortest distance is calculated for the sub-pixel edge point sets of adjacent pins in turn.