A volume rendering processing method and device for medical images
By applying the CUDA architecture and customizing the CUDA kernel function in medical image drawing, the problem of large calculation and slow speed of the ray projection algorithm is solved, and efficient and real-time medical image drawing processing is achieved.
Patent Information
- Application Number
- CN202411071879.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-06
- Publication Date
- 2025-08-12
- Estimated Expiration
- 2044-08-06
AI Technical Summary
The existing ray projection algorithms have large calculations, slow drawing speed, and poor real-time drawing in medical image drawing, and cannot fully utilize the parallel computing capabilities of the GPU.
The CUDA architecture is used to plan the data storage area in the GPU video memory, and based on the ray projection algorithm and Lambert lighting model, parallel calculations are performed by customizing the CUDA kernel function to improve the computing efficiency and drawing speed.
It improves the computing efficiency, drawing speed and real-time nature of medical image drawing, enhances processing flexibility and optimization convenience.
Smart Images

Figure CN118799475B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data processing, and in particular to a volume rendering processing method and device for medical images. Background Art
[0002] Volume rendering (Volume Rendering) for medical imaging is an image processing technique that produces color two-dimensional images based on medical image sequences. Currently, the most commonly used algorithm for volume rendering is the ray casting algorithm. Ray casting is a fundamental graphics rendering technique, first proposed by Arthur Appel in 1968. This algorithm reconstructs and renders three-dimensional volume data by simulating the propagation paths of light rays through the data. Ray casting offers a good balance between computational complexity and reconstruction quality, but due to the large number of rays, it results in a high computational load, slow rendering speed, and poor real-time performance.
[0003] As the computing power of graphics processing units (GPUs) increases, using GPUs for parallel computing has become an important way to resolve bottlenecks in large-scale data processing and improve real-time computing. The calculation mode for each ray in the ray casting algorithm is consistent, which matches the parallel computing structure characteristics of the GPU. If GPU resources can be used to handle the calculation work of the ray casting algorithm, it will inevitably improve computing efficiency, accelerate rendering speed, and enhance real-time drawing performance. The ray casting algorithm of traditional GPU architecture maps the calculation to the graphics API. Although this processing method is convenient for users to call, it cannot optimize the processing flow.
[0004] In 2007, NVIDIA released the Computer Unified Device Architecture (CUDA). The CUDA architecture provides programming interfaces for direct access to GPU hardware. These interfaces allow for direct configuration, reading, and writing of GPU memory resources, customization of CUDA kernel functions within the GPU environment, and dynamic configuration of the number of parallel threads within the GPU environment based on application requirements. Applying the CUDA architecture to volume rendering solutions for medical imaging would not only improve computational efficiency, speed up rendering, and enhance real-time rendering, but also allow for customization of the processing flow of ray casting algorithms. Summary of the Invention
[0005] The purpose of the present invention is to address the defects of the prior art and provide a volume rendering processing method, device, electronic device and computer-readable storage medium for medical images. Before calling the CUDA architecture for processing, the present invention will first confirm the viewpoint and construct a normalized three-dimensional texture data space T based on the medical image sequence, viewpoint coordinates and viewpoint viewing distance, and select any point on the line connecting the viewpoint to the center point of the view orthogonal plane of the three-dimensional texture data space T as the corresponding imaging plane point, and make a plane at the imaging plane point that is the same size as the view orthogonal plane and parallel to all four sides as the corresponding volume rendering imaging surface, and mesh the volume rendering imaging surface based on the volume rendering imaging size to obtain multiple imaging surface pixel points p to form a corresponding pixel point set, and make a ray perpendicular to the view orthogonal plane from each imaging surface pixel point p towards the direction of the three-dimensional texture data space T, which is recorded as the corresponding pixel point projection ray, and all the obtained pixel point projection rays form a corresponding projection ray set; after completing the above data preparation work, the data storage area will be planned in the GPU video memory based on the CUDA architecture to store the three-dimensional texture data space T , viewing angle orthogonal plane, pixel point set and projection ray set, and plan an RGB pixel group storage area for storing subsequent calculation results; and based on the CUDA architecture, create a thread that calls the ray casting algorithm kernel function for each imaging surface pixel point p in the GPU operating environment, record it as the corresponding first pixel point thread, and execute all first pixel point threads in parallel in the GPU operating environment; the ray casting algorithm kernel function is a customized CUDA kernel function, which is used to calculate the RGB pixel of the pixel point corresponding to the projection ray according to the 3D texture data space T, the viewing angle orthogonal plane and a specified projection ray stored in the GPU video memory according to the ray casting algorithm and the Lambert lighting model, and update the RGB pixel group storage area based on the calculation result; finally, when all RGB pixel groups in the RGB pixel group storage area in the GPU video memory are not empty, all RGB pixel groups are used to construct an image to obtain the corresponding volume rendering image and display it. The present invention applies the CUDA architecture to the volume rendering processing solution of medical images, which can improve the computational efficiency, rendering speed and real-time rendering effect of medical image volume rendering; the present invention implements a ray casting algorithm processing flow for shading imaging pixels based on the light intensity-pixel mapping relationship under the Lambert lighting model by customizing the CUDA kernel function, which can improve the processing flexibility and optimization convenience of medical image volume rendering.
[0006] To achieve the above-mentioned object, a first aspect of an embodiment of the present invention provides a method for volume rendering of medical images, the method comprising:
[0007] Receive a first medical image sequence, viewpoint coordinates, viewpoint viewing distance, and volume rendering imaging size w0×h0; the first medical image sequence is formed by sequentially sorting a plurality of first medical images; the first medical image is a three-dimensional CT image or a three-dimensional MRI image; each of the first medical images is composed of a plurality of image pixels; each of the image pixels corresponds to at least one three-dimensional image coordinate (x, y, z) and an image grayscale; the three-dimensional image coordinate (x, y, z) is a spatial coordinate in an XYZ coordinate system, which is a three-dimensional Cartesian coordinate system composed of X, Y, and Z axes; w0 and h0 in the volume rendering imaging size w0×h0 are the pixel width and pixel height of the volume rendering image, respectively;
[0008] A three-dimensional texture data space is constructed by confirming and normalizing the viewpoint according to the first medical image sequence, the viewpoint coordinates and the viewpoint viewing distance to obtain a corresponding first viewpoint and a three-dimensional texture data space T; the three-dimensional texture data space T is a cube space with a shape of 1×1×1 in a WHD coordinate system, and the WHD coordinate system is a three-dimensional Cartesian coordinate system composed of a width W axis, a height H axis and a depth D axis; the three-dimensional texture data space T includes a plurality of texture voxel points t; the texture voxel points t correspond to the image pixel points one by one; each of the texture voxel points t corresponds to a three-dimensional coordinate (w, h, d) and a texture voxel grayscale, and the value range of the three-dimensional coordinate values w, h, d is all between 0 and 1, and the texture voxel grayscale is consistent with the corresponding image grayscale; the side surface of the eight sides of the three-dimensional texture data space T that is closest to the first viewpoint is recorded as the corresponding viewpoint orthogonal surface; the line connecting the center point of the viewpoint orthogonal surface and the first viewpoint is perpendicular to the viewpoint orthogonal surface;
[0009] A point is randomly selected on a line connecting the first viewpoint and the center point of the view orthogonal plane of the three-dimensional texture data space T as a corresponding imaging plane point; a plane having the same size as the view orthogonal plane and four parallel sides is drawn at the imaging plane point as a corresponding volume rendering imaging plane; the volume rendering imaging plane is meshed based on the volume rendering imaging size w0×h0 to obtain corresponding w0×h0 imaging plane pixel points p forming a corresponding first pixel point set; and a ray perpendicular to the view orthogonal plane is drawn from each imaging plane pixel point p toward the direction of the three-dimensional texture data space T as a corresponding pixel point projection ray, and all the obtained pixel point projection rays form a corresponding first projection ray set;
[0010] Based on the processing functions for planning memory space and reading and writing memory data in the CUDA function set, a three-dimensional texture data storage area, an orthogonal surface data storage area, a pixel point data storage area and a projection ray data storage area are planned in the GPU video memory for storing the corresponding three-dimensional texture data space T, the viewing angle orthogonal surface of the three-dimensional texture data space T, the first pixel point set and the first projection ray set; and an RGB pixel group storage area is planned in the GPU video memory; the RGB pixel group storage area is used to store a plurality of RGB pixel groups, each of the RGB pixel groups consists of an R channel pixel value, a G channel pixel value and a B channel pixel value, the number of the RGB pixel groups in the RGB pixel group storage area matches the number of the imaging surface pixel points p in the pixel point data storage area, and the RGB pixel groups correspond to the imaging surface pixel points p one-to-one, and all the RGB pixel groups stored in the RGB pixel group storage area are initialized to empty;
[0011] In the GPU operating environment, a thread that calls the ray casting algorithm kernel function is created for each pixel point p on the imaging surface, which is recorded as the corresponding first pixel point thread; and all the first pixel point threads are executed in parallel in the GPU operating environment; the ray casting algorithm kernel function is a CUDA kernel function that can only be run in the GPU operating environment and can only use the GPU video memory; the input parameter of the ray casting algorithm kernel function is the first pixel point index; the first pixel point index is the unique index number corresponding to one of the imaging surface pixel points p in the first pixel point set stored in the GPU video memory; the ray casting algorithm kernel function is used to take the imaging surface pixel point p corresponding to the pixel point index in the first pixel point set stored in the GPU video memory as the corresponding The current pixel point is obtained by calculating the projection ray of the pixel point corresponding to the current imaging surface pixel point in the first pixel point set stored in the GPU video memory as the corresponding current projection ray, and the RGB pixel of the current pixel point is calculated according to the three-dimensional texture data space T stored in the GPU video memory, the viewing angle orthogonal surface and the current projection ray according to the ray casting algorithm and the Lambert illumination model, and the RGB pixel of the current pixel point is updated based on the calculation result; the input parameter of each first pixel point thread is the second pixel point index; each first pixel point thread is used to input the input second pixel point index as the corresponding first pixel point index to the ray casting algorithm kernel function and run the ray casting algorithm kernel function for calculation;
[0012] When all the RGB pixel groups in the RGB pixel group storage area in the GPU display memory are not empty, an image is constructed based on all the obtained RGB pixel groups and the obtained constructed image is used as the corresponding volume rendering image and displayed.
[0013] Preferably, the constructing of the three-dimensional texture data space by performing viewpoint confirmation and normalization according to the first medical image sequence, the viewpoint coordinates, and the viewpoint viewing distance to obtain the corresponding first viewpoint and the three-dimensional texture data space T specifically includes:
[0014] Identify the largest X, Y, and Z axis coordinates among all the three-dimensional image coordinates (x, y, z) in the first medical image sequence to obtain the corresponding maximum value x max 、y max 、z max ; and the maximum value x max 、y max and z max The maximum value of the maximum side length b is used as the corresponding maximum side length b; and in the XYZ coordinate system, a cube space with a shape of b×b×b is constructed based on the maximum side length b and recorded as the corresponding three-dimensional volume data space R1; and the spatial coordinate point corresponding to each image pixel point in the first medical image sequence in the three-dimensional volume data space R1 is recorded as the corresponding voxel point v; the voxel point v corresponds to the image pixel point one-to-one;
[0015] The method comprises the following steps: marking the viewpoint based on the viewpoint coordinates in the XYZ coordinate system to obtain the corresponding first viewpoint; calculating the straight-line distances from the center points of the eight side surfaces of the three-dimensional volume data space R1 to the first viewpoint, and taking the side surface with the shortest distance as the corresponding viewpoint orthogonal surface; rotating and displacing the three-dimensional volume data space R1 in the XYZ coordinate system until the line connecting the center point of the viewpoint orthogonal surface of the three-dimensional volume data space R2 obtained after the rotation and displacement and the first viewpoint is perpendicular to the viewpoint orthogonal surface and the length of the line matches the viewpoint viewing distance; and performing an equal rotation and displacement on the spatial coordinates of each voxel point v in the three-dimensional volume data space R1 to obtain the corresponding voxel point v in the three-dimensional volume data space R2. * ; The voxel point v * One-to-one correspondence with the voxel point v;
[0016] The opposite side of the viewing angle orthogonal plane in the three-dimensional volume data space R2 is recorded as the corresponding orthogonal face; and a three-dimensional Cartesian coordinate system is constructed with the lower left corner vertex of the viewing angle orthogonal plane as the origin, the direction from the lower left corner vertex to the lower right corner vertex of the viewing angle orthogonal plane as the width W axis direction, the direction from the lower left corner vertex to the upper left corner vertex of the viewing angle orthogonal plane as the height H axis direction, and the direction from the lower left corner vertex of the viewing angle orthogonal plane to the lower left corner vertex of the orthogonal face as the depth D axis direction, and the three-dimensional volume data space corresponding to the three-dimensional volume data space R2 in the XYZ coordinate system in the WHD coordinate system is recorded as the corresponding three-dimensional volume data space R3; and each voxel point v in the three-dimensional volume data space R2 is rotated and displaced based on the rotational displacement relationship between the WHD coordinate system and the XYZ coordinate system. * The spatial coordinates of the 3D volume are rotated and displaced to obtain the corresponding voxel point v in the 3D volume data space R3. ’ ; The voxel point v ’ The three-dimensional coordinates are expressed as (w ’ ,h ’ ,d ’ ); the voxel point v ’ With the voxel point v * One-to-one correspondence;
[0017] The three-dimensional size of the three-dimensional volume data space R3 and each voxel point v are calculated based on the maximum side length b in the WHD coordinate system. ’ The three-dimensional coordinates of the voxel point v are normalized, and the obtained normalized data space is used as the corresponding three-dimensional texture data space T, and the voxel points v in the three-dimensional texture data space T are normalized. ’ The corresponding spatial coordinate point is used as the corresponding texture voxel point t; the three-dimensional texture data space T is a cube space with a shape of (b / b)×(b / b)×(b / b)=1×1×1; the texture voxel point t and the voxel point v ’ One-to-one correspondence; the three-dimensional coordinates (w, h, d) of the texture voxel point t and the voxel point v ’ The three-dimensional coordinates (w ’ ,h ’ ,d ’ ) is w=w ’ / b,h=h ’ / b,d=d ’ / b;
[0018] The viewing distance of the viewing point is normalized based on the maximum side length b to obtain the corresponding normalized viewing distance = viewing distance of the viewing point / b; and the center point of the viewing orthogonal plane of the three-dimensional texture data space T is recorded as the corresponding current center point; and at the current center point, a perpendicular line of the viewing orthogonal plane is drawn from the current center point to the outside direction of the three-dimensional texture data space T and is recorded as the corresponding outer edge perpendicular line; and the coordinates of the spatial point on the outer edge perpendicular line whose distance from the current center point matches the normalized viewing distance are used as the new coordinates of the first viewing point.
[0019] Preferably, the calculating the RGB pixels of the current pixel point according to the three-dimensional texture data space T stored in the GPU memory, the viewing angle orthogonal plane, and the current projection ray according to the ray casting algorithm and the Lambert lighting model and updating the RGB pixel group storage area based on the calculation result specifically includes:
[0020] Step 31: The ray casting algorithm kernel function sets a corresponding pixel illumination intensity I for the current pixel; initializes the pixel illumination intensity I to a preset negative intensity threshold less than 0; and records the spatial coordinate point corresponding to the preset volume rendering light source point coordinates as the corresponding volume rendering light source point;
[0021] Step 32: Calculate the intersection of the current projection light and the plane orthogonal to the viewing angle to obtain a corresponding starting intersection point; and use the starting intersection point as the corresponding light sampling point s;
[0022] Step 33, and identify the sampling point grayscale corresponding to the light sampling point s, specifically: confirm whether there is the texture voxel point t matching the spatial coordinates of the light sampling point s in the three-dimensional texture data space T; if so, use the texture voxel grayscale of the texture voxel point t matching the spatial coordinates of the light sampling point s as the corresponding sampling point grayscale; if not, search for paired neighboring texture voxel points in the three groups of directions of front, back, left, and top and bottom of the light sampling point s in the three-dimensional texture data space T. If only a pair of neighboring texture voxel points in one of the directions is found, then use the one-dimensional linear interpolation method to find the texture voxel point t. Performing a one-dimensional linear interpolation calculation on the texture voxel grayscale of the currently searched pair of neighboring texture voxel points and using the calculation result as the corresponding sampling point grayscale; if two pairs of neighboring texture voxel points in two groups of directions are searched, performing a bilinear interpolation calculation on the texture voxel grayscale of the two pairs of neighboring texture voxel points currently searched and using the calculation result as the corresponding sampling point grayscale; if three pairs of neighboring texture voxel points in three groups of directions are searched, performing a trilinear interpolation calculation on the texture voxel grayscale of the three pairs of neighboring texture voxel points currently searched and using the calculation result as the corresponding sampling point grayscale;
[0023] Step 34, and identify whether the grayscale of the sampling point exceeds the preset grayscale threshold; if so, go to step 35; if not, go to step 36;
[0024] Step 35: Determine the corresponding unit normal vector N based on the gradient of the light sampling point s; determine the corresponding unit light source vector L based on the straight line direction from the light sampling point s to the volume rendering light source point; and calculate the illumination intensity based on the preset ambient light diffuse reflection coefficient K according to the illumination intensity calculation method of the Lambert illumination model. a , preset ambient light intensity I a , preset light source diffuse reflectance K d , preset light source intensity I d The unit normal vector N and the unit light source vector L are used to calculate the illumination intensity to obtain the corresponding illumination intensity I * ; and based on the light intensity I * Reset the pixel illumination intensity I; and identify whether the reset pixel illumination intensity I is greater than 0, if so, go to step 36, if not, go to step 37;
[0025] Among them, I * =K a ×I a +K a ×I d (L·N);
[0026] Step 36: Identify whether the distance from the light sampling point s to the starting intersection exceeds a preset first length; if so, go to step 37; if not, set the spatial coordinate point on the current projection light that is after the light sampling point s and is a preset incremental length Δd away from the light sampling point s as the new light sampling point s, and return to step 33; the first length is defaulted to
[0027] Step 37, record the RGB pixel group corresponding to the current pixel in the RGB pixel group storage area as the corresponding current pixel group; and identify whether the pixel illumination intensity I is greater than 0; if the pixel illumination intensity I is less than or equal to 0, set the corresponding R channel pixel value, G channel pixel value and B channel pixel value in the current pixel group according to the preset background R channel pixel value, the preset background G channel pixel value and the preset background B channel pixel value; if the pixel illumination intensity I is greater than 0, calculate the corresponding first pixel value = r0×I, second pixel value = g0×I and third pixel value = b0×I based on the preset R channel pixel coefficient r0, the preset G channel pixel coefficient g0, the preset B channel pixel coefficient b0 and the pixel illumination intensity I, and set the corresponding R channel pixel value, G channel pixel value and B channel pixel value in the current pixel group according to the calculated first, second and third pixel values.
[0028] A second aspect of an embodiment of the present invention provides an apparatus for implementing the volume rendering processing method of medical images described in the first aspect, the apparatus comprising: a data receiving module, a first data preprocessing module, a second data preprocessing module, a first CUDA processing module, a second CUDA processing module, and a volume rendering image composition module;
[0029] The data receiving module is used to receive a first medical image sequence, viewpoint coordinates, viewpoint viewing distance, and volume rendering imaging size w0×h0; the first medical image sequence is formed by sequentially sorting a plurality of first medical images; the first medical image is a three-dimensional CT image or a three-dimensional MRI image; each of the first medical images is composed of a plurality of image pixels; each of the image pixels corresponds to at least one three-dimensional image coordinate (x, y, z) and an image grayscale; the three-dimensional image coordinate (x, y, z) is a spatial coordinate in an XYZ coordinate system, which is a three-dimensional Cartesian coordinate system composed of X, Y, and Z axes; w0 and h0 in the volume rendering imaging size w0×h0 are the pixel width and pixel height of the volume rendering image, respectively;
[0030] The first data preprocessing module is used to construct a three-dimensional texture data space for viewpoint confirmation and normalization based on the first medical image sequence, the viewpoint coordinates and the viewpoint viewing distance to obtain a corresponding first viewpoint and a three-dimensional texture data space T; the three-dimensional texture data space T is a cube space with a shape of 1×1×1 in a WHD coordinate system, and the WHD coordinate system is a three-dimensional Cartesian coordinate system composed of a width W axis, a height H axis and a depth D axis; the three-dimensional texture data space T includes a plurality of texture voxel points t; the texture voxel points t correspond to the image pixel points one by one; each of the texture voxel points t corresponds to a three-dimensional coordinate (w, h, d) and a texture voxel grayscale, the value range of the three-dimensional coordinate values w, h, d are all between 0 and 1, and the texture voxel grayscale is consistent with the corresponding image grayscale; the side surface of the eight sides of the three-dimensional texture data space T that is closest to the first viewpoint is recorded as the corresponding view orthogonal plane; the line connecting the center point of the view orthogonal plane and the first viewpoint is perpendicular to the view orthogonal plane;
[0031] The second data preprocessing module is configured to select any point on a line connecting the first viewpoint to the center point of the view orthogonal plane of the three-dimensional texture data space T as a corresponding imaging plane point; draw a plane at the imaging plane point that is the same size as the view orthogonal plane and has four parallel sides, recording it as a corresponding volume rendering imaging plane; grid-divide the volume rendering imaging plane based on the volume rendering imaging size w0×h0 to obtain corresponding w0×h0 imaging plane pixel points p to form a corresponding first pixel point set; and draw a ray perpendicular to the view orthogonal plane from each imaging plane pixel point p toward the direction of the three-dimensional texture data space T, recording it as a corresponding pixel point projection ray, and all the obtained pixel point projection rays form a corresponding first projection ray set;
[0032] The first CUDA processing module is used to plan a three-dimensional texture data storage area, an orthogonal surface data storage area, a pixel point data storage area and a projection ray data storage area in the GPU video memory based on the processing functions for planning memory space and for reading and writing memory data in the CUDA function set, for storing the corresponding three-dimensional texture data space T, the viewing angle orthogonal surface of the three-dimensional texture data space T, the first pixel point set and the first projection ray set; and plan an RGB pixel group storage area in the GPU video memory; the RGB pixel group storage area is used to store multiple RGB pixel groups, each of the RGB pixel groups consists of an R channel pixel value, a G channel pixel value and a B channel pixel value, the number of the RGB pixel groups in the RGB pixel group storage area matches the number of the imaging surface pixel points p in the pixel point data storage area, and the RGB pixel groups have a one-to-one correspondence with the imaging surface pixel points p, and all the RGB pixel groups stored in the RGB pixel group storage area are initialized to empty;
[0033] The second CUDA processing module is used to create a thread that calls the ray casting algorithm kernel function for each pixel point p on the imaging surface in the GPU operating environment, which is recorded as the corresponding first pixel point thread; and all the first pixel point threads are executed in parallel in the GPU operating environment; the ray casting algorithm kernel function is a CUDA kernel function that can only be run in the GPU operating environment and can only use the GPU video memory; the input parameter of the ray casting algorithm kernel function is the first pixel point index; the first pixel point index is the unique index number corresponding to one of the imaging surface pixel points p in the first pixel point set stored in the GPU video memory; the ray casting algorithm kernel function is used to convert the imaging surface pixel point corresponding to the pixel point index in the first pixel point set stored in the GPU video memory into the first pixel point index. point p is used as the corresponding current pixel point, and the pixel point projection ray corresponding to the current imaging surface pixel point in the first pixel point set stored in the GPU video memory is used as the corresponding current projection ray, and the RGB pixel of the current pixel point is calculated according to the three-dimensional texture data space T stored in the GPU video memory, the viewing angle orthogonal plane and the current projection ray according to the ray casting algorithm and the Lambert lighting model, and the RGB pixel of the current pixel point is updated based on the calculation result; the input parameter of each first pixel point thread is the second pixel point index; each first pixel point thread is used to input the input second pixel point index as the corresponding first pixel point index to the ray casting algorithm kernel function and run the ray casting algorithm kernel function for calculation;
[0034] The volume rendering image composition module is configured to construct an image based on all the obtained RGB pixel groups when all the RGB pixel groups in the RGB pixel group storage area in the GPU display memory are not empty, and to display the obtained constructed image as the corresponding volume rendering image.
[0035] A third aspect of an embodiment of the present invention provides an electronic device, including: a memory, a processor, and a transceiver;
[0036] The processor is configured to be coupled to the memory, read and execute instructions in the memory, so as to implement the method steps described in the first aspect above;
[0037] The transceiver is coupled to the processor, and the processor controls the transceiver to send and receive messages.
[0038] A fourth aspect of an embodiment of the present invention provides a computer-readable storage medium, which stores computer instructions. When the computer instructions are executed by a computer, the computer executes the instructions of the method described in the first aspect above.
[0039] The embodiment of the present invention provides a volume rendering processing method, device, electronic device and computer-readable storage medium for medical images. As can be seen from the above content, before calling the CUDA architecture for processing, the embodiment of the present invention will first confirm the viewpoint and construct a normalized three-dimensional texture data space T based on the medical image sequence, viewpoint coordinates and viewpoint viewing distance, and select any point on the line connecting the viewpoint to the center point of the viewpoint orthogonal plane of the three-dimensional texture data space T as the corresponding imaging plane point, and make a plane at the imaging plane point that is the same size as the viewpoint orthogonal plane and parallel to all four sides as the corresponding volume rendering imaging surface, and mesh the volume rendering imaging surface based on the volume rendering imaging size to obtain multiple imaging surface pixel points p to form a corresponding pixel point set, and make a ray perpendicular to the viewpoint orthogonal plane from each imaging surface pixel point p toward the direction of the three-dimensional texture data space T, which is recorded as the corresponding pixel point projection ray, and all the obtained pixel point projection rays form a corresponding projection ray set; after completing the above data preparation work, the data storage area will be planned in the GPU video memory based on the CUDA architecture to store the three-dimensional texture. The invention relates to a method for processing a data space T, a viewing angle orthogonal surface, a pixel point set and a projection ray set, and planning an RGB pixel group storage area for storing subsequent calculation results; and based on the CUDA architecture, a thread calling a ray casting algorithm kernel function is created for each imaging surface pixel point p in the GPU operating environment, recorded as the corresponding first pixel point thread, and all first pixel point threads are executed in parallel in the GPU operating environment; the ray casting algorithm kernel function is a customized CUDA kernel function, which is used to calculate the RGB pixel of the pixel point corresponding to the projection ray according to the three-dimensional texture data space T, the viewing angle orthogonal surface and a specified projection ray stored in the GPU video memory according to the ray casting algorithm and the Lambert lighting model, and update the RGB pixel group storage area based on the calculation result; finally, when all RGB pixel groups in the RGB pixel group storage area in the GPU video memory are not empty, an image is constructed by all RGB pixel groups to obtain a corresponding volume rendering image and display it. The embodiment of the present invention applies the CUDA architecture to the volume rendering processing solution of medical images, thereby improving the computational efficiency, rendering speed and real-time rendering effect of medical image volume rendering; the embodiment of the present invention implements a ray casting algorithm processing flow for shading imaging pixels based on the light intensity-pixel mapping relationship under the Lambert lighting model through customized CUDA kernel functions, thereby improving the processing flexibility and optimization convenience of medical image volume rendering. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] Figure 1 A schematic diagram of a volume rendering processing method for medical images provided in the first embodiment of the present invention;
[0041] Figure 2Schematic diagram of conversion among three-dimensional volume data space R1, three-dimensional volume data space R2, three-dimensional volume data space R3 and three-dimensional texture data space T provided in the first embodiment of the present invention;
[0042] Figure 3 Schematic diagram of the volume rendering imaging surface, the imaging surface pixel point p, the pixel point projection light and the light sampling point s provided in the first embodiment of the present invention;
[0043] Figure 4 Schematic diagram of the unit normal vector N and unit light source vector L of the volume rendering light source point and the light sampling point s provided in the first embodiment of the present invention;
[0044] Figure 5 A module structure diagram of a volume rendering processing device for medical images provided in the second embodiment of the present invention;
[0045] Figure 6 This is a structural diagram of an electronic device provided in Example 3 of the present invention. DETAILED DESCRIPTION
[0046] To make the objectives, technical solutions, and advantages of the present invention more apparent, the present invention will be further described in detail below with reference to the accompanying drawings. It should be understood that the embodiments described herein are merely some, rather than all, of the present invention. All other embodiments derived by persons of ordinary skill in the art based on the embodiments of the present invention without inventive effort are intended to fall within the scope of protection of the present invention.
[0047] A first embodiment of the present invention provides a volume rendering method for medical images, such as Figure 1 A schematic diagram of a volume rendering method for medical images provided in the first embodiment of the present invention is shown. The method mainly includes the following steps:
[0048] Step 1: Receive a first medical image sequence, viewpoint coordinates, viewpoint viewing distance, and volume rendering imaging size w0×h0.
[0049] Here, the first medical image sequence is formed by sequentially sorting multiple first medical images; the first medical image is a three-dimensional CT image or a three-dimensional MRI image; each first medical image is composed of multiple image pixels; each image pixel corresponds to at least one three-dimensional image coordinate (x, y, z) and an image grayscale; wherein the three-dimensional image coordinate (x, y, z) is a spatial coordinate in an XYZ coordinate system, and the XYZ coordinate system is a three-dimensional Cartesian coordinate system composed of X, Y, and Z axes; w0 and h0 in the volume rendering imaging size w0×h0 are the pixel width and pixel height of the volume rendering imaging, respectively.
[0050] Step 2: Confirm the viewpoint and construct a normalized three-dimensional texture data space based on the first medical image sequence, the viewpoint coordinates, and the viewpoint distance to obtain a corresponding first viewpoint and three-dimensional texture data space T;
[0051] Among them, the three-dimensional texture data space T is a cube space with a shape of 1×1×1 in the WHD coordinate system, and the WHD coordinate system is a three-dimensional Cartesian coordinate system composed of a width W axis, a height H axis and a depth D axis; the three-dimensional texture data space T includes multiple texture voxel points t; the texture voxel points t correspond to image pixels one by one; each texture voxel point t corresponds to a three-dimensional coordinate (w, h, d) and a texture voxel grayscale, the value range of the three-dimensional coordinate values w, h, d are all between 0 and 1, and the texture voxel grayscale is consistent with the corresponding image grayscale; among the eight sides of the three-dimensional texture data space T, the side closest to the first viewpoint is recorded as the corresponding view orthogonal plane; the line connecting the center point of the view orthogonal plane and the first viewpoint is perpendicular to the view orthogonal plane;
[0052] Specifically, step 21 includes identifying the largest X, Y, and Z axis coordinates among all three-dimensional image coordinates (x, y, z) in the first medical image sequence to obtain the corresponding maximum value x max 、y max 、z max ; and set the maximum value x max 、y max and z max The maximum value among them is taken as the corresponding maximum side length b; and in the XYZ coordinate system, a cube space with a shape of b×b×b is constructed based on the maximum side length b and recorded as the corresponding three-dimensional volume data space R1; and the spatial coordinate point corresponding to each image pixel point in the first medical image sequence in the three-dimensional volume data space R1 is recorded as the corresponding voxel point v;
[0053] Among them, the voxel point v corresponds one-to-one to the image pixel point;
[0054] Here, the three-dimensional volume data space R1 is as follows Figure 2 This is a schematic diagram of conversion among the three-dimensional volume data space R1, the three-dimensional volume data space R2, the three-dimensional volume data space R3, and the three-dimensional texture data space T provided in the first embodiment of the present invention;
[0055] Step 22: Mark the viewpoint based on the viewpoint coordinates in the XYZ coordinate system to obtain the corresponding first viewpoint; calculate the straight-line distances from the center points of the eight side surfaces of the three-dimensional volume data space R1 to the first viewpoint, and use the side surface with the shortest distance as the corresponding viewpoint orthogonal plane; rotate and displace the three-dimensional volume data space R1 in the XYZ coordinate system until the line connecting the center point of the viewpoint orthogonal plane of the three-dimensional volume data space R2 obtained after the rotation and displacement and the first viewpoint is perpendicular to the viewpoint orthogonal plane and the length of the line matches the viewpoint viewing distance; and during the rotation and displacement process, perform an equivalent rotation and displacement on the spatial coordinates of each voxel point v in the three-dimensional volume data space R1 to obtain the corresponding voxel point v in the three-dimensional volume data space R2. * ;
[0056] Among them, the voxel point v * One-to-one correspondence with voxel point v;
[0057] Here, the first viewpoint, the viewpoint orthogonal plane, and the three-dimensional volume data space R2 are as follows: Figure 2 As shown;
[0058] Step 23: record the opposite side of the view orthogonal plane in the three-dimensional volume data space R2 as the corresponding orthogonal face; and construct a three-dimensional Cartesian coordinate system as the corresponding WHD coordinate system, with the lower left corner vertex of the view orthogonal plane as the origin, the direction from the lower left corner vertex to the lower right corner vertex of the view orthogonal plane as the width W axis, the direction from the lower left corner vertex to the upper left corner vertex of the view orthogonal plane as the height H axis, and the direction from the lower left corner vertex to the lower left corner vertex of the orthogonal face as the depth D axis; and record the corresponding three-dimensional volume data space R2 in the WHD coordinate system as the corresponding three-dimensional volume data space R3; and based on the rotational displacement relationship between the WHD coordinate system and the XYZ coordinate system, the voxel point v in the three-dimensional volume data space R2 is rotated. * The spatial coordinates of the three-dimensional volume are rotated and displaced to obtain the corresponding voxel point v in the three-dimensional volume data space R3. ’ ;
[0059] Among them, the voxel point v ’ The three-dimensional coordinates are expressed as (w ’ ,h ’ ,d ’ ); voxel point v ’ With voxel point v * One-to-one correspondence;
[0060] Here, the orthogonal face-to-face, WHD coordinate system, and three-dimensional volume data space R3 are as follows Figure 2 As shown;
[0061] Step 24: In the WHD coordinate system, the three-dimensional size of the three-dimensional volume data space R3 and each voxel point v are calculated based on the maximum side length b. ’ The three-dimensional coordinates of the voxel point v are normalized, and the obtained normalized data space is used as the corresponding three-dimensional texture data space T, and the three-dimensional texture data space T is ’ The corresponding spatial coordinate point is used as the corresponding texture voxel point t;
[0062] The three-dimensional texture data space T is a cube space with a shape of (b / b)×(b / b)×(b / b)=1×1×1; the texture voxel point t and the voxel point v ’ One-to-one correspondence; the three-dimensional coordinates (w, h, d) of the texture voxel point t and the voxel point v ’ The three-dimensional coordinates (w ’ ,h ’ ,d ’ ) is w=w ’ / b,h=h ’ / b,d=d ’ / b;
[0063] Here, the three-dimensional texture data space T is as follows Figure 2 As shown;
[0064] Step 25, normalize the viewing distance of the viewpoint based on the maximum side length b to obtain the corresponding normalized viewing distance = viewing distance of the viewpoint / b; and record the center point of the viewing orthogonal plane of the three-dimensional texture data space T as the corresponding current center point; and at the current center point, draw a perpendicular line of the viewing orthogonal plane from the current center point to the outside direction of the three-dimensional texture data space T as the corresponding outer edge perpendicular line; and use the coordinates of the spatial point on the outer edge perpendicular line whose distance from the current center point matches the normalized viewing distance as the new coordinates of the first viewpoint.
[0065] Step 3: randomly select a point on the line connecting the first viewpoint to the center point of the view orthogonal plane of the three-dimensional texture data space T as the corresponding imaging plane point; and draw a plane at the imaging plane point that is the same size as the view orthogonal plane and has four parallel sides, which is recorded as the corresponding volume rendering imaging plane; based on the volume rendering imaging size w0×h0, the volume rendering imaging plane is grid-divided to obtain the corresponding w0×h0 imaging plane pixel points p to form the corresponding first pixel point set; and from each imaging plane pixel point p, draw a ray perpendicular to the view orthogonal plane toward the direction of the three-dimensional texture data space T, which is recorded as the corresponding pixel point projection ray, and all the obtained pixel point projection rays form the corresponding first projection ray set.
[0066] Here, the volume rendering imaging surface, the imaging surface pixel point p, and the pixel point projection light are as follows Figure 3This is a schematic diagram of a volume rendering imaging surface, an imaging surface pixel point p, a pixel point projection light, and a light sampling point s provided in the first embodiment of the present invention.
[0067] Step 4: Based on the processing functions for planning memory space and reading and writing memory data in the CUDA function set, a three-dimensional texture data storage area, an orthogonal surface data storage area, a pixel point data storage area, and a projection ray data storage area are planned in the GPU video memory to store the corresponding three-dimensional texture data space T, the viewing angle orthogonal surface of the three-dimensional texture data space T, the first pixel point set, and the first projection ray set; and an RGB pixel group storage area is planned in the GPU video memory;
[0068] Among them, the RGB pixel group storage area is used to store multiple RGB pixel groups, each RGB pixel group consists of an R channel pixel value, a G channel pixel value and a B channel pixel value, the number of RGB pixel groups in the RGB pixel group storage area matches the number of imaging surface pixel points p in the pixel point data storage area, and the RGB pixel groups correspond one-to-one to the imaging surface pixel points p, and all RGB pixel groups stored in the RGB pixel group storage area are initialized to empty.
[0069] Here, the 3D texture / orthogonal surface / pixel point / projected ray data storage areas in the GPU display memory can be regarded as input data storage areas, while the RGB pixel group storage area is the output data storage area; the CUDA architecture also provides many upper-level data objects, which can perform read and write operations on some data storage structures with fixed formats; after creating the data storage area, 1) either custom data objects can be constructed based on these custom data structures to perform data read and write operations, or 2) the stored data can be converted into a format according to some data storage structures with fixed formats, so that the ready-made data objects can be directly called for data read and write access; both methods are supported in the embodiment of the present invention. For example, the CUDA architecture provides a three-dimensional texture data storage structure with a fixed format and corresponding data objects. Therefore, when storing data in the three-dimensional texture data storage area and the orthogonal surface data storage area, the first processing method can be used to convert the three-dimensional texture data space T and the viewing angle orthogonal surface according to the CUDA three-dimensional texture data storage structure before storing them. For another example, the CUDA architecture does not have a good point set and line set data storage structure. Therefore, when storing data in the pixel point data storage area and the projection ray data storage area, the second processing method must be used to customize the data objects based on the data structure of the first pixel point set and the first projection ray set to perform data reading and writing operations.
[0070] Step 5: Create a thread for each pixel point p on the imaging surface that calls the kernel function of the ray casting algorithm under the GPU operating environment, and record it as the corresponding first pixel point thread; and execute all the first pixel point threads in parallel under the GPU operating environment;
[0071] Here, the ray casting algorithm kernel function of the embodiment of the present invention is a customized CUDA kernel function that can only be run in a GPU operating environment and can only use GPU video memory;
[0072] The input parameter of the kernel function of the ray casting algorithm is the first pixel index; the first pixel index is the unique index number corresponding to an imaging surface pixel p in the first pixel set stored in the GPU memory;
[0073] The ray casting algorithm kernel function is used to use the imaging surface pixel point p corresponding to the pixel point index in the first pixel point set stored in the GPU display memory as the corresponding current pixel point; and use the pixel point projection ray corresponding to the current imaging surface pixel point in the first pixel point set stored in the GPU display memory as the corresponding current projection ray; and calculate the RGB pixel of the current pixel point according to the 3D texture data space T stored in the GPU display memory, the view orthogonal plane and the current projection ray according to the ray casting algorithm and the Lambert lighting model, and update the RGB pixel group storage area based on the calculation result;
[0074] The input parameter of each first pixel point thread is the second pixel point index; each first pixel point thread is used to input the input second pixel point index as the corresponding first pixel point index to the ray casting algorithm kernel function and run the ray casting algorithm kernel function for calculation;
[0075] According to the ray casting algorithm and Lambert lighting model, the RGB pixel of the current pixel is calculated based on the three-dimensional texture data space T stored in the GPU memory, the orthogonal plane of the viewing angle, and the current projection light, and the RGB pixel group storage area is updated based on the calculation result. Specifically, it includes:
[0076] Step A1: The ray casting algorithm kernel function sets a corresponding pixel illumination intensity I for the current pixel; initializes the pixel illumination intensity I to a preset negative intensity threshold less than 0; and records the spatial coordinate point corresponding to the preset volume rendering light source point coordinate as the corresponding volume rendering light source point;
[0077] Here, the negative intensity threshold is a preset illumination intensity value, but a negative number less than 0; the volume rendering light source point coordinate is a preset WHD coordinate system coordinate; the volume rendering light source point is as follows Figure 4 The unit normal vector N and the unit light source vector L of the volume rendering light source point and the light sampling point s provided in the first embodiment of the present invention are shown as a schematic diagram;
[0078] Step A2: Calculate the intersection of the current projected light and the plane orthogonal to the viewing angle to obtain the corresponding starting intersection point; and use the starting intersection point as the corresponding light sampling point s;
[0079] Here, the light sampling point s is as follows Figure 4 As shown;
[0080] Step A3, identifying the grayscale of the sampling point corresponding to the light sampling point s;
[0081] Specifically, step A3-1 is to confirm whether there is a texture voxel point t in the three-dimensional texture data space T that matches the spatial coordinates of the light sampling point s;
[0082] Step A3-2: If it exists, the texture voxel grayscale of the texture voxel point t that matches the spatial coordinates of the light sampling point s is used as the corresponding sampling point grayscale;
[0083] Step A3-3: If it does not exist, then search for pairs of neighboring texture voxel points in the three groups of directions of front, back, left, and top and bottom of the light sampling point s in the three-dimensional texture data space T. If only a pair of neighboring texture voxel points in one of the directions is found, then one-dimensional linear interpolation is performed based on the texture voxel grayscale of the currently searched pair of neighboring texture voxel points based on the one-dimensional linear interpolation method, and the calculation result is used as the corresponding sampling point grayscale. If two pairs of neighboring texture voxel points in two of the directions are found, then bilinear interpolation is performed based on the texture voxel grayscale of the two pairs of neighboring texture voxel points currently searched, and the calculation result is used as the corresponding sampling point grayscale. If three pairs of neighboring texture voxel points in three groups of directions are found, then trilinear interpolation is performed based on the texture voxel grayscale of the three pairs of neighboring texture voxel points currently searched, and the calculation result is used as the corresponding sampling point grayscale.
[0084] Step A4: Identify whether the grayscale of the sampling point exceeds a preset grayscale threshold; if so, go to step A5; if not, go to step A6;
[0085] Here, the grayscale threshold is a preset grayscale value; in certain cases, it can also be set to a grayscale range. If the grayscale threshold is a grayscale range, then exceeding the preset grayscale threshold means exceeding the preset grayscale range;
[0086] Step A5: Determine the corresponding unit normal vector N based on the gradient of the light sampling point s; determine the corresponding unit light source vector L based on the straight line direction from the light sampling point s to the volume rendering light source point; and calculate the illumination intensity based on the preset ambient light diffuse reflection coefficient K according to the illumination intensity calculation method of the Lambert illumination model. a , preset ambient light intensity Ia , preset light source diffuse reflectance K d , preset light source intensity I d And the unit normal vector N and the unit light source vector L are used to calculate the illumination intensity to obtain the corresponding illumination intensity I * ; and based on the light intensity I * Reset the pixel illumination intensity I; and identify whether the reset pixel illumination intensity I is greater than 0. If so, go to step A6; otherwise, go to step A7;
[0087] Among them, I * =K a ×I a +K d ×I d (L·N);
[0088] Here, the unit normal vector N and the unit light source vector L are as follows Figure 4 As shown;
[0089] In step A6, it is determined whether the distance from the ray sampling point s to the starting intersection point exceeds a preset first length. If so, the process proceeds to step A7. If not, a spatial coordinate point on the current projection ray that is after the ray sampling point s and that is a preset incremental step length Δd away from the ray sampling point s is set as the new ray sampling point s, and the process returns to step A3.
[0090] Here, the first length defaults to √3, which is actually the diagonal length of the three-dimensional texture data space T; the incremental step length △d is a preset length less than 1; the first length and the incremental step length △d are as follows Figure 3 As shown;
[0091] Step A7, recording the RGB pixel group corresponding to the current pixel in the RGB pixel group storage area as the corresponding current pixel group; and identifying whether the pixel illumination intensity I is greater than 0; if the pixel illumination intensity I is less than or equal to 0, setting the corresponding R channel pixel value, G channel pixel value, and B channel pixel value in the current pixel group by the preset background R channel pixel value, the preset background G channel pixel value, and the preset background B channel pixel value; if the pixel illumination intensity I is greater than 0, calculating the corresponding first pixel value = r0×I, second pixel value = g0×I, and third pixel value = b0×I based on the preset R channel pixel coefficient r0, the preset G channel pixel coefficient g0, the preset B channel pixel coefficient b0, and the pixel illumination intensity I, and setting the corresponding R channel pixel value, G channel pixel value, and B channel pixel value in the current pixel group by the calculated first, second, and third pixel values;
[0092] Here, the preset background R / G / B channel pixel values are three preset pixel values; the preset R channel pixel coefficient r0, G channel pixel coefficient g0, and B channel pixel coefficient b0 are three preset pixel coefficients, which reflect the mapping relationship between light intensity and R / G / B channel pixels.
[0093] Step 6: When all RGB pixel groups in the RGB pixel group storage area in the GPU display memory are not empty, perform image construction based on all obtained RGB pixel groups and use the obtained constructed image as the corresponding volume rendering image and display it.
[0094] Figure 5 This is a module structure diagram of a volume rendering processing device for medical images provided in the second embodiment of the present invention. The device is a terminal device or server that implements the aforementioned method embodiment, or can be a device that enables the aforementioned terminal device or server to implement the aforementioned method embodiment. For example, the device can be a device or chip system of the aforementioned terminal device or server. Figure 5 As shown, the apparatus includes: a data receiving module 201 , a first data pre-processing module 202 , a second data pre-processing module 203 , a first CUDA processing module 204 , a second CUDA processing module 205 and a volume rendering image composition module 206 .
[0095] The data receiving module 201 is used to receive a first medical image sequence, viewpoint coordinates, viewpoint viewing distance, and volume rendering imaging size w0×h0; the first medical image sequence is formed by sequentially sorting multiple first medical images; the first medical image is a three-dimensional CT image or a three-dimensional MRI image; each first medical image is composed of multiple image pixels; each image pixel corresponds to at least one three-dimensional image coordinate (x, y, z) and an image grayscale; the three-dimensional image coordinate (x, y, z) is a spatial coordinate in an XYZ coordinate system, which is a three-dimensional Cartesian coordinate system composed of X, Y, and Z axes; w0 and h0 in the volume rendering imaging size w0×h0 are the pixel width and pixel height of the volume rendering image, respectively.
[0096] The first data preprocessing module 202 is used to construct a three-dimensional texture data space for viewpoint confirmation and normalization based on the first medical image sequence, viewpoint coordinates and viewpoint viewing distance to obtain a corresponding first viewpoint and a three-dimensional texture data space T; the three-dimensional texture data space T is a cube space with a shape of 1×1×1 in a WHD coordinate system, and the WHD coordinate system is a three-dimensional Cartesian coordinate system composed of a width W axis, a height H axis and a depth D axis; the three-dimensional texture data space T includes multiple texture voxel points t; the texture voxel points t correspond one-to-one to the image pixels; each texture voxel point t corresponds to a three-dimensional coordinate (w, h, d) and a texture voxel grayscale, the value range of the three-dimensional coordinate values w, h, d are all between 0 and 1, and the texture voxel grayscale is consistent with the corresponding image grayscale; the side surface of the eight sides of the three-dimensional texture data space T that is closest to the first viewpoint is recorded as the corresponding view orthogonal plane; the line connecting the center point of the view orthogonal plane and the first viewpoint is perpendicular to the view orthogonal plane.
[0097] The second data preprocessing module 203 is used to select any point on the line connecting the first viewpoint to the center point of the view orthogonal plane of the three-dimensional texture data space T as the corresponding imaging plane point; and make a plane with the same size as the view orthogonal plane and four parallel sides at the imaging plane point as the corresponding volume rendering imaging plane; based on the volume rendering imaging size w0×h0, the volume rendering imaging plane is grid-divided to obtain corresponding w0×h0 imaging plane pixel points p to form a corresponding first pixel point set; and from each imaging plane pixel point p, a ray perpendicular to the view orthogonal plane is made in the direction of the three-dimensional texture data space T as the corresponding pixel point projection ray, and all the obtained pixel point projection rays form the corresponding first projection ray set.
[0098] The first CUDA processing module 204 is used to plan a three-dimensional texture data storage area, an orthogonal surface data storage area, a pixel point data storage area and a projection ray data storage area in the GPU video memory based on the processing functions in the CUDA function set for planning memory space and for reading and writing memory data, for storing the corresponding three-dimensional texture data space T, the viewing orthogonal surface of the three-dimensional texture data space T, the first pixel point set and the first projection ray set; and plan an RGB pixel group storage area in the GPU video memory; the RGB pixel group storage area is used to store multiple RGB pixel groups, each RGB pixel group consists of an R channel pixel value, a G channel pixel value and a B channel pixel value, the number of RGB pixel groups in the RGB pixel group storage area matches the number of imaging surface pixel points p in the pixel point data storage area, and the RGB pixel groups correspond one-to-one to the imaging surface pixel points p, and all RGB pixel groups stored in the RGB pixel group storage area are initialized to empty.
[0099] The second CUDA processing module 205 is used to create a thread that calls the ray casting algorithm kernel function for each imaging surface pixel point p in the GPU operating environment, which is recorded as the corresponding first pixel point thread; and all first pixel point threads are executed in parallel in the GPU operating environment; the ray casting algorithm kernel function is a CUDA kernel function that can only be run in the GPU operating environment and can only use the GPU video memory; the input parameter of the ray casting algorithm kernel function is the first pixel point index; the first pixel point index is the unique index number corresponding to an imaging surface pixel point p in the first pixel point set stored in the GPU video memory; the ray casting algorithm kernel function is used to convert the pixel point index corresponding to the pixel point index in the first pixel point set stored in the GPU video memory The image plane pixel point p is taken as the corresponding current pixel point, and the pixel point projection light corresponding to the current imaging plane pixel point in the first pixel point set stored in the GPU video memory is taken as the corresponding current projection light, and the RGB pixel of the current pixel point is calculated according to the ray casting algorithm and the Lambert lighting model based on the three-dimensional texture data space T stored in the GPU video memory, the viewing angle orthogonal surface and the current projection light, and the RGB pixel group storage area is updated based on the calculation result; the input parameter of each first pixel point thread is the second pixel point index; each first pixel point thread is used to input the input second pixel point index as the corresponding first pixel point index to the ray casting algorithm kernel function and run the ray casting algorithm kernel function for calculation.
[0100] The volume rendering image composition module 206 is configured to construct an image based on all obtained RGB pixel groups when all RGB pixel groups in the RGB pixel group storage area in the GPU display memory are not empty, and to display the obtained constructed image as the corresponding volume rendering image.
[0101] An embodiment of the present invention provides a volume rendering processing device for medical images, which can execute the method steps in the above method embodiment. Its implementation principles and technical effects are similar and will not be described in detail here.
[0102] It should be noted that the division of the various modules of the above device is merely a division of logical functions. In actual implementation, they can be fully or partially integrated into a single physical entity, or they can be physically separated. Furthermore, these modules can all be implemented in the form of software called by a processing element; or all be implemented in the form of hardware; or some modules can be implemented in the form of software called by a processing element, and some modules can be implemented in the form of hardware. For example, the data receiving module can be a separate processing element, or it can be integrated into a chip of the above device. In addition, it can be stored in the form of program code in the memory of the above device, and called by a processing element of the above device to perform the functions of the above-mentioned module. The implementation of other modules is similar. In addition, these modules can all or partly be integrated together, or they can be implemented independently. The processing element described here can be an integrated circuit with signal processing capabilities. During implementation, each step of the above method or each of the above modules can be completed by hardware integrated logic circuits in the processor element or by software instructions.
[0103] For example, the above modules may be one or more integrated circuits configured to implement the above methods, such as one or more application-specific integrated circuits (ASICs), one or more digital signal processors (DSPs), or one or more field programmable gate arrays (FPGAs). For another example, when a module is implemented by scheduling program code through a processing element, the processing element may be a general-purpose processor, such as a central processing unit (CPU) or other processor that can call program code. For another example, these modules may be integrated together and implemented in the form of a system-on-a-chip (SOC).
[0104] In the above embodiments, all or part of the embodiments may be implemented using software, hardware, firmware, or any combination thereof. When implemented using software, all or part of the embodiments may be implemented in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the processes or functions described in the above method embodiments are generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The above-mentioned computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the above-mentioned computer instructions can be transmitted from one website, computer, server or data center to another website, computer, server or data center via wired (such as coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (such as infrared, wireless, Bluetooth, microwave, etc.) means. The above-mentioned computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server or data center that includes one or more available media. The above-mentioned available medium can be a magnetic medium (such as a floppy disk, hard disk, tape), an optical medium (such as a DVD), or a semiconductor medium (such as a solid state disk (SSD)), etc.
[0105] Figure 6 This is a schematic diagram of the structure of an electronic device provided in the third embodiment of the present invention. The electronic device can be a terminal device or server that implements the method of the aforementioned embodiment, or it can be a terminal device or server that implements the method of the aforementioned embodiment connected to the aforementioned terminal device or server. Figure 6 As shown, the electronic device may include: a processor 301 (such as a CPU), a memory 302, and a transceiver 303; the transceiver 303 is coupled to the processor 301, and the processor 301 controls the transceiver 303's transceiver actions. Various instructions may be stored in the memory 302 for completing various processing functions and implementing the processing steps described in the aforementioned embodiment method. Preferably, the electronic device involved in the embodiment of the present invention further includes: a power supply 304, a system bus 305, and a communication port 306. The system bus 305 is used to realize communication connections between components. The above-mentioned communication port 306 is used for connecting and communicating between the electronic device and other peripherals.
[0106] exist Figure 6The system bus 305 mentioned in the figure can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The system bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus. The communication interface is used to realize communication between the database access device and other devices (such as clients, read-write libraries, and read-only libraries). The memory may include random access memory (RAM) and may also include non-volatile memory (Non-Volatile Memory), such as at least one disk storage.
[0107] The above-mentioned processors can be general-purpose processors, including central processing units (CPUs), network processors (NPs), graphics processing units (GPUs), etc.; they can also be digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.
[0108] It should be noted that an embodiment of the present invention further provides a computer-readable storage medium, which stores instructions. When the computer-readable storage medium is run on a computer, it enables the computer to execute the methods and processing procedures provided in the above embodiments.
[0109] An embodiment of the present invention further provides a chip for executing instructions, which is used to execute the processing steps described in the above method embodiment.
[0110] The embodiment of the present invention provides a volume rendering processing method, device, electronic device and computer-readable storage medium for medical images. As can be seen from the above content, before calling the CUDA architecture for processing, the embodiment of the present invention will first confirm the viewpoint and construct a normalized three-dimensional texture data space T based on the medical image sequence, viewpoint coordinates and viewpoint viewing distance, and select any point on the line connecting the viewpoint to the center point of the viewpoint orthogonal plane of the three-dimensional texture data space T as the corresponding imaging plane point, and make a plane at the imaging plane point that is the same size as the viewpoint orthogonal plane and parallel to all four sides as the corresponding volume rendering imaging surface, and mesh the volume rendering imaging surface based on the volume rendering imaging size to obtain multiple imaging surface pixel points p to form a corresponding pixel point set, and make a ray perpendicular to the viewpoint orthogonal plane from each imaging surface pixel point p toward the direction of the three-dimensional texture data space T, which is recorded as the corresponding pixel point projection ray, and all the obtained pixel point projection rays form a corresponding projection ray set; after completing the above data preparation work, the data storage area will be planned in the GPU video memory based on the CUDA architecture to store the three-dimensional texture. The invention relates to a method for processing a data space T, a viewing angle orthogonal surface, a pixel point set and a projection ray set, and planning an RGB pixel group storage area for storing subsequent calculation results; and based on the CUDA architecture, a thread calling a ray casting algorithm kernel function is created for each imaging surface pixel point p in the GPU operating environment, recorded as the corresponding first pixel point thread, and all first pixel point threads are executed in parallel in the GPU operating environment; the ray casting algorithm kernel function is a customized CUDA kernel function, which is used to calculate the RGB pixel of the pixel point corresponding to the projection ray according to the three-dimensional texture data space T, the viewing angle orthogonal surface and a specified projection ray stored in the GPU video memory according to the ray casting algorithm and the Lambert lighting model, and update the RGB pixel group storage area based on the calculation result; finally, when all RGB pixel groups in the RGB pixel group storage area in the GPU video memory are not empty, an image is constructed by all RGB pixel groups to obtain a corresponding volume rendering image and display it. The embodiment of the present invention applies the CUDA architecture to the volume rendering processing solution of medical images, thereby improving the computational efficiency, rendering speed and real-time rendering effect of medical image volume rendering; the embodiment of the present invention implements a ray casting algorithm processing flow for shading imaging pixels based on the light intensity-pixel mapping relationship under the Lambert lighting model through customized CUDA kernel functions, thereby improving the processing flexibility and optimization convenience of medical image volume rendering.
[0111] Professionals should also be further aware that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the above description has generally described the components and steps of each example according to their functions. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0112] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein may be implemented using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0113] The specific implementation methods described above further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific implementation method of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. A volume rendering processing method for medical images, characterized in that: The method comprises: Receive a first medical image sequence, viewpoint coordinates, viewpoint viewing distance, and volume rendering imaging size w0×h0; the first medical image sequence is formed by sequentially sorting a plurality of first medical images; the first medical image is a three-dimensional CT image or a three-dimensional MRI image; each of the first medical images is composed of a plurality of image pixels; each of the image pixels corresponds to at least one three-dimensional image coordinate (x, y, z) and an image grayscale; the three-dimensional image coordinate (x, y, z) is a spatial coordinate in an XYZ coordinate system, which is a three-dimensional Cartesian coordinate system composed of X, Y, and Z axes; w0 and h0 in the volume rendering imaging size w0×h0 are the pixel width and pixel height of the volume rendering image, respectively; A three-dimensional texture data space is constructed by confirming and normalizing the viewpoint according to the first medical image sequence, the viewpoint coordinates and the viewpoint viewing distance to obtain a corresponding first viewpoint and a three-dimensional texture data space T; the three-dimensional texture data space T is a cube space with a shape of 1×1×1 in a WHD coordinate system, and the WHD coordinate system is a three-dimensional Cartesian coordinate system composed of a width W axis, a height H axis and a depth D axis; the three-dimensional texture data space T includes a plurality of texture voxel points t; the texture voxel points t correspond to the image pixel points one by one; each of the texture voxel points t corresponds to a three-dimensional coordinate (w, h, d) and a texture voxel grayscale, and the value range of the three-dimensional coordinate values w, h, d is all between 0 and 1, and the texture voxel grayscale is consistent with the corresponding image grayscale; the side surface of the eight sides of the three-dimensional texture data space T that is closest to the first viewpoint is recorded as the corresponding viewpoint orthogonal surface; the line connecting the center point of the viewpoint orthogonal surface and the first viewpoint is perpendicular to the viewpoint orthogonal surface; A point is randomly selected on a line connecting the first viewpoint and the center point of the view orthogonal plane of the three-dimensional texture data space T as a corresponding imaging plane point; a plane having the same size as the view orthogonal plane and four parallel sides is drawn at the imaging plane point as a corresponding volume rendering imaging plane; the volume rendering imaging plane is meshed based on the volume rendering imaging size w0×h0 to obtain corresponding w0×h0 imaging plane pixel points p forming a corresponding first pixel point set; and a ray perpendicular to the view orthogonal plane is drawn from each imaging plane pixel point p toward the direction of the three-dimensional texture data space T as a corresponding pixel point projection ray, and all the obtained pixel point projection rays form a corresponding first projection ray set; Based on the processing functions for planning memory space and reading and writing memory data in the CUDA function set, a three-dimensional texture data storage area, an orthogonal surface data storage area, a pixel point data storage area and a projection ray data storage area are planned in the GPU video memory for storing the corresponding three-dimensional texture data space T, the viewing angle orthogonal surface of the three-dimensional texture data space T, the first pixel point set and the first projection ray set; and an RGB pixel group storage area is planned in the GPU video memory; the RGB pixel group storage area is used to store a plurality of RGB pixel groups, each of the RGB pixel groups consists of an R channel pixel value, a G channel pixel value and a B channel pixel value, the number of the RGB pixel groups in the RGB pixel group storage area matches the number of the imaging surface pixel points p in the pixel point data storage area, and the RGB pixel groups correspond to the imaging surface pixel points p one-to-one, and all the RGB pixel groups stored in the RGB pixel group storage area are initialized to empty; In the GPU operating environment, a thread that calls the ray casting algorithm kernel function is created for each pixel point p on the imaging surface, which is recorded as the corresponding first pixel point thread; and all the first pixel point threads are executed in parallel in the GPU operating environment; the ray casting algorithm kernel function is a CUDA kernel function that can only be run in the GPU operating environment and can only use the GPU video memory; the input parameter of the ray casting algorithm kernel function is the first pixel point index; the first pixel point index is the unique index number corresponding to one of the imaging surface pixel points p in the first pixel point set stored in the GPU video memory; the ray casting algorithm kernel function is used to take the imaging surface pixel point p corresponding to the pixel point index in the first pixel point set stored in the GPU video memory as the The method further comprises the steps of: determining a current pixel point corresponding to the first pixel point, using the pixel point projection ray corresponding to the current pixel point in the first pixel point set stored in the GPU video memory as the corresponding current projection ray, and calculating the RGB pixel of the current pixel point according to the three-dimensional texture data space T stored in the GPU video memory, the viewing angle orthogonal plane and the current projection ray according to the ray casting algorithm and the Lambert lighting model, and updating the RGB pixel group storage area based on the calculation result; the input parameter of each first pixel point thread is the second pixel point index; each first pixel point thread is used to input the input second pixel point index as the corresponding first pixel point index to the ray casting algorithm kernel function and run the ray casting algorithm kernel function for calculation; When all the RGB pixel groups in the RGB pixel group storage area in the GPU display memory are not empty, an image is constructed based on all the obtained RGB pixel groups and the obtained constructed image is used as the corresponding volume rendering image and displayed.
2. The volume rendering processing method for medical images according to claim 1, characterized in that: The step of performing viewpoint confirmation and normalization on the three-dimensional texture data space according to the first medical image sequence, the viewpoint coordinates, and the viewpoint viewing distance to obtain the corresponding first viewpoint and the three-dimensional texture data space T specifically includes: Identify the largest X, Y, and Z axis coordinates among all the three-dimensional image coordinates (x, y, z) in the first medical image sequence to obtain the corresponding maximum value x max 、y max 、z max ; and the maximum value x max 、y max and z max The maximum value of the maximum side length b is used as the corresponding maximum side length b; and in the XYZ coordinate system, a cube space with a shape of b×b×b is constructed based on the maximum side length b and recorded as the corresponding three-dimensional volume data space R1; and the spatial coordinate point corresponding to each image pixel point in the first medical image sequence in the three-dimensional volume data space R1 is recorded as the corresponding voxel point v; the voxel point v corresponds to the image pixel point one-to-one; The method comprises the following steps: marking the viewpoint based on the viewpoint coordinates in the XYZ coordinate system to obtain the corresponding first viewpoint; calculating the straight-line distances from the center points of the eight side surfaces of the three-dimensional volume data space R1 to the first viewpoint, and taking the side surface with the shortest distance as the corresponding viewpoint orthogonal surface; rotating and displacing the three-dimensional volume data space R1 in the XYZ coordinate system until the line connecting the center point of the viewpoint orthogonal surface of the three-dimensional volume data space R2 obtained after the rotation and displacement and the first viewpoint is perpendicular to the viewpoint orthogonal surface and the length of the line matches the viewpoint viewing distance; and performing an equal rotation and displacement on the spatial coordinates of each voxel point v in the three-dimensional volume data space R1 to obtain the corresponding voxel point v in the three-dimensional volume data space R2. * ; The voxel point v * One-to-one correspondence with the voxel point v; The opposite side of the viewing angle orthogonal plane in the three-dimensional volume data space R2 is recorded as the corresponding orthogonal face; and a three-dimensional Cartesian coordinate system is constructed with the lower left corner vertex of the viewing angle orthogonal plane as the origin, the direction from the lower left corner vertex to the lower right corner vertex of the viewing angle orthogonal plane as the width W axis direction, the direction from the lower left corner vertex to the upper left corner vertex of the viewing angle orthogonal plane as the height H axis direction, and the direction from the lower left corner vertex of the viewing angle orthogonal plane to the lower left corner vertex of the orthogonal face as the depth D axis direction, and the three-dimensional volume data space corresponding to the three-dimensional volume data space R2 in the XYZ coordinate system in the WHD coordinate system is recorded as the corresponding three-dimensional volume data space R3; and each voxel point v in the three-dimensional volume data space R2 is rotated and displaced based on the rotational displacement relationship between the WHD coordinate system and the XYZ coordinate system. * The spatial coordinates of the 3D volume are rotated and displaced to obtain the corresponding voxel point v in the 3D volume data space R3. ’ ; The voxel point v ’ The three-dimensional coordinates are expressed as (w ’ ,h ’ ,d ’ ); the voxel point v ’ With the voxel point v * One-to-one correspondence; The three-dimensional size of the three-dimensional volume data space R3 and each voxel point v are calculated based on the maximum side length b in the WHD coordinate system. ’ The three-dimensional coordinates of the voxel point v are normalized, and the obtained normalized data space is used as the corresponding three-dimensional texture data space T, and the voxel points v in the three-dimensional texture data space T are normalized. ’ The corresponding spatial coordinate point is used as the corresponding texture voxel point t; the three-dimensional texture data space T is a cube space with a shape of (b / b)×(b / b)×(b / b)=1×1×1; the texture voxel point t and the voxel point v ’ One-to-one correspondence; the three-dimensional coordinates (w, h, d) of the texture voxel point t and the voxel point v ’ The three-dimensional coordinates (w ’ ,h ’ ,d ’ ) is w=w ’ / b,h=h ’ / b,d=d ’ / b; The viewing distance of the viewing point is normalized based on the maximum side length b to obtain the corresponding normalized viewing distance = viewing distance of the viewing point / b; and the center point of the viewing orthogonal plane of the three-dimensional texture data space T is recorded as the corresponding current center point; and at the current center point, a perpendicular line of the viewing orthogonal plane is drawn from the current center point to the outside direction of the three-dimensional texture data space T and is recorded as the corresponding outer edge perpendicular line; and the coordinates of the spatial point on the outer edge perpendicular line whose distance from the current center point matches the normalized viewing distance are used as the new coordinates of the first viewing point.
3. The volume rendering processing method for medical images according to claim 1, characterized in that: The step of calculating the RGB pixels of the current pixel point according to the three-dimensional texture data space T stored in the GPU memory, the viewing angle orthogonal surface, and the current projection light according to the ray casting algorithm and the Lambert lighting model, and updating the RGB pixel group storage area based on the calculation result, specifically includes: Step 31: The ray casting algorithm kernel function sets a corresponding pixel illumination intensity I for the current pixel; initializes the pixel illumination intensity I to a preset negative intensity threshold less than 0; and records the spatial coordinate point corresponding to the preset volume rendering light source point coordinates as the corresponding volume rendering light source point; Step 32: Calculate the intersection of the current projection light and the plane orthogonal to the viewing angle to obtain a corresponding starting intersection point; and use the starting intersection point as the corresponding light sampling point s; Step 33, and identify the sampling point grayscale corresponding to the light sampling point s, specifically: confirm whether there is the texture voxel point t matching the spatial coordinates of the light sampling point s in the three-dimensional texture data space T; if so, use the texture voxel grayscale of the texture voxel point t matching the spatial coordinates of the light sampling point s as the corresponding sampling point grayscale; if not, search for paired neighboring texture voxel points in the three groups of directions of front, back, left, and top and bottom of the light sampling point s in the three-dimensional texture data space T. If only a pair of neighboring texture voxel points in one of the directions is found, then use the one-dimensional linear interpolation method to find the texture voxel point t. Performing a one-dimensional linear interpolation calculation on the texture voxel grayscale of the currently searched pair of neighboring texture voxel points and using the calculation result as the corresponding sampling point grayscale; if two pairs of neighboring texture voxel points in two groups of directions are searched, performing a bilinear interpolation calculation on the texture voxel grayscale of the two pairs of neighboring texture voxel points currently searched and using the calculation result as the corresponding sampling point grayscale; if three pairs of neighboring texture voxel points in three groups of directions are searched, performing a trilinear interpolation calculation on the texture voxel grayscale of the three pairs of neighboring texture voxel points currently searched and using the calculation result as the corresponding sampling point grayscale; Step 34, and identify whether the grayscale of the sampling point exceeds the preset grayscale threshold; if so, go to step 35; if not, go to step 36; Step 35: Determine the corresponding unit normal vector N based on the gradient of the light sampling point s; determine the corresponding unit light source vector L based on the straight line direction from the light sampling point s to the volume rendering light source point; and calculate the illumination intensity based on the preset ambient light diffuse reflection coefficient K according to the illumination intensity calculation method of the Lambert illumination model. a , preset ambient light intensity I a , preset light source diffuse reflectance K d , preset light source intensity I d The unit normal vector N and the unit light source vector L are used to calculate the illumination intensity to obtain the corresponding illumination intensity I * ; and based on the light intensity I * Reset the pixel illumination intensity I; and identify whether the reset pixel illumination intensity I is greater than 0, if so, go to step 36, if not, go to step 37; Among them, I * =K a ×I a +K d ×I d (L·N); Step 36: Identify whether the distance from the light sampling point s to the starting intersection exceeds a preset first length; if so, go to step 37; if not, set the spatial coordinate point on the current projection light that is after the light sampling point s and is a preset incremental length Δd away from the light sampling point s as the new light sampling point s, and return to step 33; the first length is defaulted to Step 37, record the RGB pixel group corresponding to the current pixel in the RGB pixel group storage area as the corresponding current pixel group; and identify whether the pixel illumination intensity I is greater than 0; if the pixel illumination intensity I is less than or equal to 0, set the corresponding R channel pixel value, G channel pixel value and B channel pixel value in the current pixel group according to the preset background R channel pixel value, the preset background G channel pixel value and the preset background B channel pixel value; if the pixel illumination intensity I is greater than 0, calculate the corresponding first pixel value = r0×I, second pixel value = g0×I and third pixel value = b0×I based on the preset R channel pixel coefficient r0, the preset G channel pixel coefficient g0, the preset B channel pixel coefficient b0 and the pixel illumination intensity I, and set the corresponding R channel pixel value, G channel pixel value and B channel pixel value in the current pixel group according to the calculated first, second and third pixel values.
4. A device for executing the volume rendering processing method of medical images according to any one of claims 1 to 3, characterized in that: The device comprises: a data receiving module, a first data pre-processing module, a second data pre-processing module, a first CUDA processing module, a second CUDA processing module and a volume rendering image composition module; The data receiving module is used to receive a first medical image sequence, viewpoint coordinates, viewpoint viewing distance, and volume rendering imaging size w0×h0; the first medical image sequence is formed by sequentially sorting a plurality of first medical images; the first medical image is a three-dimensional CT image or a three-dimensional MRI image; each of the first medical images is composed of a plurality of image pixels; each of the image pixels corresponds to at least one three-dimensional image coordinate (x, y, z) and an image grayscale; the three-dimensional image coordinate (x, y, z) is a spatial coordinate in an XYZ coordinate system, which is a three-dimensional Cartesian coordinate system composed of X, Y, and Z axes; w0 and h0 in the volume rendering imaging size w0×h0 are the pixel width and pixel height of the volume rendering image, respectively; The first data preprocessing module is used to construct a three-dimensional texture data space for viewpoint confirmation and normalization based on the first medical image sequence, the viewpoint coordinates and the viewpoint viewing distance to obtain a corresponding first viewpoint and a three-dimensional texture data space T; the three-dimensional texture data space T is a cube space with a shape of 1×1×1 in a WHD coordinate system, and the WHD coordinate system is a three-dimensional Cartesian coordinate system composed of a width W axis, a height H axis and a depth D axis; the three-dimensional texture data space T includes a plurality of texture voxel points t; the texture voxel points t correspond to the image pixel points one by one; each of the texture voxel points t corresponds to a three-dimensional coordinate (w, h, d) and a texture voxel grayscale, the value range of the three-dimensional coordinate values w, h, d are all between 0 and 1, and the texture voxel grayscale is consistent with the corresponding image grayscale; the side surface of the eight sides of the three-dimensional texture data space T that is closest to the first viewpoint is recorded as the corresponding view orthogonal plane; the line connecting the center point of the view orthogonal plane and the first viewpoint is perpendicular to the view orthogonal plane; The second data preprocessing module is configured to select any point on a line connecting the first viewpoint to the center point of the view orthogonal plane of the three-dimensional texture data space T as a corresponding imaging plane point; draw a plane at the imaging plane point that is the same size as the view orthogonal plane and has four parallel sides, recording it as a corresponding volume rendering imaging plane; grid-divide the volume rendering imaging plane based on the volume rendering imaging size w0×h0 to obtain corresponding w0×h0 imaging plane pixel points p to form a corresponding first pixel point set; and draw a ray perpendicular to the view orthogonal plane from each imaging plane pixel point p toward the direction of the three-dimensional texture data space T, recording it as a corresponding pixel point projection ray, and all the obtained pixel point projection rays form a corresponding first projection ray set; The first CUDA processing module is used to plan a three-dimensional texture data storage area, an orthogonal surface data storage area, a pixel point data storage area and a projection ray data storage area in the GPU video memory based on the processing functions for planning memory space and for reading and writing memory data in the CUDA function set, for storing the corresponding three-dimensional texture data space T, the viewing angle orthogonal surface of the three-dimensional texture data space T, the first pixel point set and the first projection ray set; and plan an RGB pixel group storage area in the GPU video memory; the RGB pixel group storage area is used to store multiple RGB pixel groups, each of the RGB pixel groups consists of an R channel pixel value, a G channel pixel value and a B channel pixel value, the number of the RGB pixel groups in the RGB pixel group storage area matches the number of the imaging surface pixel points p in the pixel point data storage area, and the RGB pixel groups have a one-to-one correspondence with the imaging surface pixel points p, and all the RGB pixel groups stored in the RGB pixel group storage area are initialized to empty; The second CUDA processing module is used to create a thread that calls the ray casting algorithm kernel function for each pixel point p of the imaging surface in the GPU operating environment, which is recorded as the corresponding first pixel point thread; and all the first pixel point threads are executed in parallel in the GPU operating environment; the ray casting algorithm kernel function is a CUDA kernel function that can only be run in the GPU operating environment and can only use the GPU video memory; the input parameter of the ray casting algorithm kernel function is the first pixel point index; the first pixel point index is the unique index number corresponding to one of the imaging surface pixel points p in the first pixel point set stored in the GPU video memory; the ray casting algorithm kernel function is used to convert the imaging surface corresponding to the pixel point index in the first pixel point set stored in the GPU video memory into the first pixel point set. The pixel point p is used as the corresponding current pixel point, and the pixel point projection ray corresponding to the current pixel point in the first pixel point set stored in the GPU video memory is used as the corresponding current projection ray, and the RGB pixel of the current pixel point is calculated according to the three-dimensional texture data space T stored in the GPU video memory, the viewing angle orthogonal plane and the current projection ray according to the ray casting algorithm and the Lambert lighting model, and the RGB pixel group storage area is updated based on the calculation result; the input parameter of each first pixel point thread is the second pixel point index; each first pixel point thread is used to input the input second pixel point index as the corresponding first pixel point index to the ray casting algorithm kernel function and run the ray casting algorithm kernel function for calculation; The volume rendering image composition module is configured to construct an image based on all the obtained RGB pixel groups when all the RGB pixel groups in the RGB pixel group storage area in the GPU display memory are not empty, and to display the obtained constructed image as the corresponding volume rendering image.
5. An electronic device, characterized in that: include: memory, processors, and transceivers; The processor is configured to be coupled to the memory, read and execute instructions in the memory, so as to implement the method according to any one of claims 1 to 3; The transceiver is coupled to the processor, and the processor controls the transceiver to send and receive messages.
6. A computer-readable storage medium, characterized in that The computer-readable storage medium stores computer instructions, and when the computer instructions are executed by a computer, the computer is caused to execute the method according to any one of claims 1 to 3.
Citation Information
Patent Citations
A man-machine interactive editing method for segmentation results of volume data
CN109147061A
Rendering device, rendering method, and program
JP2020086803A