Method for generating a two-dimensional projection image, computer device and computer program product
By working collaboratively between the CPU and GPU to adaptively determine the projection area and the number of thread blocks, the problem of balancing efficiency and applicability in parallel generation of 2D projection images by GPUs in existing technologies is solved, and projection images of different objects are generated efficiently.
Patent Information
- Application Number
- CN202511345221.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-19
- Publication Date
- 2026-01-06
- Estimated Expiration
- 2045-09-19
AI Technical Summary
Existing methods for generating 2D projected images in parallel using GPUs cannot simultaneously balance generation efficiency and applicable scenarios, especially when the efficiency decreases as the 3D voxel data changes.
The CPU determines the projection areas of the target patient and the target medical device, and the number of thread blocks is adaptively determined based on the GPU performance parameters. The GPU is used to process the projection operations in parallel and fuse the projection images of different objects.
It improves the efficiency of generating target projection images, expands the scope of application of the method, and reduces computational overhead, especially shortening the time consumption when generating projection images of small objects.
Smart Images

Figure CN120833403B_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of medical imaging technology, and in particular relates to a method for generating two-dimensional projection images, a computer device, and a computer program product. Background Technology
[0002] Digitally reconstructed radiograph (DRR) technology is a computational technique that generates two-dimensional projected images based on three-dimensional medical imaging data. Its core principle is to simulate the X-ray imaging process by projecting three-dimensional voxel data from computed tomography (CT) or magnetic resonance imaging (MRI), thereby generating virtual X-ray images that are highly similar to real X-ray images without additional radiation. Based on this, DRR technology has been widely applied in medical scenarios such as radiotherapy, surgical planning, and surgical navigation.
[0003] To improve the generation efficiency of 2D projected images based on DRR technology, related technologies have provided a method for parallel generation of 2D projected images using a graphics processing unit (GPU). However, this method only achieves high image generation efficiency when the 3D voxel data remains unchanged. When generating 2D projected images of multiple different objects, variations in the 3D voxel data of these objects lead to a decrease in GPU data processing efficiency. Therefore, the GPU-based parallel generation method for 2D projected images cannot simultaneously achieve both high generation efficiency and suitable application scenarios. Summary of the Invention
[0004] In view of this, embodiments of this application provide a method for generating two-dimensional projected images, a computer device, and a computer program product to solve the technical problem in related technologies that the method for generating two-dimensional projected images in parallel based on GPUs cannot simultaneously take into account the generation efficiency and applicable scenarios of two-dimensional images.
[0005] In a first aspect, embodiments of this application provide a method for generating a two-dimensional projected image, applied to a computer device, the computer device including a central processing unit (CPU) and a graphics processing unit (GPU); the method includes:
[0006] The CPU determines the first projection area on the virtual projection screen corresponding to the first three-dimensional voxel data of the target patient, and determines the second projection area on the virtual projection screen corresponding to the second three-dimensional voxel data of the target medical device; the area of the second projection area is smaller than the area of the first projection area.
[0007] The CPU determines the first number of thread blocks to be launched based on the performance parameters of the GPU.
[0008] The CPU transmits the first three-dimensional voxel data, the first projection area, the second three-dimensional voxel data, the second projection area, the first quantity, and the preset projection parameters to the GPU;
[0009] The GPU initiates the first number of thread blocks and, based on the preset projection parameters, performs a digital reconstruction projection operation on the first three-dimensional voxel data in the first projection area in parallel through the first number of thread blocks to obtain a first projected image; and, based on the preset projection parameters, performs the digital reconstruction projection operation on the second three-dimensional voxel data in the second projection area in parallel through the first number of thread blocks to obtain a second projected image.
[0010] The GPU fuses the first projected image and the second projected image to obtain the target projected image.
[0011] In one optional implementation of the first aspect, the CPU determines a first projection area on a virtual projection screen corresponding to the first three-dimensional voxel data of the target patient, and determines a second projection area on the virtual projection screen corresponding to the second three-dimensional voxel data of the target medical device, including:
[0012] The CPU acquires preset projection parameters; the preset projection parameters include the projection source position, projection screen position, projection angle, projection image size, and the preset projection pose of the second three-dimensional voxel data;
[0013] The CPU determines the first projection area as a first axis-aligned rectangular area whose center point coincides with the center point of the virtual projection screen and whose size is the same as the size of the projected image.
[0014] The CPU determines the second projection area based on the projection source position, the projection screen position, the projection angle, and the preset projection pose of the second three-dimensional voxel data.
[0015] In one optional implementation of the first aspect, the CPU determines the second projection area based on the projection source position, the projection screen position, the projection angle, and the preset projection pose of the second three-dimensional voxel data, including:
[0016] The CPU determines the positions of each vertex of the three-dimensional bounding box corresponding to the second three-dimensional voxel data when the second three-dimensional voxel data is in the preset projection pose;
[0017] The CPU determines the two-dimensional coordinates of each virtual intersection point of each virtual ray emitted from the virtual projection source and passing through each of the vertices with the virtual projection screen in the projection screen coordinate system based on the projection source position, the position of each vertex, and the projection screen position.
[0018] The CPU determines the second projection area as the second axis-aligned rectangular region defined by the minimum horizontal coordinate value, the maximum horizontal coordinate value, the minimum vertical coordinate value, and the maximum vertical coordinate value in all the two-dimensional coordinates.
[0019] In one optional implementation of the first aspect, the CPU determines a first number of thread blocks to be launched based on the performance parameters of the GPU, including:
[0020] The CPU determines the number of parallel processors contained in the GPU and the maximum number of concurrent threads for each parallel processor based on the model of the GPU.
[0021] The CPU determines a second number of threads contained in each thread block;
[0022] The CPU calculates the first quantity using the following formula, based on the number of parallel processors, the maximum number of concurrent threads, and the second quantity:
[0023] G =( M / B )* S * R ;
[0024] in, G For the first quantity, M The maximum number of concurrent threads, B For the second quantity, S The number of parallel processors, R This is the preset expansion factor.
[0025] In one optional implementation of the first aspect, based on the preset projection parameters, the digital reconstruction projection operation is performed in parallel on the second three-dimensional voxel data within the second projection region using the first number of thread blocks to obtain a second projected image, including:
[0026] The GPU determines the target threads responsible for each pixel within the second projection region from all threads contained in the first number of thread blocks, and performs the following digital reconstruction projection operation in parallel through all the target threads:
[0027] For each target thread, a projection ray is determined, pointing from the virtual projection source to the pixel that the target thread is responsible for. If the projection ray intersects with the three-dimensional bounding box corresponding to the second three-dimensional voxel data, the original pixel value of the pixel that the target thread is responsible for is determined based on the voxel values of all target voxels that the projection ray passes through in the three-dimensional bounding box.
[0028] In an optional implementation of the first aspect, determining the original pixel value of the pixel for which the target thread is responsible, based on the voxel values of all target voxels traversed by the projection ray within the three-dimensional bounding box, includes:
[0029] The near-end intersection and far-end intersection of the projection ray and the 3D bounding box are determined for each target thread;
[0030] For each target thread, the corresponding projection ray is determined to pass through the target voxels sequentially within the three-dimensional bounding box, starting from the near intersection point and ending at the far intersection point.
[0031] The original pixel value of the pixel being handled by the target thread is obtained by integrating and summing the voxel values of all the target voxels that the corresponding projection ray passes through within the 3D bounding box.
[0032] In an optional implementation of the first aspect, each target thread determines its corresponding projected ray to pass sequentially through the target voxels within the 3D bounding box from the near intersection point to the far intersection point, including:
[0033] For each target thread, the voxel containing the proximal intersection and the voxel containing the distal intersection are respectively designated as the first and last target voxels. Starting from the first target voxel, the following voxel determination steps are repeated until the current voxel is the last target voxel:
[0034] Based on the direction vector of the projection ray, determine three mutually perpendicular candidate boundary surfaces from all the boundary surfaces of the current target voxel.
[0035] Calculate the travel parameter value required for the projected ray to travel from the incident point of the current target voxel to each of the candidate boundary surfaces;
[0036] The voxel adjacent to the candidate boundary surface corresponding to the smallest travel parameter value is determined as the next target voxel.
[0037] In an optional implementation of the first aspect, the GPU fuses the first projected image and the second projected image to obtain a target projected image, including:
[0038] The GPU calculates the normalized pixel value of each pixel in the first projected image in parallel through multiple target threads corresponding to the first projected image based on the minimum and maximum original pixel values in the first projected image, and obtains the first normalized image.
[0039] The GPU calculates the normalized pixel value of each pixel in the second projected image in parallel through multiple target threads corresponding to the second projected image based on the minimum and maximum original pixel values in the second projected image, and obtains the second normalized image.
[0040] The GPU uses a pixel value accumulation method to fuse the first normalized image and the second normalized image into the target projection image.
[0041] In a second aspect, embodiments of this application provide a computer device, including a memory and a computer program stored in the memory and executable on a processor, wherein the processor executes the computer program to implement the method as described in any of the optional implementations of the first aspect above.
[0042] Thirdly, embodiments of this application provide a computer-readable storage medium storing a computer program that, when executed by a processor, implements the method described in any of the optional implementations of the first aspect above.
[0043] Fourthly, embodiments of this application provide a computer program product that, when run on a computer device, enables the computer device to implement the method described in any optional implementation of the first aspect.
[0044] The method for generating two-dimensional projected images, computer equipment, computer-readable storage medium, and computer program product provided in the embodiments of this application have the following beneficial effects:
[0045] The two-dimensional projection image generation method provided in this application allows the CPU to adaptively determine projection regions of different areas for different objects. Therefore, when the GPU generates projection images of small objects such as medical devices, it only performs digital reconstruction projection operations within the corresponding projection region, which has an area much smaller than the global image size. This reduces the total number of pixels to be processed and unnecessary computational overhead, shortens the projection time for small objects, and improves the overall generation efficiency of the target projection image. Since the CPU can adaptively determine the first number of thread blocks to be started that match the GPU's performance parameters, this method is applicable to GPUs with different performance parameters. Furthermore, because this method can efficiently generate projection images of different objects even when the three-dimensional voxel data changes, it expands the applicability of the method while improving the overall generation efficiency of the target projection image. Attached Figure Description
[0046] To more clearly illustrate the technical solutions in the embodiments of this application, 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 this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0047] Figure 1 A schematic flowchart illustrating a method for generating a two-dimensional projection image provided in an embodiment of this application;
[0048] Figure 2 This is a schematic diagram illustrating the implementation process of step S101 in a method for generating a two-dimensional projected image provided in an embodiment of this application.
[0049] Figure 3A A schematic diagram of a first projection area provided in an embodiment of this application;
[0050] Figure 3B A schematic diagram of a second projection area provided in an embodiment of this application;
[0051] Figure 4 A schematic diagram illustrating the implementation flow of S105 in a method for generating a two-dimensional projected image provided in an embodiment of this application;
[0052] Figure 5 This is a schematic diagram of the structure of a computer device provided in an embodiment of this application. Detailed Implementation
[0053] The following embodiments are only used to illustrate the technical solutions of this application more clearly, and are therefore only examples and should not be used to limit the scope of protection of this application.
[0054] In the description of the embodiments of this application, the technical terms "comprising," "including," "having," and any variations thereof all mean "including but not limited to," unless otherwise specifically emphasized. In the description of the embodiments of this application, unless otherwise stated, the technical term "multiple" refers to two or more, and the technical terms "at least one" or "one or more" refer to one, two, or more than two. The technical terms "first," "second," etc., are only used to distinguish different objects and should not be construed as indicating or implying relative importance or implicitly specifying the number, specific order, or primary / secondary relationship of the indicated technical features. The technical term "and / or" is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, or B existing alone. Additionally, the character " / " in this document generally indicates that the preceding and following related objects have an "or" relationship.
[0055] This application first provides a method for generating a two-dimensional projected image. The method can be executed by a computer device. Exemplarily, the computer device can be an electronic device such as a desktop computer, laptop computer, tablet computer, or mobile phone. This application does not limit the type of computer device.
[0056] Optionally, the computer device may include a central processing unit (CPU), a GPU, and memory. Both the GPU and memory are connected to the CPU. The GPU may include multiple parallel processors. Parallel processors may be, for example, streaming multiprocessors (SM). It should be noted that the specific functions of the CPU, GPU, and memory in the computer device can be found in the descriptions in the following method embodiments or computer device embodiments, and will not be detailed here.
[0057] Figure 1 This is a schematic flowchart illustrating a method for generating a two-dimensional projected image, as provided in an embodiment of this application. Figure 1 As shown, the method may include S101 to S105, as detailed below:
[0058] S101, the CPU determines the first projection area on the virtual projection screen corresponding to the first three-dimensional voxel data of the target patient, and determines the second projection area on the virtual projection screen corresponding to the second three-dimensional voxel data of the target medical device; the area of the second projection area is smaller than the area of the first projection area.
[0059] Optionally, the target medical device can be a surgical instrument for performing surgical procedures, a surgical implant for implantation into the target patient, or other types of medical devices. This application does not limit the type of target medical device.
[0060] In some application scenarios, users can directly import existing first three-dimensional voxel data of the target patient and second three-dimensional voxel data of the target medical device into the computer device. This allows the computer device to skip the step of calculating the first three-dimensional voxel data and the second three-dimensional voxel data, thereby shortening the data preparation time and improving the overall digital reconstruction projection efficiency (i.e., the overall generation efficiency of the target projection image).
[0061] In other application scenarios, users can import CT or MRI data of a target patient and a 3D model of a target medical device into a computer device. Based on this, the CPU in the computer device can perform 3D reconstruction of the target patient's CT or MRI data to obtain the first 3D voxel data of the target patient. The CPU can also use an isosurface extraction algorithm to convert the 3D model of the target medical device into second 3D voxel data. It should be noted that the specific process of reconstructing CT or MRI data into 3D voxel data and the process of using an isosurface extraction algorithm to convert the 3D model into 3D voxel data can be found in the descriptions in related technologies, and will not be detailed in the embodiments of this application.
[0062] Optionally, the computer device's memory may store preset projection parameters. These preset projection parameters can be user-defined; for example, the user can set corresponding projection parameters according to the usage scenario. For example, the preset projection parameters may include: projection source position, projection screen position, projection angle, projected image size, preset projection pose of the first three-dimensional voxel data, and preset projection pose of the second three-dimensional voxel data.
[0063] The projection source location can refer to the intended placement position of the virtual projection source (e.g., a virtual X-ray source) in the projection space. Optionally, the projection source location can be determined by the first three-dimensional coordinates of the intended placement position in the projection space. x 1, y 1, z 1) indicates.
[0064] The projection screen position can refer to the geometric location of the virtual projection screen (e.g., a virtual X-ray imaging screen) in the projection space. Optionally, the projection screen position can be determined by the second or third-dimensional coordinates of the center point of the virtual projection screen in the projection space. x 2, y 2, z 2) and the three-dimensional normal vector of the virtual projection screen ( n x ,n y , n z )express.
[0065] The projection angle can be used to describe the projection viewpoint of the virtual projection source relative to the target patient. Optionally, the projection angle can be represented by the rotation angle of the virtual projection source around the patient's body axis within a preset plane. The preset plane can refer to a plane perpendicular to the patient's body axis. For example, a projection angle of 0 degrees indicates that the virtual projection source is behind the target patient, i.e., projecting from the back of the target patient to the front; a projection angle of 90 degrees indicates that the virtual projection source is to the left of the target patient, i.e., projecting from the left to the right; a projection angle of 180 degrees indicates that the virtual projection source is in front of the target patient, i.e., projecting from the front to the back; and a projection angle of 270 degrees indicates that the virtual projection source is to the right of the target patient, i.e., projecting from the right to the left.
[0066] The size of the projected image can include the resolution of the projected image. W × H Horizontal pixel spacing Δ u and vertical pixel spacing Δ v Represented by the horizontal pixel spacing Δ. u Vertical pixel spacing Δ v They can be the same or different. Optionally, the projected image size can be set based on the first three-dimensional voxel data of the target patient.
[0067] The preset projection pose of the first 3D voxel data may include a first preset projection position and a first preset projection orientation. Optionally, the first preset projection position can be determined by the third 3D coordinates of the center point of the 3D bounding box corresponding to the first 3D voxel data in the projection space. x 3, y 3, z 3) Representation. Here, the 3D bounding box corresponding to the first 3D voxel data can refer to the smallest cuboid bounding box that can completely enclose the first 3D voxel data. Optionally, the first preset projection pose can be represented by a first rotation matrix in the projection space of the 3D bounding box corresponding to the first 3D voxel data.
[0068] The preset projection pose of the second 3D voxel data can include a second preset projection position and a second preset projection orientation. The second preset projection position can be determined by the fourth 3D coordinates of the center point of the 3D bounding box corresponding to the second 3D voxel data in the projection space. x 4, y 4, z4) Representation. Here, the 3D bounding box corresponding to the second 3D voxel data can refer to the smallest cuboid bounding box that can completely enclose the second 3D voxel data. Optionally, the second preset projection pose can be represented by a second rotation matrix in the projection space of the 3D bounding box corresponding to the second 3D voxel data.
[0069] Based on this, the CPU can determine the first projection area and the second projection area according to the aforementioned preset projection parameters. Specifically, S101 may include, for example: Figure 2 S1011 to S1013 are described in detail below:
[0070] S1011, the CPU obtains the preset projection parameters.
[0071] Specifically, the CPU can retrieve preset projection parameters from memory.
[0072] S1012, the CPU determines the first projection area as the axis-aligned rectangular area whose center point coincides with the center point of the virtual projection screen and whose size is the same as the size of the projected image.
[0073] It should be understood that since the projected image size in the preset projection parameters is usually set based on the first three-dimensional voxel data of the target patient, the CPU can directly determine the first projection area corresponding to the first three-dimensional voxel data as a first axis-aligned rectangular area whose center point coincides with the center point of the virtual projection screen and whose size is the same as the projected image size. The two sets of opposite sides of the first axis-aligned rectangular area are parallel to the horizontal and vertical directions, respectively. For example, Figure 3A This is a schematic diagram of a first projection area provided in an embodiment of this application. Figure 3A As shown, assuming Figure 3A If 31 represents the virtual projection screen, then the first axis aligned rectangular area can be... Figure 3A 32 in the middle.
[0074] S1013, the CPU determines the second projection area based on the projection source position, projection screen position, projection angle, and the preset projection pose of the second three-dimensional voxel data.
[0075] It should be understood that the larger the projection area, the longer it takes to generate the corresponding projected image, and the lower the efficiency of digital reconstruction projection. In practical applications, since the volume of the 3D bounding box corresponding to the second 3D voxel data is usually much smaller than the volume of the 3D bounding box corresponding to the first 3D voxel data, directly determining the second projection area corresponding to the second 3D voxel data based on the projected head size in the preset projection parameters would result in a large number of projection rays being discarded during the projection of the second 3D voxel data, thus reducing the efficiency of digital reconstruction projection. Based on this, in order to improve the efficiency of digital reconstruction projection, the CPU can determine the second projection area that matches the second 3D voxel data based on the projection source position, projection screen position, projection angle, and the preset projection pose of the second 3D voxel data in the preset projection parameters.
[0076] Optionally, S1013 may specifically include the following steps 1.1 to 1.3:
[0077] Step 1.1: The CPU determines the position of each vertex of the three-dimensional bounding box corresponding to the second three-dimensional voxel data when the second three-dimensional voxel data is in its preset projection pose.
[0078] It should be understood that a 3D bounding box typically comprises 8 vertices. For example, the position of each vertex can be determined using its fifth 3D coordinate in projection space. x 5, y 5, z 5) indicates.
[0079] Optionally, the CPU can determine the positions of each vertex of the 3D bounding box corresponding to the second 3D voxel data when the second 3D voxel data is in its preset projection pose, based on the preset projection pose of the second 3D voxel data and the length, width, and height of the 3D bounding box corresponding to the second 3D voxel data. The length, width, and height of the 3D bounding box corresponding to the second 3D voxel data are determined during the process of converting the 3D model of the target medical device into the second 3D voxel data using an isosurface extraction algorithm. It should be noted that the specific process of determining the positions of each vertex of the 3D bounding box when the 3D voxel data is in its preset pose using the preset pose of the 3D voxel data and the length, width, and height of the 3D bounding box corresponding to the 3D voxel data can be found in descriptions in related technologies, and will not be detailed in this embodiment.
[0080] Step 1.2: The CPU determines the two-dimensional coordinates of each virtual intersection point of each virtual ray emitted from the virtual projection source and passing through each vertex with the virtual projection screen in the projection screen coordinate system, based on the projection source position, the position of each vertex, and the projection screen position.
[0081] Optionally, for each vertex, the CPU can determine the direction vector of the virtual ray emitted from the virtual projection source and passing through the vertex using the following formula (1), based on the location of the projection source and the location of the vertex:
[0082] D = normalize ( V - P source ); formula (1)
[0083] in, D Let be the direction vector of the virtual ray. P _ source Location of the projection source V The position of the vertex. normalize () is the normalization function.
[0084] Then, for each virtual ray, the CPU can calculate the three-dimensional coordinates of the virtual intersection point between the virtual ray and the virtual projection screen in the projection space using the following formula (2), based on the location of the projection source, the direction vector of the virtual ray, and the location of the projection screen:
[0085] ;Formula (2)
[0086] in, P intersect Let be the three-dimensional coordinates of the virtual intersection point between the virtual ray and the virtual projection screen in the projection space. C Let be the three-dimensional coordinates of the center point of the virtual projection screen in the projection space. N is the three-dimensional normal vector of the virtual projection screen, and the operator "·" represents the dot product operation.
[0087] Finally, for each virtual intersection point, the CPU can calculate the two-dimensional coordinates of the virtual intersection point in the projection screen coordinate system using the following formula (3):
[0088] ;Formula (3)
[0089] in, U Let x be the x-coordinate of the virtual intersection point in the two-dimensional coordinate system of the projection screen. U 1 represents the row vector of the virtual projection screen. V Let y be the ordinate of the virtual intersection point in the two-dimensional coordinate system of the projection screen. V 1 represents the column vector of the virtual projection screen. That is, the two-dimensional vectors of each virtual intersection point can be represented by (...). U , V )express.
[0090] Step 1.3: The CPU determines the second projection region as the second axis-aligned rectangular area defined by the minimum x-coordinate value, maximum x-coordinate value, minimum y-coordinate value, and maximum y-coordinate value in all two-dimensional coordinates.
[0091] In this region, the two sets of opposite sides of the second axis-aligned rectangular area are parallel to the horizontal and vertical directions, respectively. For example, Figure 3B This is a schematic diagram of a second projection area provided in an embodiment of this application. For example... Figure 3B As shown, assume that the eight virtual rays emitted from the virtual projection source and passing through the eight vertices of the three-dimensional bounding box corresponding to the second three-dimensional voxel data intersect the virtual projection screen at eight virtual points A1 to A8. Among them, the x-coordinate value X1 of A1 is the smallest, the x-coordinate value X7 of A7 is the largest, the y-coordinate value Y5 of A5 is the smallest, and the y-coordinate value Y3 of A3 is the largest. Then, the CPU can determine the second axis-aligned rectangular region 33 defined by the x-coordinate value X1 of A1, the x-coordinate value X7 of A7, the y-coordinate value Y5 of A5, and the y-coordinate value Y3 of A3 as the second projection region corresponding to the second three-dimensional voxel data.
[0092] It is understandable that, since the area of the second projection region is smaller than that of the first projection region, the resolution (i.e. the number of pixels) of the second projection image corresponding to the subsequently generated second three-dimensional voxel data is smaller than the resolution of the first projection image corresponding to the first three-dimensional voxel data.
[0093] S102, the CPU determines the first number of thread blocks to be launched based on the GPU's performance parameters.
[0094] It should be noted that the initial quantity determined by the CPU is matched with the performance parameters of the GPU.
[0095] For example, GPU performance parameters may include the GPU model. Different GPU models typically have different numbers of parallel processors and / or the maximum number of concurrent threads per parallel processor.
[0096] Optionally, S102 may specifically include the following steps 2.1 to 2.3:
[0097] Step 2.1: The CPU determines the number of parallel processors in the GPU and the maximum number of concurrent threads for each parallel processor based on the GPU model.
[0098] Optionally, the computer device's memory may store the current GPU model, or it may store multiple mapping relationships between GPU models, the number of parallel processors included in the GPU, and the maximum number of concurrent threads for each parallel processor. Based on this, the CPU can retrieve the current GPU model and the aforementioned mapping relationships from the memory, and determine the number of parallel processors included in the current GPU and the maximum number of concurrent threads for each parallel processor according to the current GPU model and the aforementioned mapping relationships.
[0099] Step 2.2, the CPU determines the second number of threads contained in each thread block.
[0100] In one alternative implementation, the CPU can directly determine the default number as a second number of threads contained in each thread block; that is, regardless of how many parallel processors the GPU contains, each thread block can contain a default number of threads. For example, the default number can be 256.
[0101] In another alternative implementation, the CPU can determine the second number based on the number of parallel processors included in the GPU using the following formula (4):
[0102] ;Formula (4)
[0103] in, B For the second quantity, S This refers to the number of parallel processors contained in the GPU.
[0104] According to the above formula (4), when the number of parallel processors in the GPU is less than 10, each thread block can contain 128 threads; when the number of parallel processors in the GPU is greater than or equal to 10 and less than 30, each thread block can contain 256 threads; when the number of parallel processors in the GPU is greater than or equal to 30, each thread block can contain 512 threads.
[0105] Step 2.3, the CPU calculates the first quantity based on the number of parallel processors in the GPU, the maximum number of concurrent threads, and the second quantity, using the following formula (5):
[0106] G =( M / B )* S * R ;Formula (5)
[0107] in, G As the first quantity, M The maximum number of concurrent threads, R This is the preset expansion factor.
[0108] For example, to keep all parallel processors in the GPU busy and maximize parallel computing, a preset scaling factor is used. R It can be set to an integer greater than 1, for example, it can be set to 2.
[0109] S103, the CPU transmits the first three-dimensional voxel data, the first projection area, the second three-dimensional voxel data, the second projection area, the first quantity, and the preset projection parameters to the GPU.
[0110] It should be understood that, in order to improve the efficiency of digital reconstruction projection, embodiments of this application utilize a GPU containing multiple parallel processors to perform digital reconstruction projection operations on the first three-dimensional voxel data and the second three-dimensional voxel data. Based on this, after determining the first projection area, the second projection area, and the first quantity, the CPU can transmit the first three-dimensional voxel data, the first projection area, the second three-dimensional voxel data, the second projection area, the first quantity, and preset projection parameters to the GPU.
[0111] S104, the GPU starts a first number of thread blocks and, based on preset projection parameters, performs a digital reconstruction projection operation on the first three-dimensional voxel data in parallel within the first projection area through the first number of thread blocks to obtain a first projected image; and, based on preset projection parameters, performs a digital reconstruction projection operation on the second three-dimensional voxel data in parallel within the second projection area through the first number of thread blocks to obtain a second projected image.
[0112] It should be understood that, since each thread block contains a second number ( B ) threads, therefore the GPU starts the first number ( G ) A thread block is equivalent to starting G * B Each thread, meaning the GPU essentially operates through this... G * B Each thread performs a digital reconstruction projection operation on the first three-dimensional voxel data in the first projection area in parallel, and performs a digital reconstruction projection operation on the second three-dimensional voxel data in the second projection area in parallel.
[0113] Optionally, in S104, based on preset projection parameters, a first number of thread blocks are used to perform digital reconstruction projection operations on the second three-dimensional voxel data in parallel within the second projection area to obtain a second projected image. Specifically, this may include the following step 3.1:
[0114] Step 3.1: The GPU determines the target threads responsible for each pixel within the second projection region from all threads contained in the first number of thread blocks, and performs the following digital reconstruction projection operation in parallel through all target threads:
[0115] For each target thread, a projection ray is determined, pointing from the virtual projection source to the pixel that the target thread is responsible for. If the projection ray intersects with the 3D bounding box corresponding to the second 3D voxel data, the original pixel value of the pixel that the target thread is responsible for is determined based on the voxel values of all target voxels that the projection ray passes through in the 3D bounding box.
[0116] Optionally, for each thread in the first number of thread blocks, the GPU can determine the two-dimensional pixel index of the thread based on the block identifier of the thread block to which the thread belongs, the intra-block identifier of the thread, and the aforementioned second number, and identify the thread whose two-dimensional pixel index lies within the second projection area as the target thread. Each target thread is responsible for the pixel pointed to by its two-dimensional pixel index within the second projection area.
[0117] It should be noted that the specific process for determining whether there is an intersection between the ray and the three-dimensional bounding box can be found in the description in the relevant technology, and will not be described in detail in the embodiments of this application.
[0118] In one optional implementation, step 3.1 determines the original pixel value of the pixel responsible for the target thread based on the voxel values of all target voxels traversed by the projection ray within the 3D bounding box. Specifically, this may include steps 3.11 to 3.13:
[0119] Step 3.11: The GPU determines the near-end intersection and far-end intersection of the corresponding projection ray and the 3D bounding box for each target thread.
[0120] It should be noted that the GPU simultaneously determines the near and far intersections of the projection ray and the 3D bounding box for each target thread in parallel across all target threads. The near intersection of the projection ray and the 3D bounding box refers to the incident point of the projection ray on the 3D bounding box, i.e., the intersection closest to the virtual projection source among all intersections of the projection ray and the 3D bounding box. The far intersection of the projection ray and the 3D bounding box refers to the exit point of the projection ray on the 3D bounding box, i.e., the intersection farthest from the virtual projection source among all intersections of the projection ray and the 3D bounding box.
[0121] Optionally, the GPU can determine the 3D coordinates in projection space of the extreme and far intersection points of the projection ray and the 3D bounding box for each target thread. It should be noted that the specific process for determining the 3D coordinates of the near and far intersection points of the projection ray and the 3D bounding box can be found in descriptions in related technologies, and will not be detailed in this embodiment.
[0122] Step 3.12: The GPU determines the target voxels that the corresponding projection ray passes through sequentially within the 3D bounding box from the near intersection point to the far intersection point for each target thread.
[0123] It should be noted that the target voxels that the projection ray corresponding to each target thread passes through within the 3D bounding box include all voxels located inside the 3D bounding box that the projection ray passes through, as well as the voxels where the near intersection point and the far intersection point are located.
[0124] Optionally, step 3.12 may specifically include the following steps:
[0125] The GPU uses each target thread to designate the voxel containing its near-end intersection and the voxel containing its far-end intersection as the first and last target voxels, respectively. Starting from the first target voxel, the GPU repeats the following voxel determination steps until the current voxel is the last target voxel: Based on the direction vector of the projection ray, determine three mutually perpendicular candidate boundary surfaces from all the boundary surfaces of the current target voxel; calculate the travel parameter value required for the projection ray to travel from the incident point of the current target voxel to each candidate boundary surface; and determine the voxel adjacent to the candidate boundary surface with the smallest travel parameter value as the next target voxel.
[0126] Optionally, for each target thread, the GPU can calculate the travel parameter values required for the projection ray to travel from the incident point of the current target voxel to each candidate boundary surface using the direction vector of its corresponding projection ray, the three-dimensional coordinates of the incident point of the projection ray on the current target voxel in the projection space, and the voxel dimensions of each voxel in the second three-dimensional voxel. The travel parameter values can be used to represent the distance to be traveled.
[0127] Step 3.13: The GPU performs an integral summation operation on the voxel values of all target voxels that the corresponding projection ray passes through within the 3D bounding box for each target thread, to obtain the original pixel value of the pixel that the target thread is responsible for.
[0128] Optionally, for each target thread, after the GPU determines a target voxel that the corresponding projection ray passes through within the 3D bounding box, it can calculate the actual path length of the projection ray within that target voxel and integrate the voxel value based on this actual path length to obtain the contribution integral value of that target voxel. After determining all target voxels and their respective contribution integral values, the GPU can use the sum of all target voxel contribution integral values as the original pixel value of the pixel responsible for the target thread.
[0129] It should be noted that the specific process by which the GPU obtains the first projected image is similar to the specific process by which it obtains the second projected image. Therefore, the specific process by which the GPU obtains the first projected image can be referred to the relevant description in step 3.1 above, and will not be described in detail in this embodiment.
[0130] S105, the GPU fuses the first projection image with the second projection image to obtain the target projection image.
[0131] The target projection image is a two-dimensional projection image obtained by fusing the first projection image and the second projection image.
[0132] Optionally, S105 may include, for example, Figure 4 S1051 to S1053 are described in detail below:
[0133] S1051, the GPU calculates the normalized pixel value of each pixel in the first projected image in parallel through multiple target threads corresponding to the first projected image based on the minimum and maximum original pixel values in the first projected image, and obtains the first normalized image.
[0134] Specifically, the GPU can use multiple target threads corresponding to the first projected image to calculate the normalized pixel value of each pixel in the first projected image in parallel using the following formula (6):
[0135] I norm1 ( x , y )=[ I 1( x , y )- I min1 ] / ( I max1 - I min1 ); formula (6)
[0136] in, I norm1 ( x , y ) represents the normalized pixel value of the pixel that each target thread is responsible for in the first projected image. I 1( x , y () represents the original pixel value of the pixel that each target thread is responsible for in the first projected image. I min1 The minimum original pixel value in the first projected image. I max1 This is the maximum original pixel value in the first projected image.
[0137] The multiple target threads corresponding to the first projected image can refer to the threads whose two-dimensional pixel index is located within the first projection area among all the threads contained in the first number of thread blocks.
[0138] It should be understood that the resolution of the first normalized image is the same as the resolution of the first projected image. The pixel value of each pixel in the first normalized image is the normalized pixel value of the corresponding pixel in the first projected image.
[0139] S1052, the GPU calculates the normalized pixel value of each pixel in the second projected image in parallel through multiple target threads corresponding to the second projected image based on the minimum and maximum original pixel values in the second projected image, and obtains the second normalized image.
[0140] Specifically, the GPU can use multiple target threads corresponding to the second projected image to calculate the normalized pixel value of each pixel in the second projected image in parallel using the following formula (7):
[0141] I norm2 ( x , y )=[ I 2( x , y )- I min2 ] / ( I max2 - I min2 ); formula (7)
[0142] in, I norm2 ( x , y ) represents the normalized pixel value of the pixel that each target thread is responsible for in the second projected image. I 2( x , y () represents the original pixel value of the pixel for which each target thread is responsible in the second projected image. I min2 The minimum original pixel value in the second projected image. I max2 This is the maximum original pixel value in the second projected image.
[0143] It should be understood that the resolution of the second normalized image is the same as the resolution of the second projected image. The pixel value of each pixel in the second normalized image is the normalized pixel value of the corresponding pixel in the second projected image.
[0144] S1053, the GPU uses pixel value accumulation to fuse the first normalized image and the second normalized image into a target projection image.
[0145] The resolution of the target projected image is the same as that of the first normalized image.
[0146] It should be understood that since the resolution of the second normalized image is lower than that of the first normalized image, the second normalized image only corresponds to a portion of the first normalized image or the target projection image. For ease of description, the portion of the second normalized image corresponding to the first normalized image or the target projection image is referred to as the fusion region, and the region in the first normalized image or the target projection image other than the fusion region is referred to as the non-fusion region. Based on this, the GPU can determine the normalized pixel value of each pixel in the non-fusion region of the first normalized image as the pixel value of the corresponding pixel in the non-fusion region of the target projection image. The GPU can then determine the pixel value of the corresponding pixel in the fusion region of the target projection image by summing the pixel value of each pixel in the second normalized image with the pixel value of the corresponding pixel in the fusion region of the first normalized image, thereby obtaining the target projection image.
[0147] Optionally, after obtaining the target projection image, the GPU can transfer the target projection image to the CPU for subsequent use.
[0148] As can be seen from the above, the two-dimensional projection image generation method provided in this application allows the CPU to adaptively determine projection regions of different areas for different objects. Therefore, when the GPU generates projection images of small objects such as medical devices, it only performs digital reconstruction projection operations within the corresponding projection region, which has an area much smaller than the global image size. This reduces the total number of pixels to be processed and unnecessary computational overhead, shortens the projection time for small objects, and improves the overall generation efficiency of the target projection image. Since the CPU can adaptively determine the first number of thread blocks to be started that match the GPU's performance parameters, this method is applicable to GPUs with different performance parameters. Furthermore, because this method can efficiently generate projection images of different objects even when the three-dimensional voxel data changes, it can expand the applicability of the method while improving the overall generation efficiency of the target projection image.
[0149] It should be understood that the sequence number of each step in the above embodiments does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.
[0150] Please see Figure 5 , Figure 5 This is a schematic diagram of the structure of a computer device provided in an embodiment of this application. Figure 5As shown, the computer device 5 provided in this embodiment may include: a processor 50, a memory 51, and a computer program 52 stored in the memory 51 and executable on the processor 50, such as a program corresponding to a method for generating a two-dimensional projected image. When the processor 50 executes the computer program 52, it implements the steps in the above-described embodiment of the method for generating a two-dimensional projected image, for example... Figure 1 S101~S105 are shown.
[0151] For example, computer program 52 may be divided into one or more modules / units, one or more of which are stored in memory 51 and executed by processor 50 to complete this application. One or more modules / units may be a series of computer program instruction segments capable of performing a specific function, which describe the execution process of computer program 52 in computer device 5.
[0152] Optionally, the processor 50 may include a CPU 501 and a GPU 502. When the CPU 501 executes the corresponding computer program, it can, for example, achieve... Figure 1 As shown in S101~S103, when GPU502 executes the corresponding computer program, it can achieve, for example, the following: Figure 1 S104~S105 are shown.
[0153] For example, memory 51 can be an internal storage unit of computer device 5, such as a hard disk or RAM of computer device 5. Memory 51 can also be an external storage device of computer device 5, such as a plug-in hard disk, smart media card (SMC), secure digital (SD) card, or flash card equipped on computer device 5. Furthermore, memory 51 can include both internal storage units and external storage devices of computer device 5. Memory 51 is used to store computer programs and other programs and data required by the computer device. Memory 51 can also be used to temporarily store data that has been output or will be output.
[0154] Those skilled in the art will understand that Figure 5 This is merely an example of computer device 5 and does not constitute a limitation on computer device 5. It may include more or fewer components than shown, or combine certain components, or use different components.
[0155] This application also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the various steps in the method for generating a two-dimensional projected image described above.
[0156] This application provides a computer program product that, when run on a computer device, enables the computer device to perform the steps described in the various method embodiments above.
[0157] In the above embodiments, the descriptions of each embodiment have different focuses. For parts that are not described in detail or recorded in a certain embodiment, refer to the relevant descriptions of other embodiments.
[0158] It should be noted that, unless otherwise specified, all technical terms used in the embodiments of this application have the same meaning as commonly understood by those skilled in the art to which this application belongs. The technical terms used in the embodiments of this application are only used to explain specific embodiments of this application and are not intended to limit this application.
[0159] The term "embodiment" as used in the description of embodiments in this application means that a specific feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of this application. The appearance of this phrase in various places in the specification does not necessarily refer to the same embodiment, nor is it a separate or alternative embodiment mutually exclusive with other embodiments. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments.
[0160] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0161] The above-described embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application, and should all be included within the protection scope of this application.
Claims
1. A method of generating a two-dimensional projection image, characterized by, The application is applied to a computer device comprising a central processing unit (CPU) and a graphics processing unit (GPU), and the method comprises the following steps: The CPU determines a first projection area corresponding to first three-dimensional voxel data of a target patient on a virtual projection screen, and determines a second projection area corresponding to second three-dimensional voxel data of a target medical instrument on the virtual projection screen; the area of the second projection area is smaller than the area of the first projection area; The CPU determines a first number of thread blocks to be started according to a performance parameter of the GPU; The CPU transmits the first three-dimensional voxel data, the first projection area, the second three-dimensional voxel data, the second projection area, the first number, and preset projection parameters to the GPU; The GPU starts the first number of thread blocks, and performs a digital reconstruction projection operation on the first three-dimensional voxel data in the first projection area through the first number of thread blocks in parallel based on the preset projection parameters to obtain a first projection image; and performs the digital reconstruction projection operation on the second three-dimensional voxel data in the second projection area through the first number of thread blocks in parallel based on the preset projection parameters to obtain a second projection image; the preset projection parameters comprise a projection source position, a projection screen position, a projection angle, a projection image size, and a preset projection pose of the second three-dimensional voxel data; The GPU calculates normalized pixel values of each pixel in the first projection image in parallel through a plurality of target threads corresponding to the first projection image according to a minimum original pixel value and a maximum original pixel value in the first projection image to obtain a first normalized image; The GPU calculates normalized pixel values of each pixel in the second projection image in parallel through a plurality of target threads corresponding to the second projection image according to a minimum original pixel value and a maximum original pixel value in the second projection image to obtain a second normalized image; The GPU fuses the first normalized image and the second normalized image into a target projection image in a pixel value accumulation manner.
2. The method of claim 1, wherein, The CPU determines a first projection area corresponding to first three-dimensional voxel data of a target patient on a virtual projection screen, and determines a second projection area corresponding to second three-dimensional voxel data of a target medical instrument on the virtual projection screen, comprising: The CPU acquires preset projection parameters; The CPU determines a first axis-aligned rectangular area with a center point coinciding with a center point of the virtual projection screen and a size same as the projection image size as the first projection area; The CPU determines the second projection area according to the projection source position, the projection screen position, the projection angle, and a preset projection pose of the second three-dimensional voxel data.
3. The method of claim 2, wherein, The CPU determines the second projection area according to the projection source position, the projection screen position, the projection angle, and a preset projection pose of the second three-dimensional voxel data, comprising: The CPU determines positions of each vertex of a three-dimensional bounding box corresponding to the second three-dimensional voxel data when the second three-dimensional voxel data is in the preset projection pose; The CPU determines two-dimensional coordinates of each virtual intersection point of each virtual ray emitted from a virtual projection source and passing through each vertex respectively and the virtual projection screen in a projection screen coordinate system according to the projection source position, the position of each vertex and the projection screen position; The CPU determines a second axis-aligned rectangular region defined by minimum horizontal coordinate value, maximum horizontal coordinate value, minimum vertical coordinate value and maximum vertical coordinate value in all the two-dimensional coordinates as the second projection region.
4. The method of claim 1, wherein, The CPU determines a first number of thread blocks to be started according to the performance parameter of the GPU, including: The CPU determines the number of parallel processors included in the GPU and the maximum number of concurrent threads of each parallel processor according to the model of the GPU; The CPU determines a second number of threads included in each thread block; The CPU calculates the first number according to the number of parallel processors, the maximum number of concurrent threads and the second number by using the following formula: G =( M / B )* S * R ; wherein, G is the first number, M is the maximum number of concurrent threads, B is the second number, S is the number of parallel processors, R is a preset expansion factor.
5. The method of claim 1, wherein, Based on the preset projection parameter, the second digital reconstruction projection operation is performed on the second three-dimensional voxel data in the second projection region by the first number of thread blocks in parallel to obtain a second projection image, including: The GPU determines target threads responsible for each pixel in the second projection region from all threads included in the first number of thread blocks, and performs the following digital reconstruction projection operation by all the target threads in parallel: Each target thread determines a corresponding projection ray of the target thread from a virtual projection source to the pixel responsible by the target thread, and in the case that the projection ray and a three-dimensional bounding box corresponding to the second three-dimensional voxel data have an intersection point, determines the original pixel value of the pixel responsible by the target thread according to the voxel value of all target voxels through which the projection ray passes in the three-dimensional bounding box.
6. The method of claim 5, wherein, Each target thread determines a corresponding projection ray of the target thread from a virtual projection source to the pixel responsible by the target thread, and in the case that the projection ray and a three-dimensional bounding box corresponding to the second three-dimensional voxel data have an intersection point, determines the original pixel value of the pixel responsible by the target thread according to the voxel value of all target voxels through which the projection ray passes in the three-dimensional bounding box. Each target thread determines a corresponding near-end intersection point and a far-end intersection point of the projection ray and the three-dimensional bounding box; Each target thread determines target voxels through which the corresponding projection ray passes in the three-dimensional bounding box from the near-end intersection point to the far-end intersection point; Each target thread integrates and accumulates the voxel values of all target voxels through which the corresponding projection ray passes in the three-dimensional bounding box to obtain the original pixel value of the pixel responsible by the target thread.
7. The method of claim 6, wherein, Each target thread determines target voxels through which the corresponding projection ray passes in the three-dimensional bounding box from the near-end intersection point to the far-end intersection point, including: determining, by each of the target threads, a first target voxel and a last target voxel, respectively, as the voxel where the near intersection point of the corresponding projection ray is located and the voxel where the far intersection point of the corresponding projection ray is located, and starting from the first target voxel, repeatedly performing the following voxel determination steps until the current target voxel is the last target voxel: determining, according to the direction vector of the projection ray, three candidate boundary surfaces that the projection ray is about to pass through from all the boundary surfaces of the current target voxel; calculating a travel parameter value required for the projection ray to travel from the incident point of the current target voxel to each of the candidate boundary surfaces; determining, as a next target voxel, a voxel adjacent to the candidate boundary surface corresponding to the smallest travel parameter value.
8. A computer device, comprising: A computer program product, comprising a memory and a computer program stored in the memory and loadable into the working memory of a digital computer, the computer program comprising instructions which, when loaded into the computer, cause the computer to execute the method according to any one of claims 1-7.
9. A computer program product, characterised in that, The computer program product, when running on a computer device, causes the computer device to execute the method according to any one of claims 1-7.
Citation Information
Patent Citations
Industrial cone beam CT three-dimensional reconstruction method and system based on CUDA architecture
CN118314237A
Three-dimensional image data bounding box prediction method and data transmission method and device
CN120047937A