A CUDA-based method and system for 3D reconstruction using cone-beam computed tomography (CBCT) in industrial applications.
The industrial cone beam CT 3D reconstruction method based on CUDA architecture solves the problems of long reconstruction time and artifacts in traditional systems, achieves fast and efficient 3D image reconstruction and artifact correction, and improves image quality.
Patent Information
- Application Number
- CN202410732775.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-07
- Publication Date
- 2024-09-10
- Estimated Expiration
- 2044-06-07
AI Technical Summary
Traditional industrial three-dimensional cone beam CT systems have problems such as large amounts of projection data collected, long reconstruction time, and artifacts in reconstructed images. Metal artifacts are especially common in the industrial field.
An industrial cone beam CT three-dimensional reconstruction method based on CUDA architecture is adopted to optimize metal and ring artifact correction by accelerating the back-projection process, using GPU for parallel computing, and combining Fourier transform and frequency domain filtering to achieve rapid reconstruction and artifact removal. .
It significantly shortens the reconstruction time of three-dimensional images, improves image quality, effectively removes metal and ring artifacts, and improves the clarity and accuracy of reconstructed images.
Smart Images

Figure CN118314237B
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of three-dimensional reconstruction, and in particular to an industrial cone-beam CT three-dimensional reconstruction method and system based on a CUDA architecture. Background Art
[0002] Computed Tomography (CT) is an imaging technology that reconstructs the internal tissue and structure information of the object being tested by scanning the object with X-rays and obtaining a series of projection data on the detector. Among them, Cone-Beam Computed Tomography (CBCT) is widely used in medical diagnosis and industrial non-destructive testing due to its advantages of rapid acquisition and reconstruction of high-resolution images.
[0003] Traditional industrial 3D cone-beam CT systems have problems such as large amount of collected projection data, long reconstruction time, and artifacts in reconstructed images. Especially in the industrial field, the objects to be measured are often metal workpieces, so metal artifacts are more common in the field of industrial CT. Summary of the invention
[0004] In view of this, the present invention aims to overcome the shortcomings of the above-mentioned problems in the prior art and proposes an industrial cone-beam CT three-dimensional reconstruction method and system based on CUDA architecture, which can meet the needs of real-time reconstruction and quickly correct common metal artifacts and ring artifacts in the industrial field.
[0005] To achieve the above object, the technical solution of the present invention is achieved as follows:
[0006] The industrial cone-beam CT three-dimensional reconstruction method based on the CUDA architecture is accelerated on the CUDA architecture. The CUDA architecture includes a host side and a device side. The host side includes a CPU and its memory, and the device side includes a GPU and a video memory. The industrial cone-beam CT three-dimensional reconstruction method based on the CUDA architecture includes:
[0007] The collected raw data is converted into projection data using Beer's law, and a weighted parameter template equal to the projection size is generated to weight the two-dimensional projection data at each angle;
[0008] The weighted projection data at each angle is reorganized into complex numbers by row, and the rearranged data is subjected to one-dimensional Fourier transform by row, and then the transformed result is multiplied by the frequency domain filter function, and then the inverse Fourier transform is performed back to the spatial domain, and then rearranged into a two-dimensional image again;
[0009] Call the CUDA kernel function to calculate the coordinate vectors of three dimensions. Call the kernel function in the CPU main thread to start back projection. In the GPU, a thread calculates the reconstruction value of a voxel at four angles with a loop number of 1 / 4 of the number of projections. First, use the existing coordinate vector to calculate the projection coordinates in each angle component, and then use the bilinear interpolation method to calculate the reconstructed images of the four channels of the upper and lower sub-blocks. Then use the rotational symmetry within the slice to combine the four channel reconstructed images into the final three-dimensional image, and then transfer the reconstructed image data back to the CPU. The CPU calls the thread to write the two reconstructed blocks into the file. At the same time, the CPU cyclically calls the kernel function to reconstruct the remaining sub-blocks until all blocks are reconstructed and written to the file, completing the reconstruction of the three-dimensional image.
[0010] Furthermore, the CPU is responsible for task scheduling and control. It sends the tasks belonging to the GPU to the GPU for execution through the PCIe bus according to the instructions in the program. At the same time, the CPU is also responsible for data transmission between the GPU. When the image reconstruction task is completed, the CPU transfers the projection data to the GPU's memory and receives the reconstructed results; the GPU is responsible for the calculation during image reconstruction. After performing a series of parallel calculations on the projection data, the reconstructed data is transmitted back to the CPU through the PCIe bus. The communication and coordination between the CPU and GPU rely on the synchronization mechanism to ensure the smooth execution of tasks on the GPU side and return the calculation results to the CPU.
[0011] Furthermore, it also includes objectively evaluating the quality of the reconstructed image using mean square error and structural similarity.
[0012] Furthermore, the metal artifacts are corrected, including:
[0013] The reconstructed image is divided into two parts: the foreground and the background with the object and the background without the object, and a mask is generated to obtain the metal object area;
[0014] Perform forward projection operation on the binary image after threshold segmentation to obtain the projection value;
[0015] The transmission thickness is inferred based on the projection value, and then the projection value is corrected using the transmission thickness fitting correction function.
[0016] Furthermore, the signal-to-noise ratio is used to evaluate the metal artifact correction effect.
[0017] Furthermore, the ring artifacts are corrected, including:
[0018] Taking the central pixel of the reconstructed image as the origin, sampling is performed 180 degrees counterclockwise to obtain the reconstructed image in the polar coordinate system;
[0019] Convert the image from the time domain to the frequency domain, use a low-pass filter to process the spectrum image, correct the high-frequency part in the vertical axis direction, obtain a filtered spectrum map, and convert the spectrum map from the frequency domain to the time domain;
[0020] After filtering in the frequency domain, the coordinate system is transformed back to the Cartesian coordinate system.
[0021] Furthermore, the method also includes evaluating the ring artifact correction effect by using a signal-to-noise ratio.
[0022] The present invention also provides an industrial cone-beam CT three-dimensional reconstruction system based on the CUDA architecture, comprising: a projection data reading and reconstruction acceleration module, a metal artifact removal module, a slice display and annular artifact removal module, and a VTK three-dimensional rendering module. The projection data reading and reconstruction acceleration module is used to read the projection data from the hard disk and transmit it to the GPU display memory, complete the three-dimensional reconstruction of the projection data, and save the reconstructed image. The metal artifact removal module is used to realize the correction of metal artifacts. The slice display and annular artifact removal module is used to display the slice image of the reconstructed object in three dimensions, and correct the annular artifact appearing in the horizontal slice, and at the same time realize the adjustment of the display effect by translation, scaling, and adjusting the window level and window width; the VTK three-dimensional rendering module is used to perform three-dimensional visualization on the reconstructed three-dimensional image, realize surface rendering and user interactive operation.
[0023] Compared with the prior art, the industrial cone-beam CT 3D reconstruction method based on CUDA architecture described in the present invention has the following advantages:
[0024] The present invention realizes industrial cone beam CT three-dimensional reconstruction based on the CUDA architecture, and optimizes the weighting, filtering, and back-projection steps in the FDK algorithm to make it applicable to the CUDA programming architecture. The research focuses on the acceleration method of the back-projection stage, which is the longest time-consuming stage in the reconstruction process. The coordinate calculation process is decomposed by introducing the matrix operation method of the homogeneous coordinate system. At the same time, the selective symmetry and vertical symmetry of the reconstructed data are used to reduce the amount of coordinate calculation in the back-projection process. For the reconstruction of large-volume images, by dividing the reconstruction task into blocks and calculating in parallel, and using threads to control the storage of data, the occupancy of the video memory and the idleness of the GPU are reduced, and the overall simplification speed is improved. Through experiments, the algorithm of the present invention has a higher acceleration ratio than the existing acceleration algorithm, and effectively shortens the reconstruction time of the three-dimensional image.
[0025] The present invention also realizes accelerated correction of metal artifacts, obtains the metal position through threshold segmentation, accelerates the forward projection process to obtain the transmission thickness, and then uses the polynomial fitting method to correct the projection data. Through experiments, the method of the present invention can better correct the artifacts inside the metal workpiece, making the internal structure and contour clearer.
[0026] The present invention also realizes accelerated correction of ring artifacts. The ring artifacts are generated by inconsistent responses of detectors to rays. The present invention uses frequency domain filtering to filter out high-frequency artifacts, and uses CUDA for acceleration in the coordinate transformation, Fourier transformation, and filtering processes. After experiments, the method of the present invention can effectively correct most ring artifacts, and the correction effect is better for artifacts in images without metal parts. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] The accompanying drawings constituting a part of the present invention are used to provide a further understanding of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the accompanying drawings:
[0028] Figure 1 is a flow chart of the method of the present invention;
[0029] Figure 2 A pseudo code schematic diagram of the weighted process parallel calculation of the present invention;
[0030] Figure 3 The parallel calculation flow chart of the filtering process of the present invention;
[0031] Figure 4 A pseudo code schematic diagram of the parallel calculation of the filtering process of the present invention;
[0032] Figure 5 It is a flow chart of the back-projection stage of the present invention;
[0033] Figure 6 It is a schematic diagram of the coordinate system of the back-projection process of the present invention;
[0034] Figure 7 It is a perspective projection schematic diagram of the present invention;
[0035] Figure 8 It is a schematic diagram of perspective projection transformation of the present invention;
[0036] Fig. 9 It is a schematic diagram of converting the detector coordinate system into the projection coordinate system of the present invention;
[0037] Fig.10 It is a schematic diagram of vertical block reconstruction of the present invention;
[0038] Fig.11 It is a schematic diagram of the horizontal rotational symmetry of the present invention;
[0039] Fig.12 A schematic diagram of parallel transmission of reconstructed images according to the present invention;
[0040] Fig.13 It is a schematic diagram of the curve of projection value changing with the thickness of the object in the ideal and actual states of the present invention;
[0041] Fig.14 It is a schematic diagram of the reconstructed image slice, histogram, and threshold segmentation result of the present invention;
[0042] Fig.15 It is a forward projection schematic diagram of the present invention;
[0043] Fig.16 is a pseudo code schematic diagram of the metal artifact correction process of the present invention;
[0044] Fig.17 A schematic diagram of converting the Cartesian coordinate system of the present invention into polar coordinates;
[0045] Fig.18 It is a schematic diagram of the filter structure of the present invention;
[0046] Fig.19 A pseudo code schematic diagram of accelerating ring artifact correction using CUDA architecture according to the present invention;
[0047] Fig. 20 It is a schematic diagram of the system structure of the present invention. DETAILED DESCRIPTION
[0048] It should be noted that, in the absence of conflict, the embodiments of the present invention and the features in the embodiments may be combined with each other.
[0049] In the description of the present invention, it should be understood that the terms "center", "longitudinal", "lateral", "up", "down", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inside", "outside" and the like indicate positions or positional relationships based on the positions or positional relationships shown in the accompanying drawings, and are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as limiting the present invention. In addition, the terms "first", "second", and the like are only used for descriptive purposes, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, features defined as "first", "second", and the like may explicitly or implicitly include one or more of the features. In the description of the present invention, unless otherwise specified, "multiple" means two or more.
[0050] In the description of the present invention, it should be noted that, unless otherwise clearly specified and limited, the terms "installed", "connected", and "connected" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection, or it can be indirectly connected through an intermediate medium, or it can be the internal communication of two components. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood by specific circumstances.
[0051] The present invention will be described in detail below with reference to the accompanying drawings and in conjunction with embodiments.
[0052] like Figure 1 As shown, the present invention provides an industrial cone-beam CT three-dimensional reconstruction method based on the CUDA architecture, and accelerates the industrial cone-beam CT three-dimensional reconstruction method on the CUDA architecture. The CUDA architecture includes a host side and a device side. The host side includes a CPU and its memory, and the device side includes a GPU and a video memory. The CPU is mainly responsible for the scheduling and control of tasks. It sends the tasks belonging to the GPU to the GPU for execution through the PCIe bus according to the instructions in the program. At the same time, the CPU is also responsible for data transmission between the GPU. When the image reconstruction task is completed, the CPU transfers the projection data to the GPU's memory and receives the reconstructed results. The GPU is responsible for the calculation during image reconstruction. After performing a series of parallel calculations on the projection data, the reconstructed data is transmitted back to the CPU through the PCIe bus. The communication and coordination between the CPU and the GPU rely on a synchronization mechanism to ensure the smooth execution of tasks on the GPU side and return the calculation results to the CPU. By adopting the CPU+GPU heterogeneous computing model, their respective characteristics are fully utilized, and the speed of calculation when reconstructing a large amount of image data can be improved. The industrial cone-beam CT three-dimensional reconstruction method includes:
[0053] (1) The collected raw data is converted into projection data using Beer's law, a weighted parameter template equal to the projection size is generated, and the two-dimensional projection data at each angle is weighted; specifically, the collected raw data is first converted into projection data using Beer's law, and the conversion formula is shown in formula (1):
[0054] (1)
[0055] Where P is the transformed projection data, I0 represents the unattenuated ray intensity value, which can be obtained from the blank value in the original data, and I represents the projection value collected by the detector. According to the weighted formula in equation (2), the weighted parameter is only related to the distance D from the ray source to the rotation center. SO , the horizontal coordinate s and the vertical coordinate z on the projected image are related and have nothing to do with the projection angle.
[0056] (2)
[0057] In the formula, Represents the projection data before weighting, where s and z are the horizontal and vertical coordinates of each projection, respectively. represents the weighted projection data, D SO is the distance from the ray source to the center of rotation, s and z are the horizontal and vertical coordinates of each projection respectively. For each projection data, its weight value is only related to its own coordinates and device parameters, so it can meet the conditions for parallel computing. Therefore, it is only necessary to generate a weighted parameter template equal to the projection size. When weighting the two-dimensional projection data at each angle, it is only necessary to find the weighted parameters from the same position of the template and multiply them. Assume that the width and height of each projection data are N respectively. x With N y , place the origin at the center of the projected image, and its pixel coordinate ranges are , , for a point with a pixel position of (x, y) on the projection, the corresponding sampling point coordinates of the virtual projection on the rotation center are (s, z). In this step, the pixel coordinates need to be converted to the actual coordinates in space. According to the principle of triangle similarity, the conversion relationship is shown in formula (3):
[0058] (3)
[0059] Where D SO’ is the distance from the ray source to the flat-panel detector, and interval is the distance between two detectors on the flat-panel detector. Both parameters are derived from the device configuration. After the coordinates of the points on the projection image in the spatial domain are obtained by the above formula, according to the weighted formula Calculate the weighted coefficient template. Then multiply the projection data at N angles by the weighted template to calculate the weighted part. The pseudo code for the specific implementation is as follows Figure 2 shown.
[0060] (2) The weighted projection data at each angle is reorganized into complex numbers by row, and the reorganized data is subjected to one-dimensional Fourier transform by row. The transformed result is then multiplied by the frequency domain filter function, and then inverse Fourier transform is performed to convert it back to the spatial domain, and then it is reorganized into a two-dimensional image again;
[0061] The filtering process involves the conversion between the spatial domain and the frequency domain, which requires the use of Fourier transform to achieve this. CUDA provides users with a library specifically for implementing fast Fourier transforms on the GPU, cuFFT, which enables developers to use the floating-point computing power and parallelism of the GPU to perform fast Fourier transforms without having to write kernel functions specifically. cuFFT provides users with three data types of Fourier transforms, namely complex-to-complex bidirectional Fourier transform (C2C), where CUFFT_FORWARD and CUFFT_INVERSE are used to identify the direction of the transform; real-to-complex forward Fourier transform (R2C); complex-to-real inverse Fourier transform (C2R). At the same time, cuFFT provides a variety of Fourier transform configuration operations, and the configuration handle can be used to configure parameters such as the length of the signal, the transform dimension, and the number of parallel processing, thereby achieving parallel Fourier transform operations.
[0062] The three transformation methods provided by cuFFT are essentially the same in mathematics. In the R2C transformation, since the imaginary part of the input signal is assumed to be 0, the transformed spectrum is mainly composed of the real part, and the imaginary part usually does not contain useful information. Therefore, in the filtering process, the present invention first reorganizes the weighted projection data at each angle into complex numbers by row. Figure 3 As shown, the odd-numbered row data of each projection image is taken as the real part of the complex number, and the even-numbered row data is taken as the imaginary part of the complex number, and the projection data is rearranged into a complex array. For a single projection data of size Nx×Ny, the size of the rearranged data is Nx×Ny / 2. Then, a one-dimensional Fourier transform is performed on the rearranged data row by row, and the transformation result is multiplied by the frequency domain filter function, and then an inverse Fourier transform is performed back to the spatial domain. Finally, the real and imaginary parts of the complex array are rearranged back to odd and even row data to realize parallel operation of the filtering process. It should be noted that when performing an inverse Fourier transform on each row of the projection data, in order to ensure that the signal amplitude after the inverse transform is the same as the original signal, it is necessary to divide it by the signal length M before the equation, as shown in equation (4), Represents the function of Fourier transforming an image to the frequency domain. k is the index in the discrete frequency domain, n is the index in the discrete spatial domain, and i represents the imaginary part. The inverse Fourier transform in cuFFT is not divided by M, so this step needs to be completed in the process of rearranging the complex data after the Fourier transform. The pseudo code for parallel calculation of the filtering process is as follows Figure 4 shown.
[0063]
[0064] (3) After completing the filtering step, the CUDA kernel function is called to calculate the coordinate vectors of three dimensions. The kernel function is called in the CPU main thread to start back projection. In the GPU, a thread calculates the reconstruction value of a voxel at four angles with a loop number of 1 / 4 of the number of projections. First, the existing coordinate vector is used to calculate the projection coordinates in each angle component, and then the bilinear interpolation method is used to calculate the reconstructed images of the four channels of the upper and lower sub-blocks. The rotational symmetry within the slice is used to combine the four channel reconstructed images into the final three-dimensional image, and then the reconstructed image data is transmitted back to the CPU. The CPU calls the thread to write the two reconstructed blocks to the file. At the same time, the CPU cyclically calls the kernel function to reconstruct the remaining sub-blocks until all blocks are reconstructed and written to the file, completing the reconstruction of the three-dimensional image. Figure 5 shown.
[0065] Specifically, Figure 6 As shown in , assuming that the CT value of a voxel P in the object space is to be solved, the position coordinates of the voxel point projected along the ray direction to the projection image P' at each rotation angle must be calculated first, and then the projection value at that angle is obtained by interpolation based on the position coordinates. Finally, the projection value obtained at each angle is multiplied by the weight The CT value of the point is obtained by accumulating. The definition of variable U is shown in formula (5):
[0066] (5)
[0067] in is the distance from the ray source to the rotation center, is the distance from the ray source to the point P" of the voxel projection on the central ray. The present invention then implements parallel acceleration of several stages in the above back-projection process.
[0068] (1) Calculation of back-projection coordinates
[0069] In the back-projection process, it is necessary to obtain the pixel coordinates of the voxel on the projection and the distance from the point projected on the central ray to the ray source. In view of the geometric characteristics of cone-beam CT, the present invention draws on the coordinate system transformation method in OpenGL and makes modifications according to the actual needs of the back-projection process, which involves the transformation between the model coordinate system, the observer coordinate system, the clipping coordinate system, and the projection coordinate system.
[0070] ①Convert the model coordinate system to the observer coordinate system
[0071] like Figure 6 As shown, in this step, the original model coordinate system (O m ,X m ,Y m ,Z m ) is transformed to the observer coordinate system (Ov ,X v ,Y v ,Z v ), O m Represents the rotation center origin, O v Here, we convert the coordinates from Cartesian coordinates to homogeneous coordinates, so that we can use matrix multiplication to calculate in the subsequent rotation, translation and scaling. Since the ray source moves clockwise relative to the object during acquisition, we first convert the object coordinates in (X m ,O m ,Z m ) plane coordinate system is rotated clockwise by θ degrees and converted to (X v ,O v ,Z v ) coordinates. Next, change the coordinate origin from point O m Along Z v Axis direction translation to the ray source O v The transformation from the model coordinate system to the observer coordinate system is completed. The specific transformation calculation method is shown in formula (6), where the fourth dimension represents the scaling factor w, and when the value is 1, it represents the ordinary Cartesian coordinates.
[0072] (6)
[0073] ②Convert the observer coordinate system to the clipping coordinate system
[0074] In a cone-beam CT system, only three-dimensional objects within the range of the cone beam can be projected onto the detector, which is the same as the principle of perspective projection. Figure 7 As shown in the figure, in perspective projection, the way the human eye observes objects is simulated. For objects of the same size in space, the distance from the observation point is different, and the size of their projection on the screen is also different. After the observer coordinate system is converted to the clipping coordinate system, the coordinates are mapped to a viewing cone, which ranges from [-w, w] and extends along the x, y, and z directions. The fourth dimension parameter w represents the depth information of the perspective projection. The closer the point is to the observer, the smaller the w value is, and vice versa. By adjusting the value of w, the intensity of the perspective effect can be controlled, thereby achieving the effect of near big and far small.
[0075] The perspective projection matrix is needed in the process of converting the observer coordinate system to the clipping coordinate system. The function of this matrix is to scale and translate the coordinates in the x, y, and z directions so that the coordinate components of the three dimensions are mapped to the range of [-w, w]. If the transformed three-dimensional coordinate values are all within the range, it means that the point is inside the viewing cone and is retained. The present invention improves the perspective projection matrix in this step, directly converting the X and Y coordinates to the flat-panel detector coordinate system, and in the back-projection calculation stage, only the projection pixel coordinates and the perspective depth w need to be determined, so the z component is not solved. Figure 8 The display is in (X v ,O v ,Z v ) Schematic diagram of the perspective projection matrix transformation on the plane, (Y v ,O v ,Z v ) plane is the same as this principle, so I will not elaborate on it here. The triangle similarity principle is applied here. For a point P inside the viewing cone, its transmission projection onto the flat-panel detector is P', and its projection onto the central ray is P", where the perspective projection has the conversion relationship in equation (7),
[0076] , (7)
[0077] After the conversion of this proportional relationship, the x and y coordinates are mapped to the flat panel detector coordinate system (X w ,O w ,Y w )middle,
[0078] Its range is
[0079] , .
[0080] According to the above transformation method, the perspective projection transformation matrix can be written as shown in formula (8).
[0081] (8)
[0082] ③Convert the clipping coordinate system to the projection coordinate system
[0083] After the above transformation, we can get the position coordinates of the voxel projection on the detector. The last step is to get the pixel coordinates of the voxel on the projected image through viewport transformation. Fig. 9 As shown, the coordinates of the X and Y dimensions are scaled by dividing by the interval, the Y axis is flipped, and then the origin of the coordinates is translated from the center to the upper left corner, and finally transformed to the projected image to obtain the projection value of the voxel at that point.
[0084] The transformation method of this process is shown in formula (9). After the four steps of transformation of the model coordinate system, the observer coordinate system, the clipping coordinate system, and the projection coordinate system, the transformation matrix of the object coordinates in the three-dimensional space to the projection pixel coordinates can be obtained from the formula. The final x and y are divided by the depth w to obtain the coordinates of the voxel on the projection image, and the depth w represents the depth in formula (5). The value of w can be used to calculate the weighted variable U.
[0085] In the traditional FDK algorithm, when reconstructing each voxel, the corresponding projection coordinates of the voxel at all projection angles must be calculated. Suppose we want to reconstruct N x ×N x ×N y The size of the three-dimensional data, the number of projection angles is N, the number of times the coordinates are calculated is N x ×N x ×N y ×N, the amount of calculation is very large. As can be seen from formula (7), the calculation process is divided into the sum of four vectors, where the variable is only the voxel coordinate (x m ,y m ,z m ) and the rotation angle θ. Therefore, the coordinate transformation value of each dimension at each angle can be calculated in advance. In the back projection, the four vectors can be directly read and added to obtain the screen coordinates. The number of coordinate calculations is only N×(2N x +N y ). After obtaining the pixel coordinates corresponding to the voxel on the projection image, the projection value of the voxel can be obtained by bilinear interpolation.
[0086] (9)
[0087] =
[0088]
[0089] (2) Parallel computing of the back-projection process
[0090] In the process of back-projection, the calculation of coordinate transformation causes a lot of computing resource overhead, affecting the efficiency of the entire reconstruction. Therefore, by analyzing the geometric characteristics of the reconstructed image, the number of coordinate calculations can be reduced, thereby accelerating the back-projection process.
[0091] ①Vertical symmetry and block reconstruction
[0092] In the back-projection process, the amount of data of the 3D object to be reconstructed is sometimes larger than the GPU memory. When back-projecting a large volume of 3D images, it is necessary to perform block processing. As shown in formula (7), since the ray source is in (X m ,O m ,Z m ) plane around the rotation center axis Y m Do clockwise circular motion, so the projection coordinate in the Y-axis direction is only related to the coordinate y m It is related to the rotation angle θ and is not affected by other factors. m The axis divides the 3D image into blocks and divides the entire back-projection calculation into multiple subtasks. After each 3D image is reconstructed, it can be directly copied to the host side to avoid occupying the video memory. Fig.10 As shown in , the reconstruction area is symmetrical along the rotation plane, and the projection data of the two symmetrical blocks on the receiver have the same horizontal coordinates and opposite vertical coordinates. Therefore, the two symmetrical sub-blocks can be reconstructed at the same time, saving the amount of coordinate calculation, thereby speeding up the entire reconstruction process.
[0093] ②Horizontal rotational symmetry
[0094] Each horizontal slice of the reconstructed 3D image is a square image. Therefore, when the ray source rotates one circle, the viewing angles separated by 90 degrees have similar geometric shapes in the back-projection process. This feature can be used to simultaneously process projection reconstruction at four angles, reducing the number of coordinate calculations. Fig.11 As shown in m In a certain horizontal slice in the direction, the projection positions of four ray beams separated by 90 degrees on the slice are symmetrical. Therefore, the parallel characteristics of the GPU can be used to simultaneously reconstruct the reconstructed images at four projection angles, and then the reconstructed images at each angle are rearranged to obtain the final reconstructed image.
[0095] In the specific implementation process, four-channel structured volume data is used to store the reconstructed data values at each angle for each reconstructed voxel. Here, a strategy of exchanging space for time is adopted to calculate the conversion of coordinate values once and reconstruct the three-dimensional images at four angles at the same time. The number of angle cycles is 1 / 4 of the scanning angle. Combined with the previous symmetry properties in the vertical direction, the number of coordinate calculations becomes 1 / 8 of the original, and the number of repeated calculations is greatly reduced, which saves computing resources and improves the efficiency of parallel computing, and can effectively shorten the reconstruction time. After the projection data at four angles are reconstructed simultaneously, the four-channel reconstructed images need to be superimposed into a single-channel image according to the geometric relationship on the slice. The conversion relationship is shown in formula (10),
[0096] (10)
[0097] Wherein, the data under the four channels c1, c2, c3, and c4 correspond to the reconstructed images of the four parts of the projection data of 0°-90°, 90°-180°, 180°-270°, and 270°-360° respectively. The reconstructed data at each angle are rotated and accumulated to obtain a complete reconstructed image.
[0098] (3) Reconstruction of data parallel transmission
[0099] After reconstructing each 3D image, the data needs to be transferred from the GPU to the main memory, and then the CPU writes the reconstructed data of that part to the hard disk file. For large volumes of reconstructed data, the writing process is very time-consuming, and the GPU is idle while the CPU is writing. Therefore, the present invention improves the data transmission part. After the GPU reconstructs a 3D image and sends it back to the main memory, the CPU calls a thread specifically for writing to the hard disk, and the main thread calls the GPU kernel function to reconstruct the next image. Fig.12 As shown, assuming that the number of reconstructed blocks is Blocknum, the back-projection time of each block of data is T b , the time to write the file is T w , the serial transmission method requires Blocknum×(T b +T w ), and the time for parallel transmission is Blocknum×T b +T w ,The parallel transmission method can avoid GPU idle during data transmission, thereby improving the ,reconstruction speed and saving reconstruction time.
[0100] Specifically, the method for correcting metal artifacts of the present invention is based on projection data restoration, which restores the nonlinear projection value of multi-energy rays to the ideal projection value of monoenergy rays, thereby correcting the metal artifacts.
[0101] from Fig.13 It can be observed that the projection data change curve under ideal state and the projection data change curve under real state intersect at the origin, and the function value begins to separate as the thickness increases. Therefore, by fitting the function L2 of the real projection data changing with thickness, the curve L1 under ideal state can be obtained according to the slope at the origin, thereby realizing the repair of projection data.
[0102] In order to fit the function curve under the real state, we first need to obtain the independent variables and dependent variables of the fitting sample points, namely the thickness and projection value of the ray passing through the metal object. The projection value can be calculated based on the data collected by the CT flat panel detector, while the thickness of the ray passing through the metal object needs to be calculated based on the reconstructed three-dimensional data. This step involves the segmentation of the image and the calculation of the forward projection.
[0103] (1) Segmentation of reconstructed images
[0104] In the image segmentation stage, it is necessary to segment the reconstructed image into two parts: the foreground and the background with objects and the background without objects, and generate a mask to obtain the metal object area. The image segmentation method adopted by the present invention is the Otsu threshold method (Otsu), which is widely used in the fields of image processing and computer vision. The basic idea is to select the threshold by the maximum inter-class variance, calculate the grayscale histogram of the image and traverse the threshold, calculate the inter-class variance corresponding to the threshold respectively, and select the threshold with the largest inter-class variance to divide the foreground and the background into two parts. When the grayscale value difference between the foreground and background in the image is large, the grayscale histogram presents a bimodal distribution. At this time, the Otsu threshold method works best. Fig.14 (a) shows the reconstructed image of the 1000th slice. Fig.14 (b) shows the image histogram. It can be observed from the histogram that the foreground image and the background image present a bimodal distribution, and the grayscale values of the foreground and background are quite different. Therefore, the Otsu threshold method is suitable for segmenting the foreground and background parts of the CT image. The present invention calls the Otsu threshold image segmentation function in the OpenCV computer vision library to perform foreground and background segmentation on the 1000th layer of the reconstructed image. Fig.14 As shown in (c), although there are darker gray areas inside the metal object, the metal object and the blank area can still be separated by threshold segmentation. Therefore, the segmentation effect using the Otsu threshold method is better and can meet the requirements of foreground and background segmentation.
[0105] (2) Forward projection
[0106] At this stage, it is necessary to perform a forward projection operation on the binary image after threshold segmentation. Different from the general forward projection method, the method of the present invention only needs to obtain the length of the ray passing through the object during forward projection, and does not care about the specific projection value of the object, so it does not involve the interpolation calculation of the projection value. In the process of implementing forward projection, the calculation is performed in a ray-driven manner. By traversing each ray that shines on the detector, the integral is calculated along the direction of the ray to obtain the length of the ray passing through the object. When calculating the integral, the method of equally spaced sampling is used to accumulate the distance, such as Fig.15 As shown in , the ray emitted from the ray source is integrated along the direction of the line connecting the ray source and the detector with a step length of h. If the area passed through is the object area, the length is accumulated to finally obtain the length of the ray passing through the metal workpiece. When collecting sample points, the present invention only collects the y in the reconstructed image. mThe projection length value of the middle slice with a value of 0 at all angles. Taking the real reconstruction data as an example, the number of sampling points at each angle is 2000, with a total of 720 rotation angles. The data volume can meet the fitting of the curve of projection value changing with thickness. First, the coordinates of the ray source and the detector are converted to the object coordinate system. The conversion formula is shown in formula (11):
[0107]
[0108] (11)
[0109] Where (x s ,z s ) represents the coordinates of the ray source in the object coordinate system, (x e ,z e ) is the coordinate of the detector in the object coordinate system, is the distance from the ray source to the rotation center, is the distance from the rotation center to the receiver, θ represents the rotation angle, x w is the projection coordinate.
[0110] After the coordinate transformation, a line integral is performed on each ray to solve the length of the ray passing through the object. As shown in formula (12), L represents the ray length, h represents the integration step, and f(x, z) represents the value of the slice after the foreground and background segmentation. The value of the part containing the metal workpiece is 1, and the value of the part containing the metal workpiece is 0. After the line integral, the length of the ray passing through the metal object can be obtained.
[0111]
[0112] (12)
[0113] In the forward projection process, the present invention uses the CUDA architecture to accelerate the calculation process. At each projection angle, the ray source coordinates are fixed, the detector coordinates are related to their positions on the detector, and there is no dependency between the line integral operations of each ray, so the forward projection calculation can be implemented in parallel. In the GPU, each thread is assigned to the line integral operation of a ray, and the forward projection process can be completed quickly by using the GPU parallel computing principle.
[0114] (3) Curve fitting and projection correction
[0115] Since only the projection value can be obtained in actual application, it is necessary to first infer the transmission thickness based on the projection value, and then use the transmission thickness to correct the projection value. The present invention uses a fifth-order polynomial to fit the curve, as shown in formula (13). First, a fifth-order function with the projection value p as the independent variable and the thickness of the transmitted object l as the dependent variable is fitted, and then a fifth-order function with the thickness of the transmitted object l as the independent variable and the projection value p as the dependent variable is fitted. Finally, the linear part of the function of the projection value p with respect to the change of l is taken to obtain the corrected projection value p'. In actual operation, the present invention uses the Eigen library for fitting function curves. The Eigen library is a C++ template library for linear algebra calculations, which provides a relatively rich matrix operation function, among which the solve() method in HouseholderQR can be used to quickly obtain the least squares solution.
[0116]
[0117]
[0118] (13)
[0119] Among them, a0, a1, a2, a3, a4, a5, b0, b1, b2, b3, b4, and b5 are polynomial parameters. After the above three processes, the true value of the multi-energy projection can be converted into a theoretical value through the fitted function. In the process of secondary reconstruction, the projection value is corrected in the weighted part to reduce the impact of metal artifacts on the quality of the reconstructed image. Pseudo code of the metal artifact correction process Fig.16 shown.
[0120] Specifically, in order to improve the quality of the reconstructed image while ensuring the reconstruction speed, the present invention chooses to correct the ring artifact in the CT image post-processing stage and accelerates it using the CUDA architecture.
[0121] The present invention selects a method for performing artifact correction in polar coordinates. After conversion to polar coordinates, the annular artifact presents a high-frequency linear artifact, so it can be removed by frequency domain filtering. The correction method of the present invention is divided into the following steps:
[0122] (1) Conversion from Cartesian coordinate system to polar coordinate system
[0123] In this step, the present invention takes the central pixel of the image as the origin and samples 180 degrees counterclockwise to obtain a reconstructed image in a polar coordinate system. Fig.17 As shown in (a), the length and width of each slice are N x , the range of the polar radius r is [0,N x ), the sampling range is radius N x / 2 circle. Because the effective range of CT reconstruction is the inscribed circle of the image, this sampling method is completely consistent with the effective area of CT reconstruction, so no valid image information will be lost. In order to ensure that the image will not be distorted due to sampling after polar coordinate transformation, the rotation angle of the sampling interval should be as small as possible. The sampling angle interval Δθ adopted by the present invention is The interval between the sampling points at the two angles farthest from the rotation center is only 1 pixel, which ensures that the sampling points are densely distributed in polar coordinates to avoid resolution reduction due to sampling. By sampling 180° counterclockwise, the width and height of the image converted to polar coordinates are N x , , the polar coordinate conversion formula is shown in formula (12). Taking the 1000th slice as an example, the image converted to polar coordinates is as follows Fig.17 As shown in (b).
[0124] 2) Frequency domain low-pass filtering to correct high-frequency straight line artifacts
[0125] By converting the image to polar coordinates, it can be observed that the ring artifact appears as a horizontal straight line in the image. The closer to the rotation center, the more obvious the artifact. Fig.17 In (c), on a vertical sampling line in the polar coordinate image, the gray value changes very quickly and has a large amplitude at the rotation center. Therefore, the present invention adopts frequency domain filtering to filter high-frequency straight line artifacts in the vertical direction.
[0126] ①Convert time domain to frequency domain
[0127] First, the image needs to be converted from the time domain to the frequency domain. The present invention uses a two-dimensional Fourier transform method for conversion and uses the cuFFT Fourier transform library that comes with the CUDA architecture for processing. Since the high-frequency artifacts in the vertical direction need to be filtered in the next step, and the low-frequency information is distributed in the four corners and the high-frequency information is distributed in the center after the Fourier transform, it is necessary to centralize the spectrum before the Fourier transform to ensure that the center of the spectrum is located at the center of the image after the Fourier transform.
[0128] In the process of spectrum centering, the translation property of the two-dimensional Fourier transform is involved. In the time domain, the center of the spectrum can be translated by multiplying it with an exponential term, as shown in equation (14), where f(x, y) represents the image pixel value in the time domain, and F(u, v) represents the spectrum image. If the image is translated by (u0, v0) units in the frequency domain, it is necessary to multiply it by an exponential term, where Nx and Ny are the spectrum width and height. If the center of the spectrum is set to the center of the image, the spectrum needs to be translated. , then according to the transformation of Euler's formula, the time domain image needs to be multiplied by .
[0129]
[0130] (14)
[0131] Then, the present invention utilizes cufftPlanMany in the CUDA architecture to formulate a two-dimensional Fourier transform plan to convert the image from the time domain to the frequency domain.
[0132] ② Frequency domain low-pass filtering
[0133] The spectrum of the converted spectrum image has a higher brightness in the high-frequency part, so in the filtering process, the high-frequency part is mainly filtered to achieve the effect of correcting the high-frequency straight line artifacts. In the filter design, the present invention uses a low-pass filter to process the spectrum image and correct the high-frequency part. The filter structure is as follows Fig.18 As shown in the figure, with the origin as the center, the high-frequency part is set to 0 along the positive and negative directions of the vertical axis, and only the low-frequency and horizontal frequency parts are retained. In the filter template, the cutoff frequency length at both ends of the vertical axis is L, and the width is W. The L and W values are determined according to the actual situation of the artifact. For wider artifacts, the W value can be appropriately increased. The larger the L value, the less high-frequency components are retained. The filtered spectrum can be obtained by multiplying the filter template with the spectrum image.
[0134] ③Convert frequency domain to time domain
[0135] The frequency domain and time domain conversion process is also accelerated using the cuFFT library function in CUDA. Since cuFFT does not divide by the transform size when performing the inverse Fourier transform, it should be multiplied by After the frequency domain is converted to the time domain, the image origin should be located at the upper left corner of the image. Therefore, after completing the inverse Fourier transform, the image should also be translated in the spatial domain. As shown in equation (15), similar to the principle of spectrum centering, after multiplying the frequency domain function by the exponential term, the image origin can be translated in the spatial domain, thereby placing the image origin in the upper left corner.
[0136] (15)
[0137] (3) Conversion from polar coordinate system to Cartesian coordinate system
[0138] After frequency domain filtering, the coordinate system needs to be converted back to the Cartesian coordinate system. The conversion formula is shown in equation (16), where is the function name, representing the function representation in polar coordinates;
[0139]
[0140] (16)
[0141] Since the image origin is located in the upper left corner of the image, it is necessary to translate the image coordinates and solve the corresponding position of the point on the polar coordinates, and then obtain the pixel value on the Cartesian coordinate system through nearest interpolation. The pseudo code for accelerating the correction of ring artifacts using the CUDA architecture is as follows: Fig.19 shown.
[0142] like Fig. 20 As shown, the present invention also provides an industrial cone-beam CT three-dimensional reconstruction system based on the CUDA architecture, which is used to read, reconstruct, display, correct artifacts and perform three-dimensional rendering on projection data collected by the cone-beam CT system or existing reconstructed three-dimensional images.
[0143] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. An industrial cone-beam CT 3D reconstruction method based on CUDA architecture, characterized by: The method for accelerating the three-dimensional reconstruction of industrial cone-beam CT on the CUDA architecture includes a host side and a device side. The host side includes a CPU and its memory, and the device side includes a GPU and video memory. The specific method for the three-dimensional reconstruction of industrial cone-beam CT based on the CUDA architecture is as follows: The collected raw data is converted into projection data using Beer's law, and a weighted parameter template equal to the projection size is generated to weight the two-dimensional projection data at each angle. First, the collected raw data is converted into projection data using Beer's law. The conversion formula is shown in formula (1): (1) Where P is the transformed projection data, I0 represents the unattenuated ray intensity value, which is obtained by the value of the blank space in the original data, and I represents the projection value collected by the detector. According to the weighted formula in formula (2), the weighted parameter is only related to the distance D from the ray source to the rotation center. SO , the horizontal coordinate s on the projected image is related to the vertical coordinate z, and has nothing to do with the projection angle. (2) In the formula, Represents the projection data before weighting, where s and z are the horizontal and vertical coordinates of each projection, respectively. represents the weighted projection data, D SO is the distance from the ray source to the rotation center, s and z are the horizontal and vertical coordinates of each projection, respectively. For each projection data, its weight value is only related to its own coordinates and device parameters, so it can meet the conditions for parallel computing. It only needs to generate a weighted parameter template equal to the projection size. When weighting the two-dimensional projection data at each angle, it only needs to find the weighted parameters from the same position of the template and multiply them. Assume that the width and height of each projection data are N respectively. x With N y , place the origin at the center of the projected image, and its pixel coordinate ranges are , , for a point with a pixel position (x, y) on the projection, the corresponding sampling point coordinates of the virtual projection on the rotation center are (s, z). In this step, the pixel coordinates need to be converted to the actual coordinates in space. According to the principle of triangle similarity, the conversion relationship is shown in formula (3): (3) Where D SO’ is the distance from the ray source to the flat-panel detector, and interval is the distance between two detectors on the flat-panel detector. Both parameters are derived from the device configuration. After the coordinates of the points on the projected image in the spatial domain are obtained by the above formula, the weighted formula is used. Calculate a weighted parameter template, and then multiply the projection data at N angles by the weighted parameter template to calculate the weighted part; The weighted projection data at each angle is reorganized into complex numbers by row, and the rearranged data is subjected to one-dimensional Fourier transform by row, and then the transformed result is multiplied by the frequency domain filter function, and then the inverse Fourier transform is performed back to the spatial domain, and then rearranged into a two-dimensional image again; Call the CUDA kernel function to calculate the coordinate vector of three dimensions. Call the kernel function in the CPU main thread to start back projection. In the GPU, a thread uses 1 / 4 of the number of projections as the loop number to calculate the reconstruction value of a voxel at four angles. First, use the existing coordinate vector to calculate the projection coordinates in each angle component, and then use the bilinear interpolation method to calculate the reconstructed images of the four channels of the upper and lower sub-blocks. Then use the rotational symmetry within the slice to combine the four channel reconstructed images into the final three-dimensional image, and then transfer the reconstructed image data back to the CPU. The CPU calls the thread to write the two reconstructed blocks to the file. At the same time, the CPU cyclically calls the kernel function to reconstruct the remaining sub-blocks until all blocks are reconstructed and written to the file. The reconstruction of the three-dimensional image is completed. Each horizontal slice of the reconstructed three-dimensional image is a square image. During the rotation of the ray source, in a certain horizontal slice along the Y-axis direction, the projection positions of four ray beams separated by 90 degrees on the slice are symmetrical. The parallel characteristics of the GPU are used to simultaneously reconstruct the reconstructed images at four projection angles, and then the reconstructed images at each angle are rearranged to obtain the final reconstructed image. In the specific implementation process, four-channel structured volume data is used to store the reconstructed data value at each angle for each reconstructed voxel. Here, a strategy of using space in exchange for time is adopted to calculate the conversion of coordinate values once, and reconstruct the three-dimensional images at four angles at the same time. The number of angle cycles is 1 / 4 of the scanning angle. After the projection data at the four angles are reconstructed simultaneously, the four-channel reconstructed images need to be superimposed into a single-channel image according to the geometric relationship on the slice. The conversion relationship is shown in the following formula: ; Wherein, the data under the four channels c1, c2, c3, and c4 correspond to the reconstructed images of the four parts of the projection data of 0°-90°, 90°-180°, 180°-270°, and 270°-360° respectively. The reconstructed data at each angle are rotated and accumulated to obtain a complete reconstructed image.
2. The industrial cone-beam CT 3D reconstruction method based on CUDA architecture according to claim 1, characterized in that: The CPU is responsible for task scheduling and control. It sends the tasks belonging to the GPU to the GPU through the PCIe bus for execution according to the instructions in the program. At the same time, the CPU is also responsible for data transmission between the GPU. When the image reconstruction task is completed, the CPU transfers the projection data to the GPU's memory and receives the reconstructed results; the GPU is responsible for the calculation during image reconstruction. After performing a series of parallel calculations on the projection data, the reconstructed data is transmitted back to the CPU through the PCIe bus. The communication and coordination between the CPU and GPU rely on the synchronization mechanism to ensure the smooth execution of tasks on the GPU side and return the calculation results to the CPU.
3. The industrial cone-beam CT 3D reconstruction method based on CUDA architecture according to claim 1, characterized in that: It also includes objective evaluation of the reconstructed image quality using mean square error and structural similarity.
4. The industrial cone-beam CT 3D reconstruction method based on CUDA architecture according to claim 1, characterized in that: It also includes correction for metal artifacts, including: The reconstructed image is divided into two parts: the foreground and background with objects and the background without objects, and a mask is generated to obtain the metal object area; Perform forward projection operation on the binary image after threshold segmentation to obtain the projection value; The transmission thickness is inferred from the projection value, and then the projection value is corrected using the transmission thickness fitting correction function.
5. The industrial cone-beam CT 3D reconstruction method based on CUDA architecture according to claim 4, characterized in that: It also includes the evaluation of metal artifact correction effect using signal-to-noise ratio.
6. The industrial cone-beam CT 3D reconstruction method based on CUDA architecture according to claim 1, characterized in that: It also includes correction for ring artifacts, including: Taking the central pixel of the reconstructed image as the origin, sampling is performed 180 degrees counterclockwise to obtain the reconstructed image in the polar coordinate system; Convert the image from the time domain to the frequency domain, use a low-pass filter to process the spectrum image, correct the high-frequency part in the vertical axis direction, obtain a filtered spectrum map, and convert the spectrum map from the frequency domain to the time domain; After filtering in the frequency domain, the coordinate system is transformed back to the Cartesian coordinate system.
7. The industrial cone-beam CT 3D reconstruction method based on CUDA architecture according to claim 5, characterized in that: It also includes the evaluation of the ring artifact correction effect using the signal-to-noise ratio.
8. An industrial cone-beam CT 3D reconstruction system based on CUDA architecture, used to implement the method described in any one of claims 1 to 7, characterized in that: include: The projection data reading and reconstruction acceleration module, the metal artifact removal module, the slice display and ring artifact removal module, and the VTK three-dimensional rendering module, the projection data reading and reconstruction acceleration module is used to read the projection data from the hard disk and transfer it to the GPU video memory, complete the three-dimensional reconstruction of the projection data, and save the reconstructed image, the metal artifact removal module is used to realize the correction of metal artifacts, the slice display and ring artifact removal module is used to display the slice image of the reconstructed object in three dimensions, and correct the ring artifacts appearing in the horizontal slice, and adjust the display effect by translation, scaling, adjusting the window level and window width; the VTK three-dimensional rendering module is used to perform three-dimensional visualization of the reconstructed three-dimensional image, realize surface rendering and user interactive operation.
