Terminal equipment X-ray quality inspection image processing methods, electronic devices, storage media and software products

By stitching and registering X-ray images and superimposing a reference mask, the problems of detection accuracy and real-time performance caused by the limited field of view of X-ray equipment are solved, enabling rapid and efficient quality inspection of terminal equipment.

CN123118716APending Publication Date: 2026-11-17转转一零二四(北京)科技有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611530554.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-09-29
Publication Date
2026-11-17

AI Technical Summary

Technical Problem

The limited field of view of X-ray equipment leads to image fragmentation in terminal devices, resulting in poor stability of traditional registration algorithms and high computational load of deep learning algorithms, making it difficult to meet the real-time requirements of industrial online inspection while ensuring accuracy.

Method used

By acquiring the reference image and reference mask of the terminal device, multiple local X-ray images are stitched together along the smaller dimension of the device outline, image registration is performed, and the reference mask is superimposed to output the quality inspection results, avoiding complex calculations that rely on the texture features of the image itself.

Benefits of technology

It enables rapid detection even with limited field of view in X-ray equipment, improving detection accuracy and real-time performance while reducing computational complexity.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123118716A_ABST
    Figure CN123118716A_ABST
Patent Text Reader

Abstract

This application provides an X-ray quality inspection image processing method, electronic device, storage medium, and program product for terminal equipment. The method includes: acquiring a reference image and a reference mask corresponding to the target terminal equipment under test; acquiring multiple local X-ray images obtained by taking multiple X-ray images of the target terminal equipment under test; stitching the multiple local X-ray images along a first direction to obtain a stitched image to be tested; registering the stitched image to be tested with the reference image to obtain a registered image to be tested; superimposing the reference mask onto the registered image to be tested; and obtaining a standardized quality inspection result of the target terminal equipment under test based on the matching degree between the reference mask and the image to be tested. This method aims to achieve rapid detection of terminal equipment.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of terminal quality inspection technology, and in particular to a terminal device X-ray quality inspection image processing method, electronic device, storage medium and program product. Background Technology

[0002] With the increasing functionality and complexity of smartphones, quality control in the mobile phone manufacturing process has become increasingly important. X-ray inspection, as a non-destructive testing method, can reveal the internal structure of a mobile phone without disassembling it, and is widely used in quality inspection stages such as component positioning, welding quality inspection, and internal defect identification on mobile phone production lines.

[0003] Because X-ray equipment has a limited field of view, a single image often cannot cover the entire width of a mobile phone. Furthermore, the local images obtained from multiple images suffer from sparse features and insufficient texture. This results in poor stability of traditional registration algorithms and high computational demands for deep learning algorithms, making it difficult to meet the real-time requirements of industrial online inspection while ensuring accuracy.

[0004] Therefore, there is an urgent need for a method that can enable rapid detection by terminal devices when the limited field of view of X-ray equipment leads to image fragmentation. Summary of the Invention

[0005] This application provides a terminal device X-ray quality inspection image processing method, electronic device, storage medium, and program product to achieve rapid detection effect of terminal device.

[0006] In a first aspect, embodiments of this application provide a terminal device X-ray quality inspection image processing method, including: acquiring a reference image and a reference mask corresponding to a target terminal device under test, wherein the reference image is a model reference X-ray image of the target terminal device under test, and the reference mask is used to mark the outline of the body region of the target terminal device under test in the reference image;

[0007] Multiple local X-ray images obtained by taking multiple X-ray images of the target terminal device under test are acquired, and the multiple local X-ray images are stitched together along the first direction to obtain the stitched image under test, wherein the first direction is the smaller dimension direction in the outline of the body area of ​​the target terminal device under test.

[0008] The image to be tested is registered with the reference image to obtain the registered image to be tested.

[0009] The reference mask is superimposed on the registered image to be tested, and the standardized quality inspection result of the target terminal device to be tested is obtained based on the matching degree between the reference mask and the image to be tested.

[0010] In one possible implementation, multiple X-ray images of the same model of the target terminal device under test are obtained, and images that meet preset quality requirements are selected as a qualified X-ray image set, wherein the preset quality requirements meet at least one of the following indicators: imaging sharpness is greater than or equal to a sharpness threshold, no geometric distortion, and no obstruction.

[0011] From the set of qualified X-ray images, the image with the largest imaging sharpness index value and the smallest geometric distortion index value is selected as the model reference X-ray image to determine the benchmark image;

[0012] Edge detection is performed on the reference image to extract the outer contour boundary of the target terminal device under test, wherein the outer contour boundary is a closed contour line used to distinguish the solid part and non-solid part of the target terminal device under test in the reference image;

[0013] Based on the outer contour boundary, the reference image is divided into two regions: the inner region enclosed by the outer contour boundary is the body region of the target terminal device under test, and the outer region located outside the outer contour boundary is the background region.

[0014] A binary mask is generated based on the body region and the background region as the reference mask, wherein the image pixel value corresponding to the body region in the reference mask is set as a first value, and the image pixel value corresponding to the background region is set as a second value;

[0015] The reference image and the reference mask are associated and stored with the model identifier of the target terminal device under test.

[0016] In one possible implementation, the reference image is subjected to size adaptive estimation along the first direction to determine the preliminary boundary position of the target terminal device under test. The preliminary boundary position is a rough position estimate of the outer contour boundary in the first direction, which is used to limit the search range of subsequent edge detection.

[0017] Based on the preliminary boundary positions, the reference image is divided into multiple regions, and edge detection is performed independently on each region to obtain the edge detection results for each region;

[0018] The edge detection results of each region are fused and binarized to obtain the continuous outer contour boundary of the terminal device.

[0019] In one possible implementation, grayscale gradients are scanned along the first direction on both sides of the vertical center line of the reference image.

[0020] Detect the locations of gray-level gradient transitions as preliminary boundary estimates;

[0021] The preliminary boundary estimate is corrected based on the pre-stored model size tolerance of the target terminal device under test, and the accurate boundary position of the target terminal device under test is output.

[0022] In one possible implementation, the target terminal device under test is kept fixed in the second direction, and at least two independent images are taken of the first side region and the second side region of the target terminal device under test in the first direction to obtain a first local X-ray image and a second local X-ray image, wherein the second direction is perpendicular to the first direction;

[0023] Based on the geometric constraints of the target terminal device under test, the first local X-ray image and the second local X-ray image are stitched together in the first direction so that the two side borders of the target terminal device under test in the first direction are fully presented and aligned in the stitched image. The geometric constraints include the proportional relationship between the length and width of the target terminal device under test.

[0024] In one possible implementation, the reference mask is superimposed onto the registered image to be tested according to pixel positions;

[0025] The consistency measure between the reference mask and the registered image under test in the overlapping region is calculated and used as the matching degree.

[0026] If the matching degree is greater than or equal to the preset threshold, output a quality inspection pass result;

[0027] If the matching degree is less than the preset threshold, the quality inspection result is output as unqualified.

[0028] In one possible implementation, the registered image to be tested is synchronized with the reference mask in terms of position, so that the spatial coordinate system of the reference mask is consistent with the spatial coordinate system of the registered image to be tested.

[0029] In one possible implementation, feature points are extracted from the stitched image to be tested and the reference image, and the extracted feature points are matched.

[0030] Based on the matching results, the geometric transformation parameters between the stitched image to be tested and the reference image are calculated. The geometric transformation parameters are then used to transform the stitched image to be tested, so that the body region in the stitched image to be tested is aligned with the device body region in the reference image in spatial position.

[0031] The transformed image is output as the registered image to be tested.

[0032] Secondly, embodiments of this application provide an X-ray quality inspection image processing device for terminal equipment, including: an acquisition module, used to acquire a reference image and a reference mask corresponding to a target terminal equipment under test, wherein the reference image is a model reference X-ray image of the target terminal equipment under test, and the reference mask is used to mark the outline of the body region of the target terminal equipment under test in the reference image;

[0033] The stitching module is used to acquire multiple local X-ray images obtained by taking multiple X-ray images of the target terminal device under test, and stitch the multiple local X-ray images along a first direction to obtain a stitched image under test, wherein the first direction is the smaller dimension direction in the outline of the body area of ​​the target terminal device under test.

[0034] The registration module is used to perform image registration between the stitched image to be tested and the reference image to obtain the registered image to be tested.

[0035] The quality inspection module is used to overlay the reference mask onto the registered image to be tested, and obtain the standardized quality inspection result of the target terminal device under test based on the matching degree between the reference mask and the image to be tested.

[0036] Thirdly, embodiments of this application provide a terminal device X-ray quality inspection image processing device, including: a memory and a processor;

[0037] The memory stores computer-executed instructions;

[0038] The processor executes computer execution instructions stored in the memory, causing the processor to perform the first aspect and / or various possible implementations of the first aspect as described above.

[0039] Fourthly, embodiments of this application provide a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, are used to implement the first aspect and / or various possible implementations of the first aspect.

[0040] Fifthly, embodiments of this application provide a computer program product, including a computer program that, when executed by a processor, implements the first aspect and / or various possible implementations of the first aspect.

[0041] The terminal device X-ray quality inspection image processing method, electronic device, storage medium, and program product provided in this application embodiment pre-establish a reference image and reference mask for the target model. During online detection, multiple local X-ray images captured multiple times are acquired and stitched together along a first direction to obtain a complete image. Then, the stitched image is registered with the reference image to achieve spatial alignment. Finally, the reference mask is superimposed on the registered image, and the quality inspection result is output according to the matching degree. This makes the entire preprocessing process no longer dependent on the rich texture features of the image under test itself, and does not require complex deep learning calculations for each image, thus achieving the effect of rapid detection by the terminal device. Attached Figure Description

[0042] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.

[0043] Figure 1 Flowchart of the X-ray quality inspection image processing method for the terminal equipment provided in this application Figure 1 ;

[0044] Figure 2 Flowchart of the X-ray quality inspection image processing method for the terminal equipment provided in this application Figure 2 ;

[0045] Figure 3 A schematic diagram of the first partial X-ray image (left side region) provided for this application;

[0046] Figure 4 A schematic diagram of the second partial X-ray image (right side region) provided in this application;

[0047] Figure 5 A schematic diagram of the stitched image to be tested provided in this application;

[0048] Figure 6 A schematic diagram of the structure of the X-ray quality inspection image processing device for the terminal equipment provided in this application;

[0049] Figure 7 This is a schematic diagram of the structure of the X-ray quality inspection image processing device provided in this application.

[0050] The accompanying drawings illustrate specific embodiments of this application, which will be described in more detail below. These drawings and descriptions are not intended to limit the scope of the concept in any way, but rather to illustrate the concept of this application to those skilled in the art through reference to particular embodiments. Detailed Implementation

[0051] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.

[0052] The technical solution of this application and how the technical solution of this application solves the above-mentioned technical problems are described in detail below with specific embodiments. These specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments. The embodiments of this application will now be described with reference to the accompanying drawings.

[0053] Figure 1 Flowchart of the X-ray quality inspection image processing method for the terminal equipment provided in this application Figure 1 ,like Figure 1 As shown, the method includes:

[0054] S101. Obtain the reference image and reference mask corresponding to the model of the target terminal device under test.

[0055] The reference image is a reference image selected in advance from qualified X-ray images of the target terminal equipment model under test, and the reference mask is used to mark the outline of the equipment body area in the reference image.

[0056] The term "terminal device" refers to an electronic device with a screen, including but not limited to mobile phones, tablets, laptops, smartwatches, and in-vehicle displays. In this embodiment, a mobile phone is used as an example, but the scope of protection of this application is not limited thereto.

[0057] An X-ray image is an image taken by an X-ray device that can reveal the internal structure of a terminal device, including information such as the distribution of components, solder joints, and internal circuitry.

[0058] In this step, the image processing device first needs to obtain the model information of the mobile phone under test. This model information can be obtained through manual input, barcode scanning, or automatic reading from the production management system. Based on this model information, the image processing device loads the reference image and reference mask corresponding to the model from a pre-built template library.

[0059] S102. Acquire multiple local X-ray images obtained by taking multiple X-ray images of the target terminal device under test, and stitch the multiple local X-ray images along the first direction to obtain the stitched image under test.

[0060] The first direction is the dimension with the smaller size in the shape of the target terminal device under test.

[0061] Taking a mobile phone as an example, when the phone is in portrait mode, its width is less than its length, and the first direction is the width direction; when the phone is in landscape mode, its height is less than its length, and the first direction is the height direction. Those skilled in the art will understand that the specific definition of the first direction can be flexibly determined based on the actual shape of the terminal device and the X-ray imaging method.

[0062] A partial X-ray image refers to an image of a localized area obtained when a single image cannot completely cover the terminal device due to the limited field of view of the X-ray equipment. The number of partial X-ray images can be two or more, depending on the relative size of the terminal device and the field of view of the X-ray equipment.

[0063] Since X-ray equipment typically has a limited field of view, a single image often cannot completely cover the entire area of ​​a mobile phone, especially in the first direction (i.e., the smaller dimension of the phone's shape, such as the width). To address this issue, this step first acquires multiple partial X-ray images of the phone under test through multiple X-ray imaging sessions. Then, these partial images are stitched together along the first direction to form a stitched image of the phone under test that includes the complete outline of the phone.

[0064] S103. Perform image registration between the stitched image to be tested and the reference image to obtain the registered image to be tested.

[0065] Registration refers to the process of aligning two or more images in spatial position so that the same objects or regions in different images have consistent coordinate positions after transformation.

[0066] Overlay refers to the operation of merging the pixel information of two images point by point according to their positions. For example, overlaying a mask image onto the original image, and deciding whether to retain or mask the pixels in the original image based on the mask value.

[0067] Because the placement of the mobile phone under test in the X-ray equipment may be off, even after stitching, the absolute position of the mobile phone body area in the stitched image may not be consistent with its position in the reference image. Therefore, this step requires image registration between the stitched image under test and the reference image, and spatial transformation of the stitched image under test to align it spatially with the reference image, resulting in the registered image under test.

[0068] S104. Overlay the reference mask onto the registered image to be tested, and obtain the standardized quality inspection result of the target terminal device under test based on the matching degree between the reference mask and the image to be tested.

[0069] After image registration is completed, this step overlays a reference mask onto the registered image under test. Since the registered image under test and the reference image have already achieved spatial alignment, the reference mask can be directly overlaid onto the registered image under test according to pixel position, thereby removing the background area.

[0070] Matching degree can be calculated in various ways. For example, the proportion of effective pixels in the device body region of the image under test can be counted, the degree of overlap between the edge of the image under test and the boundary of the reference mask can be calculated, the similarity between the image under test and the reference image in the device body region can be calculated, or other metrics that can quantify the consistency between two images can be used.

[0071] After obtaining the matching degree, the image processing device compares the matching degree with a preset threshold. The preset threshold can be set according to the specific application scenario and accuracy requirements, for example, it can be set to a value such as 0.7, 0.8, or 0.9, or it can be set as a percentage. When the matching degree is greater than or equal to the preset threshold, a quality inspection qualified result is output, indicating that the X-ray image quality of the target terminal device under test is qualified, the device is correctly placed, and the image acquisition is complete; when the matching degree is less than the preset threshold, a quality inspection unqualified result is output, indicating that there is an anomaly in the image under test, which can trigger an alarm, prompt a re-shoot, or mark it as requiring manual review.

[0072] Quality inspection results can be output in various forms, such as displaying "qualified" or "unqualified" text or icons on a screen, displaying different colors via indicator lights, providing sound prompts, uploading the results to the production management system, or storing the results in a log file. The specific choice of output format does not constitute a limitation of this application.

[0073] In addition, this step also outputs the quality inspection result based on the matching degree between the reference mask and the registered image under test. When the matching degree is high, it indicates that the image under test is consistent with the reference template, and a quality inspection qualified result is output; when the matching degree is low, it indicates that there is an anomaly in the image under test, and a quality inspection unqualified result is output.

[0074] The X-ray quality inspection image processing method for terminal devices provided in this application pre-establishes a reference image and a reference mask for the target model. During online detection, multiple local X-ray images captured multiple times are acquired and stitched together along a first direction to obtain a complete image. Then, the stitched image is registered with the reference image to achieve spatial alignment. Finally, the reference mask is superimposed on the registered image, and the quality inspection result is output according to the matching degree. This makes the entire preprocessing process no longer dependent on the rich texture features of the image under test itself, and does not require complex deep learning calculations for each image, thus achieving the effect of rapid detection by the terminal device.

[0075] Figure 2Flowchart of the X-ray quality inspection image processing method for the terminal equipment provided in this application Figure 2 ,like Figure 2 As shown, in this embodiment... Figure 1 Based on the embodiments, the X-ray quality inspection image processing method of the terminal device is described in detail. The method includes:

[0076] S301. Obtain multiple X-ray images of the same model of the target terminal device under test, and select images that meet the preset quality requirements as a set of qualified X-ray images; from the set of qualified X-ray images, select the image with the largest imaging clarity index value and the smallest geometric distortion index value as the model reference X-ray image to determine the benchmark image; perform edge detection on the benchmark image to extract the outer contour boundary of the target terminal device under test; according to the outer contour boundary, divide the benchmark image into two regions: the inner region enclosed by the outer contour boundary as the body region of the target terminal device under test, and the outer region located outside the outer contour boundary as the background region;

[0077] A binary mask is generated based on the body region and the background region as a reference mask. The reference image and the reference mask are then associated and stored with the model identifier of the target terminal device under test.

[0078] In this reference mask, the image pixel value corresponding to the body region is set to the first value, and the image pixel value corresponding to the background region is set to the second value.

[0079] Image sharpness index (ISI) is a numerical metric used to quantify the clarity of X-ray images. Generally, higher ISI indicates sharper edges and richer details in the image. ISI values ​​can be calculated in various ways, such as based on the root mean square of the gray-level gradient, the variance of the image's Laplacian operator, or the energy proportion of high-frequency components in the frequency domain. A higher ISI value indicates a sharper image.

[0080] The geometric distortion index (GDI) is a numerical measure used to quantify the degree of geometric deformation in X-ray images. Geometric distortion is typically caused by factors such as the optical path characteristics of X-ray equipment, equipment aging, or shooting angle deviations, manifesting as curved lines and distorted object shapes in the image. A smaller GDI value indicates that the geometry of the equipment in the image is closer to its true form. The GDI value can be calculated in various ways, such as based on the straightness deviation of reference lines in the image (e.g., equipment edges, lines on a standard calibration plate), statistical analysis based on corner offsets, or distortion field analysis based on the calibration template.

[0081] No geometric distortion means that the degree of geometric distortion in an image is slight, within an acceptable range, and does not affect subsequent registration and quality inspection operations. In practical applications, "no geometric distortion" can be quantitatively judged by setting a distortion threshold: when the geometric distortion index value is less than or equal to the threshold, it is considered to have no geometric distortion.

[0082] Optionally, the selection of the reference X-ray image for the machine model can also be determined by whether there is any occlusion in the image.

[0083] Unobstructed means that the main body area of ​​the target terminal device in the X-ray image is not obstructed by other objects (such as clamps, cables, operators' hands, etc.), and the internal structure of the device is clearly visible. Unobstructedness is an important condition for ensuring that the reference image has complete reference value.

[0084] Edge detection refers to image processing techniques that detect pixels in an image where their brightness changes drastically and connect these pixels to form lines that outline the contours of objects. Examples include the Sobel operator, the Canny operator, and the Laplacian operator.

[0085] In this step, the image processing equipment first needs to acquire multiple X-ray images of the target terminal device model under test. These X-ray images can come from various sources: for example, extracting qualified X-ray images of the model from a historical production inspection database; taking a batch of X-ray images specifically for the model on the production line as a sample; or collecting them from test images during the product development phase.

[0086] After acquiring multiple X-ray images, the image processing device performs a quality assessment on each image one by one to determine whether it meets preset quality requirements. These preset quality requirements are the basic conditions used to select qualified images. In this embodiment, the preset quality requirements include the following three conditions:

[0087] Condition 1: Image sharpness is greater than or equal to the sharpness threshold.

[0088] Image sharpness reflects the sharpness and detail visibility of an X-ray image. In mobile phone X-ray quality inspection scenarios, a clear image can clearly display key information such as component boundaries, solder joint shapes, and circuit routing, while an unclear image (such as blur caused by motion blur, defocus, underexposure, or overexposure) makes accurate registration and defect identification difficult.

[0089] Image processing devices can employ various algorithms to calculate the image sharpness index. As an optional implementation, a gray-level gradient-based method can be used: the sharper the image edges, the larger the gradient, and the higher the sharpness index value.

[0090] Specifically, the gradient magnitude of each pixel in the image can be calculated, and then the root mean square of the gradient magnitudes of all pixels can be taken as the sharpness index. The sharpness threshold can be set according to specific application requirements; for example, it can be set to 80% of an empirical value, or it can be determined by statistically analyzing the sharpness distribution of a large number of qualified images.

[0091] Condition 2: No geometric distortion:

[0092] Geometric distortion refers to the deformation of an object's shape in an X-ray image relative to its true shape. Geometric distortion can be caused by the optical path characteristics of the X-ray equipment (such as barrel or pincushion distortion in edge regions), equipment aging, or deviations in the shooting angle. Images with geometric distortion will distort the actual shape of the equipment itself, leading to deviations in subsequent registration and mask stacking.

[0093] Image processing devices can employ various methods to detect geometric distortion. As an optional implementation, the linearity of device edges can be utilized for detection: when device edges appear curved rather than straight in an image, it indicates the presence of geometric distortion. Specifically, candidate edge points of the device border in the image can be extracted, straight lines can be fitted to these points, and the average or maximum distance from each point to the fitted line can be calculated as a geometric distortion index. When this index value is less than or equal to a preset distortion threshold, it is determined that there is no geometric distortion.

[0094] Condition 3: No obstructions:

[0095] Occlusion refers to the obscuring of a region of the equipment in an X-ray image by other objects, making parts of the internal structure invisible. In a production environment, factors that may cause occlusion include: clamps blocking the edges of the equipment, cables hanging down and covering the equipment, and operators accidentally placing their hands in the imaging area. Images with occlusion are unsuitable as reference bases because the missing information in the occluded area will result in an incomplete reference mask.

[0096] Image processing devices can employ various methods to detect occlusion. One optional implementation is template matching: a coarse positional model of the device's body area is pre-established to determine if there are abnormal grayscale jumps or shape abrupt changes within that area. Another optional implementation is grayscale statistics-based methods: the grayscale values ​​of X-ray images within the device's body area typically exhibit certain regularities (e.g., symmetry between the left and right sides). When the grayscale values ​​of a certain area significantly deviate from this statistical regularity, it may indicate the presence of occlusion.

[0097] It should be noted that all three conditions in the preset quality requirements can be met simultaneously, or only some conditions can be required to be met according to actual application needs. For example, on a production line with stable image quality, the sharpness threshold can be set higher, while strict requirements are also placed on geometric distortion and occlusion; when the number of samples is limited, some conditions can be appropriately relaxed. Those skilled in the art can flexibly configure the specific content of the preset quality requirements according to the specific application scenario.

[0098] In this step, the image processing equipment filters out images that meet the quality requirements from multiple raw X-ray images, forming a qualified X-ray image set. The images in this set all have good imaging quality and can serve as a reliable candidate pool for further screening of benchmark images.

[0099] After obtaining a set of qualified X-ray images, this step selects the best image as the baseline image. The selection criteria are: the highest image sharpness index value and the lowest geometric distortion index value.

[0100] "Maximum image sharpness index value" means that the selected image has the highest sharpness among the qualified image set, providing the richest edge and detail information, which is beneficial to the accuracy of subsequent edge detection and mask generation. "Minimum geometric distortion index value" means that the selected image has the slightest degree of geometric distortion among the qualified image set, and the device outline is closest to the real shape. In this way, the generated reference mask can accurately reflect the actual boundary of the device body.

[0101] In practice, there may be two images where one has higher clarity but greater distortion, and the other has less distortion but slightly lower clarity. In this case, a weighted scoring method can be used for comprehensive ranking, or one of the indicators can be prioritized. As a preferred implementation method in this embodiment, priority is given to ensuring the accuracy of the device's outer contour, that is, the image with the smallest geometric distortion is selected first, and then the image with the highest clarity is selected based on this.

[0102] After selecting a reference image, this step performs edge detection on the reference image to extract the outer contour boundary of the terminal device. The purpose of edge detection is to find the boundary line between the device body area and the background area in the image.

[0103] Specifically, the image processing device first applies an edge detection operator to the reference image to obtain an edge map containing all edge points. Then, edge points belonging to the device's outer contour are selected from the edge map. This selection can be done by retaining the longest edges located outside the image and forming closed regions, based on prior knowledge of the device's shape (e.g., the four sides of a rectangle). Finally, the selected edge points are connected to form a continuous closed curve, which serves as the outer contour boundary of the device.

[0104] As an alternative implementation, to improve the accuracy of edge detection, the reference image can be divided into multiple regions, and edge detection can be performed independently on each region. The detection results from each region are then fused. This partitioned edge detection method can effectively address differences in grayscale distribution across different regions of the image, improving the robustness of edge detection.

[0105] After obtaining the outer contour boundary of the device, this step generates a corresponding binary mask based on the boundary.

[0106] A binary mask is an image of the same size as the reference image, with pixel values ​​taking only two values. In this embodiment, pixels within the device body region are set to a first value (e.g., 1, 255, or any non-zero value), and pixels within the background region are set to a second value (e.g., 0). Specifically, the image processing device first creates an image of all zeros (i.e., all pixel values ​​are 0) of the same size as the reference image. Then, all pixel values ​​within the closed region enclosed by the outer contour boundary are set to the first value. This generates a binary mask that only identifies the location of the device body region.

[0107] It should be noted that the specific values ​​of the first and second values ​​can be selected according to the needs of subsequent processing. For example, when the mask is used for pixel-level multiplication, the device body area can be set to 1 and the background area to 0. In this way, after the mask is multiplied by the image, the pixels in the device body area remain unchanged, while the background area becomes black. When the mask is used for image fusion, other values ​​can also be used. This application does not limit the specific values ​​of the first and second values.

[0108] After the reference image and reference mask are generated, this step associates and stores them with the identifier of the target terminal device model for quick retrieval and retrieval during subsequent online detection.

[0109] Specifically, the image processing device assigns a unique model identifier to the target terminal device, such as "Model_A" or "Product_12345". Then, it establishes a relationship between this model identifier, the reference image, and the reference mask, and stores them together in a storage medium. The storage medium can be a local hard drive, solid-state drive, network-attached storage, database system, or cloud storage service, etc.

[0110] There are several ways to implement associative storage. For example, a template table can be created in the database, with each record containing three fields: aircraft model identifier, file path of the baseline image, and file path of the baseline mask. Alternatively, subdirectories can be created in the file system based on the aircraft model identifier, storing the baseline image and baseline mask files in these subdirectories. The filenames are fixed, and the corresponding subdirectory can be located and accessed using the aircraft model identifier. Another option is to encode the baseline image and baseline mask into binary data and store them as key-value pairs in an in-memory database or cache system, with the aircraft model identifier as the key and the combined image and mask data as the value.

[0111] For example, the size of the reference image is adaptively estimated along a first direction to determine the boundary position of the terminal device; the reference image is divided into multiple regions, and edge detection is performed independently on each region to obtain the edge detection results of each region; the edge detection results of each region are fused and binarized to obtain the continuous outer contour boundary of the terminal device.

[0112] Size adaptive estimation refers to a method that automatically calculates and determines the size range (such as width, height, and boundary position) of a terminal device within an image based on the image's inherent content features. Unlike fixed-size assumptions, size adaptive estimation can adapt to size variations caused by different devices, shooting distances, and imaging scales, improving the robustness of boundary detection. Size adaptive estimation can be achieved by analyzing image gray-level gradient distribution, statistically analyzing edge point projections, or utilizing shape prior constraints.

[0113] Boundary location refers to the specific coordinates of the outer contour of the terminal device in the image, typically including the left, right, top, and bottom boundaries (i.e., the rectangular area occupied by the device itself). Accurately determining the boundary location is fundamental for subsequent edge detection and mask generation.

[0114] In this embodiment, in order to solve the problem of unstable edge detection caused by large differences in features in different regions of mobile phone X-ray images (e.g., different component densities in the top and bottom regions of the phone, and different X-ray transmittance in the screen and non-screen regions), this embodiment proposes a processing method that combines size adaptive estimation and partitioned edge detection, which can accurately and robustly extract the continuous outer contour boundary of the terminal device.

[0115] Before performing edge detection, it is necessary to first determine the approximate position and size range of the terminal device in the reference image. Since different mobile phone models have different sizes, and the imaging position and scaling ratio of the same model may also differ in different X-ray images, a size adaptive estimation method is needed to automatically determine the boundary position, avoiding boundary positioning errors caused by relying on fixed size assumptions.

[0116] In this step, the image processing device performs adaptive size estimation of the reference image along a first direction (i.e., the smaller dimension of the device's shape, such as the width of a mobile phone). The specific implementation is as follows:

[0117] First, the image processing device scans the grayscale gradient along the horizontal direction (i.e., the first direction) on both sides of the vertical center line of the reference image. The vertical center line is a straight line that divides the reference image evenly in the vertical direction (i.e., the second direction, perpendicular to the first direction). In the regions to the left and right of this center line, the image is scanned pixel by pixel from the edge towards the center, and the grayscale difference between adjacent pixels, i.e., the grayscale gradient, is calculated.

[0118] When the scan line passes the left edge of the phone, a significant positive jump in the grayscale gradient occurs due to the obvious grayscale difference between the phone and the background (the phone appears gray under X-ray, while the background is usually darker). Similarly, when the scan line passes the right edge of the phone, a significant negative jump in the grayscale gradient occurs. By detecting these jump locations, the image processing device can preliminarily estimate the left and right boundary positions of the phone.

[0119] However, due to potential noise, localized grayscale anomalies, or interfering objects in the background of X-ray images, boundary estimates obtained using only a single scan line may contain errors. To improve robustness, multiple scan lines can be selected in the vicinity of the vertical center line (e.g., several horizontal scan lines above and below the vertical center line), and the boundary position can be detected for each scan line separately. Then, statistical analysis (such as taking the median or average) can be performed on the multiple detection results to obtain a preliminary boundary estimate.

[0120] After obtaining the initial boundary estimate, the image processing device further corrects the boundary position based on the pre-stored size tolerance of the target terminal device under test. Specifically, the standard width (in pixels) of the device under standard shooting conditions is known. The image processing device compares the initially estimated width with this standard width. If the deviation exceeds the preset tolerance range (e.g., the number of pixels corresponding to ±2mm), the boundary position is adjusted appropriately according to the standard width so that the final output boundary position conforms to the size characteristics of the device.

[0121] Through the above processing, the image processing device outputs the precise positions of the left and right boundaries. Similar methods can also be used to determine the positions of the upper and lower boundaries, but since mobile phones are usually large in length and the X-ray imaging field of view is usually sufficient in this direction, the determination of the upper and lower boundaries is relatively simple and can be achieved through projection methods or similar adaptive estimation.

[0122] After determining the boundary location of the terminal device, the image processing equipment learns the approximate range of the phone's body area. However, the X-ray image characteristics of different areas inside the phone vary significantly: for example, the screen area (the upper half of the phone) typically has low grayscale, sparse texture, and indistinct edges; the motherboard area (the middle of the phone) has dense components, dramatic grayscale changes, and rich edges; the battery area (the lower half of the phone) typically appears as a large area of ​​uniform grayscale with fewer edges. If uniform edge detection parameters are used for the entire image, weak edges in the screen area may be missed, or noise in the battery area may be misdetected as edges.

[0123] To address this issue, this step divides the reference image into multiple regions and performs edge detection independently on each region. The division can be a regular rectangular grid, such as dividing the image into 6 regions in a 2x3 grid or 9 regions in a 3x3 grid. The granularity of the division can be adjusted according to specific application requirements: more regions offer greater flexibility but also increase computational load; fewer regions result in higher processing efficiency but reduced adaptability. As a preferred embodiment, a 2x3 grid division can be used to divide the phone body area into three horizontal strips: top, middle, and bottom, with each strip further divided into left and right sections.

[0124] After segmentation, the image processing device performs edge detection on each region separately. Since the grayscale distribution and noise levels differ in each region, the parameters of the edge detection algorithm (such as the high and low thresholds of the Canny operator) can be set individually based on the statistical characteristics of that region. For example, for screen regions with low grayscale values ​​and weak contrast, a lower detection threshold can be set to capture weak edges; for regions with more noise and frequent grayscale changes, a higher detection threshold can be set to suppress false edges.

[0125] By performing edge detection independently in each region, a local edge map is obtained for each region, which contains all the edge points detected in that region.

[0126] After obtaining the local edge maps of each region, this step merges them into a complete edge map and further processes them to obtain the continuous outer contour boundary of the terminal device.

[0127] The fusion process includes the following sub-steps:

[0128] First, the local edge maps of each region are stitched together according to their original spatial positions to form a complete edge map with the same size as the original image. During stitching, attention must be paid to the edge continuity at the boundaries of adjacent regions. For example, there may be edge breaks between the left and right regions at the horizontal boundary line; in this case, morphological dilation or edge-connecting algorithms can be used to connect the breaks.

[0129] Secondly, the fused complete edge image is binarized to convert the grayscale edge image into a binary edge image. The purpose of binarization is to clearly separate edge points (foreground) from non-edge points (background). Binarization can be performed using a global thresholding method (such as Otsu's method to automatically determine the threshold) or an adaptive thresholding method (dynamically adjusting the threshold based on local grayscale characteristics).

[0130] After binarization, a black and white image is obtained: white pixels represent detected edge points, and black pixels represent non-edge points.

[0131] Finally, the continuous outer contour boundary of the terminal device is extracted from the binary edge map. The outer contour boundary refers to the closed curve that constitutes the outermost edge of the phone casing. It should be a continuous, unbroken boundary line that completely surrounds the phone body area.

[0132] Edge tracking algorithms can be used to extract continuous outer contour boundaries. Specifically, starting from the top left corner of the binary edge map, the algorithm moves counterclockwise along the edge points, recording the path taken. When there are breaks in the edge map, the following methods can be used for repair: first, perform morphological closing operations (dilation followed by erosion) to connect the breaks; second, perform edge connection, connecting neighboring edge points based on the gradient direction and distance of the edge points.

[0133] Through the above processing, a continuous, closed outer contour boundary of the terminal device is finally obtained. This boundary can accurately define the contour of the device body area, providing a reliable boundary basis for the subsequent generation of accurate reference masks.

[0134] For example, grayscale gradients are scanned along a first direction on both sides of the vertical center line of the reference image; the grayscale gradient transition positions are detected as preliminary boundary estimates; the preliminary boundary estimates are corrected according to the pre-stored model size tolerance of the target terminal device under test, and the accurate boundary position of the target terminal device under test is output.

[0135] The vertical centerline refers to the center line in the reference image that extends vertically (i.e., the second direction, perpendicular to the first direction) and divides the image horizontally (i.e., the first direction) into left and right halves. The vertical centerline is typically located at half the image width. Performing symmetrical scanning with the vertical centerline as a reference can improve the accuracy of boundary detection by utilizing the symmetry of the phone's shape in the width direction.

[0136] Gray-level gradient refers to the rate of change of gray level between adjacent pixels in an image. In digital images, the gray-level gradient can be approximately calculated using the gray-level difference between adjacent pixels. The magnitude of the gray-level gradient reflects the drastic degree of local gray-level change in the image; a larger gradient value indicates the possible presence of an edge at that location. In this embodiment, the gray-level gradient is scanned along a first direction, that is, the gray-level difference between the current pixel and its right-side adjacent pixel is calculated pixel by pixel in the horizontal direction.

[0137] Gray-level gradient transition locations refer to the pixel locations where the gray-level gradient exhibits extreme values ​​or significant changes. When a scan line enters the phone's main body area from the background area, a large positive peak appears in the gray-level gradient due to the significant gray-level difference between the background and the phone's main body. Conversely, when the scan line leaves the phone's main body area and enters the background area, a large negative peak appears in the gray-level gradient. The locations where these peaks occur are potential boundary locations.

[0138] Model dimensional tolerance refers to the allowable deviation range of the image size (such as width and height) of a specific mobile phone model under standard shooting conditions. Due to manufacturing tolerances, the actual physical dimensions of different individual mobile phones may vary slightly. In addition, there may be slight positional deviations during the shooting process. Therefore, it is necessary to set a reasonable dimensional tolerance range. Dimensional tolerance is usually expressed in pixels, but it can also be calculated by combining physical dimensions (such as millimeters) with image resolution.

[0139] In this embodiment, in order to solve the problem of unstable boundary detection caused by interference factors such as local noise and uneven grayscale that may occur in a single shot, this embodiment proposes a boundary positioning method that combines multi-scan line statistics and model size tolerance correction, which can accurately and robustly determine the left and right boundary positions of the terminal device.

[0140] In this step, the image processing device uses the vertical center line of the reference image as the reference axis and scans the grayscale gradient along the first direction (i.e., the horizontal direction, which is the width direction of the mobile phone) on both the left and right sides of the reference image.

[0141] The vertical center line is determined as follows: Assuming the width of the reference image is W pixels, the vertical center line is located at x = W / 2 (if W is odd, it can be rounded down). This center line divides the image into a left and right half.

[0142] In the region to the left of the vertical center line, the image processing device starts from the left edge of the image (x=0) and scans to the right towards the vertical center line (x=W / 2). During the scanning process, the gray-level gradient is calculated pixel by pixel. The gray-level gradient can be calculated using the first-order difference method: let the gray-level value of the pixel at the current position be I(x), then the gradient G(x) = I(x+1) - I(x). A positive gradient value indicates a change in gray level from low to high (i.e., from the background into the phone body), and a negative gradient value indicates a change in gray level from high to low (i.e., from leaving the phone body into the background). Since the left edge of the phone body is where the background enters the phone body, the left boundary position usually corresponds to a positive gradient peak.

[0143] Similarly, in the region to the right of the vertical center line, the image processing device starts from the right edge of the image (x=W-1) and scans to the left towards the vertical center line (x=W / 2). The right edge is where the phone body leaves the background, so the right boundary position usually corresponds to a negative gradient peak (a peak in absolute terms).

[0144] To improve detection robustness, this step does not scan at a single height position on the vertical centerline, but instead selects multiple scan lines within a certain height range near the vertical centerline. Specifically, K horizontal scan lines (e.g., K=10) can be selected above and below the vertical centerline, forming a total of 2K+1 scan lines (including the vertical centerline itself). Each scan line independently performs grayscale gradient scanning and transition position detection to obtain a set of boundary candidate points.

[0145] By using multiple scan lines, boundary detection errors caused by noise or local anomalies (such as blurring or occlusion in a single scan line) can be reduced. When the boundary positions detected by different scan lines are inconsistent, a more robust estimate can be obtained through statistical methods (such as taking the median, mean, or mode).

[0146] After obtaining the grayscale gradient curve, this step detects the transition positions from the gradient curve as preliminary boundary estimates.

[0147] The specific method for detecting transition positions is as follows:

[0148] For scanning the left region, the image processing device scans the gradient curve from left to right, searching for the first positive peak position that exceeds a preset gradient threshold. The gradient threshold can be dynamically set based on the overall contrast of the image; for example, it can be set to 10% of the image's global grayscale range, or empirically to 20-30. When the gradient value first exceeds this threshold, that position is recorded as a candidate position for the left boundary. If multiple peaks are detected on the same scan line (e.g., due to other interfering edges in the image), the first significant peak is taken as the candidate value for the left boundary.

[0149] For scanning the right-side region, the image processing device scans the gradient curve from right to left, searching for the first negative peak position that exceeds a preset gradient threshold (i.e., the negative position where the absolute value of the gradient exceeds the threshold). This position is recorded as a candidate position for the right boundary.

[0150] Repeat the above detection process for each scan line to obtain a set of left boundary candidate positions L = {l1, l2,..., lM} and a set of right boundary candidate positions R = {r1, r2, ..., rM}, where M is the total number of scan lines (e.g., M = 2K+1).

[0151] To obtain robust preliminary boundary estimates, the image processing device performs statistical analysis on the candidate location set. For the left boundary, the median or mean of all candidate locations can be calculated, and then the average value is taken after removing significantly outliers. For example, the candidate locations can be sorted from smallest to largest, the largest and smallest 10% can be removed, and the average value of the remaining candidate locations can be calculated. The resulting value is used as the preliminary estimate of the left boundary, L_est. Similarly, the same statistical analysis is performed on the candidate location set for the right boundary to obtain the preliminary estimate of the right boundary, R_est.

[0152] In addition, a preliminary estimated width W_est = (R_est - L_est + 1) can be calculated for subsequent tolerance correction. If the preliminary estimated width deviates significantly from the expected width, it may indicate a large error in the detection process, requiring more stringent correction or alarms to be triggered.

[0153] After obtaining the initial boundary estimate, this step corrects the boundary position based on the pre-stored model size tolerance to ensure that the final output boundary position conforms to the physical size characteristics of the model.

[0154] Specifically, for the target terminal device model, the system pre-stores the standard width W_std (in pixels) of that model under regulated shooting conditions, as well as the allowable tolerance range ΔW (e.g., ±10 pixels, corresponding to a physical tolerance of ±2mm). The standard width can be obtained through calibration: place a calibration board of known size on the shooting station, calculate the conversion relationship between pixels and physical size based on the imaging size of the calibration board, and then multiply it by the actual width of the phone to obtain the standard width. Alternatively, it can be determined by statistically averaging the widths of multiple qualified images of that model.

[0155] The image processing device first calculates a preliminary estimated width W_est = R_est - L_est + 1, and compares it with the standard width W_std:

[0156] If |W_est - W_std| ≤ ΔW, meaning the initial estimated width is within the tolerance range, then the initial boundary estimate is accepted and output as the final precise boundary position.

[0157] If W_est - W_std > ΔW, meaning the initial estimated width is greater than the upper limit of the standard width, it indicates a possible outward offset in boundary detection. In this case, using the standard width as a constraint, adjust the boundary position based on the initial boundary estimate: for example, fix the left boundary L_est and set the right boundary as R_corrected = L_est + W_std - 1; or fix the right boundary R_est and set the left boundary as L_corrected = R_est - W_std + 1; or simultaneously shrink both sides towards the middle until the width meets the standard. The specific adjustment method can be determined based on the confidence level of the initial boundary estimate (for example, if the left boundary detection is consistent but the right boundary is scattered, then fix the left boundary and adjust the right boundary).

[0158] If W_std - W_est > ΔW, meaning the initial estimated width is less than the lower limit of the standard width, it indicates that there may be an inward offset in boundary detection. Similarly, the boundary position is expanded outward with the standard width as a constraint.

[0159] Through the above correction process, even if there is a small offset in the initial boundary estimate (for example, the boundary shrinks inward by a few pixels due to local noise), it can be corrected by dimensional tolerance constraints, ensuring that the boundary position of the final output is accurate and reliable.

[0160] The image processing device ultimately outputs the precise left boundary position L_final and right boundary position R_final. These two positions define the horizontal area occupied by the terminal device in the reference image, providing a precise spatial range basis for subsequent partition edge detection and mask generation.

[0161] If necessary, a similar method can be used to estimate the positions of the upper and lower boundaries along the second direction (vertical direction). However, since the length of a mobile phone is usually large and the field of view of an X-ray is usually sufficient in this direction, the determination of the upper and lower boundaries is relatively simple and will not be elaborated here.

[0162] S302. The target terminal device under test is kept fixed in the second direction. At least two independent images are taken of the first side area and the second side area of ​​the target terminal device under test in the first direction to obtain a first partial X-ray image and a second partial X-ray image. Based on the geometric constraints of the target terminal device under test, the first partial X-ray image and the second partial X-ray image are stitched together in the first direction so that the two side borders of the target terminal device under test in the first direction are fully presented and kept aligned in the stitched image.

[0163] The second direction is perpendicular to the first direction; the geometric constraints include the proportional relationship between the length and width of the target terminal device under test.

[0164] The first and second side regions refer to the two side regions of the target terminal device under test in the first direction. Taking a mobile phone as an example, when the first direction is the width direction, the first side region is the left side region (including the left border and the internal structure on the left), and the second side region is the right side region (including the right border and the internal structure on the right). The first and second side regions can partially overlap or be exactly adjacent. When there is an overlapping area, the content of the overlapping area can be used for matching and alignment during subsequent splicing.

[0165] In this embodiment, in order to solve the problem that the field of view of X-ray equipment is limited and a single shot cannot completely cover the width direction of the terminal equipment, this embodiment proposes a stitching method based on two independent shots and geometric constraints of the shape. By shooting the left and right regions separately, and then stitching the two local images along the first direction, a stitched image to be tested containing the complete left and right borders is obtained.

[0166] In this step, the image processing device first needs to set the shooting parameters of the X-ray equipment and control the X-ray equipment to perform two independent X-ray shooting operations.

[0167] The X-ray equipment remains fixed along the second direction, meaning that its relative position to the target terminal device along its length remains unchanged during the two imaging processes. In practice, the target terminal device can be placed on a conveyor belt with its length aligned with the conveyor belt direction (or with the scanning direction of the X-ray equipment), while the position of the X-ray equipment in the width direction can be adjusted between the two imaging processes.

[0168] First image capture: The image processing device controls the X-ray equipment to align with the target terminal device in a first direction, targeting a first side region (e.g., the left side region), triggering X-ray exposure and acquiring a first partial X-ray image. This image contains the left border of the target terminal device and information about its internal structure on the left side. If the X-ray equipment has an automatic positioning function, it can automatically calculate the position of the first image capture based on the device's estimated width and a preset overlap rate.

[0169] Second image capture: After the first image capture, the image processing equipment controls the X-ray equipment (or controls the mobile platform carrying the target terminal device to move a certain distance along the first direction, aligning it with the second side region (e.g., the right side region) of the target terminal device in the first direction. A second X-ray exposure is triggered, acquiring a second local X-ray image. This image contains the right frame of the target terminal device and information about its internal structure on the right side.

[0170] The distance traveled during the two shots needs to be carefully chosen to ensure sufficient overlap between the two images (e.g., an overlap rate of 10% to 30%). The existence of this overlap is crucial for subsequent stitching alignment: the overlapping areas in the two images contain the same internal structural features of the device, which can be used as matching points to calculate the stitching position.

[0171] like Figure 3 As shown, a first partial X-ray image is obtained by taking a picture of the first side region of the target terminal device in a first direction. This image includes the left border and the internal structure on the left side of the device. Figure 4 As shown, a second local X-ray image is obtained by taking a picture of the second side region of the target terminal device in the first direction. This image contains the right frame of the device and the internal structure on the right side.

[0172] Then the first partial X-ray image and the second partial X-ray image are stitched together along the first direction, such as... Figure 5 As shown, in the stitched image, the left and right borders of the device are fully presented and remain aligned.

[0173] It is worth noting that this embodiment uses two shots as an example for illustration. However, in some implementation scenarios, if the terminal device is larger or the X-ray equipment has a smaller field of view, three or more shots may be required. Those skilled in the art can adjust the number of shots according to the actual situation, and these variations all fall within the protection scope of this application.

[0174] After obtaining two partial X-ray images, this step stitches them together along the first direction to form a complete stitched image to be tested.

[0175] The splicing process mainly includes the following sub-steps:

[0176] Sub-step 1: Determine the overlapping area.

[0177] Since the positions of the two images are known, the image processing device can make a preliminary estimate of the relative offset between the two images. This offset is equal to the distance the X-ray device moved in the first direction. Based on this offset, the approximate location of the overlapping area between the first and second local images can be determined.

[0178] To obtain more accurate stitching positions, image processing devices can perform local image matching within overlapping areas. Common matching methods include: gray-level cross-correlation-based matching (calculating the gray-level correlation coefficient within the overlapping area and finding the alignment position that maximizes the correlation coefficient), feature point-based matching methods (extracting feature points within the overlapping area and matching them), or phase correlation-based matching methods.

[0179] Sub-step 2: Perform splicing transformation.

[0180] After determining the optimal alignment position, the image processing device performs spatial transformation and fusion on the two images according to the alignment parameters. Specifically, the first local image can be used as the reference image, and the second local image is translated according to the calculated offset to align it with the content of the first local image in the overlapping area. Within the overlapping area, a weighted average method can be used for pixel fusion: pixels closer to the center of the overlapping area are taken as the weighted average of the pixel values ​​of the two images; pixels closer to the edge are biased towards taking the pixel value of a single image to avoid blurring caused by fusion.

[0181] Sub-step 3: Verify the splicing results by applying geometric constraints on the shape.

[0182] After stitching, the image processing device verifies the stitching result based on the geometric constraints of the terminal device's shape. These geometric constraints include the proportional relationship between the length and width of the terminal device. Taking a mobile phone as an example, the length of a typical mobile phone is approximately twice its width (i.e., the aspect ratio is approximately 2:1). In the stitched image, the image processing device can calculate the device's width (pixel distance from the left border to the right border) and length (pixel distance from the top border to the bottom border), calculate the actual aspect ratio, and compare it with the expected aspect ratio range (e.g., 1.8:1 to 2.2:1).

[0183] If the calculated aspect ratio is within the expected range, the stitching result is reasonable and the stitching is successful. If the aspect ratio deviates significantly from the expected range (e.g., the width is much larger than the length, resembling a "square" rather than a "rectangle"), it indicates that there may be an error in the stitching, such as excessive or insufficient overlap between the two images, or misalignment. In this case, the image processing device can trigger a re-stitching process, adjust the stitching parameters, and try again, or output an alarm signal indicating stitching failure, prompting the operator to check the equipment or retake the image.

[0184] Sub-step four: Output the stitched image to be tested.

[0185] After the stitching verification is passed, the image processing device outputs the complete stitched image as the stitched image to be tested. In this image, the two side borders of the target terminal device under test are fully presented in the first direction and remain aligned (that is, the left and right borders are in the correct positions in the image, and the internal structures on the left and right sides are smoothly transitioned at the stitching point without breaks, misalignments, repetitions or missing parts).

[0186] S303. Extract feature points from the stitched image to be tested and the reference image, and match the extracted feature points; calculate the geometric transformation parameters between the stitched image to be tested and the reference image based on the matching results, and use the geometric transformation parameters to transform the stitched image to be tested so that the device body area in the stitched image to be tested is aligned with the device body area in the reference image in spatial position; output the transformed image as the registered image to be tested.

[0187] Feature points are pixels in an image that possess significant characteristics and can be reliably detected and identified across different images. Feature points are typically located at corners, edge inflection points, and texture-rich areas of an image. Common types of feature points include corners (such as the intersection of two edges), spots (such as local extrema), and significant inflection points within edges. In X-ray images, feature points can be selected at structurally significant locations such as corners of internal components of a mobile phone, the centers of solder joints, and the intersections of chip boundaries.

[0188] The image processing device first extracts feature points from the stitched image to be tested and the reference image, respectively. Feature points can be corner points, edge inflection points, or other pixel locations with significant features in the image. Commonly used algorithms such as ORB, SIFT, and SURF can be used for feature point extraction, and this application does not limit the specific algorithms used.

[0189] After extracting feature points, the image processing device matches the feature points in the stitched image to be tested with the feature points in the reference image to find corresponding feature point pairs in the two images. The matching is based on the local image information around the feature points (i.e., feature descriptors). The more similar the descriptors are, the more likely the two feature points are to correspond.

[0190] To improve the accuracy of matching, a ratio test method can be used to screen for high-quality matches: for each feature point in the image to be tested, find the two closest and second closest feature points in the reference image. If the closest distance is significantly smaller than the second closest distance, the match is accepted; otherwise, it is rejected.

[0191] After obtaining feature point matching pairs, the image processing device calculates geometric transformation parameters based on these correspondences. Geometric transformation parameters may include translation amounts (Δx, Δy), rotation angles θ, scaling factors s, etc., depending on the transformation model used (such as translation transformation, similarity transformation, affine transformation, etc.).

[0192] After obtaining the geometric transformation parameters, the image processing device performs geometric transformations on the stitched image to be tested, such as translation, rotation, scaling, or affine transformation, so that the device body region in the stitched image to be tested is aligned with the device body region in the reference image in spatial position.

[0193] After the geometric transformation is completed, the image processing device outputs the transformed image as the registered test image. The device body region in this image is spatially aligned with the device body region in the reference image at the pixel level, providing a basis for subsequent mask overlay and quality inspection.

[0194] The X-ray quality inspection image processing method for terminal devices provided in this application pre-establishes a reference image and a reference mask for the target model. During online detection, multiple local X-ray images captured multiple times are acquired and stitched together along a first direction to obtain a complete image. Then, the stitched image is registered with the reference image to achieve spatial alignment. Finally, the reference mask is superimposed on the registered image, and the quality inspection result is output according to the matching degree. This makes the entire preprocessing process no longer dependent on the rich texture features of the image under test itself, and does not require complex deep learning calculations for each image, thus achieving the effect of rapid detection by the terminal device.

[0195] Figure 6 This is a schematic diagram of the structure of the X-ray quality inspection image processing device for the terminal equipment provided in this application, as shown below. Figure 6 As shown, the terminal device X-ray quality inspection image processing apparatus 40 provided in this embodiment includes:

[0196] The acquisition module 401 is used to acquire the reference image and reference mask corresponding to the model of the target terminal device under test. The reference image is a reference image selected in advance from the qualified X-ray images of the target terminal device model under test, and the reference mask is used to mark the outline of the device body area in the reference image.

[0197] The stitching module 402 is used to acquire multiple local X-ray images obtained by taking multiple X-ray images of the target terminal device under test, and stitch the multiple local X-ray images along a first direction to obtain the stitched image under test, wherein the first direction is the direction of the smaller dimension in the shape of the target terminal device under test.

[0198] The registration module 403 is used to perform image registration between the stitched image to be tested and the reference image to obtain the registered image to be tested.

[0199] The quality inspection module 404 is used to overlay the reference mask onto the registered image to be tested, and obtain the standardized quality inspection result of the target terminal device under test based on the matching degree between the reference mask and the image to be tested.

[0200] In one possible implementation, the acquisition module 401 is used to acquire multiple X-ray images of the same model of the target terminal device under test, select images that meet preset quality requirements as a set of qualified X-ray images, wherein the preset quality requirements include at least one of the following: imaging sharpness greater than or equal to a sharpness threshold, no geometric distortion, and no occlusion; from the set of qualified X-ray images, select the image with the largest imaging sharpness index value and the smallest geometric distortion index value as the model reference X-ray image to determine the reference image; perform edge detection on the reference image to extract the outer contour boundary of the target terminal device under test; generate a binary mask based on the outer contour boundary as the reference mask, wherein the pixel value of the device body area in the reference mask is a first value, and the pixel value of the background area is a second value; and associate and store the reference image and the reference mask with the identifier of the terminal device model.

[0201] In one possible implementation, the acquisition module 401 is used to perform size adaptive estimation on the reference image along a first direction to determine the boundary position of the terminal device; divide the reference image into multiple regions, perform edge detection independently on each region to obtain the edge detection results of each region; and perform fusion and binarization processing on the edge detection results of each region to obtain the continuous outer contour boundary of the terminal device.

[0202] In one possible implementation, the acquisition module 401 is used to scan the gray-level gradient along a first direction on both sides of the vertical center line of the reference image; detect the gray-level gradient transition position as a preliminary boundary estimate; correct the preliminary boundary estimate according to the pre-stored model size tolerance of the target terminal device under test, and output the accurate boundary position of the target terminal device under test.

[0203] In one possible implementation, the stitching module 402 is used to control the X-ray device to remain fixed along the second direction, and to take two independent images of the first side region and the second side region of the target terminal device under test in the first direction to obtain a first partial X-ray image and a second partial X-ray image, wherein the second direction is perpendicular to the first direction; based on the geometric constraints of the target terminal device under test, the first partial X-ray image and the second partial X-ray image are stitched together in the first direction so that the two side borders of the target terminal device under test in the first direction are fully presented and aligned in the stitched image, wherein the geometric constraints include the proportional relationship between the length and width of the terminal device.

[0204] In one possible implementation, the above-mentioned device further includes: a matching module (not shown in the figure), used to superimpose a reference mask onto the registered image under test according to pixel position; calculate the consistency measure between the reference mask and the registered image under test in the overlapping area as the matching degree; output a quality inspection qualified result when the matching degree is greater than or equal to a preset threshold; and output a quality inspection unqualified result when the matching degree is less than the preset threshold.

[0205] In one possible implementation, the matching module (not shown in the figure) is also used to synchronize the registered image under test with the reference mask to ensure that the spatial coordinate system of the reference mask is consistent with the spatial coordinate system of the registered image under test.

[0206] In one possible implementation, the registration module 403 is used to extract feature points from the stitched image to be tested and the reference image, match the extracted feature points, calculate the geometric transformation parameters between the stitched image to be tested and the reference image based on the matching results, transform the stitched image to be tested using the geometric transformation parameters, so that the device body region in the stitched image to be tested is aligned with the device body region in the reference image in spatial position, and output the transformed image as the registered image to be tested.

[0207] The terminal device X-ray quality inspection image processing device provided in this embodiment can execute the method provided in the above method embodiment. Its implementation principle and technical effect are similar, and will not be described in detail here.

[0208] Figure 7 This is a schematic diagram of the structure of the X-ray quality inspection image processing equipment provided in this application. Figure 7 As shown, the electronic device 50 provided in this embodiment includes at least one processor 501 and a memory 502. Optionally, the device 50 further includes a communication component 503. The processor 501, memory 502, and communication component 503 are connected via a bus 504.

[0209] In a specific implementation, at least one processor 501 executes computer execution instructions stored in memory 502, causing at least one processor 501 to perform the above-described method.

[0210] The specific implementation process of processor 501 can be found in the above method embodiments, and its implementation principle and technical effect are similar. It will not be repeated here.

[0211] In the above embodiments, it should be understood that the processor can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), etc. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the method disclosed in this invention can be directly implemented by a hardware processor, or implemented by a combination of hardware and software modules within the processor.

[0212] The memory may include random access memory (RAM) and may also include non-volatile memory (NVM), such as at least one disk storage device.

[0213] The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. Buses can be categorized as address buses, data buses, control buses, etc. For ease of illustration, the buses shown in the accompanying drawings are not limited to a single bus or a single type of bus.

[0214] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the above-described method.

[0215] This application also provides a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, implement the above-described method.

[0216] The aforementioned readable storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk. The readable storage medium can be any available medium accessible to a general-purpose or special-purpose computer.

[0217] An exemplary readable storage medium is coupled to a processor, enabling the processor to read information from and write information to the readable storage medium. Of course, the readable storage medium can also be a component of the processor. The processor and the readable storage medium can reside in an Application Specific Integrated Circuit (ASIC). Alternatively, the processor and the readable storage medium can exist as discrete components in the device.

[0218] The division of units is merely a logical functional division; in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be indirect coupling or communication connection through some interfaces, devices, or units, and may be electrical, mechanical, or other forms.

[0219] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0220] In addition, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.

[0221] If a function is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0222] Those skilled in the art will understand that all or part of the steps of the above-described method embodiments can be implemented by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When executed, the program performs the steps of the above-described method embodiments; and the aforementioned storage medium includes various media capable of storing program code, such as ROM, RAM, magnetic disks, or optical disks.

[0223] Finally, it should be noted that other embodiments of the invention will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This invention is intended to cover any variations, uses, or adaptations of the invention that follow the general principles of the invention and include common knowledge or customary techniques in the art not disclosed herein, and is not limited to the precise structures described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of the invention is limited only by the appended claims.

Claims

1. A method for processing X-ray quality inspection images of a terminal device, characterized in that, include: Obtain a reference image and a reference mask corresponding to the target terminal device under test, wherein the reference image is a model reference X-ray image of the target terminal device under test, and the reference mask is used to mark the outline of the body area of ​​the target terminal device under test in the reference image; Multiple local X-ray images obtained by taking multiple X-ray images of the target terminal device under test are acquired, and the multiple local X-ray images are stitched together along a first direction to obtain a stitched image under test, wherein the first direction is the smaller dimension direction in the outline of the body area of ​​the target terminal device under test. The image to be tested is registered with the reference image to obtain the registered image to be tested. The reference mask is superimposed on the registered image to be tested, and the standardized quality inspection result of the target terminal device to be tested is obtained based on the matching degree between the reference mask and the image to be tested.

2. The method according to claim 1, characterized in that, The reference image and reference mask corresponding to the target terminal device under test are obtained using the following method: Multiple X-ray images of the same model of the target terminal device are obtained, and images that meet preset quality requirements are selected as a qualified X-ray image set. The preset quality requirements must meet at least one of the following indicators: imaging clarity is greater than or equal to the clarity threshold, no geometric distortion, and no obstruction. From the set of qualified X-ray images, the image with the largest imaging sharpness index value and the smallest geometric distortion index value is selected as the model reference X-ray image to determine the benchmark image; Edge detection is performed on the reference image to extract the outer contour boundary of the target terminal device under test, wherein the outer contour boundary is a closed contour line used to distinguish the solid part and non-solid part of the target terminal device under test in the reference image; Based on the outer contour boundary, the reference image is divided into two regions: the inner region enclosed by the outer contour boundary is the body region of the target terminal device under test, and the outer region located outside the outer contour boundary is the background region. A binary mask is generated based on the body region and the background region as the reference mask, wherein the image pixel value corresponding to the body region in the reference mask is set as a first value, and the image pixel value corresponding to the background region is set as a second value; The reference image and the reference mask are associated and stored with the model identifier of the target terminal device under test.

3. The method according to claim 2, characterized in that, The step of performing edge detection on the reference image to extract the outer contour boundary of the target terminal device includes: The reference image is subjected to size adaptive estimation along the first direction to determine the preliminary boundary position of the target terminal device under test. The preliminary boundary position is a rough position estimate of the outer contour boundary in the first direction, which is used to limit the search range of subsequent edge detection. Based on the preliminary boundary positions, the reference image is divided into multiple regions, and edge detection is performed independently on each region to obtain the edge detection results for each region; The edge detection results of each region are fused and binarized to obtain the continuous outer contour boundary of the terminal device.

4. The method according to claim 3, characterized in that, The step of performing adaptive size estimation on the reference image along the first direction to determine the boundary position of the target terminal device under test includes: On both sides of the vertical center line of the reference image, the gray-scale gradient is scanned along the first direction respectively; Detect the locations of gray-level gradient transitions as preliminary boundary estimates; The preliminary boundary estimate is corrected based on the pre-stored model size tolerance of the target terminal device under test, and the accurate boundary position of the target terminal device under test is output.

5. The method according to claim 1, characterized in that, The step of acquiring multiple partial X-ray images obtained by taking multiple X-ray images of the target terminal device under test, and stitching the multiple partial X-ray images along a first direction to obtain the stitched image under test includes: The target terminal device under test is kept fixed in the second direction, and at least two independent images are taken of the first side region and the second side region of the target terminal device under test in the first direction to obtain a first local X-ray image and a second local X-ray image, wherein the second direction is perpendicular to the first direction; Based on the geometric constraints of the target terminal device under test, the first local X-ray image and the second local X-ray image are stitched together in the first direction so that the two side borders of the target terminal device under test in the first direction are fully presented and aligned in the stitched image. The geometric constraints include the proportional relationship between the length and width of the target terminal device under test.

6. The method according to any one of claims 1 to 5, characterized in that, After superimposing the reference mask onto the registered image to be tested, and obtaining the standardized quality inspection result of the target terminal device under test based on the matching degree between the reference mask and the image to be tested, the method further includes: The reference mask is superimposed onto the registered image to be tested according to pixel positions; The consistency measure between the reference mask and the registered image under test in the overlapping region is calculated and used as the matching degree. If the matching degree is greater than or equal to the preset threshold, output a quality inspection pass result; If the matching degree is less than the preset threshold, the quality inspection result is output as unqualified.

7. The method according to claim 6, characterized in that, Before superimposing the reference mask onto the registered image to be tested according to pixel positions, the method further includes: The registered image to be tested is synchronized with the reference mask so that the spatial coordinate system of the reference mask is consistent with the spatial coordinate system of the registered image to be tested.

8. The method according to claim 1, characterized in that, Image registration is performed between the stitched image to be tested and the reference image, including: Feature points are extracted from the stitched image to be tested and the reference image, and the extracted feature points are matched. Based on the matching results, the geometric transformation parameters between the stitched image to be tested and the reference image are calculated. The geometric transformation parameters are then used to transform the stitched image to be tested, so that the body region in the stitched image to be tested is aligned with the device body region in the reference image in spatial position. The transformed image is output as the registered image to be tested.

9. A terminal device for X-ray quality inspection image processing, characterized in that, include: The acquisition module is used to acquire a reference image and a reference mask corresponding to the target terminal device under test. The reference image is a model reference X-ray image of the target terminal device under test, and the reference mask is used to mark the outline of the body area of ​​the target terminal device under test in the reference image. The stitching module is used to acquire multiple local X-ray images obtained by taking multiple X-ray images of the target terminal device under test, and stitch the multiple local X-ray images along a first direction to obtain a stitched image under test, wherein the first direction is the smaller dimension direction in the outline of the body area of ​​the target terminal device under test. The registration module is used to perform image registration between the stitched image to be tested and the reference image to obtain the registered image to be tested. The quality inspection module is used to overlay the reference mask onto the registered image to be tested, and obtain the standardized quality inspection result of the target terminal device under test based on the matching degree between the reference mask and the image to be tested.

10. A terminal device X-ray quality inspection image processing device, characterized in that, include: Memory, processor; The memory stores computer-executed instructions; The processor executes computer execution instructions stored in the memory, causing the processor to perform the method as described in any one of claims 1-8.

11. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, which, when executed by a processor, are used to implement the method as described in any one of claims 1-8.

12. A computer program product, characterized in that, Includes a computer program that, when executed by a processor, implements the method described in any one of claims 1-8.