DR detection method and device based on swin-unet and medium
By using an image registration method based on Swin-UNet, combining Swin-Transformer and UNet frameworks, the problems of poor image registration effect and high computational complexity in traditional DR detection systems are solved, achieving efficient image registration and clear imaging.
Patent Information
- Application Number
- CN202311343186.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-10-17
- Publication Date
- 2026-11-20
- Estimated Expiration
- 2043-10-17
AI Technical Summary
Traditional DR detection systems suffer from several drawbacks: poor image registration algorithms when the number of feature points is small or unevenly distributed; high computational complexity of region-based matching algorithms; and mismatches in texture-similar regions, all of which affect image quality.
We employ an image registration method based on Swin-UNet, combining the Swin-Transformer and UNet frameworks to extract global and local features from both floating and fixed images. Image registration is achieved through a ring-shaped rotation mechanism, and deep learning is used to improve the registration effect.
It improves the image registration effect, solves the problems of unclear imaging and high computational complexity of traditional algorithms, and ensures the clarity and stability of imaging.
Smart Images

Figure CN117522931B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image registration technology, and in particular to a DR detection method, device and medium based on Swin-UNet. Background Technology
[0002] After X-rays pass through an object, they are received by a detector. The detector converts the analog signal of the image into a digital signal and inputs it into a computer for image processing. The digital image is stored in the computer according to a specific format and displayed on a screen. By observing the inspection image and applying computer programs to assess defects according to relevant standards, non-destructive testing can be achieved. The inspection image can be stored on a computer or digital storage media. With the development of X-ray digital imaging technology, X-ray detectors have gone through three stages: image intensifiers, linear array detectors, and flat panel detectors, forming three technical routes. Therefore, X-ray digital imaging inspection technology has formed three technical routes: image intensifier imaging technology, linear array detector imaging technology, and flat panel detector imaging technology. Different imaging technology routes have different imaging equipment configurations, forming different X-ray digital imaging inspection systems for users to choose from.
[0003] In conventional DR (Digital Radiography) inspection systems, the detector and the object are isolated by devices such as conveyor belts, and the distance between the detector and the object is relatively far, which affects the image quality and results in unclear images.
[0004] Most common DR (Digital Radiography) detection systems employ traditional image registration algorithms. The basic steps begin with preprocessing the CT and visible light images. For CT images, morphological processing and edge detection methods can be used to extract object contours or feature points. For color images, algorithms such as SIFT (Scale Invariant Feature Transform), SURF (Speeded Up Robust Features), and ORB (Oriented Fast and Rotated Brief) can be used to extract feature points or feature regions. Next, feature matching involves matching the feature points or feature regions extracted from the two images to find their correspondence. Common image registration algorithms include: feature point-based registration: image registration is achieved by extracting feature points in the image, such as corners and edges, and matching these feature points. Region-based registration: the image is divided into multiple regions, and the entire image is registered by registering these regions. Deformation model-based registration: the image is deformed to match a reference image; common deformation models include affine transformations and perspective transformations. Deep learning-based registration: Image registration is performed using models similar to convolutional neural networks. However, traditional image registration algorithms based on feature points often perform poorly on images with few or unevenly distributed feature points. Region-based matching algorithms require dividing the image into blocks, resulting in high computational complexity. Deformation model-based registration algorithms may mismatch large areas with similar textures.
[0005] In recent years, due to its excellent performance in NLP (Natural Language Processing), the Transformer has been widely used in CV (Computer Vision) tasks, achieving remarkable results. The Transformer network incorporates an attention mechanism, which associates information from different positions in the input sequence, helping the model capture dependencies between these positions and thus improving performance. In contrast, CNNs (Convolutional Neural Networks) typically use pooling layers to capture global features of the input tensor rather than explicitly modeling dependencies. To address the shortcomings of CNNs, the Transformer and CNN are organically combined, resulting in a series of network models such as Transformer-UNet and Swin-UNet. This paper proposes a DR detection method, device, and medium based on Swin-UNet. Summary of the Invention
[0006] In view of this, the purpose of this invention is to propose a DR detection method based on Swin-UNet. Based on the Swin-UNet image registration network, Swin-Transformer is introduced into the UNet framework to extract global and local features from floating and fixed images, thereby effectively generating deformation fields. This is a new method for registration of visible light images and CT images using deep learning, which can improve the image registration effect.
[0007] To achieve the above-mentioned technical objectives, the technical solution adopted by this invention is as follows:
[0008] This invention provides a DR detection method based on Swin-UNet, comprising the following steps:
[0009] Step 1: Real-time X-ray and visible light images of the object under test moving within the detection area are acquired using a detector and a camera, respectively; the X-rays from the detector penetrate the object under test.
[0010] Step 2: Extract two original feature maps from the X-ray image and the visible light image using a UNet network; combine the two original feature maps and combine them with position encoding to obtain a context feature map; extract the second position coordinates of the visible light image from the context feature map and the first coordinate position corresponding to the X-ray image after position encoding using a Swin-Transformer network.
[0011] Step 3: Perform image registration based on the first coordinate position and the second coordinate position.
[0012] Furthermore, step 1 specifically includes:
[0013] Step 11: Prepare a cyclic track scanning digital imaging detection device. The cyclic track scanning digital imaging detection device includes a control cabinet, in which a PLC controller is installed. A worktable is installed on the control cabinet. Circular rotating mechanisms are installed on both sides of the worktable. Motor drive mechanisms are installed at the front ends of the two circular rotating mechanisms and are electrically connected to the PLC controller. Multiple pairs of symmetrically distributed pushing mechanisms are installed on the inner sides of the two circular rotating mechanisms. When the pushing mechanism rotates along the circular rotating mechanism to the upper surface of the worktable, the bottom of the pushing mechanism is close to the side of the worktable. A light-transmitting plate is installed on the upper surface of the worktable, with one end of the light-transmitting plate close to the pushing mechanism. An opening is horizontally arranged in the middle of the worktable as a detection area. A detector is installed directly below the opening, and a camera and a light source are installed directly above the opening.
[0014] Step 12: The PLC controller controls the motor drive mechanism to move, and the motor drive mechanism drives the ring rotating mechanism to rotate, thereby driving the pushing mechanism to push the light-transmitting plate on the surface of the workbench along the ring rotating mechanism, so that the object to be tested on the light-transmitting plate moves to the opening position.
[0015] Step 13: Set the opening area as the detection area. When the object being tested passes through the detection area, the detector returns an X-ray image of the current state of the object to the computer interface for display. It also updates and acquires multiple X-ray images in real time as the pushing mechanism moves. At the same time, the camera captures a visible light image of the object to be tested above the detector and returns it to the computer interface for display.
[0016] Step 14: Obtain X-ray images of all times within the detection area, and stitch the multiple X-ray images together to form a complete X-ray image.
[0017] Furthermore, step 2 specifically includes:
[0018] Step 21: Take the X-ray image as a fixed image I and the visible light image as a floating image I′. After normalizing the fixed image I, obtain the corresponding first coordinate position s∈[0,1]. 2 As a query point;
[0019] Step 22: Set the input to the Swin-Transformer network as: a fixed image I, a floating image I′, and a first coordinate position s∈[0,1]. 2 The output is: the normalized second coordinate position s′∈[0,1] on the floating image I′. 2 Then find the optimal set of parameters Φ that minimizes the function as follows:
[0020]
[0021] Among them, symbols Represents the square of the norm 2;
[0022] Will Model it as a Swin-Transformer network;
[0023] Step 23: Adjust the fixed image I and the floating image I′ to 256*256, and extract two original feature maps ε with dimensions of 16*16*256 through the same UNet network and process them;
[0024] Step 24: Combine the two original feature maps together, and then combine them using a position encoder. The results of position encoding of the coordinate function Ω are combined to obtain the context feature map c;
[0025] Step 25: Add the context feature map c and the location-encoded query point as input to the Swing-Transformer network, and use the encoder. Encode the context feature map c and use a decoder. The query point with location encoding is decoded to obtain the output of the Swin-Transformer network;
[0026] Step 26: Decode the output result through a multilayer perceptron module to obtain the second position coordinates s′ corresponding to the floating image I′, and use it as the matching point; the second position coordinates x′ are represented as:
[0027]
[0028] Furthermore, in step 23, two original feature maps ε with dimensions of 16*16*256 are extracted through the same UNet network and processed, specifically including:
[0029] Step 231: Add a sliding window operation to the Swing-Transformer network;
[0030] Step 232: Extract two original feature maps from the fixed image and the floating image using the same UNet network, and input them into the image encoder;
[0031] Step 233: Convert the input into sequence embedding, divide the original feature map into 4*4 non-overlapping image patches, and project the feature dimensions of the image patches to arbitrary dimensions through a linear embedding layer;
[0032] Step 234: The transformed image patch is processed alternately by multiple sliding window-based transformer blocks and an image integration layer to generate hierarchical feature representations, which are then input into the image decoder. The image integration layer is responsible for downsampling and dimensionality enhancement, and the sliding window-based transformer block is responsible for learning the hierarchical feature representations.
[0033] Step 235: The image decoder and image encoder are symmetrical structures. The original feature maps of adjacent dimensions are reshaped into large feature maps with a resolution of 2 times upsampled by alternating processing of multiple sliding window-based transformer blocks and image expansion layers in the image decoder. Finally, the last layer of image expansion layer is used to perform 4 times upsampling to restore the resolution of the large feature map after sampling to the input resolution.
[0034] Step 236: After dimensionality adjustment through the linear embedding layer, the final original feature map is obtained.
[0035] Furthermore, the sliding window-based transformer block consists of a normalization module, a multi-head self-attention module, and a multilayer perceptron module. The multi-head self-attention modules in two consecutive sliding window-based transformer blocks are respectively a window-based multi-head self-attention module and a sliding window-based multi-head self-attention module. Based on this window partitioning mechanism, consecutive sliding window-based transformer blocks can be represented as follows:
[0036]
[0037]
[0038]
[0039]
[0040] in, and z l These represent the outputs of the window-based multi-head self-attention module and the multilayer perceptron module of the l-th block, respectively; and Z l+1 represents the output of the sliding window-based multi-head self-attention module and the multilayer perceptron module of the (l+1)th block, respectively; LN represents the normalization module, WMSA represents the window-based multi-head self-attention module, SWMSA represents the sliding window-based multi-head self-attention module, and MLP represents the multilayer perceptron module.
[0041] The complexity calculation formula for a multi-head self-attention module is as follows:
[0042]
[0043] Where Q, K, and V represent Query, Key, and Value respectively, d represents dimension, B represents relative position encoding, and T represents the transpose of the matrix.
[0044] Furthermore, the specific location encoding process for the query point after location encoding in step 25 is as follows:
[0045] For a given coordinate s = [x, y], its position is encoded in the following form:
[0046]
[0047] p k (s)=[sin(kπs),cos(kπs)]
[0048] Where N = 256 is the number of channels in the feature map, p k The dimension of (s) is 4, so The dimension is N.
[0049] Furthermore, step 3 specifically involves: using a skip connection between the sliding window-based transformer block in the image encoder and the corresponding sliding window-based transformer block in the image decoder.
[0050] Furthermore, step 3 specifically involves comparing the first coordinate position and the second coordinate position. If they match, the image registration is successful; if they do not match, the image registration fails.
[0051] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement a DR detection method based on Swin-UNet as described above.
[0052] The present invention also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the DR detection method based on Swin-UNet as described above.
[0053] By adopting the above technical solution, the present invention has the following beneficial effects compared with the prior art:
[0054] This invention employs a ring-shaped rotating mechanism (ring track) design, ensuring structural stability during operation. Furthermore, an opening is incorporated above the detector to ensure unobstructed views between the detector and the object being measured, maximizing image clarity.
[0055] This invention utilizes a circular track for cyclic operation, pushing the object under test on a worktable for detection. Because the worktable is relatively stable and does not produce vibration, it solves the problem of unclear imaging caused by vibration from the conveyor belt in other DR systems. The improved Swin-UNet can also solve the problem of poor registration results caused by traditional image registration algorithms, providing a new approach for subsequent image registration using deep learning. Attached Figure Description
[0056] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0057] Figure 1This is a schematic diagram of the structure of a cyclic orbit scanning digital imaging detection device (excluding the light-transmitting plate) provided in an embodiment of the present invention.
[0058] Figure 2 This is a schematic diagram of the structure of a cyclic orbit scanning digital imaging detection device (including a light-transmitting plate) provided in an embodiment of the present invention.
[0059] Figure 3 This is one of the perspective views of the annular rotating mechanism provided in the embodiments of the present invention.
[0060] Figure 4 This is the second perspective view of the annular rotating mechanism provided in the embodiment of the present invention.
[0061] Figure 5 This is one of the perspective views of the transmission connection between the ring rotation mechanism, the motor drive mechanism and the push mechanism provided in the embodiments of the present invention.
[0062] Figure 6 This is a second perspective view of the transmission connection between the ring rotation mechanism, the motor drive mechanism, and the push mechanism provided in the embodiments of the present invention.
[0063] Figure 7 This is a structural diagram of the transmission connection between the pulley and the shaft provided in an embodiment of the present invention.
[0064] Figure 8 This is one of the perspective views of the control cabinet provided in the embodiments of the present invention.
[0065] Figure 9 This is the second perspective view of the control cabinet provided in the embodiment of the present invention.
[0066] Figure 10 This is a structural diagram of the workbench provided in an embodiment of the present invention.
[0067] Figure 11 This is one of the perspective views of the light source bracket provided in the embodiment of the present invention.
[0068] Figure 12 This is the second perspective view of the light source bracket provided in the embodiment of the present invention.
[0069] Figure 13 This is a schematic diagram showing the connection relationship between the PLC controller, motor, coupling and rotating shaft provided in the embodiment of the present invention.
[0070] Figure 14 This is an execution flowchart of the DR detection method based on Swin-UNet provided in the embodiments of the present invention.
[0071] Figure 15 This is an image registration flowchart provided in an embodiment of the present invention.
[0072] Figure 16 This is a diagram of the Swin-UNet network architecture provided in an embodiment of the present invention.
[0073] Figure 17 This is a structural diagram of the Swing-Transformer block provided in an embodiment of the present invention.
[0074] Figure 18 This is a schematic diagram of an electronic device provided in an embodiment of the present invention.
[0075] Figure 19 This is a schematic diagram of a computer-readable storage medium provided in an embodiment of the present invention.
[0076] Explanation of the labels in the diagram:
[0077] Control cabinet 1, PLC controller 11, fixed plate 12, casters 13, adjusting rod 14, fixed base 15; Workbench 2, opening 21, support plate 22, support frame 23, connecting plate 24; Circular rotating mechanism 3, circular fixed frame 31, track support 32, circular track 33, belt 34, pulley 35, rotating shaft 36, connecting shaft 37, stop bar 38, limit bracket 39, upright frame 310, reinforcing frame 311; Motor drive mechanism 4, motor 41, coupling 42, electric... Machine bracket 43; pushing mechanism 5, push rod 51, slide 52, eccentric wheel 53; light-transmitting shelf 6, detector 7, camera 8, light source 9, light source bracket 10, first connecting rod 101, second connecting rod 102, first limiting rod 103, second limiting rod 104, first long slot 105, first limiting hole 106, second long slot 107, second limiting hole 108, third connecting rod 109, third limiting rod 110, third long slot 111, third limiting hole 112. Detailed Implementation
[0078] The present invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be particularly noted that the following embodiments are for illustrative purposes only and do not limit the scope of the invention. Similarly, the following embodiments are only some, not all, embodiments of the present invention, and all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0079] Please see Figures 1-13The present invention discloses a cyclic track scanning digital imaging detection device, comprising: a control cabinet 1, wherein a PLC controller 11 is installed inside the control cabinet 1, a worktable 2 is installed on the control cabinet 1, and annular rotating mechanisms 3 are installed on both sides of the worktable 2. Motor drive mechanisms 4 are installed at the front ends of the two annular rotating mechanisms 3, and the motor drive mechanisms 4 are electrically connected to the PLC controller 11; multiple pairs of symmetrically distributed pushing mechanisms 5 are installed on the inner sides of the two annular rotating mechanisms 3. When the pushing mechanism 5 rotates along the annular rotating mechanism 3 to the upper surface of the worktable 2, the bottom of the pushing mechanism 5 is close to the worktable surface. On the side of the worktable 2; a light-transmitting plate 6 is installed on the upper surface of the worktable 2. The light-transmitting plate is a foam board used to place the object to be tested, and at the same time, it can emit X-rays emitted by the detector 7 onto the object to be tested, so as to successfully acquire the X-ray image of the object to be tested; one end of the light-transmitting plate 6 is close to the pushing mechanism 5, and an opening 21 is horizontally arranged in the middle of the worktable 2 as a detection area. A detector 7 is installed directly below the opening 21. The detector 7 is a linear array detector or a flat panel detector. Preferably, a linear array detector is used; a camera 8 and a light source 9 are installed directly above the opening 21.
[0080] The PLC controller 11 controls the motor drive mechanism 4 to move, which in turn drives the annular rotating mechanism 3 to rotate. This, in turn, drives the pushing mechanism 5 to push the light-transmitting plate 6 along the annular rotating mechanism 3 onto the surface of the worktable 2. This moves the object to be tested on the light-transmitting plate 6 to the opening 21, and the detector 7 and camera 8 respectively capture X-ray and visible light images of the object's movement within the detection area. This invention employs an annular rotating mechanism 3 (annular track) design to achieve repeated operation, ensuring structural stability during operation. Furthermore, an opening 21 is provided above the detector 7 to ensure unobstructed view between the detector 7 and the object to be tested, maximizing image clarity.
[0081] In this embodiment, the annular rotating mechanism 3 includes an annular fixed frame 31, two track supports 32, an annular track 33, a belt 34, two pulleys 35, two rotating shafts 36, and a connecting shaft 37. The two track supports 32 are respectively installed on the inner sides of the front and rear arc-shaped portions of the annular fixed frame 31. The front and rear arc-shaped portions of the annular track 33 are fixedly installed on the inner sides of the track supports 32. The pulleys 35 are rotatably connected to the inner sides of the track supports 32 and are located in the middle of the arc-shaped portion of the annular track 33. The two ends of the belt 34 are respectively sleeved on the two pulleys 35. The rotating shaft 36 is installed on the outer side of the track supports 22 and is rotatably connected to the pulleys 35. The two ends of the connecting shaft 37 are rotatably connected to the two rotating shafts 36 at the front end. The motor drive mechanism 4 is installed on the rotating shaft 36 on the corresponding side of the front end. The pushing mechanism 5 is installed on the annular track 23 and the belt 34. The motor drive mechanism 4 drives the rotating shaft 36 on the corresponding side of the front end to rotate, which in turn drives the pulley 35 on the corresponding side to rotate. The rotation of the pulley 35 drives the connecting shaft 37 to rotate, which in turn drives the pulley 35 on the other side of the front end to rotate. Through the driving action of the pulleys 35 on both sides of the front end and the belt, the pulleys 35 on both sides of the rear end also rotate. Through the driving action of the belt 34 and the sliding action of the annular track 23, the push mechanism 5 can repeatedly run along the annular track 23 under the action of the belt 34, ensuring the stability during operation.
[0082] In this embodiment, the annular rotating mechanism 3 further includes multiple stop bars 38 and multiple limiting brackets 39. The multiple stop bars 38 are installed on the inner surface of the belt 34 and protrude from the outer side of the belt 34. The multiple limiting brackets 39 are installed on the inner surface of the annular fixing frame 31 and are close to the outer side of the stop bars 38. Due to the structural design of the stop bars 38 and limiting brackets 39, the stop bars 38 will rotate along the limiting brackets 39 during the rotation of the belt 34. The stop bars 38 can prevent the belt 34 from being worn during operation, and the limiting brackets 39 can prevent the belt 34 from running off-center.
[0083] In this embodiment, the annular rotating mechanism 3 further includes multiple uprights 310. The upper ends of the multiple uprights 310 are fixedly installed on the inner side of the upper horizontal part of the annular fixed frame 31, and the lower ends of the uprights 310 pass through the lower horizontal part of the annular fixed frame 31 and are fixed to the control cabinet 1. The uprights 310 can strengthen the annular fixed frame 31, thereby ensuring the fixation of the annular track 33.
[0084] In this embodiment, the annular rotating mechanism 3 further includes multiple reinforcing frames 311, which abut against the outer side of the lower horizontal portion of the upright frame 310 and the annular fixing frame 31 and are fixed to the control cabinet 1. The reinforcing frames are used to strengthen the upright frame 310.
[0085] In this embodiment, the motor drive mechanism 4 includes a motor 41, a coupling 42, and a motor bracket 43. The motor bracket 43 is fixedly connected to the outside of any one of the front track brackets 32. The coupling 42 and the corresponding rotating shaft 36 are installed inside the motor bracket 43. The motor 41 is fixedly installed on the motor bracket 43 and rotatably connected to the coupling 42. The coupling 42 is rotatably connected to the corresponding rotating shaft 36. The motor drive mechanism 4 provides power to the annular rotating mechanism 3, driving it to rotate. When the motor 41 is running, it drives the corresponding rotating shaft 36 to rotate via the coupling 42, which in turn drives the belt 34, thus ensuring the smooth operation of the annular rotating mechanism 3 and guaranteeing its stability during operation.
[0086] In this embodiment, the pushing mechanism 5 includes a push rod 51, a slide block 52, and an eccentric wheel 53. The push rod 51 has an L-shaped structure, and the eccentric wheel 53 is mounted on an annular track 33. The inner side of the eccentric wheel 53 is fixedly connected to the slide block 52, and one end of the slide block 52 near the belt 34 is fixedly connected to the belt 34. The vertical plate of the push rod 51 is fixedly connected to the inner side of the slide block 52, and the horizontal plate of the push rod 51 faces inward. The belt 34 drives the slide block 52, causing the eccentric wheel 53 to rotate along the annular track 33. When the push rod 51 rotates to the upper surface of the worktable 2, the horizontal plate of the push rod 51 moves along the side of the worktable 2, pushing the light-transmitting display plate 6 close to the horizontal plate to move. Under the action of the belt 34, the pushing mechanism 5 runs repeatedly along the annular track 23, thereby pushing the object to be tested on the light-transmitting display plate 6 forward, ensuring that the object to be tested can stably run to the opening 21.
[0087] In this embodiment, four fixing plates 12 are installed at the bottom corners of the control cabinet 1. Each fixing plate 12 has a fixed caster 13 and an adjusting rod 14 that is retractably connected via nuts. A fixing seat 15 is provided at the bottom of the adjusting rod 14. The caster 13 is for moving the device, and the adjusting rod 14 can extend and retract vertically to change its height. When the device needs to be moved, the adjusting nuts are used to retract the adjusting rod 14 upwards, causing it to deviate from the ground while the caster 13 contacts the ground. The four caster 13s allow for easy movement of the entire device, saving time and effort. Once the position is determined, the nuts are adjusted again to lower the adjusting rod 14 downwards, causing the caster 13 to deviate from the ground while the adjusting rod 14 contacts the ground, and the fixing seat 15 secures the device in place. Therefore, the caster 13 and adjusting rod 14 allow for easy repositioning to meet measurement needs at different locations.
[0088] In this embodiment, a light source bracket 10 is also included, mounted above the opening 21. Two first connecting rods 101 are arranged parallel to each other at the upper end of the light source bracket 10, and two second connecting rods 102 are arranged parallel to each other below the two first connecting rods 101. The upper end of the light source 9 is fixed to the first connecting rods 101 by two first limiting rods 103, and the lower end of the light source 9 is fixed to the second connecting rods 102 by two second limiting rods 104. At least one first elongated slot 105 is provided on the first connecting rod 101, and at least one first limiting hole 106 is provided on the first limiting rod 103. The first limiting hole 106 and the first elongated slot are connected... The first limiting rod 103 and the first connecting rod 101 are connected by threaded engagement. The second connecting rod 102 has at least one second elongated slot 107, and the second limiting rod 104 has at least one second limiting hole 108. The second limiting hole 108 and the second elongated slot 107 are connected by threaded engagement to complete the connection between the second limiting rod 104 and the second connecting rod 102. The position of the light source 9 can be adjusted by adjusting the position of the first limiting hole 106 on the first elongated slot 105 and the position of the second limiting hole 108 on the first elongated slot 107. In this way, the position of the light source 9 can be adjusted as needed, which is convenient and simple to operate.
[0089] A third connecting rod 109 connects the two second connecting rods 102. The third connecting rod 109 is fixed to the camera 8 by a third limiting rod 110. A third elongated slot 111 is formed on the inner side of the third connecting rod 109, and a third limiting hole 112 is formed on the third limiting rod 110. The third limiting hole 112 and the third elongated slot 111 are threaded together to complete the connection between the third limiting rod 110 and the third connecting rod 109. The position of the camera 8 can be adjusted by adjusting the position of the third limiting hole 112 on the third elongated slot 111. This allows for easy and simple adjustment of the camera 8's position as needed.
[0090] In this embodiment, the worktable 2 includes a support plate 22 and a support frame 23. The support plate 21 is fixed to the support frame 23. An opening 21 is laterally provided in the middle of the support plate 22. The detector 7 is fixedly connected to the lower surface of the support plate 22 and closely attached to the opening 21 through multiple connecting plates 24. This ensures unobstructed communication between the detector 7 and the object under test, maximizing the clarity of the image.
[0091] Please see Figures 14-17 The present invention provides a DR detection method based on Swin-UNet, comprising the following steps:
[0092] Step 1: Real-time X-ray and visible light images of the object under test moving within the detection area are acquired by detector 7 and camera 8, respectively; the X-rays from detector 7 penetrate the object under test.
[0093] In this embodiment, step 1 specifically includes:
[0094] Step 11: Prepare a cyclic track scanning digital imaging detection device. The cyclic track scanning digital imaging detection device includes a control cabinet 1, a PLC controller 11 installed inside the control cabinet 1, a worktable 2 installed on the control cabinet 1, and circular rotating mechanisms 3 installed on both sides of the worktable 2. Motor drive mechanisms 4 are installed at the front ends of the two circular rotating mechanisms 3, and the motor drive mechanisms 4 are electrically connected to the PLC controller 11. Multiple pairs of symmetrically distributed pushing mechanisms 5 are installed on the inner sides of the two circular rotating mechanisms 3. The pushing mechanisms 5 rotate along the circular rotating mechanisms 3. When the push mechanism 5 moves to the upper surface of the worktable 2, the bottom of the push mechanism 5 is close to the side of the worktable 2; a light-transmitting plate 6 is installed on the upper surface of the worktable 2. The light-transmitting plate is a foam board used to place the object to be tested, and at the same time, it can emit X-rays emitted by the detector 7 onto the object to be tested, so as to successfully collect the X-ray image of the object to be tested; one end of the light-transmitting plate 6 is close to the push mechanism 5, and an opening 21 is horizontally arranged in the middle of the worktable 2 as a detection area. The detector 7 is installed directly below the opening 21; a camera 8 and a light source 9 are installed directly above the opening 21.
[0095] The detector 7 is either a linear array detector or a flat panel detector. Both are types of X-ray detectors, but their structures and operating principles differ. A linear array detector consists of multiple photosensitive elements arranged in a straight line. When X-rays enter the detector, they are absorbed by the photosensitive elements and converted into electrical signals. These electrical signals are then amplified and processed to provide information about the X-rays, allowing for rapid and accurate X-ray measurement. A flat panel detector, on the other hand, consists of a single, large-area detector. When X-rays enter the detector, they are absorbed by a scintillation crystal and emit visible or ultraviolet signals. These light signals are then collected and converted into electrical signals, amplified and processed by an electronic system, enabling the flat panel detector to provide high-resolution and high-contrast imaging. Preferably, the detector 7 is a linear array detector.
[0096] Step 12: The PLC controller 11 controls the motor drive mechanism 4 to move, which in turn drives the annular rotating mechanism 3 to rotate. This, in turn, drives the pushing mechanism 5 to push the light-transmitting plate 6 along the annular rotating mechanism 3 on the upper surface of the worktable 2, so that the object to be tested on the light-transmitting plate 6 moves to the opening 21 position. This ensures that the pushing mechanism 5 can push the object to be tested between the detector 7 and the light source 9.
[0097] Step 13: Set the opening 21 area as the detection area. When the object being tested passes through the detection area, the detector 7 returns an X-ray image of the current state of the object being tested to the computer interface for display. It also updates and acquires multiple X-ray images in real time as the pushing mechanism 5 moves. At the same time, the camera 8 captures a visible light image of the object being tested above the detector 7 and returns it to the computer interface for display.
[0098] Step 14: Obtain X-ray images of all times within the detection area, and stitch the multiple X-ray images together to form a complete X-ray image.
[0099] Step 2: Extract two original feature maps from the X-ray image and the visible light image using a UNet network; combine the two original feature maps and combine them with position encoding to obtain a context feature map; extract the second position coordinates of the visible light image from the context feature map and the first coordinate position corresponding to the position encoded X-ray image using a Swin-Transformer network; the Transformer network was first applied in the field of NLP (Natural Language Processing), and because it is necessary to use local and global information of the image, a network structure combining Transformer and UNet is considered.
[0100] In this embodiment, step 2 specifically includes:
[0101] Step 21: Take the X-ray image as a fixed image I and the visible light image as a floating image I′. After normalizing the fixed image I, obtain the corresponding first coordinate position s∈[0,1]. 2 As a query point;
[0102] Step 22: Set the input to the Swin-Transformer network as: a fixed image I, a floating image I′, and a first coordinate position s∈[0,1]. 2 The output is: the normalized second coordinate position s′∈[0,1] on the floating image I′. 2 Then find the optimal set of parameters Φ that minimizes the function as follows:
[0103]
[0104] Among them, symbols Represents the square of norm 2;
[0105] Will Model it as a Swin-Transformer network;
[0106] Step 23: Adjust the fixed image I and the floating image I′ to 256*256, and extract two original feature maps ε with a dimension of 16*16**256 through the same UNet network and process them;
[0107] Step 24: Combine the two original feature maps together, and then combine them using a position encoder. The results of position encoding of the coordinate function Ω are combined to obtain the context feature map c;
[0108] Step 25: Add the context feature map c and the location-encoded query point as input to the Swing-Transformer network, and use the encoder. Encode the context feature map c and use a decoder. The query point with location encoding is decoded to obtain the output result of the Swin-Transformer network;
[0109] Step 26: Decode the output result through a multilayer perceptron module to obtain the second position coordinates s′ corresponding to the floating image I′, and use them as the matching point; the second position coordinates x′ are represented as:
[0110]
[0111] In this embodiment, step 23 involves extracting two original feature maps ε with dimensions of 16*16*256 using the same UNet network and processing them, specifically including:
[0112] Step 231: Add a sliding window operation to the Swing-Transformer network. It has a hierarchical design. The Swing-Transformer network is based on the Transformer. The sliding window can restrict the attention calculation to a window, which can not only introduce the locality of convolution operation, but also save computation.
[0113] Step 232: Extract two original feature maps from the fixed image and the floating image using the same UNet network, and input them into the image encoder.
[0114] Step 233: Convert the input into sequence embedding, divide the original feature map into 4*4 non-overlapping image patches, and project the feature dimensions of the image patches to arbitrary dimensions through a linear embedding layer;
[0115] Step 234: The transformed image patch is processed alternately by multiple sliding window-based transformer blocks (also known as Swin-Transformer blocks) and an image merging layer to generate hierarchical feature representations, which are then input into the image decoder. The image merging layer is responsible for downsampling and dimensionality enhancement, while the sliding window-based transformer block is responsible for learning the hierarchical feature representations.
[0116] Step 235: The image decoder and image encoder are symmetrical structures. The original feature maps of adjacent dimensions are reshaped into large feature maps with a resolution of 2 times upsampled by alternating processing of multiple sliding window-based transformer blocks and patch expanding layers in the image decoder. Finally, the last layer of the patch expanding layer is used to perform upsampling by 4 times, restoring the resolution of the large feature map after sampling to the input resolution.
[0117] Step 236: After dimensionality adjustment through the linear embedding layer, the final original feature map is obtained.
[0118] In this embodiment, unlike traditional multi-head self-attention mechanisms, the Swin-Transformer bbck (sliding window transformer block) is constructed based on a sliding window. Figure 16 There are two consecutive Swin-Trnansforrnerbbcks. Each sliding window-based transformer block consists of a normalization module (LN), a multi-head self-attention module (MSA), and a multilayer perceptron module (MLP). The multi-head self-attention modules in two consecutive sliding window-based transformer blocks are respectively window-based multi-head self-attention module (W-MSA) and sliding window-based multi-head self-attention module (SW-MSA). Based on this window partitioning mechanism, consecutive sliding window-based transformer blocks can be represented as:
[0119]
[0120]
[0121]
[0122]
[0123] in, and z lThese represent the outputs of the window-based multi-head self-attention module and the multilayer perceptron module of the l-th block, respectively; and z l+1 represents the output of the sliding window-based multi-head self-attention module and the multilayer perceptron module of the (l+1)th block, respectively; LN represents the normalization module, WMSA represents the window-based multi-head self-attention module, SWMSA represents the sliding window-based multi-head self-attention module, and MLP represents the multilayer perceptron module.
[0124] The complexity calculation formula for a multi-head self-attention module is as follows:
[0125]
[0126] Where Q, K, and V represent Query, Key, and Value respectively, d represents dimension, B represents relative position encoding, and T represents the transpose of the matrix.
[0127] In this embodiment, the location encoding process for the query point in step 25 is as follows:
[0128] For a given coordinate s = [x, y], its position is encoded in the following form:
[0129]
[0130] p k (s)=[sin(kπs), cos(kπvs)]
[0131] Where N = 256 is the number of channels in the feature map, p k The dimension of (s) is 4, so The dimension is N.
[0132] In this embodiment, step 3 specifically involves using a skip connection between the sliding window-based transformer block in the image encoder and the corresponding sliding window-based transformer block in the image decoder. This skip connection effectively reduces gradient vanishing and network degradation problems, making training easier. Introducing feature information at the corresponding scale from the image encoder into the upsampling process in the image decoder provides multi-scale, multi-level information for subsequent image registration, maximizing the utilization of feature information in each layer of the network and resulting in more accurate registration.
[0133] Swin-UNet components:
[0134] (1) Encoder: In the encoder, a C-dimensional input with a resolution of H / 4 × W / 4 is fed into two consecutive Swin-Transform blocks for learning, where the feature size and resolution remain unchanged. Simultaneously, the patch expanding layer reduces the number of representations (by a factor of 2) and increases the feature dimension to twice its original value. This process is repeated three times in the encoder.
[0135] (2) Patch merging layer: The input patch is divided into 4 parts and connected together by a patch merging layer. After this processing, the feature resolution will be reduced by a factor of 2. Furthermore, since the concatenation operation increases the feature dimension by a factor of 4, a linear layer is applied to the concatenated features to unify the feature dimension to twice the original dimension.
[0136] (3) Bottleneck: Since the transformer is too deep to converge, two consecutive Swin-Transformer blocks are used to construct a bottleneck for learning deep feature representations. In the bottleneck, the feature size and resolution remain unchanged.
[0137] (4) Decoder: Corresponding to the encoder, the symmetric decoder is built on Swing Transformer blocks. To this end, unlike the patch merging layer used in the encoder, we use a patch expanding layer in the decoder to upsample the extracted depth features. The patch expanding layer reshapes the feature maps of adjacent dimensions into higher resolution feature maps (2x upsampling) and accordingly reduces the feature dimension to half of the original dimension.
[0138] (5) Patch expanding layer: Taking the first patch expanding layer as an example, before upsampling, a linear layer is applied to the input features (W / 32×H / 32×8C) to increase the feature dimension to twice its original value (W / 32×H / 32×16C). Then, a rearrange operation is used to expand the resolution of the input features to twice the input resolution and reduce the feature dimension to one-quarter of the input dimension (W / 32×H / 32×16C→W / 16×H / 16×4C).
[0139] (6) Skip connection: Similar to UNet, it is used to fuse multi-scale features from the encoder with upsampled features. We concatenate shallow and deep features together to reduce the spatial information loss caused by downsampling. After the linear layer, the dimension of the concatenated features remains the same as the dimension of the upsampled features.
[0140] Step 3: Perform image registration based on the first coordinate position and the second coordinate position.
[0141] In this embodiment, step 3 specifically involves comparing the first coordinate position and the second coordinate position. If they match, the image registration is successful; otherwise, the image registration fails.
[0142] like Figure 18 As shown, this embodiment of the invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, it implements the above-described DR detection method based on Swin-UNet.
[0143] like Figure 19 As shown, this embodiment of the invention also provides a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the above-described DR detection method based on Swin-UNet.
[0144] Furthermore, 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. The integrated unit can be implemented in hardware or as a software functional unit.
[0145] If the integrated unit 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, in essence, or the part that contributes to the prior art, or all or 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.) or processor to execute all or part of the steps of the methods of 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.
[0146] The above description is only a part of the embodiments of the present invention and does not limit the scope of protection of the present invention. Any equivalent device or equivalent process transformation made based on the content of the present invention specification and drawings, or direct or indirect application in other related technical fields, are similarly included within the patent protection scope of the present invention.
Claims
1. A DR detection method based on Swin-UNet, characterized in that, Includes the following steps: Step 1: Real-time acquisition of X-ray and visible light images of the object under test moving within the detection area using a detector and a camera, respectively; the X-rays from the detector penetrate the object under test; specifically including: Step 11: Prepare a cyclic track scanning digital imaging detection device. The cyclic track scanning digital imaging detection device includes a control cabinet, in which a PLC controller is installed. A worktable is installed on the control cabinet. Circular rotating mechanisms are installed on both sides of the worktable. Motor drive mechanisms are installed at the front ends of the two circular rotating mechanisms and are electrically connected to the PLC controller. Multiple pairs of symmetrically distributed pushing mechanisms are installed on the inner sides of the two circular rotating mechanisms. When the pushing mechanism rotates along the circular rotating mechanism to the upper surface of the worktable, the bottom of the pushing mechanism is close to the side of the worktable. A light-transmitting plate is installed on the upper surface of the worktable, with one end of the light-transmitting plate close to the pushing mechanism. An opening is horizontally arranged in the middle of the worktable as a detection area. A detector is installed directly below the opening, and a camera and a light source are installed directly above the opening. Step 12: The PLC controller controls the motor drive mechanism to move, and the motor drive mechanism drives the ring rotating mechanism to rotate, thereby driving the pushing mechanism to push the light-transmitting plate on the surface of the workbench along the ring rotating mechanism, so that the object to be tested on the light-transmitting plate moves to the opening position. Step 13: Set the opening area as the detection area. When the object being tested passes through the detection area, the detector returns an X-ray image of the current state of the object to the computer interface for display. It also updates and acquires multiple X-ray images in real time as the pushing mechanism moves. At the same time, the camera captures a visible light image of the object to be tested above the detector and returns it to the computer interface for display. Step 14: Obtain X-ray images of all times within the detection area, and stitch multiple X-ray images together to form a complete X-ray image; Step 2: Extract two original feature maps from the X-ray image and the visible light image using a UNet network; combine the two original feature maps and combine them with position encoding to obtain a context feature map; extract the second position coordinates of the visible light image from the context feature map and the first coordinate position corresponding to the X-ray image after position encoding using a Swin-Transformer network. Step 3: Perform image registration based on the first coordinate position and the second coordinate position.
2. The DR detection method based on Swin-UNet as described in claim 1, characterized in that, Step 2 specifically includes: Step 21: Use the X-ray image as a fixed image. The visible light image is used as a floating image. The fixed image After normalization, the corresponding first coordinate position is obtained. [0,1] 2 As a query point; Step 22: Set the input to the Swin-Transformer network to: a fixed image. Floating images and the first coordinate position [0,1] 2 The output is: a floating image. The normalized second coordinate position [0,1] 2 Then the optimal set of parameters is found. Minimize the following residuals for the function : Among them, symbols Represents the square of the norm 2; Will Model it as a Swin-Transformer network; Step 23: Fix the image and floating images The image was adjusted to 256*256 and then processed through the same UNet network to extract two original feature maps with dimensions of 16*16*256. And process it; Step 24: Combine the two original feature maps together, and then combine them using a position encoder. For coordinate functions The results of positional encoding are combined to obtain the context feature map. ; Step 25: Transfer the context feature map The location-encoded query point is added as input to the Swing-Transformer network and used as an encoder. Context feature map Encode using a decoder The query point with location encoding is decoded to obtain the output of the Swin-Transformer network; Step 26: Decode the output result using a multilayer perceptron module to obtain a floating image. Corresponding second position coordinates And serve as the matching point; the second position coordinates Represented as: 。 3. The DR detection method based on Swin-UNet as described in claim 2, characterized in that, In step 23, two original feature maps with dimensions of 16*16*256 are extracted using the same UNet network. And it will be processed, specifically including: Step 231: Add a sliding window operation to the Swing-Transformer network; Step 232: Extract two original feature maps from the fixed image and the floating image using the same UNet network, and input them into the image encoder; Step 233: Convert the input into sequence embedding, divide the original feature map into 4*4 non-overlapping image patches, and project the feature dimensions of the image patches to arbitrary dimensions through a linear embedding layer; Step 234: The transformed image patch is processed alternately by multiple sliding window-based transformer blocks and an image integration layer to generate hierarchical feature representations, which are then input into the image decoder. The image integration layer is responsible for downsampling and dimensionality enhancement, and the sliding window-based transformer block is responsible for learning the hierarchical feature representations. Step 235: The image decoder and image encoder are symmetrical structures. The original feature maps of adjacent dimensions are reshaped into large feature maps with a resolution of 2 times upsampled by alternating processing of multiple sliding window-based transformer blocks and image expansion layers in the image decoder. Finally, the last layer of image expansion layer is used to perform 4 times upsampling to restore the resolution of the large feature map after sampling to the input resolution. Step 236: After dimensionality adjustment through the linear embedding layer, the final original feature map is obtained.
4. The DR detection method based on Swin-UNet as described in claim 3, characterized in that, The sliding window-based transformer block consists of a normalization module, a multi-head self-attention module, and a multilayer perceptron module. The multi-head self-attention modules in two consecutive sliding window-based transformer blocks are respectively a window-based multi-head self-attention module and a sliding window-based multi-head self-attention module. Based on this window partitioning mechanism, consecutive sliding window-based transformer blocks are represented as follows: in, and They represent the first The outputs of the window-based multi-head self-attention module and the multilayer perceptron module of the block; and They represent the first +1 block of output from the sliding window-based multi-head self-attention module and multilayer perceptron module; This indicates the normalization module. This indicates a window-based multi-head self-attention module. This indicates a multi-head self-attention module based on a sliding window. This represents a multilayer perceptron module; The complexity calculation formula for a multi-head self-attention module is as follows: in, They represent Query, Key, and Value, respectively. Representing dimension, This represents the relative position encoding; T represents the transpose of the matrix.
5. The DR detection method based on Swin-UNet as described in claim 2, characterized in that, The specific location encoding process for the query point after location encoding in step 25 is as follows: For a given coordinate Its positional encoding is in the following form: in =256 is the number of channels in the feature map. The dimension is 4, so The dimension is .
6. The DR detection method based on Swin-UNet as described in claim 3, characterized in that, Step 3 specifically involves using a skip connection between the sliding window-based transformer block in the image encoder and the corresponding sliding window-based transformer block in the image decoder.
7. The DR detection method based on Swin-UNet as described in claim 1, characterized in that, Step 3 specifically involves comparing the first coordinate position and the second coordinate position. If they match, the image registration is successful; otherwise, the image registration fails.
8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements a DR detection method based on Swin-UNet as described in any one of claims 1 to 7.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When executed by the processor, the program implements a DR detection method based on Swin-UNet as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Thoracic X-ray image lesion anomaly detection method
CN114266735A
Target detection confrontation sample generation method based on region of interest of feature map
CN115713623A
