Medical volume real rendering method based on ambient light shielding
By introducing ambient light occlusion technology and OA occlusion calculation in medical volume rendering, combined with Phong lighting model and texture coding, the problems of unreal rendering effects and low computing efficiency in the existing technology are solved, and higher details and reality are achieved and improve computing efficiency and real-time performance.
Patent Information
- Application Number
- CN202411319277.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-20
- Publication Date
- 2025-01-03
AI Technical Summary
The existing medical volume rendering methods lack realism in anatomical structure display, especially in the case of organ occlusion, and the ambient light occlusion technology has not been effectively applied in the medical field, and the computing efficiency and real-time performance are insufficient.
Using a medical volume real rendering method based on ambient occlusion, the intersection point between rays and voxels is calculated and texture encoding is performed through the Ray Casting algorithm combined with the Phong lighting model, and OA occlusion calculation and random incremental sampling are introduced to generate occlusion texture maps to improve rendering The authenticity and details of the image.
It improves the realism and details of the rendered image, improves the ray projection algorithm, can more conveniently identify spatial locations, improves computing efficiency and real-time performance, and realizes real-time interaction.
Smart Images

Figure CN119251377A_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the technical field of medical image processing, and specifically relates to a medical volumetric realistic rendering method based on ambient light occlusion. Background Art
[0002] With the development of medical imaging, diagnostic equipment has become more advanced, especially the emergence of high-resolution tomographic images such as CT and MRI, which has led to the continuous advancement of medical 3D reconstruction technology. These technologies can provide rich information about the internal structure of the human body. In the past, 2D images often failed to meet clinical needs, especially in complex surgical planning and disease diagnosis. Therefore, 3D real volume rendering can provide more intuitive, detailed and comprehensive medical image information.
[0003] Ray Casting is a common method in 3D reconstruction technology, especially in volume rendering. It generates images by simulating light emitted from a light source, passing through three-dimensional space and intersecting with objects in the scene. Rays are emitted from a virtual camera and projected into the scene along the line of sight.
[0004] For each ray, check its intersection with all pixels in the scene. This involves geometric calculations, which may include intersections with pixels at different positions. At the intersection point, sample the pixel color based on the material properties and lighting conditions at that location.
[0005] The result of the interaction of light with the volume data is calculated by applying a lighting model. The light source direction, intensity and color properties are calculated. Colors are blended along the light path, and transparency and light attenuation are superimposed. For semi-transparent or blurred objects, additional calculations are required to simulate absorption effects. Finally, the color contribution of all lights is synthesized into the final image. This process involves the accumulation and blending of pixels, and finally generates the corresponding rendered image.
[0006] Although ray casting can show anatomical structures to a certain extent, the lighting effects are usually composed of direct lighting (such as directional light, point light source) and indirect lighting (such as global illumination). However, these technologies often ignore the tiny local occlusion details, resulting in differences between the rendering effect and the real world. In order to improve this problem, the ambient occlusion technology is introduced, which can simulate the subtle shadows of light on the surface and corners of objects, enhancing the realism of volume rendering.
[0007] The existing rendering methods have the following disadvantages:
[0008] Although Ray Casting-based volume rendering can display anatomical structures, it is not realistic enough, especially when there are organs blocking the view, and it is not easy to identify the spatial position.
[0009] Ambient occlusion technology is currently mainly used in the gaming industry, and is usually used for rendering surface reconstruction. It has not yet been applied to medical volume reconstruction.
[0010] Ambient occlusion technology involves a lot of calculations due to occlusion operations, which affects the operation efficiency and real-time performance, and needs to be improved to achieve real-time interaction.
[0011] Therefore, it is necessary to develop an improved medical volumetric realistic rendering method based on ambient occlusion. Summary of the invention
[0012] The purpose of the present application is to overcome the deficiencies of the above-mentioned prior art and provide a method for realistic rendering of medical volumes based on ambient light occlusion.
[0013] In order to solve the technical problem, the technical method of the present application is: a medical volumetric real rendering method based on ambient light occlusion, comprising the following steps:
[0014] Step 1: Read in Dicom image;
[0015] Step 2: Generate volume data: Analyze the Dicom image and determine whether the inter-layer spacing meets the reconstruction requirements according to the image number sequence. The condition for reconstruction is that the inter-layer spacing of all images is consistent. If it is met, the corresponding volume data is generated.
[0016] Step 3: Perform raycast rendering: input volume data into the buffer, define the ray Ray, Ray = (O, D), where o is the starting point of the ray and D is the direction vector of the ray; for each ray, calculate the intersection of the ray and the voxel, and calculate the depth distance t, where the voxel is the basic unit of volume data;
[0017] in:
[0018]
[0019] t represents the depth distance, pixels;
[0020] Pi represents the corresponding voxel;
[0021] i represents the voxel unit count in all projection directions;
[0022] Step 4: Sample voxel data at the intersection obtained in step 3, obtain the color and density attributes of the voxel, apply the Phong illumination model to calculate the interaction between light and voxel, calculate the color of the intersection according to the color and density attributes of the voxel and the Phong illumination model, accumulate the color and transparency along the light path, the contribution of distant voxels to the color will be reduced due to the attenuation of light, accumulate the contribution of each sampling point along the light path, consider the transparency of light, and use the final accumulated color as the output color of the light to generate a rendered image;
[0023] Step 5: Position texture encoding: Define the position vector of any point P in three-dimensional space through all the intersection points calculated in step 3 Normalize the position first, then perform texture encoding;
[0024] Step 6: Vector texture encoding: Calculate the vector of each voxel through all the intersection points calculated in step 3, encode all vectors, and for any point P vector Perform texture encoding;
[0025] Step 7: Screen space incremental sampling: Map the rendered image generated in step 4 to the viewport area, emit rays from each pixel in the viewport area, use viewport random incremental sampling, and collect viewport pixel values each time randomly incremented;
[0026] Step 8: OA occlusion calculation: For each sampling point, calculate whether the current pixel is occluded. If the sampling point depth distance t is less than the current pixel depth plus an offset determined by the normal direction of the sampling point and the vector to the current pixel, the sampling point is considered to be occluded, and the occlusion value is calculated to achieve real-time rendering;
[0027] Step 9: Compare with the original texture depth: Map the rendered image generated in step 4 to the viewport area, emit rays from each pixel in the viewport area, use viewport random increment sampling, collect viewport pixel values at each random increment, calculate the offset of two random positions, first transfer this offset from the tangent space to the observation space, and then transfer the sampling point from the observation space to the screen space, use the obtained screen coordinates to sample the depth buffer to obtain the depth value randomDepth of the sampling point, extract the depth distance t after texture encoding for comparison, if randomDepth is greater than the depth distance t, perform occlusion weighting, and calculate the occlusion weighting coefficient OA, otherwise discard it;
[0028] Step 10: Weighted synthesis of OA and synthetic result image: The rendered image generated in step 4 and the occlusion weighting coefficient OA calculated in step 9 are traversed and weightedly drawn to generate a real image with ambient occlusion. Step 7 is looped again for incremental sampling, and progressive drawing is performed in sequence. The synthetic result image is drawn to the high-definition display multiple times to end the rendering process.
[0029] Preferably, the light ray is defined in step 3 as consisting of a viewing starting point and a direction vector, the direction vector is normalized and represents the propagation direction of the light ray; Ray = (O, D), where O is the starting point of the light ray and D is the direction vector of the light ray.
[0030] Preferably, the specific formula for normalizing the position in step 5 is:
[0031]
[0032] in:
[0033] represents the normalized position vector;
[0034] w is the normalized weight, which is the maximum size of the scene and is in the range of [0, 1];
[0035] The texture encoding method is as follows:
[0036]
[0037] in:
[0038] Represents the position RGB texture vector;
[0039] sRGB is a function that converts a linear texture space into an SRGB color space, which is used to handle the nonlinear characteristics of color.
[0040] Preferably, the texture encoding method in step 6 is as follows:
[0041]
[0042] in:
[0043] Octahedron Encode is used as the Encode function, as follows:
[0044]
[0045] Represents the corresponding octahedral mapping vector.
[0046] Preferably, the formula for calculating whether the current pixel is blocked in step 8 is as follows:
[0047]
[0048] Where:
[0049] When occlusion is 0, the sampling point is considered to be occluded, and when occlusion is 1, the sampling point is considered to be unoccluded;
[0050] Where sampleDepth is the depth distance t; currentDepth is the current pixel depth;
[0051] N is the number of sampling points;
[0052] The step function returns 1 if the first argument is less than 0, otherwise it returns 0;
[0053] Bias is a small offset added to avoid noise in the depth map.
[0054] Preferably, the shielding weighted coefficient OA formula of the shielding weighting in step 9 is as follows:
[0055]
[0056] Where:
[0057] n p represents the normal of p;
[0058] w represents an arbitrary unit vector in the positive direction of the tangent plane of p;
[0059] V(p, w) represents the visibility function, which is 1 if the object is blocked in the w direction and 0 otherwise.
[0060] Compared with the prior art, the advantages of this application are:
[0061] (1) This application discloses a medical volumetric real rendering method based on ambient light occlusion, which realizes the shadow effect of ray casting volume rendering, improves the level and details, improves the ray casting algorithm, generates an occlusion texture map during the projection process, improves the sampling points and the use of random algorithms to reduce occlusion defects, and uses OA incremental sampling to achieve progressive rendering to meet real-time drawing, making the rendered image more realistic and lifelike, especially when there is organ occlusion, it can easily identify the spatial position;
[0062] (2) The volume reconstruction of this application introduces ambient light occlusion technology, which increases the depth and details of medical images, making the reconstruction more realistic;
[0063] (3) This application introduces position texture coding and vector texture coding in the ray casting algorithm, which facilitates the subsequent GPU parallel acceleration of weighted calculation and drawing, improves the calculation efficiency and real-time performance, and can achieve real-time interaction;
[0064] (4) This application optimizes the efficiency and quality of occlusion calculations through an occlusion random position detection scheme, and can more conveniently identify spatial positions. BRIEF DESCRIPTION OF THE DRAWINGS
[0065] Figure 1 , a flowchart of a method for realistic medical volume rendering based on ambient occlusion in the present application;
[0066] Figure 2 , the Raycast projection algorithm of the embodiment of the present application performs volume rendering, and the image obtained by rendering is applied to the phong lighting model;
[0067] Figure 3, the texture converted after the Raycast projection intersection position encoding in the embodiment of the present application, the texture change represents the distance of the voxel position from the camera;
[0068] Figure 4 , the texture converted after the Raycast projection intersection position vector in the embodiment of the present application, the texture change represents the voxel projection direction;
[0069] Figure 5 , the embodiment of the present application synthesizes a masking texture image through position coding and position vector, and the texture change represents the corresponding tissue masking situation;
[0070] Figure 6 , a Raycaset projected rendering image in an embodiment of the present application superimposed with a rendering image after ambient light occlusion;
[0071] Figure 7 , Rendering effect of existing ray casting algorithm:
[0072] Figure 8 , This application adds the rendering effect after OA light shielding. DETAILED DESCRIPTION
[0073] The specific implementation of this application is described below in conjunction with embodiments:
[0074] It should be noted that the contents shown in the drawings of this specification are only used to cooperate with the principles, features and content descriptions disclosed in the specification for people familiar with this technology to understand and read, and are not used to limit the conditions for the implementation of this application. Without affecting the effects and purposes that can be achieved by this application, they should still fall within the scope of the technical contents disclosed in this application.
[0075] The purpose of this application is to provide a medical volume rendering technology based on ambient occlusion, which achieves occlusion effect by improving the volume rendering method of the ray casting algorithm to improve the realism and visual quality of the rendering.
[0076] The process is as follows:
[0077] The present application discloses a method for realistic rendering of medical volumes based on ambient light occlusion, comprising the following steps:
[0078] Step 1: Read in Dicom image;
[0079] Step 2: Generate volume data: Analyze the Dicom image and determine whether the inter-layer spacing meets the reconstruction requirements according to the image number sequence. The condition for reconstruction is that the inter-layer spacing of all images is consistent. If it is met, the corresponding volume data is generated.
[0080] Step 3: Perform raycast rendering: input volume data into the buffer, define the ray Ray, Ray = (O, D), where o is the starting point of the ray and D is the direction vector of the ray; for each ray, calculate the intersection of the ray and the voxel, and calculate the depth distance t, where the voxel is the basic unit of volume data;
[0081] in:
[0082]
[0083] t represents the depth distance, pixels;
[0084] Pi represents the corresponding voxel;
[0085] i represents the voxel unit count in all projection directions;
[0086] Step 4: Sample voxel data at the intersection obtained in step 3, obtain the color and density attributes of the voxel, apply the Phong illumination model to calculate the interaction between light and voxel, calculate the color of the intersection according to the color and density attributes of the voxel and the Phong illumination model, accumulate the color and transparency along the light path, the contribution of distant voxels to the color will be reduced due to the attenuation of light, accumulate the contribution of each sampling point along the light path, consider the transparency of light, and use the final accumulated color as the output color of the light to generate a rendered image;
[0087] The Phong lighting model is a general lighting model for volume rendering. The color of the intersection is calculated based on the color and density attributes of the voxel and the Phong lighting model. The raycast projection rendering of the current volume data reconstruction is not the focus of this application.
[0088] Step 5: Position texture encoding: Define the position vector of any point P in three-dimensional space through all the intersection points calculated in step 3 Normalize the position first, then perform texture encoding;
[0089] Step 6: Vector texture encoding: Calculate the vector of each voxel through all the intersection points calculated in step 3, encode all vectors, and for any point P vector Perform texture encoding;
[0090] Step 7: Screen space incremental sampling: Map the rendered image generated in step 4 to the viewport area, emit rays from each pixel in the viewport area, use viewport random incremental sampling, and collect viewport pixel values each time randomly incremented;
[0091] Step 8: OA occlusion calculation: For each sampling point, calculate whether the current pixel is occluded. If the sampling point depth distance t is less than the current pixel depth plus an offset determined by the normal direction of the sampling point and the vector to the current pixel, the sampling point is considered to be occluded, and the occlusion value is calculated to achieve real-time rendering;
[0092] Step 9: Compare with the original texture depth: Map the rendered image generated in step 4 to the viewport area, emit rays from each pixel in the viewport area, use viewport random increment sampling, collect viewport pixel values at each random increment, calculate the offset of two random positions, first transfer this offset from the tangent space to the observation space, and then transfer the sampling point from the observation space to the screen space, use the obtained screen coordinates to sample the depth buffer to obtain the depth value randomDepth of the sampling point, extract the depth distance t after texture encoding for comparison, if randomDepth is greater than the depth distance t, perform occlusion weighting, and calculate the occlusion weighting coefficient OA, otherwise discard it;
[0093] Step 10: Weighted synthesis of OA and synthetic result image: The rendered image generated in step 4 and the occlusion weighting coefficient OA calculated in step 9 are traversed and weightedly drawn to generate a real image with ambient occlusion. Step 7 is looped again for incremental sampling, and progressive drawing is performed in sequence. The synthetic result image is drawn to the high-definition display multiple times to end the rendering process.
[0094] Preferably, the light ray defined in step 3 is composed of a viewing starting point and a direction vector, the direction vector is normalized and represents the propagation direction of the light ray; Ray = (O, D), where O is the starting point of the light, and D is the direction vector of the light.
[0095] Preferably, the specific formula for normalizing the position in step 5 is:
[0096]
[0097] in:
[0098] represents the normalized position vector;
[0099] w is the normalized weight, which is the maximum size of the scene and is in the range of [0, 1];
[0100] The texture encoding method is as follows:
[0101]
[0102] in:
[0103] Represents the position RGB texture vector;
[0104] sRGB is a function that converts a linear texture space into an SRGB color space, which is used to handle the nonlinear characteristics of color.
[0105] Preferably, the texture encoding method in step 6 is as follows:
[0106]
[0107] in:
[0108] Octahedron Encode is used as the Encode function, as follows:
[0109]
[0110] Represents the corresponding octahedral mapping vector.
[0111] Preferably, the formula for calculating whether the current pixel is blocked in step 8 is as follows:
[0112]
[0113] Where:
[0114] When occlusion is 0, the sampling point is considered to be occluded, and when occlusion is 1, the sampling point is considered to be unoccluded;
[0115] Where sampleDepth is the depth distance t; currentDepth is the current pixel depth;
[0116] N is the number of sampling points;
[0117] The step function returns 1 if the first argument is less than 0, otherwise it returns 0;
[0118] Bias is a small offset added to avoid noise in the depth map.
[0119] Preferably, the shielding weighted coefficient OA formula of the shielding weighting in step 9 is as follows:
[0120]
[0121] Where:
[0122] n p represents the normal of p;
[0123] w represents an arbitrary unit vector in the positive direction of the tangent plane;
[0124] V(p, w) represents the visibility function, which is 1 if p is occluded in the w direction and 0 otherwise.
[0125] Example 1
[0126] The following is a detailed description of the embodiments of the present invention with reference to the accompanying drawings. Figure 1 The flowchart of a medical volume rendering based on ambient occlusion provided by an embodiment of the present application is shown, and the method comprises the following steps:
[0127] Step S1: Read in the Dicom image.
[0128] Step S2: Analyze the Dicom image and determine whether the inter-slice spacing meets the reconstruction requirements according to the image number sequence. If it does, generate the corresponding volume data.
[0129] Step S3: input the volume data into the buffer, define the light, which is defined by a viewing starting point and a direction vector; the direction vector is normalized and represents the propagation direction of the light;
[0130] Ray=(O,D)
[0131] Where O is the starting point (origin) of the light and D is the direction vector of the light.
[0132] For each ray, calculate the intersection point between the ray and the voxel. Use the following algorithm to find the intersection point. Since the ray will pass through the voxels in the projection direction in sequence, it means that there is an intersection point. Calculate until the voxel transparency accumulates to 1 and cannot pass through, and calculate the depth distance t.
[0133]
[0134] in:
[0135] t represents the depth distance;
[0136] Pi represents the corresponding voxel.
[0137] Step S4: Sample voxel data at the intersection calculated in S3 to obtain the color and density attributes of the voxel. Apply the phong lighting model to calculate the interaction between light and voxels. Calculate the color of the intersection based on the voxel attributes and the phong lighting model. Accumulate color and transparency along the light path. The contribution of voxels farther away to color will be reduced due to light attenuation. Accumulate the contribution of each sampling point along the light path, taking into account the transparency of the light. Use the final accumulated color as the output color of the light to generate a rendered image, such as Figure 2 shown.
[0138] Step S5: All intersection points have been calculated through S3, and the position vector of any point P in three-dimensional space is
[0139] In order to encode this position into the color channel, a normalization method is used so that the encoded color value is suitable for display on the display.
[0140] Normalized position:
[0141]
[0142] Where w is the normalized weight and is the maximum size of the scene, which is guaranteed to be in the range [0,1].
[0143] Texture encoding:
[0144]
[0145] Among them, sRGB is a function that converts a linear texture space into an SRGB color space, which is used to process the nonlinear characteristics of color.
[0146] After position encoding, it is converted into texture display, and all position points are encoded in a loop in sequence.
[0147] like Figure 3 As shown, the texture is transformed after the Raycast projection intersection position is encoded, and the texture change represents the distance of the voxel position from the camera.
[0148] Step S6: Through S3, calculate the vector of each voxel through all the intersection points calculated in step 3, and encode all vectors. For any point P vector Using a coding method similar to S5, normals do not need to be normalized. Texture coding is as follows:
[0149]
[0150] Among them, Encode is an encoding function, as follows:
[0151]
[0152] The encoding method is to map the normal to a unit octahedron, then map it to the range [0, 1], and then cyclically encode all vectors in turn.
[0153] like Figure 4 As shown, the texture is transformed after Raycast projects the intersection position vector, and the texture change represents the voxel projection direction.
[0154] Step S7: Map the rendered image generated in step 4 to the viewport area, and emit rays from each pixel in the viewport area. If the number is too large and the length is too long, it may cause a sharp drop in performance, while if the number is insufficient, it may cause band errors. This application uses a random algorithm to disrupt the direction of the outgoing rays of each pixel, which can significantly reduce the band error and improve the display quality. At the same time, through the viewport random incremental sampling, each random increment collects the viewport pixel value, quickly calculates the occlusion value, and realizes real-time rendering.
[0155] Step S8: For each sampling point, calculate whether the current pixel is blocked. If the depth of the sampling point is less than the current pixel depth plus an offset determined by the normal direction of the sampling point and the vector to the current pixel, the sampling point is considered to be blocked.
[0156] Occlusion calculation formula:
[0157]
[0158] in:
[0159] N is the number of sampling points. The step function returns 1 when the first parameter is less than 0, otherwise it returns 0. Bias is a small offset added to avoid noise in the depth map. In the implementation, 0.01 can be used as a reference offset.
[0160] Step S9: Map the rendered image generated in step 4 to the viewport area, emit rays from each pixel in the viewport area, use viewport random incremental sampling, collect viewport pixel values each time with random increments, calculate the offset of two random positions, first transfer this offset from the tangent space to the observation space, and then transfer the sampling point from the observation space to the screen space, use the obtained screen coordinates to sample the depth buffer to obtain the depth value randomDepth of the sampling point, extract the depth distance t after texture encoding for comparison, if randomDepth is greater than the depth distance t, perform occlusion weighting, and calculate the occlusion weighting coefficient OA, otherwise discard it.
[0161] Step S10: Through step S9, calculate the weighted coefficient of ambient occlusion, the formula is as follows:
[0162]
[0163] Where np represents the normal of p, w represents an arbitrary unit vector in the positive direction of the tangent plane of p, and V(p, w) is the visibility function, which is 1 if p is obscured in the w direction and 0 otherwise.
[0164] like Figure 5 As shown, the masking texture image is synthesized by position encoding and position vector, and the texture change represents the corresponding tissue masking situation.
[0165] Step S11: Perform traversal weighted rendering on the rendering image generated by S4 and the occlusion weighted coefficient OA calculated by S10 to generate a real image with ambient light occlusion. Repeat step S7 for incremental sampling, progressive rendering in sequence, and multiple renderings to high-definition display.
[0166] like Figure 6 As shown, the Raycaset projection rendering image is superimposed with the ambient occlusion rendering image.
[0167] End the rendering process.
[0168] The rendering examples are compared as follows:
[0169] Comparison of the two rendering effects. Figure 7 Rendering effects for existing ray casting algorithms, Figure 8 Add the rendering effect after OA light shielding for this application.
[0170] By comparison, it can be found that the patent realizes occlusion and shadow rendering through OA, and the displayed details are more realistic, especially for soft tissues and more complex anatomical structures, with better spatial structure expression capabilities, providing high-quality diagnostic basis for clinical diagnosis.
[0171] The present application discloses a medical volumetric realistic rendering method based on ambient light occlusion, which realizes the shadow effect of ray-casting volume rendering, improves the level and details, improves the ray-casting algorithm, generates an occlusion texture map during the projection process, improves the sampling points and the use of random algorithms to reduce occlusion defects, and uses OA incremental sampling to achieve progressive rendering to meet real-time drawing, making the rendered image more realistic and lifelike, especially when there is organ occlusion, and can easily identify the spatial position.
[0172] The volume reconstruction of this application introduces ambient light occlusion technology, which increases the depth and details of medical images and makes the reconstruction more realistic.
[0173] This application introduces position texture encoding and vector texture encoding in the ray casting algorithm to facilitate the subsequent GPU parallel acceleration of weighted calculation and drawing, improve the calculation efficiency and real-time performance, and achieve real-time interaction.
[0174] This application optimizes the efficiency and quality of masking operations through a masked random position detection scheme, and can more conveniently identify spatial positions.
[0175] The preferred implementation modes of the present application are described in detail above, but the present application is not limited to the above implementation modes, and various changes can be made within the knowledge scope of ordinary geologists in this field without departing from the purpose of the present application.
[0176] Many other changes and modifications can be made without departing from the concept and scope of the present application.It should be understood that the present application is not limited to specific embodiments, and the scope of the present application is defined by the appended claims.
Claims
1. A method for realistic rendering of medical volumes based on ambient occlusion, characterized in that: The following steps are involved: Step 1: Read in Dicom image; Step 2: Generate volume data: Analyze the Dicom image and determine whether the inter-layer spacing meets the reconstruction requirements according to the image number sequence. The condition for reconstruction is that the inter-layer spacing of all images is consistent. If it is met, the corresponding volume data is generated. Step 3: Perform raycast rendering: input volume data into the buffer, define the ray Ray, Ray = (O, D), where O is the starting point of the ray and D is the direction vector of the ray; for each ray, calculate the intersection of the ray and the voxel, and calculate the depth distance t, where the voxel is the basic unit of volume data; in: t represents the depth distance, pixels; Pi represents the corresponding voxel; i represents the voxel unit count in all projection directions; Step 4: Sample voxel data at the intersection obtained in step 3, obtain the color and density attributes of the voxel, apply the Phong illumination model to calculate the interaction between light and voxel, calculate the color of the intersection according to the color and density attributes of the voxel and the Phong illumination model, accumulate the color and transparency along the light path, the contribution of distant voxels to the color will be reduced due to the attenuation of light, accumulate the contribution of each sampling point along the light path, consider the transparency of light, and use the final accumulated color as the output color of the light to generate a rendered image; Step 5: Position texture encoding: Define the position vector of any point P in three-dimensional space through all the intersection points calculated in step 3 Normalize the position first, then perform texture encoding; Step 6: Vector texture encoding: Calculate the vector of each voxel through all the intersection points calculated in step 3, encode all vectors, and for any point P vector Perform texture encoding; Step 7: Screen space incremental sampling: Map the rendered image generated in step 4 to the viewport area, emit rays from each pixel in the viewport area, use viewport random incremental sampling, and collect viewport pixel values each time randomly incremented; Step 8: OA occlusion calculation: For each sampling point, calculate whether the current pixel is occluded. If the sampling point depth distance t is less than the current pixel depth plus an offset determined by the normal direction of the sampling point and the vector to the current pixel, the sampling point is considered to be occluded, and the occlusion value is calculated to achieve real-time rendering; Step 9: Compare with the original texture depth: Map the rendered image generated in step 4 to the viewport area, emit rays from each pixel in the viewport area, use viewport random increment sampling, collect viewport pixel values at each random increment, calculate the offset of two random positions, first transfer this offset from the tangent space to the observation space, and then transfer the sampling point from the observation space to the screen space, use the obtained screen coordinates to sample the depth buffer to obtain the depth value randomDepth of the sampling point, extract the depth distance t after texture encoding for comparison, if randomDepth is greater than the depth distance t, perform occlusion weighting, and calculate the occlusion weighting coefficient OA, otherwise discard it; Step 10: Weighted synthesis of OA and synthetic result image: The rendered image generated in step 4 and the occlusion weighting coefficient OA calculated in step 9 are traversed and weightedly drawn to generate a real image with ambient occlusion. Step 7 is looped again for incremental sampling, and progressive drawing is performed in sequence. The synthetic result image is drawn to the high-definition display multiple times to end the rendering process.
2. The method for realistic medical volume rendering based on ambient occlusion according to claim 1, characterized in that: The light ray defined in step 3 is composed of a viewing starting point and a direction vector, the direction vector is normalized and represents the propagation direction of the light ray; Ray = (O, D), where O is the starting point of the light ray and D is the direction vector of the light ray.
3. The method for realistic medical volume rendering based on ambient occlusion according to claim 1, characterized in that: The specific formula for normalizing the position in step 5 is: in: represents the normalized position vector; w is the normalized weight, which is the maximum size of the scene and is in the range of [0, 1]; The texture encoding method is as follows: in: Represents the position RGB texture vector; sRGB is a function that converts a linear texture space into an SRGB color space, which is used to handle the nonlinear characteristics of color.
4. The method for realistic medical volume rendering based on ambient occlusion according to claim 3, characterized in that: The texture encoding method in step 6 is as follows: in: Octahedron Encode is used as the Encode encoding function, as follows: Represents the corresponding octahedral mapping vector.
5. The method for realistic medical volume rendering based on ambient occlusion according to claim 1, characterized in that: The formula for calculating whether the current pixel is blocked in step 8 is as follows: Where: When occlusion is 0, the sampling point is considered to be occluded, and when occlusion is 1, the sampling point is considered to be unoccluded; Where sampleDepth is the depth distance t; currentDepth is the current pixel depth; N is the number of sampling points; The step function returns 1 if the first argument is less than 0, otherwise it returns 0; Bias is a small offset added to avoid noise in the depth map.
6. The method for realistic medical volume rendering based on ambient occlusion according to claim 1, characterized in that: The shielding weighting coefficient OA formula of the shielding weighting in step 9 is as follows: Where: n p represents the normal of p; w represents an arbitrary unit vector in the positive direction of the tangent plane of p; V(p, w) represents the visibility function, which is 1 if the object is blocked in the w direction and 0 otherwise.
