Lead frame multi-scale plastic package defect detection method and system
Patent Information
- Application Number
- CN202611436073.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-16
- Publication Date
- 2026-10-20
AI Technical Summary
该方式能够根据待检测区域的大小调整检测尺度,但是其检测尺度主要依据已经获得的感兴趣区域尺寸确定,并未利用被检测对象正常结构本身的几何关系建立统一的结构尺度基准,因此不同检测尺度之间缺少共同的结构参照
1.本发明基于塑封边界、引线位置及结构间距建立结构尺度基准,并据此确定各塑封结构区域的检测尺度,使检测尺度与引线框架实际塑封结构相匹配,提高不同尺度塑封缺陷的表征准确性。
Smart Images

Figure FT_1 
Figure FT_2
Abstract
Description
Technical Field
[0001] This invention relates to the field of image processing and defect detection technology, and in particular to a method and system for detecting multi-scale molding defects in lead frames. Background Technology
[0002] The leadframe is a crucial structural component in semiconductor packaging, used to support the chip and connect its internal circuitry to external electrical components. During the molding process, the chip, bonding structure, and portions of the leadframe are encapsulated with molding material to form a package, retaining exposed leads or functional areas. Influenced by factors such as molding material filling, mold condition, demolding, and subsequent transport processes, the molded leadframe may exhibit surface defects such as abnormal molding edges, localized defects, excess adhesive, burrs, surface depressions, scratches, cracks, and foreign matter. Different defects vary in size, shape, grayscale changes, and their position relative to the molding boundary; therefore, accurate identification and defect localization of the molded area are necessary during packaging quality inspection. With the reduction in semiconductor package size and the increasing sophistication of leadframe structures, manual visual inspection is insufficient to consistently meet the efficiency and consistency requirements of online inspection. Utilizing industrial cameras to acquire images of the molded leadframe and performing automatic defect detection through image processing has become an important technical method for quality inspection.
[0003] Patent CN118052817A discloses a method and system for detecting surface defects in lead frames. It obtains shallow and deep features by downsampling lead frame images, performs defect detail enhancement and defect semantic enhancement respectively, and fuses features from different levels to obtain comprehensive defect features and determine surface defects in the lead frame. This method can represent defect information at different scales using features from different levels. However, each detection scale is mainly determined by a preset feature extraction level, and there is a lack of correspondence between the detection scale and specific structural locations such as the molding boundary, the interior of the molding body, and the adjacent area of the lead. Therefore, different structural regions are still processed according to a preset scale system.
[0004] For example, patent CN116385414A discloses a method for extracting multi-scale defect features of components. This method determines the size of a corresponding feature window based on the size of the region of interest (ROI) and uses the determined window to extract defect features. While this method can adjust the detection scale according to the size of the region to be detected, its detection scale is primarily determined based on the already obtained ROI size. It does not utilize the geometric relationships of the normal structure of the object being inspected to establish a unified structural scale benchmark. Therefore, there is a lack of common structural reference between different detection scales. When normal structural edges, localized reflections, and actual molding defects may all produce abnormal responses at different scales, adjusting the detection scale solely based on the region size still makes it difficult to determine whether the same anomaly maintains a spatial correspondence consistent with the molding structure at different scales.
[0005] Therefore, how to establish a unified structural scale benchmark based on the structural characteristics of the lead frame encapsulation area itself, and use the structural scale benchmark to simultaneously constrain the determination of the detection scale and the corresponding judgment of abnormal areas under different detection scales, so as to improve the detection accuracy of encapsulation defects at different scales, has become an urgent problem to be solved. Summary of the Invention
[0006] To address the shortcomings of existing technologies, the present invention aims to provide a method and system for detecting multi-scale molding defects in lead frames. This method establishes a unified structural scale benchmark based on the structural characteristics of the lead frame molding area, and utilizes this benchmark to simultaneously constrain the determination of the detection scale and the corresponding judgment of abnormal regions at different detection scales, thereby improving the detection accuracy of molding defects at different scales. To solve the above technical problem, the present invention provides the following technical solution: A first aspect of the present invention relates to a method for detecting multi-scale molding defects in lead frames, comprising the following steps: S1. Obtain the plastic encapsulation image of the lead frame, determine the plastic encapsulation boundary and lead position, divide the plastic encapsulation structure region according to the spatial correspondence between the plastic encapsulation boundary and the lead position, and obtain the plastic encapsulation structure region information; S2. Extract the structural spacing between the corresponding boundary segment and the inner boundary of each plastic-encapsulated structure region from the plastic-encapsulated structure region information, and determine the structural scale benchmark from the structural spacing; S3. Using the structural scale benchmark as a reference, set the detection scale of the corresponding plastic sealing structure area according to the progressive change of the spatial coverage range to form a detection scale sequence, and extract the area image corresponding to each detection scale to obtain a multi-scale detection image. S4. Compare the grayscale continuity and edge integrity of the multi-scale detection image and extract abnormal image regions to obtain abnormal candidate regions; S5. Map the abnormal candidate region to the lead frame molding image, use the structural scale benchmark to associate the abnormal candidate regions corresponding to the same molding structure position in the detection scale sequence, compare the spatial position and contour range of the associated region under adjacent detection scales, and record the continuity state between scales to obtain the cross-scale continuity relationship. S6. Based on the cross-scale continuous relationship, filter out abnormal candidate regions that maintain the corresponding and continuous existence of the structural position, determine the location of the molding defect, and obtain the detection result of the molding defect of the lead frame.
[0007] Further, step S1 includes: Extract the molding material image region from the lead frame molding image, and define the molding boundary along the outer contour of the molding material image region; Extract the lead image regions not covered by the encapsulation material image region, and obtain the position range and extension direction of each lead image region; Extend the two side boundaries along the extension direction of each lead image area until they intersect with the plastic encapsulation boundary, and determine the plastic encapsulation boundary between the two intersection points as the lead corresponding boundary segment at the lead position; The molding boundary is divided according to the boundary segment corresponding to the lead and the boundary interval segment between adjacent lead boundary segments, and each boundary segment is extended along the interior direction of the molding material image area to form the molding structure area, thus obtaining the molding structure area information.
[0008] Further, step S2 includes: Obtain the boundary segments corresponding to each molding structure region, as well as the inner boundary of the region opposite to the corresponding boundary segment in the molding structure region; Measurement positions are selected sequentially along the boundary segment, and the interval distance is measured at each measurement position along the normal direction of the boundary segment toward the inner boundary of the region to obtain the structural spacing of the corresponding plastic-encapsulated structure region. The structural spacing is recorded according to the arrangement order of each measurement position on the boundary section to form a structural spacing sequence; The median structural spacing of the structural spacing sequence is extracted as the reference value of the corresponding encapsulated structural region, and the reference value is associated with the position of the corresponding encapsulated structural region to form a structural dimensional reference.
[0009] Further, step S3 includes: Read the position and corresponding reference value of each plastic-encapsulated structural region in the structural dimensional reference, and use the center position of the corresponding boundary segment as the detection anchor point; The coverage scale along the boundary extension direction is defined by the length of the boundary segment, and the coverage scale along the boundary normal direction is defined by the reference value, thus forming a reference detection scale for the corresponding plastic-encapsulated structure area. Keeping the detection anchor points unchanged, the coverage scale along the boundary extension direction and the boundary normal direction are increased synchronously to form a detection scale sequence arranged according to the spatial coverage range; Based on the spatial coverage defined by each detection scale in the detection scale sequence, the corresponding region image is extracted from the lead frame encapsulation image, and the region image is organized according to the arrangement order of the detection scales to obtain a multi-scale detection image.
[0010] Further, step S4 includes: Read the region image corresponding to each detection scale according to the detection scale sequence, and maintain the correspondence between the region image and the corresponding detection scale and the encapsulation structure region; Traverse the image positions along the extension direction and normal direction of the corresponding boundary segment in each region image, compare the gray-level changes of adjacent image positions, extract the image positions where gray-level continuity is interrupted, and obtain the gray-level abnormal positions. Local image edges formed by grayscale changes are extracted from the image of each region. The continuity of adjacent edge positions is compared along the extension direction of the local image edges. The image positions where the continuity of the edge is interrupted are extracted to obtain the edge anomaly positions. Within the region image corresponding to the same detection scale, spatially adjacent gray-level anomaly locations and edge anomaly locations are merged into connected regions according to pixel adjacency to form anomaly image regions. The anomaly image regions are then associated with the corresponding detection scale and encapsulation structure regions to obtain anomaly candidate regions.
[0011] Further, step S5 includes: Based on the extraction positions of each region image in the lead frame encapsulation image, the abnormal candidate regions are transformed to the corresponding positions in the lead frame encapsulation image to obtain candidate mapping regions; Using the boundary segment of the corresponding encapsulated structure region as the position reference along the boundary extension direction, and using the reference value of the corresponding encapsulated structure region in the structural scale reference as the scale reference along the boundary normal direction, the position range of each candidate mapping region along the boundary extension direction is obtained, and the position range of each candidate mapping region along the boundary normal direction is calibrated according to the reference value. According to the arrangement order of the detection scale sequence, the candidate mapping regions under adjacent detection scales are compared. The candidate mapping regions that overlap in both the position range along the boundary extension direction and the position range along the boundary normal direction as indicated by the reference value are determined as corresponding to the same plastic encapsulation structure position, forming a cross-scale matching region pair. Compare the spatial position and contour range of two candidate mapping regions in each cross-scale matching region pair. When the two candidate mapping regions maintain the same corresponding position of the plastic encapsulation structure, it is recorded as a continuous state. When the two candidate mapping regions no longer maintain the same corresponding position of the plastic encapsulation structure, it is recorded as a terminated state. The continuous state or the terminated state is taken as the inter-scale continuation state. By associating cross-scale matching region pairs corresponding to the same plastic encapsulation structure position along the detection scale sequence, and recording the detection scale corresponding to the continuous position of the abnormal candidate region and its inter-scale continuity state, a cross-scale continuity relationship is obtained.
[0012] Further, step S6 includes: Extract each pair of cross-scale matching regions that continuously correspond to the same plastic encapsulation structure position along the detection scale sequence from the cross-scale persistence relationship, and connect them sequentially according to the arrangement order of the detection scale sequence to form an abnormal persistence chain; Based on the inter-scale continuity status of each group of cross-scale matching region pairs in the abnormal persistence chain, each abnormal candidate region that maintains positional continuity under multiple consecutive detection scales is selected to form a continuous abnormal candidate region group. Obtain the contour range of the candidate mapping region corresponding to each abnormal candidate region in the continuous abnormal candidate region group in the lead frame molding image, and determine the location of the molding defect by the common overlapping area of the contour range of each candidate mapping region. By associating the location of the molding defect with the corresponding molding structure area, the detection result of the lead frame molding defect is obtained.
[0013] A second aspect of the present invention relates to a multi-scale molding defect detection system for leadframes, comprising: The structural region segmentation module is used to acquire the lead frame molding image, determine the molding boundary and lead position, and divide the molding structure region according to the spatial correspondence between the molding boundary and the lead position to obtain molding structure region information. The scale reference construction module is used to extract the structural spacing between the corresponding boundary segment and the inner boundary of each plastic-encapsulated structure region from the plastic-encapsulated structure region information, and to determine the structural scale reference by the structural spacing. The scale sequence generation module is used to set the detection scale of the corresponding plastic encapsulation structure region according to the progressive change of the spatial coverage, with the structural scale benchmark as a reference, to form a detection scale sequence, and to extract the region image corresponding to each detection scale to obtain a multi-scale detection image. An anomaly region extraction module is used to compare the grayscale continuity and edge integrity of the multi-scale detection image and extract anomaly image regions to obtain anomaly candidate regions; The cross-scale association module is used to map the anomaly candidate region to the lead frame molding image, associate the anomaly candidate region corresponding to the same molding structure position in the detection scale sequence using the structural scale benchmark, compare the spatial position and contour range of the associated region under adjacent detection scales, and record the continuity state between scales to obtain the cross-scale continuity relationship. The defect determination module is used to filter out abnormal candidate regions that maintain the corresponding and continuous existence of the structural position based on the cross-scale continuous relationship, determine the location of the molding defect, and obtain the detection result of the molding defect of the lead frame.
[0014] A third aspect of the present invention relates to an electronic device comprising: processor; Memory used to store processor-executable instructions; The processor is configured to invoke instructions stored in the memory to execute the aforementioned method.
[0015] A fourth aspect of the present invention relates to a computer-readable storage medium having stored thereon computer program instructions that, when executed by a processor, implement the aforementioned method.
[0016] Compared with the prior art, the present invention has the following beneficial effects: 1. This invention establishes a structural dimensional benchmark based on the molding boundary, lead wire position, and structural spacing, and determines the detection scale of each molding structural region accordingly, so that the detection scale matches the actual molding structure of the lead wire frame, thereby improving the accuracy of characterization of molding defects at different scales.
[0017] 2. This invention utilizes structural scale benchmarks to associate abnormal candidate regions corresponding to the same molding structure location at different detection scales, and determines the location of molding defects based on cross-scale continuity relationships, thereby reducing the impact of single-scale abnormal responses on detection results and improving the accuracy of molding defect detection and location. Attached Figure Description
[0018] Figure 1 This is a flowchart illustrating a multi-scale molding defect detection method for leadframes according to an embodiment of the present invention. Figure 2 This is a functional block diagram of a multi-scale molding defect detection system for lead frames provided in an embodiment of the present invention. Detailed Implementation
[0019] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions in the embodiments of this invention will be described more clearly and completely below. Obviously, the described embodiments are only some embodiments of this invention, and not all embodiments. Based on the embodiments of this invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this invention.
[0020] Reference Figure 1 The diagram shown is a flowchart illustrating a multi-scale molding defect detection method for leadframes according to an embodiment of the present invention. In this embodiment, the multi-scale molding defect detection method for leadframes includes: S1. Obtain the plastic encapsulation image of the lead frame, determine the plastic encapsulation boundary and lead position, divide the plastic encapsulation structure region according to the spatial correspondence between the plastic encapsulation boundary and the lead position, and obtain the plastic encapsulation structure region information; In this embodiment of the invention, step S1 includes: Extract the molding material image region from the lead frame molding image, and define the molding boundary along the outer contour of the molding material image region; Extract the lead image regions not covered by the encapsulation material image region, and obtain the position range and extension direction of each lead image region; Extend the two side boundaries along the extension direction of each lead image area until they intersect with the plastic encapsulation boundary, and determine the plastic encapsulation boundary between the two intersection points as the lead corresponding boundary segment at the lead position; The molding boundary is divided according to the boundary segment corresponding to the lead and the boundary interval segment between adjacent lead boundary segments, and each boundary segment is extended along the interior direction of the molding material image area to form the molding structure area, thus obtaining the molding structure area information.
[0021] In one optional embodiment, the image acquisition device is fixedly installed above the molding station and employs at least one of an industrial area array camera, a fixed-focus or telecentric lens, and a diffuse coaxial light source and a dome light source. The camera's optical axis, working distance, exposure time, and light source brightness remain constant during the same batch of inspections. The camera's object-side pixel resolution is determined according to the minimum defect width to be inspected, ensuring that the minimum defect width covers at least three consecutive pixels in the original lead frame molding image. Unloaded dark-field images and uniform white-field images are acquired. Dark-field subtraction and white-field correction are performed on the original grayscale, and the correction results are linearly mapped to a uniform grayscale range to reduce illumination unevenness and sensor response differences.
[0022] The extraction of the molding material image region employs a joint determination using grayscale statistics and local texture statistics: First, based on the grayscale histogram of the corrected image, the initial segmentation threshold between the molding material and the exposed metal is obtained using the Otsu's method. Then, the grayscale variance within the neighborhood of each image location is calculated as a texture continuity measure. Only adjacent positions whose grayscale category belongs to the molding material and whose neighborhood grayscale variance is not higher than the texture threshold determined by the quartile values of the normal samples in the same batch are grouped as molding material candidate regions. Closure operations are performed on the candidate regions to connect local breaks with a width not greater than two pixels and fill small holes surrounded by continuous molding regions. For regions where the grayscale reaches the saturation range or the local gradient simultaneously exceeds the reflectivity threshold, they are first recorded in a reflectivity mask and do not participate in molding boundary tracking. Then, continuous boundary interpolation is performed using the effective molding pixels around the reflectivity mask. If a closed outer contour cannot be formed after interpolation, the current image is recorded as an acquisition anomaly and re-acquired, without being included in subsequent structural scale calculations.
[0023] Image positions and corresponding pixel representations are read line by line from the lead frame encapsulation image. The grayscale representation and texture continuity difference between the continuous coverage area of the encapsulation material and the exposed metal area are used as the distinction criteria. Adjacent image positions with consistent encapsulation material image representations are continuously grouped together, and the exposed lead background area located outside the continuous area is excluded. The continuously grouped image positions constitute the encapsulation material image area. Then, the outermost continuous image positions of the encapsulation material image area are sequentially traced to ensure that adjacent outer positions are continuously arranged according to the actual connection order in the image. The closed outer contour is used as the boundary between the encapsulation material image area and the external area, thereby defining the encapsulation boundary.
[0024] In the lead frame encapsulation image, the positions of the metal lead images located outside the encapsulation material image area and connected to the edge of the encapsulation material image area are read. Adjacent metal image positions with continuous grayscale representation and extending outwards along a fixed direction are grouped into the same lead image area. The outermost image position contained in each lead image area is taken as the position range of the corresponding lead image area. Then, the middle positions located between the two boundaries of each lead image area are continuously obtained along the length direction of each lead image area. The arrangement direction of the continuous middle positions is taken as the extension direction of the corresponding lead image area, thereby obtaining the position range and extension direction of each lead image area.
[0025] Continue extending the two side boundaries of the corresponding lead image area along the extension direction of each lead image area, so that the two extension boundaries advance from the exposed lead side toward the encapsulation material image area, and check the contact relationship between the extension boundary and the encapsulation boundary at each position. An intersection point is formed at the position where each extension boundary first reaches the encapsulation boundary. According to the continuous arrangement of the encapsulation boundary itself, the boundary portion corresponding to the lead image area between the two intersection points is cut off, and the boundary portion is associated with the corresponding lead position, thereby obtaining the lead-corresponding boundary segment of the lead position.
[0026] According to the arrangement order of the boundary segments corresponding to each lead along the molding boundary, the unoccupied portion of the molding boundary between two adjacent boundary segments corresponding to each lead is identified, and this portion of the molding boundary is used as a boundary interval segment. The boundary segments corresponding to the leads and the boundary interval segments together complete the continuous segmentation of the molding boundary. Then, the direction of each boundary segment towards the interior of the molding material image area and away from the molding boundary is used as the extension direction, and the corresponding boundary segments are continuously extended into the interior of the molding material image area, so that the image positions formed by the extension of the same boundary segment are included in the same planar range. The boundary position between the planar ranges formed by the extension of adjacent boundary segments is used as the region separation, forming a molding structure region corresponding to each boundary segment. Finally, the boundary segment, region position, region range and corresponding lead position of each molding structure region are recorded to obtain the molding structure region information.
[0027] During the formation of the area, each boundary segment serves as the initial boundary, and the corresponding image position is expanded layer by layer along the normal direction toward the interior of the molding material image area. When the expansion front of an adjacent boundary segment first reaches the same image position, the shortest image distance from that image position to the adjacent boundary segment is compared. The side with the shorter distance is taken as the region to which the image position belongs, and image positions with equal distances are recorded as the common boundary positions of adjacent molding structure regions. Each boundary segment continues to expand until all image positions within the molding material image area have been assigned, and then the expansion stops. The common boundary positions that connect with other molding structure regions continuously form the inner boundary of the corresponding molding structure region, so that each molding structure region has a unique corresponding boundary segment and inner boundary of the region.
[0028] Therefore, by dividing the plastic-encapsulated structure area according to the spatial correspondence between the plastic-encapsulated boundary and the lead wire position, the subsequent detection object corresponds to the actual plastic-encapsulated structure of the lead wire frame, providing a clear spatial basis for structural spacing extraction and scale determination.
[0029] S2. Extract the structural spacing between the corresponding boundary segment and the inner boundary of each plastic-encapsulated structure region from the plastic-encapsulated structure region information, and determine the structural scale benchmark from the structural spacing; In this embodiment of the invention, step S2 includes: Obtain the boundary segments corresponding to each molding structure region, as well as the inner boundary of the region opposite to the corresponding boundary segment in the molding structure region; Measurement positions are selected sequentially along the boundary segment, and the interval distance is measured at each measurement position along the normal direction of the boundary segment toward the inner boundary of the region to obtain the structural spacing of the corresponding plastic-encapsulated structure region. The structural spacing is recorded according to the arrangement order of each measurement position on the boundary section to form a structural spacing sequence; The median structural spacing of the structural spacing sequence is extracted as the reference value of the corresponding encapsulated structural region, and the reference value is associated with the position of the corresponding encapsulated structural region to form a structural dimensional reference.
[0030] The region range and corresponding boundary segments of each molding structure region are read from the molding structure region information. The boundary that constitutes the molding structure region and is located on the outer side of the molding material image region is taken as the corresponding boundary segment. Then, the boundary composition of the region is checked along the extension direction of the molding structure region from the corresponding boundary segment toward the interior of the molding material image region. The boundary that is located on both sides of the molding structure region with the corresponding boundary segment and restricts the region from continuing to extend inward is taken as the inner boundary of the region. The corresponding boundary segment and the inner boundary of the region together define the structural width of the molding structure region along the inward extension direction, and maintain the positional association between the two and the corresponding molding structure region.
[0031] Measurement positions are sequentially selected from one end to the other along the boundary segment, so that each measurement position is continuously distributed according to its arrangement order on the boundary segment. At each measurement position, the adjacent boundary positions before and after the position are read, and the local extension direction of the boundary segment at the measurement position is obtained from their arrangement direction. Then, the direction perpendicular to the local extension direction and towards the inner boundary of the corresponding region is selected as the normal direction of the measurement position. The image positions are continuously passed from the measurement position into the interior of the encapsulated structure region along the normal direction until the inner boundary of the region is reached. The image distance between the measurement position and the inner boundary of the region is recorded, and the image distance is used as the structural spacing corresponding to the measurement position. The structural spacing of the corresponding encapsulated structure region is obtained from the structural spacing corresponding to all measurement positions.
[0032] In this embodiment, five measurement positions are selected for each boundary segment. The boundary segment is divided into six equal-length intervals according to its arc length, and the five inner division points are used as measurement positions in sequence, so that adjacent measurement positions have the same boundary arc length interval and the two ends of the boundary segment are not used as measurement positions. When the inner division point is located at the boundary turning point, it is moved along the arrangement direction of the boundary segment to the image position adjacent to the inner division point and having a unique local extension direction as the alternative measurement position.
[0033] The normal direction at each measurement position is determined by the direction of the line connecting the adjacent boundary positions before and after the measurement position, and is taken as the direction that faces the inside of the molding material image area and is perpendicular to the local extension direction. When multiple intersections are formed with the inner boundary of the area along the normal direction, the first intersection point reached from the measurement position into the inside of the molding material image area is taken as the measurement endpoint. When no intersection is formed with the inner boundary of the area along the normal direction, the current measurement position is canceled, and the image position closest to the current measurement position and capable of forming an intersection with the inner boundary of the area is selected as the alternative measurement position between the current measurement position and the adjacent valid measurement positions, so that the number of measurement positions participating in the establishment of the structural spacing sequence is kept to five.
[0034] Maintaining the correspondence between each structural spacing and the original measurement position, the structural spacing is recorded sequentially from one end of the boundary segment to the other according to the arrangement order of the measurement positions. This ensures that each structural spacing maintains the same front-to-back positional relationship as its measurement position in the recording order. All structural spacings recorded in sequence within the same encapsulated structural area are then compiled into a structural spacing sequence. This allows the structural spacing sequence to simultaneously reflect the normal direction spacing of the corresponding encapsulated structural area at different positions along the boundary segment, as well as the arrangement relationship of each structural spacing on the boundary segment.
[0035] All structural spacings in the structural spacing sequence of the same encapsulated structural region are rearranged in ascending order of value. When selecting measurement positions, the number of structural spacings is kept odd. The structural spacing at the center position after sorting is read as the median structural spacing. The median structural spacing is used as the reference value for the corresponding encapsulated structural region. The reference value is then associated with the position of the encapsulated structural region in the lead frame encapsulation image, so that each encapsulated structural region has a reference value corresponding to its own structural spacing. The position of each encapsulated structural region and its corresponding reference value are recorded together to form a structural scale reference.
[0036] Therefore, by measuring the structural spacing between the corresponding boundary segments and the inner boundary of each plastic-encapsulated structure area and forming a structural dimensional benchmark, the subsequent inspection scale can be determined based on the actual geometric scale of the plastic-encapsulated structure itself.
[0037] S3. Using the structural scale benchmark as a reference, set the detection scale of the corresponding plastic sealing structure area according to the progressive change of the spatial coverage range to form a detection scale sequence, and extract the area image corresponding to each detection scale to obtain a multi-scale detection image. In this embodiment of the invention, step S3 includes: Read the position and corresponding reference value of each plastic-encapsulated structural region in the structural dimensional reference, and use the center position of the corresponding boundary segment as the detection anchor point; The coverage scale along the boundary extension direction is defined by the length of the boundary segment, and the coverage scale along the boundary normal direction is defined by the reference value, thus forming a reference detection scale for the corresponding plastic-encapsulated structure area. Keeping the detection anchor points unchanged, the coverage scale along the boundary extension direction and the boundary normal direction are increased synchronously to form a detection scale sequence arranged according to the spatial coverage range; Based on the spatial coverage defined by each detection scale in the detection scale sequence, the corresponding region image is extracted from the lead frame encapsulation image, and the region image is organized according to the arrangement order of the detection scales to obtain a multi-scale detection image.
[0038] The positions of each encapsulated structural region in the lead frame encapsulation image and the corresponding reference values of the encapsulated structural regions are read from the structural scale reference. The corresponding boundary segments are retrieved according to the positions of the encapsulated structural regions. The boundary segments are traversed from one end to the other in a continuous arrangement order of boundary positions. The boundary position that is arranged to the middle of the boundary segment is taken as the center position of the corresponding boundary segment. The center position is then established as a correspondence between the position and reference value of the corresponding encapsulated structural region. The center position is used as the detection anchor point that remains unchanged for each subsequent detection scale.
[0039] The length of the boundary segment between its two ends is obtained along the continuous direction of the boundary segment. This boundary length is used as the scale basis for coverage in both directions along the boundary extension direction with the detection anchor point as the center. At the same time, the reference value of the corresponding plastic-encapsulated structure area in the structural scale reference is read. This reference value is used as the scale basis for covering the plastic-encapsulated structure area along the boundary normal direction with the detection anchor point as the starting reference. This establishes a correspondence between the coverage scale in the boundary extension direction and the actual length of the corresponding boundary segment, and a correspondence between the coverage scale in the boundary normal direction and the actual structural spacing of the corresponding plastic-encapsulated structure area. The coverage scales in both directions are used together as the reference detection scale for the corresponding plastic-encapsulated structure area.
[0040] Keeping the position of the detection anchor point unchanged in the lead frame encapsulation image, the reference detection scale is used as the starting scale. The coverage scale is increased simultaneously along the boundary extension direction and the boundary normal direction in an arrangement that increases outward from the current spatial coverage range. This ensures that each scale change expands the corresponding spatial coverage range in both directions, while maintaining the complete inclusion of the image position covered by the previous detection scale in the subsequent detection scale. The detection scales formed in each step are arranged in the order of expansion of spatial coverage range from the reference detection scale outward, so that each detection scale is associated with the corresponding encapsulation structure area and the detection anchor point, forming a sequence of detection scales arranged according to spatial coverage range.
[0041] To ensure that the detection scale sequence has a definite generation relationship, the first... The coverage scale of the level detection scale along the boundary extension direction and the boundary normal direction is related as follows: ; ; in, The coverage scale is the reference detection scale along the boundary extension direction, and the length of the corresponding boundary segment is taken. The coverage scale along the boundary normal direction is used as the reference detection scale, and the reference value for the corresponding plastic-sealed structure area is taken. To determine the scale level, increments from 0 in integers. As... As the coverage scale in both directions increases, it expands synchronously at the same level, thus forming a detection scale with progressively changing spatial coverage.
[0042] For each subsequent detection scale generated, the intersection of the corresponding window and the molding material image region is taken as the effective coverage area. Generation of the next detection scale stops when the effective coverage area no longer adds new molding material image positions relative to the previous detection scale, and the detection scales already formed before stopping are then processed according to... The detection scales are arranged in ascending order of size. When the window corresponding to the detection scale exceeds the boundary of the lead frame encapsulated image, the portion exceeding the boundary is truncated, and the area outside the boundary is not filled.
[0043] To avoid diluting the grayscale and edge response of minute defects during the averaging process due to a large coverage area, the regional images corresponding to each detection scale are directly cropped according to the original sampling interval of the lead frame sealing image, retaining the original pixel grayscale. The effective coverage of the subsequent detection scale is not compressed to the number of pixel rows and columns of the baseline detection scale. Therefore, regional images corresponding to different detection scales are allowed to have different numbers of pixel rows and columns, while the same original image location maintains the same pixel grayscale value across all detection scales. Anomaly location extraction is performed independently within their respective original resolution regional images. Cross-scale comparisons use only the normalized calibration results of the position coordinates. This allows the baseline scale to retain the original details of the smallest detectable defects and enables the expanded detection scale to provide structural correspondence information over a larger spatial range.
[0044] For curved boundary segments, arc length coordinates *s* are established along the continuous arrangement direction of the boundary segment, and normal coordinates *n* are established based on the normal distance from each arc length position towards the interior of the encapsulation material image area. The detection anchor point corresponds to the midpoint of the arc length coordinates. The effective coverage of each detection scale is jointly defined by the arc length interval and the normal distance interval. After projecting each original pixel position to the nearest boundary position, its arc length coordinates and normal distance coordinates are recorded. Image positions located outside the encapsulation material image area or falling into the reflective mask are recorded as invalid positions and do not participate in grayscale, edge, and connected region calculations. During cross-scale matching, *s* and *n* are normalized by the boundary extension direction coverage scale and the normal direction coverage scale of the corresponding detection scale, respectively, changing only the representation of the position coordinates without changing the original grayscale. During reverse mapping, the lead frame encapsulation image is directly restored based on the recorded original pixel index, so that curved boundaries, irregular planar areas, and windows of different sizes use the same reversible position reference.
[0045] Therefore, by defining the coverage scale of the boundary extension direction and the boundary normal direction through the structural scale benchmark, the original sampling resolution of the lead frame encapsulated image is preserved in each detection scale, and the positional relationship under different detection scales is uniformly represented by normalized structural coordinates, so that images of different scales maintain a unified structural position reference without uniformly compressing grayscale details, and independent scale representations are formed by the coverage of different original images.
[0046] S4. Compare the grayscale continuity and edge integrity of the multi-scale detection image and extract abnormal image regions to obtain abnormal candidate regions; In this embodiment of the invention, step S4 includes: Read the region image corresponding to each detection scale according to the detection scale sequence, and maintain the correspondence between the region image and the corresponding detection scale and the encapsulation structure region; Traverse the image positions along the extension direction and normal direction of the corresponding boundary segment in each region image, compare the gray-level changes of adjacent image positions, extract the image positions where gray-level continuity is interrupted, and obtain the gray-level abnormal positions. Local image edges formed by grayscale changes are extracted from the image of each region. The continuity of adjacent edge positions is compared along the extension direction of the local image edges. The image positions where the continuity of the edge is interrupted are extracted to obtain the edge anomaly positions. Within the region image corresponding to the same detection scale, spatially adjacent gray-level anomaly locations and edge anomaly locations are merged into connected regions according to pixel adjacency to form anomaly image regions. The anomaly image regions are then associated with the corresponding detection scale and encapsulation structure regions to obtain anomaly candidate regions.
[0047] The region images corresponding to each detection scale are read sequentially according to the order of the detection scale sequence. At the same time, the detection scale, detection anchor point and encapsulation structure region corresponding to the region image are read. The current region image is limited to the processing object for independent anomaly extraction under the current detection scale. The boundary extension direction and boundary normal direction in the region image are established according to the boundary segment corresponding to the encapsulation structure region. This ensures that each image position in the current region image maintains the correspondence between the corresponding detection scale and the encapsulation structure region. After the gray-level anomaly position and edge anomaly position of the current region image are extracted, the region image corresponding to the next detection scale is read. This maintains the correspondence between each region image and the corresponding detection scale and encapsulation structure region.
[0048] Before determining grayscale continuity and local image edges, median denoising is performed on the current image region. A 3x3 neighborhood is formed by the current image position and its eight neighboring image positions. The actual grayscale values within the neighborhood are arranged from low to high, and the median grayscale value replaces the grayscale value of the current image position. Image positions located at the boundaries of the image region only use the actual adjacent image positions within the image region, without supplementing grayscale values outside the image region. When the number of actual grayscale values within the neighborhood is even, the arithmetic mean of the two sorted median grayscale values is taken as the median grayscale value.
[0049] Within the region image corresponding to the current detection scale, the extension direction of the corresponding boundary segment is taken as the first traversal direction. Starting from one side of the region image, the grayscale performance of adjacent image positions along this direction is read sequentially, and the grayscale changes between adjacent positions are recorded according to the order of the image positions. Then, the normal direction of the corresponding boundary segment is taken as the second traversal direction. Starting from the position near the boundary segment and moving towards the interior of the plastic packaging material image region, the grayscale performance of adjacent image positions is read sequentially, and the grayscale changes are recorded. For each traversal direction, the grayscale changes between consecutive adjacent positions that can maintain a continuous transition according to the position before and after are recorded as continuous parts. Positions where the continuous transition relationship cannot be maintained between consecutive adjacent positions are marked as image positions where the grayscale continuity is interrupted. Then, the interrupted positions obtained from the two traversal directions are recorded uniformly according to their positions in the current region image to obtain the grayscale abnormal position corresponding to the current region image.
[0050] The grayscale difference between adjacent image locations and the grayscale interruption threshold of the current image region are related as follows: ; ; in, and Representing the positions of adjacent images respectively and grayscale value, This represents the grayscale difference between adjacent image locations. and These represent the lower quartile and upper quartile values of all adjacent gray-level differences in the current region of the image, respectively. This is a threshold coefficient for grayscale anomaly detection, used to limit the degree to which the grayscale difference deviates from the grayscale variation range of the main image subject in the current region. In this embodiment... Take 1.5; when > At that time, and The corresponding positions between them are recorded as the image positions where grayscale continuity is interrupted; otherwise, they remain as grayscale continuous positions. The grayscale abnormal positions are obtained from all positions that meet this condition.
[0051] Within the region image corresponding to the current detection scale, the grayscale change relationship between adjacent image positions is read again. Image positions where the grayscale values are located on both sides of the same boundary and are continuously arranged along the boundary direction are identified as local image edges. The local image edges are continuously tracked from one end to the other according to the arrangement of adjacent edge positions. For each edge position read, it is checked whether there are any edge positions in its subsequent adjacent positions that can continue to maintain the current edge direction. When the adjacent edge positions can be continuously connected according to the current direction, the local image edge is recorded. When the subsequent adjacent positions cannot continue to form an edge position that connects with the current local image edge, the corresponding position is marked as the image position where the edge continuity is interrupted. The same processing is performed on all local image edges in the current region image to obtain edge abnormal positions.
[0052] Location inside the region image The edge strength and edge threshold are related as follows: ; ; in, Indicates position The absolute value of the grayscale difference between adjacent positions along the boundary extension direction. Indicates position The absolute value of the grayscale difference between adjacent positions along the boundary normal direction, E(p) represents the edge intensity at position p. and These represent the lower quartile and upper quartile values of all edge intensities in the current region image, respectively. This is the threshold coefficient for edge anomaly detection. In this embodiment... Take 1.5; when > At that time, the position The location is recorded as a local image edge. When tracing along the local image edge, an eight-neighborhood check is used to examine unvisited edge positions, excluding the previous edge position of the current edge position. If multiple unvisited edge positions exist, the edge position with the smallest deviation from the current edge's extension direction is selected as the successor. If the direction deviations are the same, the edge position with the larger edge intensity is selected. If they are still the same, the successor is selected in ascending order of image row and column numbers. If no valid successor exists, the system checks if there are any unvisited edge positions within a five-row, five-column range centered on the current edge position that can be connected. If so, the edge position closest to the current edge position is selected as the successor, and the image position between them is used as a single-pixel intermittent point for continued tracing. If no valid successor still exists, it is recorded as an interruption in the edge continuity state, resulting in an edge anomaly position.
[0053] The above five-row, five-column compensation only handles a single pixel's discontinuity: the chessboard distance of the candidate successor relative to the current edge position must be equal to 2, and there must be only one intermediate image position between the two that is not determined to be an edge in the current edge extension direction; when this condition is met, the unique intermediate image position is used as the compensation point. If the chessboard distance of the candidate successor is greater than 2, there are more than two selectable intermediate positions, the angle between the compensation point direction and the current edge extension direction exceeds the preset direction deviation, or the compensation point would enter an invalid position or a reflective mask, the compensation point is not performed, and the current position is recorded as an interruption in the edge continuity state; multiple candidate successors that meet the conditions are uniquely selected according to a predetermined order of direction deviation, edge intensity, image row number, and column number.
[0054] Gray threshold coefficient and edge threshold coefficient The value of 1.5 is only one set of optional initial values. During implementation, candidate coefficients are traversed on normal samples and labeled defective samples of the same package specification, and the coefficient with the lowest false positive rate when the recall rate of the verification sample meets the preset lower limit is used as the value for the corresponding package specification. If the upper quartile value of grayscale difference or edge intensity is equal to the lower quartile value, the minimum difference determined by the standard deviation of camera dark field noise is added to the upper quartile value as a threshold to avoid judging quantization noise as abnormal when the interquartile range is zero. The above calibration is repeated after changing the package specification, camera exposure or lighting configuration.
[0055] Within the region image corresponding to the same detection scale, the gray-level anomaly locations and edge anomaly locations are read respectively. The image locations directly adjacent to each anomaly location are taken as the adjacency range. Adjacent gray-level anomaly locations, adjacent edge anomaly locations, and adjacent gray-level anomaly locations and edge anomaly locations are grouped into the same connected range. The process continues to check adjacent anomaly locations outward from the anomaly locations already grouped into the connected range until there are no more anomaly locations that can be grouped into the current connected range. An anomaly image region is formed by all the anomaly locations grouped into the same connected range. The detection scale, the corresponding encapsulation structure region, and the position range of the anomaly image region are recorded. The anomaly image region is associated with the corresponding detection scale and the encapsulation structure region to obtain anomaly candidate regions.
[0056] The pixel adjacency relationship adopts an eight-neighbor relationship, that is, when two abnormal positions are directly adjacent in the row direction, column direction or diagonal direction, they are grouped into the same connected region; after merging gray-level abnormal positions and edge abnormal positions, only connected regions containing at least two adjacent abnormal positions are retained, and a single isolated abnormal position does not form an abnormal image region; when the same connected region contains both gray-level abnormal positions and edge abnormal positions, the region is not re-established, but an abnormal image region is formed by its entire outer edge image position.
[0057] The abnormal locations of the previous detection scale are not directly reused between different detection scales. The corresponding abnormal candidate region is generated only when the above gray-scale abnormal location or edge abnormal location determination rules are met again in the normalized region image and an abnormal image region is formed. Therefore, the same location in the original image is included in the spatial coverage of the next detection scale and does not directly constitute a cross-scale continuous relationship.
[0058] Therefore, by detecting grayscale continuity and local image edge continuity in the regional images corresponding to each detection scale, anomaly candidate regions corresponding to the detection scale and the encapsulation structure region are formed, providing a unified candidate data basis for subsequent cross-scale association.
[0059] S5. Map the abnormal candidate region to the lead frame molding image, use the structural scale benchmark to associate the abnormal candidate regions corresponding to the same molding structure position in the detection scale sequence, compare the spatial position and contour range of the associated region under adjacent detection scales, and record the continuity state between scales to obtain the cross-scale continuity relationship. In this embodiment of the invention, step S5 includes: Based on the extraction positions of each region image in the lead frame encapsulation image, the abnormal candidate regions are transformed to the corresponding positions in the lead frame encapsulation image to obtain candidate mapping regions; Using the boundary segment of the corresponding encapsulated structure region as the position reference along the boundary extension direction, and using the reference value of the corresponding encapsulated structure region in the structural scale reference as the scale reference along the boundary normal direction, the position range of each candidate mapping region along the boundary extension direction is obtained, and the position range of each candidate mapping region along the boundary normal direction is calibrated according to the reference value. According to the arrangement order of the detection scale sequence, the candidate mapping regions under adjacent detection scales are compared. The candidate mapping regions that overlap in both the position range along the boundary extension direction and the position range along the boundary normal direction as indicated by the reference value are determined as corresponding to the same plastic encapsulation structure position, forming a cross-scale matching region pair. Compare the spatial position and contour range of two candidate mapping regions in each cross-scale matching region pair. When the two candidate mapping regions maintain the same corresponding position of the plastic encapsulation structure, it is recorded as a continuous state. When the two candidate mapping regions no longer maintain the same corresponding position of the plastic encapsulation structure, it is recorded as a terminated state. The continuous state or the terminated state is taken as the inter-scale continuation state. By associating cross-scale matching region pairs corresponding to the same plastic encapsulation structure position along the detection scale sequence, and recording the detection scale corresponding to the continuous position of the abnormal candidate region and its inter-scale continuity state, a cross-scale continuity relationship is obtained.
[0060] Based on the original pixel indexes, corresponding arc length coordinates, and normal distance coordinates recorded when each region's image was cropped, the image positions contained in the anomaly candidate region are directly restored to the original pixel positions in the lead frame encapsulation image. The outline and coverage area of the anomaly candidate region in the lead frame encapsulation image are formed by the outer edge of the original pixel positions. This position restoration does not perform grid averaging or grayscale resampling, and the region after position restoration is associated with the original anomaly candidate region, the corresponding detection scale, and the corresponding encapsulation structure region to obtain the candidate mapping region.
[0061] Read the boundary segment of the molding structure region corresponding to each candidate mapping region, establish a position reference along the boundary extension direction based on the extension direction of the boundary segment, and record the start and end positions of the candidate mapping region covered along this direction as the position range along the boundary extension direction. At the same time, read the reference value of the corresponding molding structure region in the structural scale reference, and divide the image region of the molding material into equal-length scale segments along the boundary normal direction according to the reference value, with the boundary segment as the starting reference. Then record the start and end positions of the scale segments covered by the candidate mapping region along the boundary normal direction. In this way, the original image distance of the candidate mapping region along the normal direction under different detection scales is uniformly converted into a position record with the reference value as the scale reference, and the position range along the boundary normal direction calibrated by the reference value is obtained.
[0062] Candidate mapping regions corresponding to two adjacent detection scales are read sequentially according to the order of the detection scales in the detection scale sequence. Comparison is only made between candidate mapping regions corresponding to the same molding structure region. It is checked whether the position range of the two candidate mapping regions along the boundary extension direction covers the same boundary position and whether the position range along the boundary normal direction calibrated by the reference value covers the same scale position. When the position ranges in both directions have a common coverage part, the two candidate mapping regions are determined to correspond to the same molding structure position. The two candidate mapping regions are then paired according to the arrangement relationship of the previous detection scale and the next detection scale to form a cross-scale matching region pair.
[0063] When a candidate mapping region at the current detection scale has multiple candidate mapping regions at the next detection scale that simultaneously satisfy the condition of overlapping position ranges in both directions, the contour region intersection-union ratio is used as the unique matching quantity, and the relationship is as follows: ; in, This represents the candidate mapping region for the current detection scale. Indicates the first in the subsequent detection scale Candidate mapping regions that satisfy the condition of overlapping location ranges. express and The common coverage area express and The total coverage area express and The degree of overlap of the outlines. Select The largest As The preferred match object, and from In reverse, compare its intersection-union ratio with the intersection-union ratio of all candidate mapping regions in the previous detection scale, only when At the same time When considering the maximum intersection-union ratio (MOU) of objects, and Cross-scale matching region pairs are formed; when the intersection-union ratio is the same, the object with the shortest image distance between the contour centers of the two candidate mapping regions is selected. If the image distance is still the same, the object recorded first is selected according to the recording order of the candidate mapping regions in the corresponding region images. Thus, the one-to-many and many-to-one candidate relationships are converted into a unique one-to-one matching relationship.
[0064] The "maintaining the same corresponding position of the same molding structure" for the two candidate mapping regions in this invention means that they simultaneously meet the following objective conditions: their position ranges overlap along the arc length direction; their normal position ranges, calibrated by the structural scale reference, overlap; they are the best bidirectional matching objects with the largest cross-union ratio; and their contour cross-union ratio is not lower than the preset minimum cross-union ratio R. min Furthermore, the normalized center distance formed by dividing the arc length coordinate difference of the two contour centers by the coverage scale along the boundary extension direction of the reference detection scale and dividing the normal coordinate difference by the reference value is not greater than the preset maximum distance d. max In this embodiment, R can be taken as... min 0.25, d max The value is 0.5, or it can be calibrated using labeled samples of the same packaging specification according to the upper limit of the false match rate. If either condition is not met, cross-scale matching region pairs are not established and the termination state is not recorded. Therefore, candidate regions with only a very small area overlap and a significant shift in spatial center will not be recorded as a persistent state.
[0065] When continuously tracking along the detection scale sequence, if the current candidate mapping region has a cross-scale matching region pair formed according to the unique matching rule in the next detection scale, then the scale continuity state between the current detection scale and the next detection scale is recorded as a continuous state, and the candidate mapping region in the next detection scale continues to be the tracking object; if the current candidate mapping region does not have a candidate mapping region that simultaneously satisfies the overlapping conditions of the position ranges in two directions and completes a unique match in the next detection scale, then a cross-scale matching region pair pointing to the next detection scale is not formed, and the scale continuity state of the current candidate mapping region at the current detection scale is recorded as a terminated state; candidate mapping regions that participate in multiple candidate relationships but are not selected by the unique matching rule are treated as having no valid matching object and the terminated state is recorded.
[0066] Starting from the baseline detection scale, each cross-scale matching region pair is read sequentially along the detection scale sequence. Cross-scale matching region pairs that have the same encapsulation structure region and correspond to the same structural position along the boundary extension direction and the boundary normal direction calibrated by the baseline value are continuously associated. The candidate mapping region of the next detection scale in the previous cross-scale matching region pair is kept consistent with the candidate mapping region of the previous detection scale in the next cross-scale matching region pair. This allows the same abnormal candidate region to be continuously tracked backward according to the progressive order of the detection scale. At the same time, the detection scales that its continuous position corresponds to and the corresponding scale continuity state between adjacent detection scales are recorded. The detection scale records formed under the same encapsulation structure position, the corresponding relationship of candidate mapping regions and the scale continuity state are jointly organized to obtain the cross-scale continuity relationship.
[0067] Therefore, by mapping the abnormal candidate region to the same lead frame encapsulated image and establishing the structural position correspondence between adjacent detection scales using structural scale benchmarks, it is possible to obtain the cross-scale persistence relationship of the abnormal region at different detection scales.
[0068] Since each detection scale extracts the regional image within its coverage area according to the original sampling resolution and independently performs gray-level anomaly location and edge anomaly location determination within its respective regional image, the cross-scale persistence relationship takes the anomaly candidate region generated independently by each detection scale as input; the spatial inclusion relationship of the later detection scale with the original image position of the previous detection scale does not directly generate a persistence state, and the persistence state is only recorded when the later detection scale regenerates the anomaly candidate region in the regional image without average compression of the original gray level and meets the objective matching rules.
[0069] S6. Based on the cross-scale continuous relationship, filter out abnormal candidate regions that maintain the corresponding and continuous existence of the structural position, determine the location of the molding defect, and obtain the detection result of the molding defect of the lead frame.
[0070] In this embodiment of the invention, step S6 includes: Extract each pair of cross-scale matching regions that continuously correspond to the same plastic encapsulation structure position along the detection scale sequence from the cross-scale persistence relationship, and connect them sequentially according to the arrangement order of the detection scale sequence to form an abnormal persistence chain; Based on the inter-scale continuity status of each group of cross-scale matching region pairs in the abnormal persistence chain, each abnormal candidate region that maintains positional continuity under multiple consecutive detection scales is selected to form a continuous abnormal candidate region group. Obtain the contour range of the candidate mapping region corresponding to each abnormal candidate region in the continuous abnormal candidate region group in the lead frame molding image, and determine the location of the molding defect by the common overlapping area of the contour range of each candidate mapping region. By associating the location of the molding defect with the corresponding molding structure area, the detection result of the lead frame molding defect is obtained.
[0071] Read the cross-scale matching region pairs and their detection scale relationships corresponding to each plastic encapsulation structure position from the cross-scale persistence relationship. Check each group of cross-scale matching region pairs sequentially from the previous detection scale to the next detection scale according to the detection scale sequence. Compare the candidate mapping region corresponding to the next detection scale in the previous group of cross-scale matching region pairs with the candidate mapping region corresponding to the previous detection scale in the next group of cross-scale matching region pairs. When the two are the same candidate mapping region and each group of cross-scale matching region pairs corresponds to the same plastic encapsulation structure position, connect the two adjacent groups of cross-scale matching region pairs in the order of the detection scales. Continue to check the next group of cross-scale matching region pairs along the detection scale sequence until there are no cross-scale matching region pairs that can continue to satisfy the same candidate mapping region inheritance relationship. Then record each group of cross-scale matching region pairs that have been connected in series and each abnormal candidate region in them to form an abnormal persistence chain.
[0072] Read the cross-scale matching region pairs and corresponding inter-scale continuity states recorded in the abnormal persistence chain according to the detection scale order. Starting from the initial detection scale of the abnormal persistence chain, check the inter-scale continuity states between adjacent detection scales step by step. Retain the abnormal candidate regions that are recorded as continuous and continue to have the same plastic packaging structure position correspondence in the next detection scale. Continue to check along the detection scale sequence. When multiple consecutive detection scales are recorded as continuous, the corresponding abnormal candidate regions within the continuous scale range are grouped into the same group. When a termination state occurs, the continued screening of the current abnormal persistence chain ends. In this way, the abnormal candidate regions that maintain positional continuity in multiple consecutive detection scales are screened to form a continuous abnormal candidate region group.
[0073] In this embodiment, two consecutive detection scales are used as the minimum number of consecutive scales to form a persistent anomaly candidate region group. When anomaly candidate regions in a persistent anomaly chain maintain the same encapsulation structure position in two adjacent detection scales, the corresponding anomaly candidate regions form a persistent anomaly candidate region group. If the anomaly candidate regions continue to maintain the same encapsulation structure position in a subsequent detection scale, the anomaly candidate regions corresponding to the subsequent detection scale are incorporated into the persistent anomaly candidate region group, and screening continues along the detection scale sequence. When a termination state occurs, the current persistent anomaly candidate region group stops expanding along subsequent detection scales, but persistent anomaly candidate region groups already formed by two or more consecutive detection scales are retained. If an anomaly candidate region exists only in a single detection scale, or cannot maintain the same encapsulation structure position with anomaly candidate regions in adjacent detection scales, a persistent anomaly candidate region group is not formed.
[0074] Read the candidate mapping region corresponding to each abnormal candidate region in the persistent abnormal candidate region group, and obtain its contour range according to the original position of each candidate mapping region in the lead frame molding image after it has been restored. Compare the contour ranges of each candidate mapping region one by one in the positional relationship of the same lead frame molding image. Starting from the contour range of one candidate mapping region, retain the image area that is covered by the contour range of the next candidate mapping region. Then, continue to compare the commonly covered area with the contour range of the next candidate mapping region and retain the image area that is covered again. Continue to perform the above common coverage range extraction according to the candidate mapping region sequence corresponding to the detection scale sequence until all candidate mapping regions in the persistent abnormal candidate region group have been compared. The image area that is finally covered by the contour ranges of all candidate mapping regions is taken as the common overlapping area, and the position of the common overlapping area in the lead frame molding image is used to determine the molding defect location.
[0075] For candidate mapping regions in the persistent anomaly candidate region group, the cumulative overlap method is used to determine the common overlapping region. The contour ranges of the candidate mapping regions arranged in order of detection scale are denoted as follows: , … ,in, This indicates the number of nodes in the current persistent anomaly chain, ordered by detection scale. The contour range of each candidate mapping region, and the cumulative overlapping region, are determined according to the following formula: ; ; in, Indicates as of the date The cumulative overlapping region formed by each detection scale. When When not empty, continue updating the cumulative overlapping region to the next detection scale; when When empty, in the first The current cumulative overlap segment terminates at the first detection scale, and starts from the first... New cumulative overlapping segments are established starting from the candidate mapping regions corresponding to each detection scale. If a terminated cumulative overlapping segment has continuously covered at least two detection scales before termination and the final cumulative common overlapping region is not empty, a valid persistent anomaly candidate region group is formed; if the cumulative overlapping segment corresponds to only a single detection scale, or the cumulative common overlapping region is empty, a valid persistent anomaly candidate region group is not formed.
[0076] After all detection scales have been processed, the final non-empty cumulative common overlap region of each valid anomaly persistence chain is retained as the common overlap region of the corresponding persistence anomaly candidate region group, and the location of the molding defect is determined by the coverage position of the common overlap region in the lead frame molding image. When there is no valid anomaly persistence chain in the corresponding molding structure region that meets the minimum number of consecutive scales and has a non-empty cumulative common overlap region, the molding structure region is recorded as not having a molding defect in the lead frame molding defect detection result, thus forming two closed output branches: defective and no valid defect.
[0077] Before identifying the final non-empty cumulative overlapping area as the location of the molding defect, independent defect confirmation is further performed. First, a normal structural edge mask and a normal grayscale reference image are established based on a defect-free baseline image of the same package specification or the median image of normal samples from the same batch. Stable structural responses that coincide with the normal structural edge mask and whose grayscale deviation does not exceed the reference deviation threshold are excluded. Then, within the overlapping area after removing the reflective mask, the area, the average absolute grayscale deviation relative to the normal grayscale reference image, and the proportion of the abnormal edge position to the contour length are calculated. The overlapping area is confirmed as the location of the molding defect only when the area is within the effective range determined by the camera resolution and the process-allowed defect size, and at least one of the average absolute grayscale deviation or the proportion of the abnormal edge exceeds the corresponding confirmation threshold. When the normal grayscale reference image is unavailable, a local reference can be formed by registering a non-abnormal area of the same structural type on the same leadframe.
[0078] When overlapping regions fail to pass independent defect confirmation, they are not output as confirmed defects, but are recorded as candidate anomalies to be reviewed in the detection results, and the corresponding detection scale range, unmet confirmation conditions, and original image location are saved; when they pass independent defect confirmation, they are recorded as confirmed molding defects. Therefore, even if persistent reflections, normal structural edges, or fixed textures persist across multiple scales, they must produce a quantifiable deviation from the normal reference before they can be included in the confirmed defect output.
[0079] The range of the location of the molding defect in the lead frame molding image is read and compared with the location range of each molding structure region in the aforementioned molding structure region information. The molding structure region covering the location of the molding defect is determined as the corresponding molding structure region. Then, the location of the molding defect is associated with the corresponding molding structure region. At the same time, the continuous abnormal candidate region group forming the location of the molding defect and the corresponding detection scale range are recorded, so that the detection result includes both the image location of the defect and the molding structure region to which the defect belongs, thus obtaining the lead frame molding defect detection result.
[0080] Therefore, by screening out abnormal candidate regions that maintain the same position of the molding structure under multiple consecutive detection scales, and determining the location of molding defects based on their common overlapping areas, it is possible to eliminate local abnormal responses that lack cross-scale continuity and improve the accuracy of molding defect localization.
[0081] In one verification implementation, training sample groups and independent verification sample groups are established according to the packaging specifications. The samples cover samples with defects such as edge defects, excess glue, burrs, dents, scratches, cracks, foreign objects, and defect-free samples. The type, outline, and minimum width of each defect are manually labeled. The training sample group is used to determine the grayscale threshold coefficient, edge threshold coefficient, minimum crossover ratio, maximum normalized center distance, defect area range, and independent verification threshold. The independent verification sample group does not participate in parameter determination. When the packaging specifications are changed, the corresponding structural scale benchmark is re-established and the parameters are calibrated, instead of directly using the five fixed measurement positions or fixed thresholds.
[0082] During verification, the structural-scale and cross-scale continuous detection processes of this invention, a single-scale process using only the baseline detection scale, and a control process using a fixed window sequence but without a structural-scale baseline were run. Accuracy, recall, false positive rate, and the average localization error between confirmed defect contours and manually annotated contours were statistically analyzed under the same image and the same defect annotations. Recall rates for small and large defects were also statistically analyzed by grouping them according to their minimum defect width. The above verification processes are used to check the rationality of the parameters and the technical effects produced by the cross-scale continuous relationship. Specific statistical values are based on the measurement results of actual collected samples.
[0083] like Figure 2 The diagram shown is a functional block diagram of a multi-scale molding defect detection system for lead frames provided in an embodiment of the present invention.
[0084] The multi-scale molding defect detection system 100 for lead frames described in this invention can be installed in electronic devices. Depending on the functions implemented, the multi-scale molding defect detection system 100 may include a structural region division module 101, a scale reference construction module 102, a scale sequence generation module 103, an abnormal region extraction module 104, a cross-scale correlation module 105, and a defect determination module 106.
[0085] In this embodiment, the functions of each module are as follows: The structural region division module 101 is used to acquire the lead frame molding image, determine the molding boundary and lead position, divide the molding structure region according to the spatial correspondence between the molding boundary and the lead position, and obtain molding structure region information. The scale reference construction module 102 is connected to the structural region division module 101 and is used to extract the structural spacing between the corresponding boundary segment and the inner boundary of each plastic-encapsulated structural region from the plastic-encapsulated structural region information, and to determine the structural scale reference by the structural spacing. The scale sequence generation module 103 is connected to the scale reference construction module 102. It is used to set the detection scale of the corresponding plastic encapsulation structure area according to the progressive change of the spatial coverage range with the structural scale reference as a reference, form a detection scale sequence, and extract the area image corresponding to each detection scale to obtain a multi-scale detection image. The abnormal region extraction module 104 is connected to the scale sequence generation module 103 and is used to compare the grayscale continuity and edge integrity of the multi-scale detection image and extract abnormal image regions to obtain abnormal candidate regions. The cross-scale association module 105 is connected to the abnormal region extraction module 104. It is used to map the abnormal candidate region to the lead frame molding image, associate the abnormal candidate regions corresponding to the same molding structure position in the detection scale sequence using the structural scale benchmark, compare the spatial position and contour range of the associated region under adjacent detection scales, and record the continuity state between scales to obtain the cross-scale continuity relationship. The defect determination module 106 is connected to the cross-scale association module 105 and is used to filter abnormal candidate regions that maintain the corresponding and continuous existence of the structural position based on the cross-scale continuous relationship, determine the location of the molding defect, and obtain the lead frame molding defect detection result.
[0086] A third aspect of the present invention relates to an electronic device, comprising: processor; Memory used to store processor-executable instructions; The processor is configured to invoke instructions stored in the memory to execute the aforementioned method.
[0087] A fourth aspect of the present invention relates to a computer-readable storage medium having stored thereon computer program instructions that, when executed by a processor, implement the aforementioned method.
[0088] This invention can be a method, apparatus, system, and / or computer program product. The computer program product may include a computer-readable storage medium having computer-readable program instructions loaded thereon for performing various aspects of the invention.
[0089] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit it. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention.
Claims
1. A method for detecting multi-scale molding defects in lead frames, characterized in that, Includes the following steps: S1. Obtain the plastic encapsulation image of the lead frame, determine the plastic encapsulation boundary and lead position, divide the plastic encapsulation structure region according to the spatial correspondence between the plastic encapsulation boundary and the lead position, and obtain the plastic encapsulation structure region information; S2. Extract the structural spacing between the corresponding boundary segment and the inner boundary of each plastic-encapsulated structure region from the plastic-encapsulated structure region information, and determine the structural scale benchmark from the structural spacing; S3. Using the structural scale benchmark as a reference, set the detection scale of the corresponding plastic sealing structure area according to the progressive change of the spatial coverage range to form a detection scale sequence, and extract the area image corresponding to each detection scale to obtain a multi-scale detection image. S4. Compare the grayscale continuity and edge integrity of the multi-scale detection image and extract abnormal image regions to obtain abnormal candidate regions; S5. Map the abnormal candidate region to the lead frame molding image, use the structural scale benchmark to associate the abnormal candidate regions corresponding to the same molding structure position in the detection scale sequence, compare the spatial position and contour range of the associated region under adjacent detection scales, and record the continuity state between scales to obtain the cross-scale continuity relationship. S6. Based on the cross-scale continuous relationship, filter out abnormal candidate regions that maintain the corresponding and continuous existence of the structural position, determine the location of the molding defect, and obtain the detection result of the molding defect of the lead frame.
2. The multi-scale molding defect detection method for lead frames according to claim 1, characterized in that, Step S1 includes: Extract the molding material image region from the lead frame molding image, and define the molding boundary along the outer contour of the molding material image region; Extract the lead image regions not covered by the encapsulation material image region, and obtain the position range and extension direction of each lead image region; Extend the two side boundaries along the extension direction of each lead image area until they intersect with the plastic encapsulation boundary, and determine the plastic encapsulation boundary between the two intersection points as the lead corresponding boundary segment at the lead position; The molding boundary is divided according to the boundary segment corresponding to the lead and the boundary interval segment between adjacent lead boundary segments, and each boundary segment is extended along the interior direction of the molding material image area to form the molding structure area, thus obtaining the molding structure area information.
3. The multi-scale molding defect detection method for lead frames according to claim 2, characterized in that, Step S2 includes: Obtain the boundary segments corresponding to each molding structure region, as well as the inner boundary of the region opposite to the corresponding boundary segment in the molding structure region; Measurement positions are selected sequentially along the boundary segment, and the interval distance is measured at each measurement position along the normal direction of the boundary segment toward the inner boundary of the region to obtain the structural spacing of the corresponding plastic-encapsulated structure region. The structural spacing is recorded according to the arrangement order of each measurement position on the boundary section to form a structural spacing sequence; The median structural spacing of the structural spacing sequence is extracted as the reference value of the corresponding encapsulated structural region, and the reference value is associated with the position of the corresponding encapsulated structural region to form a structural dimensional reference.
4. The multi-scale molding defect detection method for lead frames according to claim 3, characterized in that, Step S3 includes: Read the position and corresponding reference value of each plastic-encapsulated structural region in the structural dimensional reference, and use the center position of the corresponding boundary segment as the detection anchor point; The coverage scale along the boundary extension direction is defined by the length of the boundary segment, and the coverage scale along the boundary normal direction is defined by the reference value, thus forming a reference detection scale for the corresponding plastic-encapsulated structure area. Keeping the detection anchor points unchanged, the coverage scale along the boundary extension direction and the boundary normal direction are increased synchronously to form a detection scale sequence arranged according to the spatial coverage range; Based on the spatial coverage defined by each detection scale in the detection scale sequence, the corresponding region image is extracted from the lead frame encapsulation image, and the region image is organized according to the arrangement order of the detection scales to obtain a multi-scale detection image.
5. The multi-scale molding defect detection method for lead frames according to claim 4, characterized in that, Step S4 includes: Read the region image corresponding to each detection scale according to the detection scale sequence, and maintain the correspondence between the region image and the corresponding detection scale and the encapsulation structure region; Traverse the image positions along the extension direction and normal direction of the corresponding boundary segment in each region image, compare the gray-level changes of adjacent image positions, extract the image positions where gray-level continuity is interrupted, and obtain the gray-level abnormal positions. Local image edges formed by grayscale changes are extracted from the image of each region. The continuity of adjacent edge positions is compared along the extension direction of the local image edges. The image positions where the continuity of the edge is interrupted are extracted to obtain the edge anomaly positions. Within the region image corresponding to the same detection scale, spatially adjacent gray-level anomaly locations and edge anomaly locations are merged into connected regions according to pixel adjacency to form anomaly image regions. The anomaly image regions are then associated with the corresponding detection scale and encapsulation structure regions to obtain anomaly candidate regions.
6. The multi-scale molding defect detection method for lead frames according to claim 5, characterized in that, Step S5 includes: Based on the extraction positions of each region image in the lead frame encapsulation image, the abnormal candidate regions are transformed to the corresponding positions in the lead frame encapsulation image to obtain candidate mapping regions; Using the boundary segment of the corresponding encapsulated structure region as the position reference along the boundary extension direction, and using the reference value of the corresponding encapsulated structure region in the structural scale reference as the scale reference along the boundary normal direction, the position range of each candidate mapping region along the boundary extension direction is obtained, and the position range of each candidate mapping region along the boundary normal direction is calibrated according to the reference value. According to the arrangement order of the detection scale sequence, the candidate mapping regions under adjacent detection scales are compared. The candidate mapping regions that overlap in both the position range along the boundary extension direction and the position range along the boundary normal direction as indicated by the reference value are determined as corresponding to the same plastic encapsulation structure position, forming a cross-scale matching region pair. Compare the spatial position and contour range of two candidate mapping regions in each cross-scale matching region pair. When the two candidate mapping regions maintain the same corresponding position of the plastic encapsulation structure, it is recorded as a continuous state. When the two candidate mapping regions no longer maintain the same corresponding position of the plastic encapsulation structure, it is recorded as a terminated state. The continuous state or the terminated state is taken as the inter-scale continuation state. By associating cross-scale matching region pairs corresponding to the same plastic encapsulation structure position along the detection scale sequence, and recording the detection scale corresponding to the continuous position of the abnormal candidate region and its inter-scale continuity state, a cross-scale continuity relationship is obtained.
7. The multi-scale molding defect detection method for lead frames according to claim 6, characterized in that, Step S6 includes: Extract each pair of cross-scale matching regions that continuously correspond to the same plastic encapsulation structure position along the detection scale sequence from the cross-scale persistence relationship, and connect them sequentially according to the arrangement order of the detection scale sequence to form an abnormal persistence chain; Based on the inter-scale continuity status of each group of cross-scale matching region pairs in the abnormal persistence chain, each abnormal candidate region that maintains positional continuity under multiple consecutive detection scales is selected to form a continuous abnormal candidate region group. Obtain the contour range of the candidate mapping region corresponding to each abnormal candidate region in the continuous abnormal candidate region group in the lead frame molding image, and determine the location of the molding defect by the common overlapping area of the contour range of each candidate mapping region. By associating the location of the molding defect with the corresponding molding structure area, the detection result of the lead frame molding defect is obtained.
8. A multi-scale molding defect detection system for lead frames, characterized in that, The method for detecting multi-scale molding defects in lead frames according to any one of claims 1 to 7 includes: The structural region segmentation module is used to acquire the lead frame molding image, determine the molding boundary and lead position, and divide the molding structure region according to the spatial correspondence between the molding boundary and the lead position to obtain molding structure region information. The scale reference construction module is used to extract the structural spacing between the corresponding boundary segment and the inner boundary of each plastic-encapsulated structure region from the plastic-encapsulated structure region information, and to determine the structural scale reference by the structural spacing. The scale sequence generation module is used to set the detection scale of the corresponding plastic encapsulation structure region according to the progressive change of the spatial coverage, with the structural scale benchmark as a reference, to form a detection scale sequence, and to extract the region image corresponding to each detection scale to obtain a multi-scale detection image. An anomaly region extraction module is used to compare the grayscale continuity and edge integrity of the multi-scale detection image and extract anomaly image regions to obtain anomaly candidate regions; The cross-scale association module is used to map the anomaly candidate region to the lead frame molding image, associate the anomaly candidate region corresponding to the same molding structure position in the detection scale sequence using the structural scale benchmark, compare the spatial position and contour range of the associated region under adjacent detection scales, and record the continuity state between scales to obtain the cross-scale continuity relationship. The defect determination module is used to filter out abnormal candidate regions that maintain the corresponding and continuous existence of the structural position based on the cross-scale continuous relationship, determine the location of the molding defect, and obtain the detection result of the molding defect of the lead frame.
9. An electronic device, characterized in that, include: processor; Memory used to store processor-executable instructions; The processor is configured to invoke instructions stored in the memory to execute the method according to any one of claims 1 to 7.
10. A computer-readable storage medium having computer program instructions stored thereon, characterized in that, When the computer program instructions are executed by the processor, they implement the method described in any one of claims 1 to 7.