Method for extracting and classifying prohibited goods in X-ray security check image

High-quality X-ray images of contraband and packages are generated by a conditional feature generator and a diffusion model, and classified using a convolutional neural network. This solves the problems of image separation and contraband extraction in complex scenarios in existing X-ray security inspection systems, and achieves efficient and accurate security inspection results.

CN121544934APending Publication Date: 2026-02-17NORTHEASTERN UNIV CHINA
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511659921.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-11-13
Publication Date
2026-02-17

AI Technical Summary

Technical Problem

Existing X-ray security inspection systems suffer from problems such as blurred target features, difficulty in image analysis, and limited ability to distinguish low-density materials when dealing with overlapping items and contraband in complex scenarios, making it difficult to meet the needs of automated security inspection.

Method used

We employ a conditional feature-based diffusion model and a contraband classification network to generate high-quality X-ray images of contraband and packages through forward diffusion and backward denoising. We then combine these images with a convolutional neural network for contraband classification.

Benefits of technology

It significantly improves the accuracy and efficiency of X-ray security inspection systems, enabling the rapid and accurate separation and classification of contraband, thus enhancing the reliability and efficiency of security inspection work.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121544934A_ABST
    Figure CN121544934A_ABST
Patent Text Reader

Abstract

The invention belongs to the technical field of image processing, and discloses a method for extracting and classifying prohibited goods in an X-ray security inspection image. And performing initial generation on an X-ray wrapping image and an X-ray contraband image in the X-ray security check image by adopting a condition feature generator. And carrying out condition merging on the X-ray image and each step of noise image subjected to reverse de-noising of the diffusion model, and finally realizing separation of packages and prohibited goods in the X-ray security check image to generate a high-quality X-ray package image and a high-quality X-ray prohibited goods image. Compared with the generative adversarial network which is widely used in the past, the diffusion model network shows higher stability in the training process, and the problems of mode collapse, difficulty in convergence and the like are effectively avoided. Meanwhile, the image generated by the diffusion model network is higher in quality, finer in details and more real in texture. In contraband goods classification, contraband goods extracted from an X-ray security check image are classified by using a method of combining a convolutional neural network with a full connection layer.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of image processing, and in particular to a method for extracting and classifying prohibited articles in X-ray security images. BACKGROUND

[0002] With the frequent occurrence of global public security events, the security inspection demand of places such as airports, rail transit and logistics hubs is growing exponentially. As a core means of non-invasive detection, the image analysis capability of X-ray security inspection directly determines the effectiveness of the security inspection system. However, there are two major pain points in existing systems: (1) The overlapping arrangement of items in luggage leads to a weak difference in X-ray attenuation coefficient between the target object and the background (such as clothes and plastic packaging), resulting in low-contrast images (typical signal-to-noise ratio <10 dB); (2) The shape variation of prohibited articles in complex scenes (such as folding of knives and packaging of liquids) leads to blurred features, and the accuracy of existing algorithms based on threshold segmentation or template matching is less than 70%, which is difficult to meet the demand of automatic security inspection.

[0003] X-ray security inspection equipment realizes imaging based on the attenuation difference of substances to X-rays, and its core principle involves physical processes such as photoelectric effect, Compton scattering and electron pair effect. Substances with different atomic numbers exhibit characteristic pseudo-colors in images. This imaging method has three major technical defects: (1) The penetrating property of X-rays causes overlapping areas in images of stacked items, resulting in blurred target features; (2) Differentiation color mapping schemes are used by different manufacturers' equipment, making cross-platform image analysis difficult; (3) Traditional attenuation imaging has limited ability to distinguish low-density substances such as plastics and liquids.

[0004] In order to overcome the above challenges, many scholars have conducted in-depth research on image segmentation and image generation. [Olaf Ronneberger, Philipp Fischer, Thomas Brox. U-Net: Convolutional Networks for Biomedical Image Segmentation. [C], Medical Image Computing and Computer-Assisted Intervention, 2015, 9351: 234-241.] proposed a U-Net network architecture based on data enhancement, which realizes efficient segmentation of images through fewer labeled samples and achieves leading performance in related challenges. A network architecture with a shrinking path and a symmetric expanding path is designed, the shrinking path is used to capture context information, and the expanding path is used to realize accurate positioning. The U-Net network has achieved better performance than previous methods in structural segmentation tasks.

[0005] Furthermore, [Hasib Zunair, A. Ben Hamza. Sharp U-Net: Depthwise Convolutional Network for Biomedical Image Segmentation[J], Computers in Biology and Medicine, 2021, 136] proposed a novel deep learning network architecture called Sharp U-Net, which sharpens feature maps through depthwise convolution to improve the accuracy of image segmentation and achieves performance superior to existing methods. By introducing depthwise convolution operations on top of U-Net, using a sharpening kernel filter to preprocess the encoder feature map, and then fusing it with the decoder feature map, the clarity of the feature map is improved.

[0006] In the field of image generation, [Alec Radford, Luke Metz, Soumith Chintala. Unsupervised Representation Learning with Deep Convolutional Generative Adversarial Networks[C], International Conference on Learning Representations, 2016] proposed a novel convolutional neural network architecture—Deep Convolutional Generative Adversarial Networks (DCGANs)—for unsupervised representation learning without labeled data, and effectively learned hierarchical representations from object parts to scenes. DCGANs can learn effective image representations and apply these features to new tasks, demonstrating their applicability as a general image representation.

[0007] To enable timely detection of prohibited items during security checks, a method for extracting and classifying prohibited items from X-ray security images is proposed. Summary of the Invention

[0008] This invention proposes a method for extracting and classifying contraband from X-ray security images. The core of this method lies in a diffusion model based on conditional features and a contraband classification network. A conditional feature generator is used to initially generate X-ray package images and X-ray contraband images from X-ray security images. Using this as a condition, noisy images from each step of the diffusion model's inverse denoising process are conditionally merged, ultimately separating packages and contraband from the X-ray security image and generating high-quality X-ray package and contraband images. Compared to the widely used Generative Adversarial Networks (GANs), the diffusion model network exhibits higher stability during training, effectively avoiding problems such as mode collapse and convergence difficulties. Simultaneously, the images generated by the diffusion model network are of higher quality, with finer details and more realistic textures. In contraband classification, a convolutional neural network combined with fully connected layers is used to classify contraband extracted from X-ray security images. This innovative approach improves the accuracy and reliability of X-ray security inspection systems and provides strong support for ensuring public safety and improving security inspection efficiency.

[0009] The technical solution of this invention is as follows: A method for extracting and classifying contraband from X-ray security inspection images, wherein a contraband extraction network extracts X-ray contraband images and X-ray package images; the contraband extraction network includes forward diffusion, a conditional feature generator, and inverse denoising; the X-ray contraband package image is used to generate an initial X-ray package image and an initial X-ray contraband image through the conditional feature generator; forward diffusion progressively adds Gaussian noise to the original X-ray package image and the original X-ray contraband image to obtain a noisy image; in inverse denoising, based on the initial X-ray package image and the initial X-ray contraband image output by the conditional feature generator, the noise image is progressively denoised to obtain the X-ray package image and the X-ray contraband image; the X-ray contraband image is classified by an X-ray contraband image classification network.

[0010] During the forward diffusion process, noise satisfying a standard Gaussian distribution is gradually added to the original X-ray contraband image W0 and the original X-ray package image B0 according to time step t. The time step range is: 1 ≤ t ≤ 1000; when t = 1000, the noisy X-ray contraband image W t and noisy X-ray wrapped image B t All images are pure noise; the forward diffusion process is shown in formula (1):

[0011] (1)

[0012] In the formula, This indicates the weight of adding noise at time step t.

[0013] The conditional feature generator includes a downsampling module, a multi-level feature extraction module, and an upsampling module. The downsampling module mainly consists of a 3×3 convolutional layer with a stride of 1, a batch normalization layer, a ReLU activation function, and a max pooling layer. After the 3×3 convolutional layer slides through a 3×3 window to traverse the feature map of the X-ray contraband package image, it is output sequentially through the batch normalization layer, the ReLU activation function, and the max pooling layer.

[0014] The multi-level feature extraction module is divided into a multi-branch feature extraction stage and a feature aggregation stage; the output of the downsampling module, after passing through the multi-branch feature extraction stage, is then processed by the feature aggregation stage to obtain the final downsampled features.

[0015] The multi-branch feature extraction stage adopts a three-way heterogeneous convolution parallel architecture, including a 7×7 large kernel convolution branch, a 5×5 medium kernel convolution branch, and a 3×3 small kernel convolution branch, which are connected in parallel.

[0016] All three convolutional branches embed a hybrid attention enhancement module; the hybrid attention enhancement module consists of a dual-branch collaborative mechanism of spatial attention and channel attention: the spatial attention branch uses deformable convolutional kernels to dynamically allocate spatial weights and automatically focus on the target region; the channel attention branch is based on the SE-Net architecture, captures the inter-channel dependencies through global average pooling and max pooling, and uses a gating mechanism to adaptively adjust the feature channel response intensity; the output features of the spatial attention branch and the channel attention branch are added element-wise and then concatenated with the original input features to form a dual-stream fusion mechanism of "feature enhancement - preservation of original information";

[0017] In the feature aggregation stage, cross-channel information interaction and dimension alignment are achieved by using 1×1 convolution on the output features of the multi-branch feature extraction stage. Then, a hybrid attention mechanism module is introduced to perform weight allocation to complete the deep fusion of the three features, generating features that have global semantic consistency, mid-level structural robustness and local detail sharpness.

[0018] The upsampling module employs a symmetric encoding / decoding structure. In each upsampling step, a transposed convolution is first used to achieve a 2x spatial dimension expansion, followed by a cascaded 3×3 depthwise separable convolution module. A multi-level skip connection channel is constructed to adaptively fuse the shallow features obtained from each downsampling step with the features obtained from each upsampling step, enhancing semantic consistency and achieving feature complementarity. Finally, the initial X-ray contraband image C is obtained. w and initial X-ray package image C b .

[0019] The reverse denoising process uses the initial X-ray contraband image C w and X-ray package image C bAs a condition, the noisy image at each step is merged into channels and then progressively denoised using a denoising network. The denoising network includes a multi-layer downsampling module and an upsampling module. The downsampling module consists of six 3×3 convolutional layers with a stride of 1, a batch normalization layer, a ReLU activation function, and a max-pooling layer. The downsampling module extracts features from the noisy image obtained by forward diffusion of the diffusion model to obtain local texture and structural information. The upsampling module is a deconvolutional layer that performs upsampling based on the feature information extracted by the multi-layer downsampling module to progressively predict noise. The input to the denoising network is the nth step image [W]. n ;B n The output is the image with added noise at step n-1 [W]. n-1 ;B n-1 ];

[0020] The noise introduced during the forward diffusion process at time step t is optimized by designing a loss function so that the predicted noise gradually approaches the introduced noise during training. The inverse denoising loss function at each time step t is defined as follows:

[0021] (2)

[0022] in, Represents real noise. Indicates predicted noise;

[0023] Predict noise at each time step Calculate the variance of the random generation module and mean As shown in formula (3):

[0024] (3)

[0025] This represents the weight of adding noise at time step t-1;

[0026] According to formula (3), the image distribution from time step t to time step t-1 is obtained through the mean and variance. When t=1, a clean X-ray image of contraband and a clean X-ray image of a package are obtained.

[0027] (4).

[0028] The X-ray contraband image classification network adopts a hierarchical feature extraction-global decision architecture, achieving accurate identification of contraband types through multi-scale feature fusion. The network consists of a 5-level downsampling feature encoder and a 3-level fully connected decision module. In the feature encoding stage, each downsampling module follows a standardized processing flow of "convolution-normalization-activation-pooling" to progressively extract multi-level features from edge contours to object components from the X-ray contraband image, ultimately generating a 32×32×512-dimensional high-dimensional semantic feature tensor. In the global decision stage of the X-ray contraband image classification network, the 3-level fully connected layers constitute the feature extraction-global decision module. The progressive processing pipeline of feature weighting, dimensionality compression, and category mapping is as follows: The first fully connected layer achieves cross-channel feature fusion through 1024 neurons; the middle fully connected layer adopts a bottleneck structure to suppress overfitting; and the last fully connected layer, in conjunction with the Softmax activation function, completes the projection from the feature space to the category label space. The entire decision-making process uses the alternating effects of linear transformation of the weight matrix and nonlinear activation of ReLU or Softmax to perform global correlation analysis and probabilistic category prediction of the high-dimensional semantic feature tensor. Finally, an N-dimensional probability vector is output, where the category corresponding to the maximum probability value is the determination result of the contraband in the X-ray contraband image.

[0029] The beneficial effects of this invention: This invention innovatively proposes a conditional feature generator and conditional diffusion model technology, specifically for research and application in the field of X-ray contraband package image processing. This technology focuses on accurately extracting contraband information from X-ray contraband package images. Through the conditional diffusion model algorithm, it can efficiently generate separate X-ray contraband images and their corresponding X-ray package images. This achievement provides a completely new solution for security inspection image processing, effectively overcoming the limitations of traditional methods in image separation and contraband extraction, bringing higher efficiency and accuracy to security inspection work.

[0030] The conditional feature generator designed in this invention plays a crucial preprocessing role. When an X-ray image of a contraband package is input, the conditional feature generator uses advanced image analysis algorithms to perform a comprehensive and detailed analysis of the image. It accurately identifies various feature elements in the image, including the shape and outline of the contraband, as well as the overall structure of the package and background features. Through comprehensive analysis and processing of these features, a series of representative and discriminative conditional features are initially generated. These conditional features can guide the diffusion model to more accurately locate and extract the contraband image, thereby significantly improving the diffusion model's extraction effect on X-ray contraband images and laying a solid foundation for subsequent high-quality image separation.

[0031] The algorithm of this invention possesses powerful automatic separation capabilities, enabling rapid and accurate separation of X-ray images of contraband and X-ray images of packages without extensive manual intervention. In real-world security inspection scenarios, security personnel process a large number of X-ray package images daily. Traditional manual inspection methods are not only inefficient but also prone to missed or false detections. The method of this invention can significantly shorten image analysis time, improve security inspection efficiency, and allow security personnel to process more packages in a shorter time.

[0032] This invention's X-ray contraband image classification network, relying on cutting-edge deep learning algorithms and image recognition technology, possesses powerful automatic classification capabilities. Once the contraband image is accurately extracted from the X-ray image of the package, the classification network quickly activates its intelligent analysis engine to conduct a detailed feature analysis of each contraband image. It comprehensively considers multiple dimensions such as the image's shape, contour, and texture, comparing and matching it with a model pre-trained on massive amounts of data to quickly and accurately classify the contraband image into the corresponding category, such as knives or flammable and explosive items. This automatic classification method clearly and intuitively presents the specific details of the contraband hidden inside the package, eliminating the need for security personnel to spend considerable time manually identifying and judging blurry images. This significantly improves the efficiency and accuracy of information acquisition, ensuring that security checks can be conducted quickly and orderly, providing a solid and reliable guarantee for public safety. Attached Figure Description

[0033] Figure 1 The following is a general technical roadmap of the present invention: (a) is an X-ray contraband extraction network, and (b) is an X-ray contraband image classification network.

[0034] Figure 2 This is a schematic diagram of the inverse denoising process in the random generation module;

[0035] Figure 3 The X-ray contraband image generation results of the present invention are compared with those of other excellent methods: (a) Method 1; (b) Method 2; (c) The method of the present invention;

[0036] Figure 4 The classification results of the X-ray images of contraband according to the present invention are as follows: (a) classification results of knives; (b) classification results of firecrackers; (c) classification results of guns; (d) classification results of scissors. Detailed Implementation

[0037] This invention relates to a method for extracting and classifying contraband from X-ray security inspection images. The method flow is as follows: Figure 1As shown, X-ray package images and X-ray contraband images are generated using a conditional feature generator. The diffusion model consists of forward diffusion and backward denoising. Forward diffusion progressively adds Gaussian noise to the target image to obtain a noisy image. In backward denoising, the image is gradually denoised using the initialization conditions of the conditional feature generator to obtain X-ray package images and X-ray contraband images. The extracted contraband is classified by combining a convolutional neural network and a fully connected layer.

[0038] The contraband extraction network comprises forward diffusion, a conditional feature generator, and inverse denoising. During forward diffusion, noise is added to the original X-ray contraband image and X-ray package image. The conditional feature generator generates the initial X-ray package image and X-ray contraband image. Inverse denoising performs progressive denoising based on the output of the conditional feature generator, generating high-quality X-ray contraband image and X-ray package image.

[0039] During the forward diffusion process, noise following a standard Gaussian distribution is gradually added to the original X-ray contraband image W0 and the X-ray package image B0 according to time step t. The time step range is: 1 ≤ t ≤ 1000; when t = 1000, the X-ray image of the contraband is W. t and X-ray package image B t All images are pure noise; the forward diffusion process is shown in formula (1):

[0040] (1)

[0041] In the formula, This indicates the weight of adding noise at time step t.

[0042] The conditional feature generator comprises a downsampling module, a multi-level feature extraction module, and an upsampling module. The downsampling module consists of a 3×3 convolutional layer with a stride of 1, a batch normalization layer, a ReLU activation function, and a max-pooling layer. The convolutional layer slides through the feature map of the X-ray contraband package image using a 3×3 window, thereby capturing multi-scale semantic information; the batch normalization layer accelerates training and alleviates overfitting; the ReLU activation function maps the linear output to a non-linear one, enabling the network to learn complex patterns; the max-pooling layer uses a 2×2 sliding window with a stride of 2 to reduce the size of the feature map at each step. An input of 512*512 X-ray contraband image, after four downsampling feature extractions, yields a 64*64 feature map.

[0043] Multi-level feature extraction module, such as Figure 2As shown, an innovative three-way heterogeneous convolutional parallel architecture is adopted, which achieves multi-scale feature complementarity and fusion through differentiated receptive field design: the 7×7 large kernel convolutional branch uses the extended receptive field to capture long-range dependent global contextual information, effectively modeling the semantic association of distant targets in the image; the 5×5 medium kernel convolutional branch focuses on extracting structured features with intermediate granularity while balancing computational efficiency and feature representation ability; and the 3×3 small kernel convolutional branch accurately depicts detailed features such as edges and textures through dense local receptive fields.

[0044] All three convolutional branches embed a hybrid attention enhancement module, which consists of a dual-branch collaborative mechanism of spatial attention and channel attention. The spatial attention branch uses deformable convolutional kernels to dynamically allocate spatial weights and automatically focus on the target region. The channel attention branch borrows from the SE-Net architecture, capturing inter-channel dependencies through global average pooling and max pooling, and employs a gating mechanism to adaptively adjust the response intensity of feature channels. The output features of the spatial and channel attention branches are element-wise summed and then concatenated with the original input features to form a dual-stream fusion mechanism that "enhances features and preserves original information."

[0045] In the feature aggregation stage, 1×1 convolution is first used to achieve cross-channel information interaction and dimensional alignment of the output features from the multi-branch feature extraction stage. Then, a hybrid attention mechanism module is introduced: this module adopts multi-scale attention weight allocation in the channel dimension and highlights significant features by enhancing the contrast of local regions in the spatial dimension. Finally, feature concatenation and soft attention weighting are used to complete the deep fusion of the three-way features, generating a multi-level feature representation that has global semantic consistency, robustness of the mid-level structure and sharpness of local details.

[0046] The upsampling module is designed with a symmetric encoding / decoding structure. In each upsampling step, transposed convolution is first used to achieve a 2x spatial dimension expansion, followed by cascading 3×3 depthwise separable convolutional modules. Deconvolution operations effectively compensate for information loss during downsampling and reconstruct high-frequency details. Through parameterized feature calibration, the convolutional layers can eliminate checkerboard artifacts that may be introduced by deconvolution and enhance the nonlinear expressive power between feature channels. A multi-level skip connection channel is constructed to adaptively fuse the shallow features obtained from each downsampling step and the features obtained from each upsampling step, enhancing semantic consistency, achieving feature complementarity, and finally obtaining the initial X-ray contraband conditional image C. w and X-ray encapsulation condition image C b .

[0047] In the reverse denoising process, the initial X-ray contraband image C is used. w and X-ray package image C bAs a condition, the noisy image at each step is channel-merged and progressively denoised using a denoising network. The denoising network includes a multi-layer downsampling module and an upsampling module. The downsampling module consists of six 3×3 convolutional layers with a stride of 1, batch normalization layers, ReLU activation functions, and max-pooling layers. The downsampling module extracts features from the noisy image obtained by forward diffusion of the diffusion model, acquiring local texture and structural information of the noisy image. The upsampling module is a deconvolutional layer that performs upsampling based on the feature information extracted by the multi-layer downsampling module to progressively predict noise. The input to the denoising network is the noisy image at step n [W]. n ;B n The output is the image with added noise at step n-1 [W]. n-1 ;B n-1 ].

[0048] The noise introduced during the forward diffusion process at time step t is optimized by designing a loss function so that the predicted noise gradually approaches the introduced noise during training. The inverse denoising loss function at each time step t is defined as follows:

[0049] (2)

[0050] in, Represents real noise. Indicates predicted noise;

[0051] Predict noise at each time step Calculate the variance of the random generation module and mean As shown in formula (3):

[0052] (3)

[0053] This represents the weight of adding noise at time step t-1;

[0054] According to formula (3), the image distribution from time step t to time step t-1 is obtained through the mean and variance. When t=1, a clean X-ray image of contraband and a clean X-ray image of a package are obtained.

[0055] (4)

[0056] The X-ray contraband image classification network adopts a hierarchical feature extraction-global decision architecture, achieving accurate identification of contraband types through multi-scale feature fusion. The network consists of a 5-level downsampling feature encoder and a 3-level fully connected decision module. In the feature encoding stage, each downsampling module follows a standardized processing flow of "convolution-normalization-activation-pooling", specifically including a 3×3 convolutional layer with a stride of 1 (for local feature extraction), a batch normalization layer (to accelerate convergence and improve generalization), a ReLU nonlinear activation function (to introduce the model's nonlinear expressive power), and a 2×2 max pooling layer (to achieve downsampling operation that halves the feature map size). This design progressively extracts multi-level features from edge contours to object parts from the original X-ray image through a step-by-step abstraction mechanism, ultimately generating a 32×32×512-dimensional high-dimensional semantic feature tensor. During the decision-making phase, a three-level fully connected layer constitutes a progressive processing pipeline of feature recalibration, dimensionality compression, and class mapping: the first fully connected layer achieves cross-channel feature fusion through 1024 neurons; the middle fully connected layer employs a bottleneck structure to suppress overfitting; and the final fully connected layer, in conjunction with the Softmax activation function, completes the projection from the feature space to the class label space. The entire decision-making process achieves global correlation analysis and probabilistic class prediction of contraband features through the alternating effects of linear transformation of the weight matrix and nonlinear activation of ReLU / Softmax. Finally, the network outputs an N-dimensional probability vector, where the class corresponding to the maximum probability value is the determination result of the contraband in the X-ray image.

[0057] We qualitatively compared the X-ray contraband image extraction algorithm proposed in this invention with several currently popular algorithms, selecting Method 1 ("Olaf Ronneberger, Philipp Fischer, Thomas Brox. U-Net: Convolutional Networks for Biomedical Image Segmentation. [C], Medical Image Computing and Computer-Assisted Intervention, 2015, 9351: 234-241.") and Method 2 ("Alec Radford, Luke Metz, Soumith Chintala. Unsupervised Representation Learning with Deep Convolutional Generative Adversarial Networks[C], International Conference on Learning Representations, 2016"), which are classic algorithms for image segmentation and image generation, respectively. In this X-ray contraband image extraction experiment, we used knives, a common and representative contraband, as the extraction target. The experimental comparison results are presented intuitively in... Figure 3After detailed observation and analysis of the extraction results, we found that the algorithm of Olaf Ronneberger et al. (Method 1) has significant shortcomings in extracting X-ray images of contraband. The extracted knife images are incomplete in shape, differing greatly from the knife shapes in real X-ray images of contraband packages, as if missing crucial parts, making it difficult to accurately represent the true characteristics of the contraband. Moreover, the X-ray package image left after extraction shows color deviation, with a significant difference in color distribution from the original image, which may interfere with subsequent image analysis and recognition. The algorithm of Alec Radford et al. (Method 2) shows some improvement over Method 1. The extracted knife images are better in terms of overall outline and shape, more clearly presenting the approximate shape of the knife. However, it still has some flaws; the details of the image are not clear enough, and the edges are slightly blurred. Furthermore, in terms of color, it still differs from real X-ray images of contraband packages; the color reproduction is not high enough, failing to accurately reflect the actual color of the contraband within the package. In stark contrast, the algorithm of this invention demonstrates superior performance in extracting X-ray images of contraband. Both the extracted X-ray images of contraband and the preserved X-ray package images show significant improvements in quality. The extracted knife images have complete outlines and rich details, accurately representing all parts of the knife and highly consistent with knives in real X-ray images of contraband packages. The overall image fidelity is high, and the colors are accurate, realistically reflecting the original state of the contraband within the package. In conclusion, through this rigorous and comprehensive comparative experiment, we can clearly see the significant advantages of this invention in extracting X-ray images of contraband, providing more accurate and reliable support for image processing and analysis in the security inspection field.

[0058] Figure 4This paper presents the detailed results of a classification experiment conducted on X-ray images of contraband. In this experiment, we carefully selected three highly representative contraband categories—knives, firecrackers, and firearms—as the core verification objects. These contraband items frequently appear in security checkpoints and pose a significant threat; accurate classification is crucial for ensuring public safety. During the experiment, we utilized the X-ray contraband classification algorithm of this invention. This algorithm, based on advanced image processing technology and deep learning models, can deeply mine the unique features of contraband in X-ray images. From image texture details to shape contours, the algorithm performs meticulous analysis, thereby constructing a comprehensive and accurate feature description. Experimental results demonstrate that the X-ray contraband classification algorithm of this invention exhibits superior performance. It can achieve extremely accurate classification of single X-ray contraband images extracted from complex backgrounds. Whether it's the sharp edge of a knife, the complex structure of a firearm, or the unique shape of scissors, the algorithm can accurately identify and classify them into the corresponding categories, providing reliable technical support for security checks and effectively improving the efficiency and accuracy of contraband detection.

Claims

1. A method for extracting and classifying contraband from X-ray security inspection images, characterized in that, A contraband extraction network extracts X-ray images of contraband and X-ray packages. The contraband extraction network includes forward diffusion, a conditional feature generator, and inverse denoising. The X-ray contraband package image is used by the conditional feature generator to generate initial X-ray package images and initial X-ray contraband images. Forward diffusion progressively adds Gaussian noise to the original X-ray package images and original X-ray contraband images to obtain noisy images. In inverse denoising, based on the initial X-ray package images and initial X-ray contraband images output by the conditional feature generator, the noise images are progressively denoised to obtain the X-ray package images and X-ray contraband images. The X-ray contraband images are then classified by an X-ray contraband image classification network.

2. The method for extracting and classifying contraband from X-ray security images according to claim 1, characterized in that, During the forward diffusion process, noise satisfying a standard Gaussian distribution is gradually added to the original X-ray contraband image W0 and the original X-ray package image B0 according to time step t. The time step range is: 1 ≤ t ≤ 1000; when t = 1000, the noisy X-ray contraband image W t and noisy X-ray wrapped image B t All images are pure noise; the forward diffusion process is shown in formula (1): (1) ; In the formula, This indicates the weight of adding noise at time step t.

3. The method for extracting and classifying contraband from X-ray security images according to claim 1, characterized in that, The conditional feature generator includes a downsampling module, a multi-level feature extraction module, and an upsampling module. The downsampling module mainly consists of a 3×3 convolutional layer with a stride of 1, a batch normalization layer, a ReLU activation function, and a max pooling layer. After the 3×3 convolutional layer slides through a 3×3 window to traverse the feature map of the X-ray contraband package image, it is output sequentially through the batch normalization layer, the ReLU activation function, and the max pooling layer.

4. The method for extracting and classifying contraband from X-ray security images according to claim 3, characterized in that, The multi-level feature extraction module is divided into a multi-branch feature extraction stage and a feature aggregation stage; the output of the downsampling module, after passing through the multi-branch feature extraction stage, is then processed by the feature aggregation stage to obtain the final downsampled features. The multi-branch feature extraction stage adopts a three-way heterogeneous convolution parallel architecture, including a 7×7 large kernel convolution branch, a 5×5 medium kernel convolution branch, and a 3×3 small kernel convolution branch, which are connected in parallel. All three convolutional branches are embedded with a hybrid attention enhancement module; the hybrid attention enhancement module consists of a dual-branch collaborative mechanism of spatial attention and channel attention: the spatial attention branch uses deformable convolutional kernels to dynamically allocate spatial weights and automatically focus on the target region; the channel attention branch is based on the SE-Net architecture, captures the inter-channel dependencies through global average pooling and max pooling, and adopts a gating mechanism to adaptively adjust the response intensity of the feature channels; The output features of the spatial attention branch and the channel attention branch are added element by element and then concatenated with the original input features to form a two-stream fusion mechanism of "feature enhancement - preservation of original information". In the feature aggregation stage, cross-channel information interaction and dimension alignment are achieved by using 1×1 convolution on the output features of the multi-branch feature extraction stage. Then, a hybrid attention mechanism module is introduced to perform weight allocation to complete the deep fusion of the three features, generating features that have global semantic consistency, mid-level structural robustness and local detail sharpness.

5. The method for extracting and classifying contraband from X-ray security images according to claim 4, characterized in that, The upsampling module employs a symmetric encoding / decoding structure. In each upsampling step, a transposed convolution is first used to achieve a 2x spatial dimension expansion, followed by a cascaded 3×3 depthwise separable convolution module. A multi-level skip connection channel is constructed to adaptively fuse the shallow features obtained from each downsampling step with the features obtained from each upsampling step, enhancing semantic consistency and achieving feature complementarity. Finally, the initial X-ray contraband image C is obtained. w and initial X-ray package image C b .

6. The method for extracting and classifying contraband from X-ray security images according to claim 5, characterized in that, The reverse denoising process uses the initial X-ray contraband image C w and X-ray package image C b As a condition, the noisy image at each step is merged into channels and then progressively denoised using a denoising network. The denoising network includes a multi-layer downsampling module and an upsampling module. The downsampling module consists of six 3×3 convolutional layers with a stride of 1, a batch normalization layer, a ReLU activation function, and a max-pooling layer. The downsampling module extracts features from the noisy image obtained by forward diffusion of the diffusion model to obtain local texture and structural information. The upsampling module is a deconvolutional layer that performs upsampling based on the feature information extracted by the multi-layer downsampling module to progressively predict noise. The input to the denoising network is the nth step image [W]. n ;B n The output is the image with added noise at step n-1 [W]. n-1 ;B n-1 ]; The noise introduced during the forward diffusion process at time step t is optimized by designing a loss function so that the predicted noise gradually approaches the introduced noise during training. The inverse denoising loss function at each time step t is defined as follows: (2) ; in, Represents real noise. Indicates predicted noise; Predict noise at each time step Calculate the variance of the random generation module and mean As shown in formula (3): (3) ; This represents the weight of the noise added at time step t-1; According to formula (3), the image distribution from time step t to time step t-1 is obtained through the mean and variance. When t=1, a clean X-ray image of contraband and a clean X-ray image of a package are obtained. (4)。 7. The method for extracting and classifying contraband from X-ray security images according to claim 1, characterized in that, The X-ray contraband image classification network adopts a hierarchical feature extraction-global decision architecture, achieving accurate identification of contraband types through multi-scale feature fusion. The network consists of a 5-level downsampling feature encoder and a 3-level fully connected decision module. In the feature encoding stage, each downsampling module follows a standardized processing flow of "convolution-normalization-activation-pooling" to progressively extract multi-level features from edge contours to object components from the X-ray contraband image, ultimately generating a 32×32×512-dimensional high-dimensional semantic feature tensor. In the global decision stage of the X-ray contraband image classification network, the 3-level fully connected layers constitute the feature extraction-global decision module. The progressive processing pipeline of feature weighting, dimensionality compression, and category mapping is as follows: The first fully connected layer achieves cross-channel feature fusion through 1024 neurons; the middle fully connected layer adopts a bottleneck structure to suppress overfitting; and the last fully connected layer, in conjunction with the Softmax activation function, completes the projection from the feature space to the category label space. The entire decision-making process uses the alternating effects of linear transformation of the weight matrix and nonlinear activation of ReLU or Softmax to perform global correlation analysis and probabilistic category prediction of the high-dimensional semantic feature tensor. Finally, an N-dimensional probability vector is output, where the category corresponding to the maximum probability value is the determination result of the contraband in the X-ray contraband image.