Rendering method and apparatus, electronic device, and storage medium
Patent Information
- Application Number
- CN202610826790.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-06-09
- Publication Date
- 2026-09-25
AI Technical Summary
然而,PBVR 采用面积光 / 环境光,而 Raycast_IVL 依赖方向光,二者光源特征差异显著,导致渲染结果显示偏差较大,难以平滑过渡
[0017]本申请实施例提供的一种渲染方法,通过基于PBVR的面积光参数计算Raycast的方向光参数,并限定二者相似度大于相似度阈值,使两种渲染算法的光源特征趋于一致,确保Raycast渲染的第一渲染图像与PBVR渲染的第二渲染图像视觉效果相近,实现从第一渲染图像到第二渲染图像的平滑过渡,通过Raycast渲染第一帧并缓存,避免PBVR初始迭代的大量噪声,同时通过PBVR渲染获得高质量、接近真实解剖效果的图像,最终通过混合渲染得到目标渲染图像,满足医学诊断对影像精度。
Smart Images

Figure CN122820951A_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of medical image rendering technology, and in particular relates to a rendering method, apparatus, electronic device and storage medium. Background Technology
[0002] In medical imaging diagnosis, physically-based volume rendering (PBVR) and raycasting-based volume rendering are two mainstream technologies. PBVR can present realistic global illumination effects by simulating photon propagation, but the rendering process is noisy, requiring multiple frame iterations to eliminate noise, affecting real-time performance. Raycast is fast and noise-free, but lacks realistic lighting details. To balance effect and performance, current technologies often use Raycast_IVL (Raycast introducing interactive volumetric lighting technology) instead of PBVR in the first frame to avoid initial noise, and then gradually transition to a noise-free PBVR hybrid rendering scheme. However, PBVR uses area lighting / ambient lighting, while Raycast_IVL relies on directional lighting. The significant differences in their light source characteristics lead to large display deviations in the rendering results, making a smooth transition difficult. Summary of the Invention
[0003] In view of this, embodiments of this application provide a rendering method, apparatus, electronic device, and storage medium that can achieve a smooth transition in the rendering process and improve the coherence of medical image rendering.
[0004] In a first aspect, embodiments of this application provide a rendering method, including: Acquire the volumetric data of the medical image to be rendered and the area lighting parameters of the physically based volume rendering method; Based on the area light parameters, the directional light parameters of the volume rendering method based on ray casting are calculated, wherein the similarity between the directional light parameters and the area light parameters is greater than or equal to a similarity threshold. The medical image volume data is rendered using a ray projection volume rendering method based on the directional light parameters to obtain a first rendered image; The medical image volume data is rendered using a physically based volume rendering method based on the area light parameters to obtain a second rendered image. The target rendered image is obtained by performing a hybrid rendering based on the first rendered image and the second rendered image.
[0005] In some embodiments, the area light parameters include: the illumination intensity of the area light, and the calculation of directional light parameters based on the area light parameters for a volume rendering method based on ray casting includes: Determine the distance between the area beam and the irradiated surface, wherein the irradiated surface is the surface within the medical image volume data bounding box that is closest to the area beam; The illumination intensity at the edge points of the area light's illumination range is calculated based on the distance and a preset illumination intensity threshold. Based on the illumination intensity at the edge point and the strongest illumination intensity of the area light, calculate the illumination range angle of the area light; The regions of light intensity attenuation and non-attenuation are determined based on the irradiation range angle. The illumination intensity of the directional light illuminating the first layer of volume data in the medical image volume data is determined based on the light intensity attenuation region and the light intensity non-attenuation region.
[0006] In some embodiments, the area light parameters further include: the direction and center of the area light, and the calculation of the directional light parameters based on the area light parameters for the volume rendering method based on ray casting includes: The direction of the area light is determined as the direction of the directional light, and the center of the area light is determined as the center of the directional light.
[0007] In some embodiments, determining the distance between the area light and the irradiated surface includes: Determine whether the direction of the area light is orthogonal to the normal vector of the irradiated surface; When the direction of the area light is orthogonal to the normal vector of the irradiated surface, the distance from the edge point of the area light to the irradiated surface is determined as the distance between the area light and the irradiated surface; When the direction of the area light is not orthogonal to the normal vector of the irradiated surface, determine the point in the area light that is closest to the irradiated surface, draw a ray from the closest point along the direction of the area light, and determine the intersection point of the ray and the irradiated surface. The distance between the closest point and the intersection point is determined as the distance between the area light and the irradiated surface.
[0008] In some embodiments, determining the illumination intensity of the directional light illuminating the first layer of volume data in the medical image volume data based on the illumination intensity attenuation region and the illumination intensity non-attenuation region includes: Determine whether each irradiation point on the first layer of volume data in the medical image volume data is within the light intensity attenuation region when the directional light is irradiated by the directional light. For each first illumination point located in the non-attenuation region of illumination intensity, the illumination intensity of the area light in the non-attenuation region of illumination intensity is determined as the illumination intensity of the corresponding first illumination point. For each second illumination point located in the light intensity attenuation region, the strongest light intensity of the area light is attenuated based on the position of the second illumination point to obtain the light intensity of each second illumination point.
[0009] In some embodiments, attenuating the strongest illumination intensity of the area light based on the position of the second illumination point to obtain the illumination intensity of each second illumination point includes: Determine the distance between each second illumination point and the center of the directional light; Subtract the radius of the non-attenuated light intensity region from the distance to obtain the calculated value corresponding to each second irradiation point; The light intensity of each second irradiation point is obtained by dividing the strongest light intensity by the square of the calculated value corresponding to each second irradiation point.
[0010] In some embodiments, the method further includes: A dark region is determined based on the light intensity attenuation region and the light intensity non-attenuation region, wherein the light intensity of the illuminated points in the dark region is less than the light intensity threshold. The light intensity at the illumination point corresponding to the dark area is set to 0.
[0011] In some embodiments, the step of performing hybrid rendering based on the first rendered image and the second rendered image to obtain the target rendered image includes: For the second rendered image in the Nth rendering, the first rendered image is multiplied by the corresponding first weight and the second rendered image is multiplied by the corresponding second weight to obtain the target rendered image in the Nth rendering. For the second rendered image in the (N+1)th rendering, the first rendered image is multiplied by the corresponding third weight and the second rendered image is multiplied by the corresponding fourth weight to obtain the target rendered image in the (N+1)th rendering, wherein the first weight is greater than the third weight and the second weight is less than the fourth weight.
[0012] In some embodiments, rendering the medical image volume data using a ray projection method based on the directional light parameters to obtain a first rendered image includes: Based on the aforementioned directional light parameters, calculate the illumination and shadow information and indirect illumination information of each voxel in the medical image volume data; The first rendered image is obtained by combining the lighting and shadow information with the indirect lighting information and the lighting model.
[0013] Secondly, embodiments of this application provide a rendering apparatus, including: The acquisition module is used to acquire the volume data of the medical image to be rendered and the area lighting parameters of the physically based volume rendering method. The calculation module is used to calculate the directional light parameters of the volume rendering method based on ray projection based on the area light parameters, wherein the similarity between the directional light parameters and the area light parameters is greater than or equal to a similarity threshold. The first rendering module is used to render the medical image volume data based on the directional light parameters using a volume rendering method of ray projection, to obtain a first rendered image, and to cache the first rendered image. The second rendering module is used to render the medical image volume data based on the area light parameters using a physically based volume rendering method to obtain a second rendered image. The hybrid rendering module is used to perform hybrid rendering based on the first rendered image and the second rendered image to obtain the target rendered image.
[0014] Thirdly, embodiments of this application provide an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement any of the methods described above.
[0015] Fourthly, embodiments of this application provide a computer-readable storage medium storing a computer program that, when executed by a processor, implements any of the methods described above.
[0016] Fifthly, embodiments of this application provide a computer program product that, when run on a terminal device, causes an electronic device to execute any of the methods described above.
[0017] The rendering method provided in this application calculates the directional light parameters of Raycast based on the area light parameters of PBVR, and limits the similarity between the two to a similarity threshold, so that the light source characteristics of the two rendering algorithms tend to be consistent, ensuring that the visual effect of the first rendered image rendered by Raycast is similar to that of the second rendered image rendered by PBVR, realizing a smooth transition from the first rendered image to the second rendered image. The first frame is rendered by Raycast and cached to avoid a lot of noise in the initial iteration of PBVR. At the same time, a high-quality image with near-realistic anatomical effect is obtained by PBVR rendering. Finally, the target rendered image is obtained through hybrid rendering to meet the image accuracy requirements of medical diagnosis. Attached Figure Description
[0018] To more clearly illustrate the technical solutions in the embodiments of this application, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0019] Figure 1 A schematic diagram illustrating the implementation flow of a rendering method provided in an embodiment of this application; Figure 2 A schematic diagram of an area light provided for an embodiment of this application; Figure 3 A schematic diagram of a directional light provided for an embodiment of this application; Figure 4 A schematic diagram of an orthogonal scene between area light and the irradiated surface provided in an embodiment of this application; Figure 5 A schematic diagram illustrating a non-orthogonal scene between an area light and an illuminated surface, provided as an embodiment of this application; Figure 6 A schematic diagram illustrating the implementation flow of a rendering method provided in this application is shown. Figure 7 A schematic diagram illustrating a non-orthogonal scene between an area light and an illuminated surface, provided as an embodiment of this application; Figure 8 A schematic diagram illustrating a non-orthogonal scene between an area light and an illuminated surface, provided as an embodiment of this application; Figure 9 A schematic diagram of light attenuation provided in an embodiment of this application; Figure 10 This is a schematic diagram of the structure of a rendering apparatus provided in an embodiment of this application; Figure 11 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0020] In the following description, specific details such as particular system architectures and techniques are set forth for illustrative purposes and not for limitation, in order to provide a thorough understanding of the embodiments of this application. However, those skilled in the art will understand that this application may also be implemented in other embodiments without these specific details. In other instances, detailed descriptions of well-known systems, apparatuses, circuits, and methods have been omitted so as not to obscure the description of this application with unnecessary detail.
[0021] It should be understood that, when used in this application specification and the appended claims, the term "comprising" indicates the presence of the described features, integrals, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components and / or a collection thereof.
[0022] It should also be understood that the term “and / or” as used in this application specification and the appended claims means any combination of one or more of the associated listed items and all possible combinations, and includes such combinations.
[0023] As used in this application specification and the appended claims, the term "if" may be interpreted, depending on the context, as "when," "once," "in response to determination," or "in response to detection." Similarly, the phrases "if determined" or "if detected" may be interpreted, depending on the context, as "once determined," "in response to determination," "once detected," or "in response to detection."
[0024] Furthermore, in the description of this application and the appended claims, the terms "first," "second," "third," etc., are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.
[0025] References to "one embodiment" or "some embodiments" in this specification mean that one or more embodiments of this application include a specific feature, structure, or characteristic described in connection with that embodiment. Therefore, the phrases "in one embodiment," "in some embodiments," "in other embodiments," "in still other embodiments," etc., appearing in different parts of this specification do not necessarily refer to the same embodiment, but rather mean "one or more, but not all, embodiments," unless otherwise specifically emphasized.
[0026] Based on the problems in related technologies, this application provides a rendering method that can be applied to electronic devices, which may include: mobile phones, tablets, wearable devices, augmented reality (AR) / virtual reality (VR) devices, laptops, ultra-mobile personal computers (UMPCs), netbooks, personal digital assistants (PDAs), etc. The electronic device can be referred to as a rendering system.
[0027] Figure 1 This is a schematic diagram illustrating the implementation flow of a rendering method provided in an embodiment of this application, as shown below. Figure 1 As shown, the rendering methods include: Step S101: Obtain the volume data of the medical image to be rendered and the area lighting parameters of the physically based volume rendering method.
[0028] In this embodiment, medical imaging volume data refers to a three-dimensional data set reflecting the internal anatomical structure of the human body, acquired through medical scanning equipment such as computed tomography (CT) and magnetic resonance (MR). It is the core object of rendering, containing key information such as the density and grayscale of human tissues and organs, providing data support for the realism of the rendering. Physically based volume rendering is a global illumination rendering technique. Its core is based on the propagation laws of light in a medium, simulating the absorption and scattering process of photons in the volume data density field, and using Monte Carlo path tracing to generate images that closely resemble realistic anatomy. This is the core algorithm for obtaining high-quality rendering results. Area light parameters are commonly used light source parameters in PBVR, referring to the core attributes of area lights, including at least the light intensity, direction, center position, and radius. They directly determine the lighting effect and image realism of PBVR rendering. Figure 2 A schematic diagram of an area light provided in an embodiment of this application is shown below. Figure 2 As shown, the illumination intensity of the area light decreases from the center to both sides.
[0029] In this embodiment, the volumetric data of the three-dimensional medical image to be rendered can be obtained through medical image processing equipment (such as CT and MR scanners), imported into the rendering system and preprocessed (such as denoising and normalization) to ensure the integrity and accuracy of the volumetric data. At the same time, the user can manually set the area light parameters of PBVR (including illumination intensity, direction, center position, radius, etc.) according to medical diagnostic needs, or call the system's preset standard area light parameters as the basis for subsequent directional light parameter calculations.
[0030] Step S102: Calculate the directional light parameters of the volume rendering method based on ray projection based on the area light parameters, wherein the similarity between the directional light parameters and the area light parameters is greater than or equal to a similarity threshold.
[0031] In this embodiment, the raycast-based volume rendering method is a direct volume data rendering technique. Its core principle is to emit a ray along each pixel of the screen, passing through the volume data and sampling voxel information. This data is then combined with a lighting model for shading. Raycast is characterized by its fast rendering speed and noise-free operation. It can be combined with IVL (Interactive Volume Lighting) technology to enhance lighting effects (i.e., Raycast_IVL). Directional light parameters are commonly used light source parameters in Raycast, referring to the core attributes of the directional light, including its intensity, direction, and center position. Figure 3 A schematic diagram of a directional light provided for an embodiment of this application, as shown below. Figure 3As shown, its lighting characteristics are parallel light propagation and uniform light intensity (which can be adjusted through an attenuation algorithm). The similarity threshold is a preset judgment standard used to measure the degree of matching between the PBVR area light parameters and the Raycast directional light parameters. When the similarity between the two is greater than or equal to the threshold, it indicates that the lighting effects of the two light sources tend to be consistent, which can ensure a smooth transition of subsequent rendering results.
[0032] In this embodiment, the obtained PBVR area light parameters are used as the core basis. The directional light parameters of the Raycast are calculated through a preset algorithm model. The core is to ensure the matching degree of the two light source parameters (similarity > similarity threshold). The specific calculation logic includes: taking the direction of the area light directly as the direction of the directional light, and taking the center position of the area light directly as the center position of the directional light; calculating the light intensity (including attenuation law) of the directional light based on the illumination intensity and radius of the area light, combined with the preset illumination intensity threshold, so that the illumination effect of the directional light tends to be consistent with that of the area light; after the calculation is completed, the similarity between the two is verified by a similarity algorithm (such as parameter difference comparison method). If the threshold is not reached, the directional light parameters are readjusted until the requirements are met.
[0033] Step S103: Render the medical image volume data using a ray projection volume rendering method based on the directional light parameters to obtain a first rendered image.
[0034] In this embodiment, the first rendered image refers to the image obtained by rendering medical image volume data using Raycast (or Raycast_IVL) based on the calculated directional light parameters. It serves as the initial image for hybrid rendering, and its core function is to avoid a large amount of noise in the initial iteration of PBVR. It is usually the rendering result of the first frame. In some embodiments, the first rendered image can be cached.
[0035] In this embodiment, the calculated directional light parameters can be imported into the Raycast rendering module to start the Raycast rendering process: parallel light rays are emitted based on the directional light parameters, the light rays pass through the preprocessed medical image volume data, and the density and grayscale information of each voxel are sampled; the lighting effect of each voxel is calculated in combination with the directional light parameters, and the image is shading through a lighting model (such as the Phong lighting model) to generate the first rendered image (without initial noise).
[0036] In this embodiment, the first rendered image is stored in the system cache for quick retrieval during subsequent mixed rendering, avoiding repeated rendering and improving efficiency.
[0037] Step S104: Based on the area light parameters, the medical image volume data is rendered using a physically based volume rendering method to obtain a second rendered image.
[0038] In this embodiment of the application, the second rendered image refers to the image obtained by rendering medical image volume data through PBVR based on area light parameters. It is the result of multiple frames iteratively accumulated. Its core features are noise-free, clear details, and close to the real anatomical effect. It is the core component of the final target rendered image.
[0039] In this embodiment, the acquired PBVR area light parameters are imported into the PBVR rendering module, and the PBVR rendering process is started: the Monte Carlo path tracing method is used to simulate the absorption and scattering process of thousands or tens of thousands of photons in the volume data density field of medical images, and the light transmission of hundreds or thousands of photon paths is simulated along each pixel; noise is eliminated by multi-frame iterative accumulation (the more iterations, the less noise), and when the preset number of iterations is reached and the noise is eliminated to meet the requirements, a second rendered image is generated, which has the characteristics of high quality and close to the real anatomical effect.
[0040] Step S105: Perform a hybrid rendering based on the first rendered image and the second rendered image to obtain the target rendered image.
[0041] In this embodiment, hybrid rendering refers to a rendering method that weights and sums the first rendered image and the second rendered image according to preset weights. The core purpose is to achieve a smooth transition from Raycast rendering results to PBVR rendering results, taking into account both noise-free and high-quality rendering requirements. The target rendered image is the final output result of hybrid rendering, combining the advantages of the first rendered image (no initial noise) and the second rendered image (high quality, realistic details). It has no obvious noise and clear details, which can meet the requirements of medical diagnosis for image accuracy and visual effects.
[0042] The method provided in this application embodiment can call the first rendered image in the cache and the generated second rendered image, and perform mixed rendering by weighted summation. For each iteration of PBVR, corresponding weights are assigned to the first rendered image and the second rendered image (the fewer the iterations, the larger the weight of the first rendered image and the smaller the weight of the second rendered image; the more the iterations, the smaller the weight of the first rendered image and the larger the weight of the second rendered image). The two images are weighted and summed to obtain the intermediate rendered image of each iteration. When the PBVR iteration is completed and the noise is completely eliminated, the final target rendered image with no obvious noise and clear details is obtained for medical diagnosis and analysis.
[0043] The method provided in this application calculates Raycast directional light parameters based on PBVR area light parameters and limits the similarity between the two to a threshold, making the light source characteristics of the two rendering algorithms tend to be consistent. This ensures that the visual effect of the first rendered image (without initial noise) rendered by Raycast is similar to that of the second rendered image (high quality) rendered by PBVR, achieving a smooth transition from the first to the second rendered image. This avoids abrupt changes and visual breaks in the rendered image, improving the coherence and consistency of medical image rendering and facilitating continuous observation of image details by doctors. By rendering and caching the first frame with Raycast, a large amount of noise in the initial iteration stage of PBVR is effectively avoided, ensuring that the initial rendered image is clear and distinguishable. At the same time, through multi-frame iterative rendering with PBVR, a high-quality second rendered image with near-realistic anatomical effects is obtained, preserving the subtle details of human tissues and organs. Finally, through hybrid rendering, combining the advantages of both methods, a target rendered image with no obvious noise and clear details is obtained, which not only meets the high requirements of medical diagnosis for image accuracy but also solves the problem of initial noise in PBVR affecting real-time observation.
[0044] In some embodiments, the area light parameter includes the area light intensity.
[0045] In this embodiment, the illumination intensity of the area light refers to the maximum illumination energy value (denoted as I) of the PBVR area light at the center position. It is the core physical parameter of the area light and directly determines the illumination intensity. The unit is usually candela (cd) or relative illumination intensity value. Different medical imaging scenarios (such as soft tissue and bone rendering) need to be matched with different illumination intensities.
[0046] Step S102 can be achieved through the following steps: Step S1021: Determine the distance between the area light and the irradiated surface, wherein the irradiated surface is the surface in the medical image volume data bounding box that is closest to the area light.
[0047] In this embodiment, the irradiation surface refers to the surface closest to the PBVR area light among the six surfaces (upper, lower, left, right, front, and back) of the three-dimensional bounding box of the medical image volume data. It is the reference surface for calculating the irradiation range of the area light and determines the effective coverage boundary of the light on the volume data.
[0048] In this embodiment, a three-dimensional bounding box for medical image volume data can be constructed, and the position coordinates and normal vectors of the six faces can be determined; the shortest straight-line distance between the center position (O) of the PBVR area beam and the six faces of the bounding box can be calculated; the six distance values can be compared, and the face corresponding to the minimum value can be selected as the irradiation surface; the vertical distance between the center of the area beam and the irradiation surface can be calculated, which is the "distance between the area beam and the irradiation surface".
[0049] In this embodiment, if the direction of the area light is parallel to the normal vector of the irradiated surface (orthogonal scene), the distance is the direct distance from the edge point of the area light to the irradiated surface; if it is a non-orthogonal scene, the distance between the nearest point and the intersection point needs to be calculated by the ray intersection method.
[0050] Step S1022: Calculate the illumination intensity at the edge points of the illumination range of the area light based on the distance and the preset illumination intensity threshold.
[0051] In this embodiment, the preset light intensity threshold refers to the lowest effective value of light intensity set manually (denoted as I). ε When the light intensity at a certain location is lower than a certain threshold, that location is determined to be outside the area light illumination range and without effective illumination. This is a key criterion for dividing the "illuminated area" and the "unilluminated area," and can be manually adjusted according to actual rendering needs. The illumination range of the area light refers to the area where the PBVR area light can effectively illuminate the medical image volume data. It is defined by the illumination range angle and distance, and is divided into a non-attenuating light intensity region (light intensity remains at its maximum) and an attenuating light intensity region (light intensity decreases with increasing distance). It is the core basis for calculating the Raycast directional light illumination distribution.
[0052] In this embodiment, a preset light intensity threshold I is used. ε (Users can adjust this according to rendering accuracy requirements, such as relative values like 0.1, 0.2, etc.); Based on the distance between the area light and the illuminated surface, derive the distance from the edge point of the area light to the illuminated surface (denoted as EF); According to the basic law of light intensity attenuation (light intensity is inversely proportional to the square of the distance), calculate the light intensity at the edge point: Formula: I 边缘 = I 最强 / (EF)²; where I 最强 EF is the maximum illumination intensity at the center of the area beam, and EF is the distance between the edge point and the illuminated surface.
[0053] Step S1023: Calculate the illumination range angle of the area light based on the illumination intensity of the edge point and the strongest illumination intensity of the area light.
[0054] In this embodiment, the illumination range angle of the area light refers to the angle between the edge light rays and the center light rays of the area light illumination range (denoted as θ), which reflects the degree of divergence of the area light illumination. It is calculated from the strongest illumination intensity of the area light and the illumination intensity of the edge point, and is a key parameter for determining the attenuation region and the non-attenuation region.
[0055] In this embodiment, the edge point illumination intensity and the strongest area illumination intensity are extracted; the illumination range angle θ is derived using trigonometric relationships. Figure 4 This is a schematic diagram of an orthogonal scene between an area beam and an irradiated surface, provided in an embodiment of this application. Figure 4As shown in the figure, AE represents the edge of the area light, CD represents the area illuminated by the area light, MQNP represents the 3D bounding box, and after calculating EF, the length of ED is... The light source intensity at point D is , according to It is possible to obtain .
[0056] In this embodiment, the light intensity ratio reflects the energy ratio of the edge rays to the center rays. It is converted into an angle value using an inverse cosine function to accurately characterize the illumination divergence range of the area light. After calculation, the θ value determines the conical boundary of the area light illumination; the larger θ is, the wider the illumination range.
[0057] Step S1024: Determine the light intensity attenuation region and the light intensity non-attenuation region based on the irradiation range angle.
[0058] In this embodiment, the non-attenuation region of illumination intensity refers to the area within the illumination range of the area light where the illumination intensity remains at its maximum value (i.e., the strongest illumination intensity of the area light). Illumination points within this region do not require illumination attenuation calculations, and the illumination effect is consistent with the center of the area light. The illumination attenuation region refers to the area within the illumination range where the illumination intensity gradually decreases with increasing distance from the center of the non-attenuation region. Illumination points within this region need to have their illumination intensity calculated using a specific formula to simulate the cone-shaped illumination characteristic of the area light, characterized by a bright center and dark edges. See also... Figure 4 If orthogonal BC and FD are attenuation regions, then BF is a non-attenuation region of light intensity. Figure 5 This application provides a schematic diagram of a non-orthogonal scene between an area light and an illuminated surface, as shown in the embodiments of this application. Figure 5 As shown, MG and FH are the attenuation regions, and FG is the non-attenuation region.
[0059] In this embodiment, a circle can be drawn with the projection of the area light center onto the irradiated surface as the center and the "non-attenuation region radius Rp" as the radius (Rp is derived from the irradiation range angle θ and the volume data bounding box size); the area inside the circle is determined as the non-attenuation region of illumination intensity: the illumination intensity at the irradiated point in this region maintains the strongest illumination intensity of the area light (I 最强 No attenuation calculation is required; the area from outside the circle to the boundary of the illumination range is determined as the light intensity attenuation area: the light intensity of the illumination point in this area decreases with increasing distance, and the actual light intensity needs to be calculated by subsequent formulas; the area outside the boundary of the illumination range is determined as the no-light area: the light intensity is 0, and there is no effective light contribution.
[0060] Step S1025: Determine the illumination intensity of the directional light illuminating the first layer of volume data in the medical image volume data based on the illumination intensity attenuation region and the illumination intensity non-attenuation region.
[0061] In this embodiment, the first layer of volume data refers to the set of voxels (denoted as Smin) that is closest to the Raycast directional light in the three-dimensional bounding box of the medical image volume data. It is the initial layer for illumination transmission during Raycast rendering and the core layer for calculating the intensity of the directional light.
[0062] In this embodiment, the first layer volume data (Smin) of the medical image volume data can be traversed, and the position of each irradiation point can be determined one by one: if the irradiation point is in a non-attenuation region: the irradiation intensity of the area light in the non-attenuation region of the light intensity is determined as the irradiation intensity of that irradiation point; if the irradiation point is in an attenuation region: the attenuation coefficient is calculated according to the position, and the irradiation intensity is dynamically calculated; if the irradiation point is in a no-illumination region: the irradiation intensity is assigned a value of 0. After completing the irradiation intensity calculation for all irradiation points of the first layer volume data, the Raycast directional light parameters that match the PBVR area light characteristics are obtained, ensuring that the first layer illumination effect of the two algorithms is consistent.
[0063] The method provided in this application accurately maps the cone-shaped illumination features of area light to Raycast directional light, making the illumination distribution of directional light (non-attenuation area, attenuation area, and no-light area) in the first layer volume data consistent with that of area light. This reduces the difference in light source features between the two algorithms, making the illumination effects of the first Raycast rendered image and the second PBVR rendered image similar, thereby improving the overall consistency and naturalness of the rendered image.
[0064] In some embodiments, the area light parameters further include: the direction and center of the area light, and the calculation of the directional light parameters based on the area light parameters for the volume rendering method based on ray casting includes: The direction of the area light is determined as the direction of the directional light, and the center of the area light is determined as the center of the directional light.
[0065] In this embodiment, the direction of the area beam refers to the propagation direction vector of the PBVR area beam (denoted as na), characterizing the directional nature of the area beam illumination. It is typically represented by a unit vector and determines the divergence direction of the illumination in three-dimensional space, directly affecting the spatial distribution characteristics of illumination on medical imaging data. The center of the area beam refers to the geometric center coordinates of the PBVR area beam (denoted as O), which is the core positioning point of the area beam. It determines the initial position of the illumination in three-dimensional space and is also the reference point for calculating illumination attenuation and illumination range. The direction of the directional beam refers to the propagation direction vector of the Raycast directional beam (denoted as nd), characterizing the illumination direction of the directional beam in three-dimensional space. Corresponding to the direction of the area beam, it is the core parameter determining the spatial distribution of Raycast illumination. The center of the directional beam refers to the geometric center coordinates of the Raycast directional beam (denoted as Od), which is the positioning reference point of the directional beam. Corresponding to the center of the area beam, it is used to determine the actual position of the directional beam in three-dimensional space.
[0066] In this embodiment, the PBVR area light direction vector na can be obtained; this vector is directly assigned to the Raycast direction light direction vector nd, that is, nd=na; after the assignment is completed, the illumination direction of the Raycast direction light is consistent with that of the PBVR area light, avoiding the deviation of the illumination angle caused by the difference in direction (such as the area light illuminating the left side of the data body obliquely, and the direction light also illuminating the left side obliquely at the same time).
[0067] In this embodiment of the application, the obtained PBVR area light center coordinates O can be directly assigned to the Raycast directional light center coordinates O. d That is, let O d =O; After the assignment is completed, the center position of the Raycast directional light is completely aligned with the PBVR area light, avoiding misalignment of the illumination coverage due to positional offset (e.g., if the center of the area light is aligned with the liver region of the volume data, the directional light is also aligned with that region simultaneously).
[0068] The method provided in this application embodiment completely unifies the direction and center of the Raycast directional light with the PBVR area light, fundamentally eliminating deviations in the spatial distribution of illumination. This ensures that the illumination direction and position of the light are completely consistent in the Raycast first rendered image and the PBVR second rendered image, providing a solid spatial foundation for the mixed rendering of the two rendering results and guaranteeing the spatial realism of the final target rendered image.
[0069] In some embodiments, step S1021 can be implemented by the following steps: Step S211: Determine whether the direction of the area light is orthogonal to the normal vector of the irradiated surface.
[0070] In this embodiment, the normal vector of the irradiated surface refers to the perpendicular direction vector of the irradiated surface (the surface closest to the area light in the medical image volume data bounding box) (denoted as...). The area beam (n) is a unit vector used to characterize the spatial orientation of the illuminated surface and is the core criterion for determining whether the area beam is orthogonal to the illuminated surface. Orthogonality refers to the direction vector n of the area beam. a The normal vector n of the irradiated surface l For two objects to be perpendicular, the mathematical criterion is that their dot product equals 0. At this point, the area light is in a state of "perpendicular illumination" of the irradiated surface, and all edge points are at the same distance from the irradiated surface.
[0071] In this embodiment, the vector dot product operation can be used to calculate... If the dot product result is equal to 0, it is determined to be an orthogonal scene, that is, the area light is perpendicular to the illuminated surface; if the dot product result is not equal to 0, it is determined to be a non-orthogonal scene, that is, the area light is oblique to the illuminated surface.
[0072] Step S212: When the direction of the area light is orthogonal to the normal vector of the irradiated surface, the distance from the edge point of the area light to the irradiated surface is determined as the distance between the area light and the irradiated surface.
[0073] In this embodiment, the edge point of the area light refers to any point on the geometric boundary of the PBVR area light. In an orthogonal scene, all edge points are equidistant from the illumination surface, and are direct reference points for calculating the distance between the area light and the illumination surface in that scene.
[0074] In this embodiment, any edge point on the geometric boundary of the PBVR area beam (such as the endpoint of the circular boundary of the area beam) can be selected and the three-dimensional coordinates of the point can be recorded. The distance formula from a spatial point to a plane is used to calculate the vertical distance from the edge point to the illumination surface (plane). Since the vertical distances from all edge points of the area beam to the illumination surface are completely equal in an orthogonal scene, the distance of the edge point is the distance between the area beam and the illumination surface, denoted as EF. Step S213: If the direction of the area light is not orthogonal to the normal vector of the irradiated surface, determine the point in the area light that is closest to the irradiated surface, draw a ray from the closest point along the direction of the area light, and determine the intersection point of the ray and the irradiated surface. The distance between the closest point and the intersection point is determined as the distance between the area light and the irradiated surface.
[0075] In this embodiment, when the beam is not orthogonal, the area beam "tilts" onto the irradiation surface. Different points on the area beam have different distances from the irradiation surface, requiring the calculation of the shortest distance using the ray intersection method. The point on the area beam closest to the irradiation surface refers to the point (denoted as point E) within the geometric range of the area beam in the non-orthogonal scenario, with the smallest straight-line distance to the irradiation surface. This is the reference point for distance calculation in this scenario and also the starting point for subsequent ray emission. A ray refers to an infinitely long straight line extending along the direction of the area beam from the closest point E in the non-orthogonal scenario, used to find the intersection point with the irradiation surface and thus calculate the shortest distance. The intersection point of the ray and the irradiation surface refers to the unique intersection point of the ray and the irradiation surface in the non-orthogonal scenario (denoted as point F). The straight-line distance between point E and point F is the shortest distance between the area beam and the irradiation surface in the non-orthogonal scenario.
[0076] In this embodiment of the application, see again Figure 5 It is possible to traverse all points within the geometric range of the PBVR area beam, calculate the perpendicular distance from each point to the irradiated surface, select the point with the smallest distance as the nearest point E, and record its three-dimensional coordinates. Starting from point E, an infinitely long ray is emitted along the direction vector of the area beam (consistent with the propagation direction of the PBVR area beam). The parametric equation of the ray can be expressed as: Substitute the ray parameter equation into the plane equation of the irradiated surface to solve for the value of parameter F. After substitution, the three-dimensional coordinates of the intersection point F are obtained. If the ray and the irradiated surface have no intersection (theoretically, they do not exist because the irradiated surface is the closest surface to the area light), then re-examine the selection of point E and the ray direction. The distance formula between two points in space can be used to calculate the straight-line distance between point E and point F. This distance is the "distance between the area light and the irradiated surface", denoted as EF.
[0077] The method provided in this application clearly distinguishes between orthogonal and non-orthogonal scenarios, offering dedicated distance calculation methods for each scenario. This covers all real-world spatial scenarios in medical image rendering, ensuring accurate calculation of the "distance between the area light and the illuminated surface" regardless of how the area light faces the irradiated surface. This avoids subsequent parameter calculation errors caused by distance deviations from the outset, providing a reliable foundation for light source parameter matching. In orthogonal scenarios, distance is calculated directly from edge points, eliminating the need for complex ray intersection calculations, simplifying the calculation process and improving efficiency. In non-orthogonal scenarios, a standardized process of "nearest point + ray intersection" ensures calculation accuracy while avoiding redundant calculations (only traversing key points of the area light to find the nearest point, rather than all points). This scenario-specific calculation logic guarantees the accuracy of distance calculations (meeting the high-precision requirements of medical image rendering) while controlling computational complexity, preventing excessive computation from affecting real-time rendering effects and adapting to the actual need for "instant rendering results" in medical image diagnosis.
[0078] In some embodiments, step S1025 can be implemented by the following steps: Step S251: Determine whether each irradiation point on the first layer of volume data in the medical image volume data is within the light intensity attenuation region.
[0079] In this embodiment, the first layer of volume data specifically refers to the set of voxels (denoted as Smin) closest to the Raycast directional light within the 3D bounding box of the medical image volume data. It is the initial layer for illumination transmission during Raycast rendering and the core layer for directional light intensity allocation; its intensity directly determines the lighting basis of the first rendered image. An illumination point refers to any spatial point on the first layer of volume data illuminated by the Raycast directional light. It is the smallest unit for intensity allocation, with each illumination point corresponding to one voxel. Its intensity directly determines the brightness of that voxel, thus affecting the detail rendering of the rendered image.
[0080] In this embodiment, the three-dimensional coordinate range of the first layer volume data (Smin) can be extracted based on the spatial range parameters of the determined light intensity attenuation region and the light intensity non-attenuation region (defined by the illumination range angle θ and the radius Rp of the non-attenuation region). All illumination points are traversed: each illumination point on the first layer volume data is traversed by Raycast direction light, and the three-dimensional coordinates of each illumination point are recorded. The three-dimensional coordinates of each illumination point are compared with the spatial ranges of the "attenuation region" and "non-attenuation region" to determine the region to which the illumination point belongs: if the illumination point coordinates fall within the spatial range of the non-attenuation region, it is determined as the first illumination point; if the illumination point coordinates fall within the spatial range of the attenuation region, it is determined as the second illumination point; if the illumination point coordinates fall outside both regions (no illumination region), it is subsequently treated as no illumination (light intensity is 0). The regional classification results of all illumination points (first / second illumination points) are stored for subsequent targeted allocation of light intensity.
[0081] Step S252: For each first illumination point located in the non-attenuation region of illumination intensity, the illumination intensity of the area light in the non-attenuation region of illumination intensity is determined as the illumination intensity of the corresponding first illumination point.
[0082] In this embodiment of the application, the first illumination point refers to the illumination point located in the non-attenuation region of the light intensity. This type of illumination point does not require light attenuation calculation and directly uses the constant light intensity of the area light. It is the illumination point corresponding to the brightest and clearest details in the first layer of volume data.
[0083] In this embodiment, the illumination intensity of the PBVR area light in the non-attenuation region can be read from the system; and this illumination intensity can be directly assigned to all first illumination points.
[0084] Step S253: For each second illumination point located in the light intensity attenuation region, the strongest light intensity of the area light is attenuated based on the position of the second illumination point to obtain the light intensity of each second illumination point.
[0085] In this embodiment of the application, the second illumination point refers to the illumination point located in the light intensity attenuation area. This type of illumination point needs to dynamically attenuate the strongest light intensity of the area light according to its own position and the distance from the non-attenuation area. Its light intensity decreases as the distance increases, simulating the light attenuation characteristics of a real light source.
[0086] In this embodiment of the application, the distance between each second illumination point and the center of the directional light can be determined; the radius of the non-attenuation region of the light intensity is subtracted from the distance to obtain the calculated value corresponding to each second illumination point; the strongest light intensity is divided by the square of the calculated value corresponding to each second illumination point to obtain the light intensity of each second illumination point.
[0087] In this embodiment of the application, the strongest illumination intensity (I) of the PBVR area light is read from the system. 最强 The radius (Rp) of the non-attenuation region is calculated, and the three-dimensional coordinates of each second irradiation point are read simultaneously. The straight-line distance between each second irradiation point and the center of the non-attenuation region is calculated and denoted as |pos. Center|; Subtract the radius Rp of the non-attenuation region from the above distance to obtain the attenuation calculation value corresponding to each second irradiation point, denoted as Length, i.e., Length = |pos Center| Rp; The light intensity at each second illumination point is calculated using the attenuation law that "light intensity is inversely proportional to the square of the distance". The core formula is: I pos =I 最强 / Length², where Ipos is the light intensity at the second illumination point, I 最强 is the strongest illumination intensity of the area light, and Length is the calculated attenuation value.
[0088] The method provided in this application accurately maps the illumination intensity distribution characteristics of PBVR area light to the first layer volume data of Raycast directional light: the first illumination point in the non-attenuation region retains the strongest illumination intensity of the area light, while the second illumination point in the attenuation region dynamically attenuates with distance, making the illumination distribution of Raycast directional light completely consistent with that of PBVR area light. This fundamentally eliminates the illumination effect deviation between the two rendering algorithms, ensuring seamless connection of the lighting visual effects of the first rendered image (Raycast) and the second rendered image (PBVR). Dynamic attenuation calculations are performed on the second illumination point, accurately simulating the cone-shaped attenuation characteristics of area light in the real world. This makes the lighting effect of the first layer volume data rendered by Raycast closer to the real physical scene, presenting a sense of hierarchy with "bright center and dark edges," making the first rendered image more closely resemble the real lighting performance of human anatomy. The combination with the high-quality PBVR rendered image is more natural, improving the realism and credibility of medical image rendering and providing more accurate visual support for clinical diagnosis. Raycast directional light has a completely consistent illumination intensity distribution with PBVR area light in the first layer volume data, ensuring a high match between the illumination details (brightness and darkness distribution, attenuation patterns) of the first and second rendered images. This avoids visual abrupt changes (such as a sudden brightening / darkening of a certain area) caused by illumination intensity distribution deviations during mixed rendering, ensuring a natural and visually coherent illumination transition in the target rendered image, which meets the continuity requirements of medical image observation.
[0089] In some embodiments, the method further includes: A dark region is determined based on the light intensity attenuation region and the light intensity non-attenuation region, wherein the light intensity of the illuminated point in the dark region is less than or equal to the light intensity threshold; the light intensity of the irradiated point corresponding to the dark region is determined to be 0.
[0090] In this embodiment, the unlit area refers to the area in the medical image data that is located outside the light intensity attenuation area and the light intensity non-attenuation area, and whose light intensity is less than or equal to a preset light intensity threshold. This area has no effective light contribution and is outside the boundary of the PBVR area light illumination range, corresponding to the area where Raycast directional light has no effective illumination.
[0091] In this embodiment, the spatial range parameters of the determined light intensity attenuation region and the light intensity non-attenuation region (defined by the illumination range angle θ, the radius Rp of the non-attenuation region, and the distance EF between the area light and the illumination surface) are simultaneously read from the preset light intensity threshold I. εThe regions with non-attenuated and attenuated light intensity are merged to form the effective illumination region of the PBVR area light, and the spatial coordinate range of this region is defined (i.e., the cone-shaped region covered by the illumination range angle θ). In the medical image volume data, all regions located "outside the spatial range of the effective illumination region" are initially identified as unilluminated regions. The light intensity of the illumination points corresponding to all unilluminated regions is uniformly determined to be 0, that is, these illumination points have no effective light contribution, and the voxels appear in the darkest state (fitting the real unilluminated scene).
[0092] The method provided in this application defines the illumination intensity of the unlit area as 0, so that the illumination distribution of the Raycast directional light (the effective illuminated area has a gradient, and the unlit area has no light) is more consistent with the PBVR area light, eliminating the rendering deviation caused by improper setting of the unlit area, and ensuring seamless connection of the lighting visual effects of the first rendered image (Raycast) and the second rendered image (PBVR).
[0093] In some embodiments, step S105 can be implemented by the following steps: Step S1051: For the second rendered image of the Nth rendering, multiply the first rendered image by the corresponding first weight and add the second rendered image by the corresponding second weight to obtain the target rendered image of the Nth rendering.
[0094] In this embodiment, the second rendered image in the Nth rendering refers to the rendered image obtained after the Nth iteration accumulation in the PBVR rendering process (N is a positive integer, N≥1). The first weight (denoted as W1) refers to the weight value assigned to the first rendered image (Raycast rendering result) in the Nth rendering during hybrid rendering. It is used to control the contribution ratio of the first rendered image in the Nth target rendered image, with a value range of 0 < W1 < 1. Its core function is to highlight the "noise-free" advantage of the first rendered image during the initial iteration of PBVR (when there is a lot of noise). The second weight (denoted as W2) refers to the weight value assigned to the Nth second rendered image (PBVR intermediate result) in the Nth rendering during hybrid rendering. It is used to control the contribution ratio of the PBVR intermediate result in the Nth target rendered image, with a value range of 0 < W2 < 1, and satisfies W1 + W2 = 1 (the total weight is 1, ensuring balanced illumination without excessive brightness or darkness).
[0095] In this embodiment, the system reads the cached first rendered image and the second rendered image (Nth second rendered image) obtained by the Nth iteration of PBVR. Simultaneously, it reads the preset first weight (W1) and second weight (W2), where W1 + W2 = 1 (e.g., W1 = 0.8, W2 = 0.2). A pixel-level weighted summation method is used to perform a mixed calculation on the first rendered image and the Nth second rendered image. The core formula is: Nth target rendered image = First rendered image × W1 + Nth second rendered image × W2. The brightness value of each pixel is obtained by multiplying the brightness value of the corresponding pixel in the first rendered image by W1, and then adding the brightness value of the corresponding pixel in the Nth second rendered image by W2, ultimately obtaining the brightness value of that pixel in the Nth target rendered image, ensuring a smooth transition for each pixel. The calculated Nth target rendered image is output (for temporary observation by the doctor) and simultaneously stored in the system as a reference for the subsequent N+1th mixed rendering, ensuring the continuity of the iteration process. Step S1052: For the second rendered image of the N+1th rendering, multiply the first rendered image by the corresponding third weight and add the second rendered image by the corresponding fourth weight to obtain the target rendered image of the N+1th rendering, wherein the first weight is greater than the third weight and the second weight is less than the fourth weight.
[0096] In this embodiment, the second rendered image in the (N+1)th rendering refers to the rendered image obtained after the (N+1)th iteration accumulation in the PBVR rendering process. It is an intermediate result after further iteration to eliminate noise based on the result of the Nth rendering. Its noise level is lower than that of the second rendered image in the Nth rendering, and its image detail clarity is higher than that of the Nth result. The third weight refers to the weight value (denoted as W3) assigned to the first rendered image in the (N+1)th rendering in the hybrid rendering. Its value range is 0 < W3 < 1, and it satisfies W3 < W1 (the first weight is greater than the third weight). Its core function is to gradually reduce the contribution ratio of the first rendered image as the number of PBVR iterations increases and the noise decreases. The fourth weight refers to the weight value (denoted as W4) assigned to the second rendered image in the (N+1)th rendering in the hybrid rendering. Its value range is 0 < W4 < 1, and it satisfies W4 > W2 and W3 + W4 = 1 (the second weight is less than the fourth weight). Its core function is to gradually increase the contribution ratio of the PBVR rendering result as the number of PBVR iterations increases and the image quality improves.
[0097] In this embodiment, the first rendered image cached in the system is read, and the second rendered image obtained by the (N+1)th iteration of PBVR is read (the noise of the (N+1)th second rendered image is less than that of the Nth iteration); at the same time, the preset third weight (W3) and fourth weight (W4) are read to ensure that W3 < W1, W4 > W2, and W3 + W4 = 1 (e.g., W3 = 0.6, W4 = 0.4); weighted summation calculation: a mixed calculation method with pixel-level weighted summation is adopted, and the core formula is: the (N+1)th target rendered image = the first rendered image × W3 + the (N+1)th second rendered image × W4. The logic is the same as the Nth calculation, but the weights are adjusted—the contribution of the first rendered image is reduced (W3 < W1), and the contribution of the PBVR rendering result is increased (W4 > W2), so that the detail clarity of the N+1th target rendered image is higher than that of the Nth, and the noise is lower than that of the Nth. The above steps are repeated until the PBVR iteration is completed (noise is eliminated to meet clinical needs). At this time, the weights of the last mixed rendering are set to W1 close to 0 and W4 close to 1 (e.g., W1=0.1, W4=0.9), and finally a noise-free, high-quality target rendered image is obtained.
[0098] In this embodiment, the weight adjustment follows the rule that the more iterations there are, the lower the weight of the first rendered image and the higher the weight of the second rendered image in PBVR. The weight gradient can be preset according to the PBVR iteration speed and noise elimination efficiency, or it can be dynamically adjusted according to the actual rendering effect to ensure a smooth transition without abrupt changes.
[0099] The method provided in this application, through dynamic weight adjustment, gradually reduces the weight of the first rendered image and increases the weight of the second rendered image in the PBVR for the Nth and N+1th iterations. This allows the target rendered image to gradually transition from "primarily based on Raycast noise-free features" to "primarily based on PBVR high-quality features." The transition is natural and without visual discontinuities, completely eliminating the visual abruptness caused by switching between the two rendering algorithms and improving the continuity and comfort of medical image observation. Through dynamic weight adjustment, in the early iterations of PBVR (when there is a lot of noise), the first rendered image (noise-free) is prioritized to mask the noise of PBVR; in the later iterations of PBVR (when there is less noise and clearer details), the second rendered image in PBVR is prioritized to highlight the high-quality advantages. The entire hybrid rendering process avoids initial noise interference while ensuring the clarity of details in the final rendered image, balancing the needs of noise-free and high-quality clinical diagnosis.
[0100] In some embodiments, step S103 can be implemented by the following steps: Step S1031: Calculate the illumination and shadow information and indirect illumination information of each voxel in the medical image volume data based on the directional light parameters.
[0101] In this embodiment, a voxel is the smallest unit of medical image volume data. It is a basic unit with a fixed volume and grayscale value in three-dimensional space (which can be understood as "pixels of a three-dimensional image"). Each voxel corresponds to a tiny area of human tissue, and its grayscale value reflects the density of the tissue in that area (e.g., the grayscale value of bone voxels is higher than that of soft tissue). It is the core processing object of Raycast rendering. Lighting and shadow information: refers to the shadow-related data generated by each voxel under directional light illumination due to occlusion by other voxels. It includes three core dimensions: shadow intensity, shadow range, and shadow softness. It is used to simulate the characteristic of "occlusion producing shadows" in real lighting, and improve the sense of layering and three-dimensionality of the rendered image. Indirect lighting information: refers to the light energy data that is transmitted to other voxels after directional light illuminates the medical image volume data and is reflected and scattered by voxels. It is different from the direct lighting generated by direct directional light illumination. It is used to simulate the "soft lighting brought by light reflection" in real scenes, avoid the problem of "overly harsh contrast between light and dark" in the rendered image, and improve the realism.
[0102] In this embodiment, the calculated directional light parameters (direction, center, and illumination intensity distribution) are read from the system, and the voxel information (three-dimensional coordinates, grayscale value, and density parameters of each voxel) of the medical image volume data is also read. For each voxel, a shadow detection ray is emitted in the opposite direction of the directional light to determine whether the ray will be occluded by other voxels (i.e., whether the voxel is within the "shadow range" of other voxels). If the voxel is occluded, the shadow intensity is calculated based on the density (grayscale value) of the occluded voxel—the higher the density of the occluded voxel, the stronger the shadow intensity (the lower the voxel brightness). If it is not occluded, the shadow intensity is 0 (no shadow). Combined with the illumination range angle of the directional light, the shadow edge is softened to avoid the shadow edge being too sharp, improve the rendering realism, and ensure that the shadow range is consistent with the illumination range of the PBVR area light, thereby obtaining the illumination and shadow information.
[0103] In the embodiments of this application, the direct illumination intensity of the directional light received by each voxel can be calculated first. For each voxel, the illumination energy reflected and scattered by the surrounding voxels is calculated—the higher the density of the surrounding voxels and the closer the distance, the stronger the reflected / scattered illumination energy and the higher the indirect illumination intensity. The indirect illumination intensity is superimposed with the direct illumination intensity to obtain the total illumination base data of each voxel, while ensuring that the distribution of indirect illumination is consistent with the direction and center of the directional light. The illumination and shadow information (shadow intensity and range) and indirect illumination information (indirect illumination intensity) of each voxel are associated and stored with the voxel coordinates to provide complete illumination data support for subsequent rendering.
[0104] Step S1032: Render the first rendered image based on the lighting and shadow information and the indirect lighting information combined with the lighting model.
[0105] In this embodiment, the lighting model refers to the mathematical model used to calculate the final brightness value of voxels. It integrates direct lighting, lighting and shadow information, and indirect lighting information, and converts various lighting data into voxel brightness values through standardized formulas. It is the core algorithm foundation of Raycast rendering and is adapted to the high-precision requirements of medical image volume rendering.
[0106] In this embodiment, a suitable lighting model for medical image volume rendering (such as the Phong lighting model or the Blinn-Phong lighting model) can be selected. This model needs to support the integrated calculation of direct lighting, shadows, and indirect lighting, accurately map the lighting characteristics of voxels, and conform to the lighting performance of human anatomical tissues. The direct lighting intensity, lighting and shadow information (shadow intensity), and indirect lighting information (indirect lighting intensity) of each voxel are input into the lighting model. The final brightness value of each voxel is calculated using a standardized formula. A rendering ray is emitted along a preset observation direction, penetrates the medical image volume data, and the brightness of the voxels on the ray is sampled. The sampled voxel brightness values are synthesized according to a certain weight to obtain the pixel brightness values of the two-dimensional image. The synthesized two-dimensional image is slightly denoised (without affecting the noise-free core features) and brightness equalized to ensure that the image has no obvious light and dark banding and matches the brightness range of the second rendering image in PBVR. After processing, the output is the first rendering image, which is also cached in the system for subsequent hybrid rendering.
[0107] The method provided in this application simulates the characteristics of "occlusion and shadow, light reflection" in real physical lighting by calculating the lighting and shadow information and indirect lighting information of each voxel. This allows the first rendered image to not only maintain the advantage of being noise-free, but also to have clear shadow levels and smooth lighting transitions. It can accurately present the spatial levels of human anatomical tissues (such as shadows generated by bones occluding soft tissues and light reflection between tissues), significantly reducing the quality gap with the second rendered image in PBVR, and providing a better foundation for a smooth transition in hybrid rendering.
[0108] Figure 6 A schematic diagram illustrating the implementation flow of a rendering method provided in this application is shown below. Figure 6 The above includes: Step S601: Load data.
[0109] In this embodiment of the application, the loaded data is medical image data.
[0110] Step S602: Prepare rendering parameters.
[0111] In this embodiment of the application, the rendering parameters include: area light parameters.
[0112] Step S603: Calculate the parameters of the Raycast_IVL light source.
[0113] In this embodiment, the parameters of the Raycast_IVL light source are the same as the directional light parameters in the above embodiments.
[0114] In this embodiment of the application, the process of calculating the parameters of the light source is as follows: Find the face closest to the area light from the six faces of the volume data bounding box, such as... Figure 4 or Figure 5 As mentioned above, MQ represents the left face of the bounding box, which is closest to the area light beam; this is denoted as the irradiated face. The determination of whether the area light beam and the irradiated face are orthogonal is made. The direction of the area light beam is denoted as... The normal vector of the irradiated surface is denoted as ,if Then the area light and volume data are orthogonal. For example... Figure 4 As shown, the dot product of the direction of the area beam and the normal vector of MQ is 0, therefore the area beam and the volume data are orthogonal. From Figure 4 From this, we can see that CD represents the area illuminated by the area beam. If BC and FD are orthogonal, they form the attenuation region; otherwise, MG and FH are the attenuation region. Define the angle FED as the illumination range angle, denoted as θ, and denote the length of ED as d. If the area beam and the illuminated surface are orthogonal, such as... Figure 4 As shown, all points on the area light are equidistant from the illuminated surface. Calculate the distance EF from edge point E to the illuminated surface. Let the vector from point M to the center O of the area light source be... ,but If the area light and the illuminated surface are not orthogonal, such as Figure 5 As shown, find the point where the area light source is closest to the illuminated surface, such as... Figure 5 From point E, define a ray along the direction of the light source. Calculate the intersection of this ray and the illuminated surface, denoted as point F. Define a plane (denoted as S) parallel to the area light source, passing through point F. The normal vector of this plane has the same direction as the area light source. As shown in the figure, FH and GM are the attenuation regions. The length of EF is calculated as follows: define the vector from the origin to point M as... ,definition The coordinates of point F are calculated as follows: Define the vector from the origin to point F as Then the following equation is satisfied at point F. ,Right now It can be calculated Based on this, the calculation is as follows: .
[0115] After determining the distance, calculate the illumination range angle: from Figure 5 It can be seen from the middle The light source intensity at point D is , according to It is possible to obtain Based on the orthogonal and non-orthogonal cases described above, the non-attenuation regions BF and GF can be calculated. The center of the non-attenuation region is defined as Center. Once the illumination range angle is calculated, the attenuation region is also determined. In some embodiments, where the area light source and the illumination surface are not orthogonal, the entire non-attenuation region (i.e., GF) exists on the illumination surface. In actual scenarios, the following two situations also exist... Figure 7 This is a schematic diagram of a non-orthogonal scene between an area beam and an irradiated surface, provided in an embodiment of this application. The non-attenuation region is outside the irradiated surface, and MH is the attenuation region. Figure 8 This is a schematic diagram of a non-orthogonal scene between an area light and an irradiated surface, provided in an embodiment of this application. The non-attenuation region is partly inside the irradiated surface and partly outside the irradiated surface. In this case, MF is the non-attenuation region and FH is the attenuation region.
[0116] During the IVL calculation process, the light is first transmitted to Smin (i.e., the first layer), and then transmitted layer by layer to Smax. During the transmission process, shadow information and indirect lighting information are calculated based on the opacity and color of the voxels. Figure 9 This is a schematic diagram of light attenuation provided in an embodiment of this application, as shown below. Figure 9 As shown, based on the illumination range angle θ of the area light, the projection radius of the area light source on the illumination surface Rp=BF / 2 or Rp=GF / 2, and the center O of the area light source, the direction of the IVL direction light uses the direction of the area light, and the position of the light source is the center O of the area light source. When the light propagates to the Smin layer, it gradually attenuates outwards according to the projection radius and the Center. The attenuation formula is as follows: ,in Here, pos represents the coordinates of a point on the Smin layer. First, it's determined whether each point is within a radius of Rp centered at the center. If it is, the illumination intensity doesn't need to be attenuated. If it's outside this radius but within the attention area, the illumination intensity needs to be attenuated. If the point is outside the attention area, the illumination intensity is 0. Through this calculation, the illumination intensity of IVL can gradually decrease from the center outwards.
[0117] Step S604: Calculate IVL cache data.
[0118] Step S605: Start Raycast rendering.
[0119] Step S606: Begin PBVR rendering.
[0120] The method provided in this application applies the light source characteristics of PBVR to Raycast_IVL. Based on the direction of the area light source and the possible illumination range, the light source intensity and direction of Raycast_IVL are determined, eliminating the need for users to manually adjust the light source of Raycast_IVL and optimizing user operation. Based on the conical characteristics of area light, the attenuation coefficient of Raycast_IVL light source intensity is determined. After attenuation calculation along the central axis, Raycast_IVL also has a conical intensity characteristic. When illuminating, the light farther from the center will be weakened, which better matches the light source of real scene.
[0121] It should be understood that the sequence number of each step in the above embodiments does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.
[0122] According to the foregoing embodiments, this application provides a rendering device. The modules and units included in the device can be implemented by a processor in a computer device; of course, they can also be implemented by specific logic circuits. In the implementation process, the processor can be a central processing unit (CPU), a microprocessor (MPU), a digital signal processor (DSP), or a field programmable gate array (FPGA), etc.
[0123] This application provides a rendering device. Figure 10 This is a schematic diagram of the structure of a rendering device provided in an embodiment of this application, such as... Figure 10 As shown, the rendering device 1000 includes: The acquisition module 1001 is used to acquire the volume data of the medical image to be rendered and the area lighting parameters of the physically based volume rendering method. Calculation module 1002 is used to calculate the directional light parameters of the volume rendering method based on ray projection based on the area light parameters, wherein the similarity between the directional light parameters and the area light parameters is greater than or equal to a similarity threshold. The first rendering module 1003 is used to render the medical image volume data based on the directional light parameters using a volume rendering method of ray projection, to obtain a first rendered image, and to cache the first rendered image. The second rendering module 1004 is used to render the medical image volume data based on the area light parameters using a physically based volume rendering method to obtain a second rendered image. The hybrid rendering module 1005 is used to perform hybrid rendering based on the first rendered image and the second rendered image to obtain the target rendered image.
[0124] In some embodiments, the area light parameters include: the illuminance of the area light, and the calculation module includes: The first determining unit is used to determine the distance between the area light and the irradiated surface, wherein the irradiated surface is the surface in the medical image volume data bounding box that is closest to the area light; The first calculation unit is used to calculate the illumination intensity at the edge points of the illumination range of the area light based on the distance and a preset illumination intensity threshold. The second calculation unit is used to calculate the illumination range angle of the area light based on the illumination intensity of the edge point and the strongest illumination intensity of the area light; The second determining unit is used to determine the light intensity attenuation region and the light intensity non-attenuation region based on the irradiation range angle. The third determining unit is used to determine the illumination intensity of the directional light illuminating the first layer of volume data in the medical image volume data based on the illumination intensity attenuation region and the illumination intensity non-attenuation region.
[0125] In some embodiments, the area light parameters further include: the direction and center of the area light, and the calculation of the directional light parameters based on the area light parameters for the volume rendering method based on ray casting includes: The direction of the area light is determined as the direction of the directional light, and the center of the area light is determined as the center of the directional light.
[0126] In some embodiments, the first determining unit includes: The first determining subunit is used to determine whether the direction of the area light is orthogonal to the normal vector of the irradiated surface; The second determining subunit is used to determine the distance from the edge point of the area light to the irradiation surface as the distance between the area light and the irradiation surface when the direction of the area light is orthogonal to the normal vector of the irradiation surface. The third determining subunit is used to determine the point in the area light that is closest to the irradiation surface when the direction of the area light is not orthogonal to the normal vector of the irradiation surface, draw a ray from the closest point along the direction of the area light, determine the intersection point of the ray and the irradiation surface, and determine the distance between the closest point and the intersection point as the distance between the area light and the irradiation surface.
[0127] In some embodiments, determining the illumination intensity of the directional light illuminating the first layer of volume data in the medical image volume data based on the illumination intensity attenuation region and the illumination intensity non-attenuation region includes: Determine whether each irradiation point on the first layer of volume data in the medical image volume data is within the light intensity attenuation region when the directional light is irradiated by the directional light. For each first illumination point located in the non-attenuation region of illumination intensity, the illumination intensity of the area light in the non-attenuation region of illumination intensity is determined as the illumination intensity of the corresponding first illumination point. For each second illumination point located in the light intensity attenuation region, the strongest light intensity of the area light is attenuated based on the position of the second illumination point to obtain the light intensity of each second illumination point.
[0128] In some embodiments, attenuating the strongest illumination intensity of the area light based on the position of the second illumination point to obtain the illumination intensity of each second illumination point includes: Determine the distance between each second illumination point and the center of the directional light; Subtract the radius of the non-attenuated light intensity region from the distance to obtain the calculated value corresponding to each second irradiation point; The light intensity of each second irradiation point is obtained by dividing the strongest light intensity by the square of the calculated value corresponding to each second irradiation point.
[0129] In some embodiments, the computing module further includes: The fourth determining unit is used to determine a dark region based on the light intensity attenuation region and the light intensity non-attenuation region, wherein the light intensity of the light point in the dark region is less than or equal to the light intensity threshold. The fifth determining unit is used to determine the light intensity of the irradiation point corresponding to the dark area as 0.
[0130] In some embodiments, the hybrid rendering module includes: The first rendering unit is used to multiply the first rendering image by a corresponding first weight and add the second rendering image by a corresponding second weight to the second rendering image rendered for the Nth time, so as to obtain the target rendering image rendered for the Nth time. The second rendering unit is used to multiply the first rendering image by the corresponding third weight and add the second rendering image by the corresponding fourth weight for the second rendering image of the N+1th rendering, to obtain the target rendering image of the N+1th rendering, wherein the first weight is greater than the third weight, the second weight is less than the fourth weight, and N≥1.
[0131] It should be noted that the information interaction and execution process between the above-mentioned devices / units are based on the same concept as the method embodiments of this application. For details on their specific functions and technical effects, please refer to the method embodiments section, and they will not be repeated here.
[0132] In addition, the rendering device described above can be a software unit, a hardware unit, or a combination of software and hardware. It can also be integrated into electronic devices as an independent component, or exist as an independent terminal device.
[0133] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is merely an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit. Furthermore, the specific names of the functional units and modules are only for easy differentiation and are not intended to limit the scope of protection of this application. The specific working process of the units and modules in the above system can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.
[0134] Figure 11 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Figure 11 As shown, the electronic device of this embodiment may include: at least one processor 30 ( Figure 11 Only one processor 30, memory 31, and computer program 32 stored in memory 31 and executable on at least one processor 30 are shown. When the processor 30 executes the computer program 32, it implements the steps in any of the above method embodiments, or the processor 30 executes the computer program 32 to implement the functions of each module / unit in the above device or system embodiments.
[0135] For example, computer program 32 may be divided into one or more modules / units, one or more of which are stored in memory 31 and executed by processor 30 to complete this application. One or more modules / units may be a series of computer program 32 instruction segments capable of performing a specific function, which describe the execution process of computer program 32 in an electronic device.
[0136] This application also provides a computer-readable storage medium storing a computer program 32, which, when executed by a processor 30, implements the steps described in the above-described method embodiments.
[0137] This application provides a computer program product that, when run on an electronic device, enables the electronic device to perform the steps described in the various method embodiments above.
[0138] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the methods of the above embodiments of this application can be implemented by a computer program 32 instructing related hardware. The computer program 32 can be stored in a computer-readable storage medium, and when executed by the processor 30, it can implement the steps of the various method embodiments described above. The computer program 32 includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable medium can include at least: any entity or device capable of carrying computer program code to a terminal, a recording medium, a computer memory, a read-only memory (ROM), a random access memory (RAM), electrical carrier information, telecommunication information, and a software distribution medium. Examples include USB flash drives, portable hard drives, magnetic disks, or optical disks.
[0139] In the above embodiments, the descriptions of each embodiment have different focuses. For parts that are not described in detail or recorded in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0140] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0141] In the embodiments provided in this application, it should be understood that the disclosed apparatus / network devices and methods can be implemented in other ways. For example, the apparatus / network device embodiments described above are merely illustrative. For instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.
[0142] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0143] The above-described embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application, and should all be included within the protection scope of this application.
Claims
1. A rendering method, characterized in that, include: Acquire the volumetric data of the medical image to be rendered and the area lighting parameters of the physically based volume rendering method; Based on the area light parameters, the directional light parameters of the volume rendering method based on ray casting are calculated, wherein the similarity between the directional light parameters and the area light parameters is greater than or equal to a similarity threshold. The medical image volume data is rendered using a ray projection volume rendering method based on the directional light parameters to obtain a first rendered image; The medical image volume data is rendered using a physically based volume rendering method based on the area light parameters to obtain a second rendered image. The target rendered image is obtained by performing a hybrid rendering based on the first rendered image and the second rendered image.
2. The method according to claim 1, characterized in that, The area light parameters include: the illumination intensity of the area light; the calculation of directional light parameters based on the area light parameters for the volume rendering method based on ray casting includes: Determine the distance between the area beam and the irradiated surface, wherein the irradiated surface is the surface within the medical image volume data bounding box that is closest to the area beam; The illumination intensity at the edge points of the area light's illumination range is calculated based on the distance and a preset illumination intensity threshold. Based on the illumination intensity at the edge point and the strongest illumination intensity of the area light, calculate the illumination range angle of the area light; The regions of light intensity attenuation and non-attenuation are determined based on the irradiation range angle. The illumination intensity of the directional light illuminating the first layer of volume data in the medical image volume data is determined based on the light intensity attenuation region and the light intensity non-attenuation region.
3. The method according to claim 1, characterized in that, The area light parameters include: the direction and center of the area light. The calculation of directional light parameters based on the area light parameters for a volume rendering method using ray casting includes: The direction of the area light is determined as the direction of the directional light, and the center of the area light is determined as the center of the directional light.
4. The method according to claim 2, characterized in that, The determination of the distance between the area light and the irradiated surface includes: Determine whether the direction of the area light is orthogonal to the normal vector of the irradiated surface; When the direction of the area light is orthogonal to the normal vector of the irradiated surface, the distance from the edge point of the area light to the irradiated surface is determined as the distance between the area light and the irradiated surface; When the direction of the area light is not orthogonal to the normal vector of the irradiated surface, determine the point in the area light that is closest to the irradiated surface, draw a ray from the closest point along the direction of the area light, and determine the intersection point of the ray and the irradiated surface. The distance between the closest point and the intersection point is determined as the distance between the area light and the irradiated surface.
5. The method according to claim 2, characterized in that, Determining the illumination intensity of the directional light illuminating the first layer of volume data in the medical image volume data based on the illumination intensity attenuation region and the illumination intensity non-attenuation region includes: Determine whether each irradiation point on the first layer of volume data in the medical image volume data is within the light intensity attenuation region when the directional light is irradiated by the directional light. For each first illumination point located in the non-attenuation region of illumination intensity, the illumination intensity of the area light in the non-attenuation region of illumination intensity is determined as the illumination intensity of the corresponding first illumination point. For each second illumination point located in the light intensity attenuation region, the strongest light intensity of the area light is attenuated based on the position of the second illumination point to obtain the light intensity of each second illumination point.
6. The method according to claim 5, characterized in that, The attenuation of the strongest illumination intensity of the area light based on the position of the second illumination point to obtain the illumination intensity of each second illumination point includes: Determine the distance between each second illumination point and the center of the directional light; Subtract the radius of the non-attenuated light intensity region from the distance to obtain the calculated value corresponding to each second irradiation point; The light intensity of each second irradiation point is obtained by dividing the strongest light intensity by the square of the calculated value corresponding to each second irradiation point.
7. The method according to claim 2, characterized in that, The method further includes: A dark region is determined based on the light intensity attenuation region and the light intensity non-attenuation region, wherein the light intensity of the illuminated points in the dark region is less than or equal to the light intensity threshold. The light intensity at the illumination point corresponding to the dark area is set to 0.
8. The method according to claim 1, characterized in that, The step of obtaining the target rendered image by blending the first rendered image and the second rendered image includes: For the second rendered image in the Nth rendering, the first rendered image is multiplied by the corresponding first weight and the second rendered image is multiplied by the corresponding second weight to obtain the target rendered image in the Nth rendering. For the second rendered image in the (N+1)th rendering, the first rendered image is multiplied by the corresponding third weight and the second rendered image is multiplied by the corresponding fourth weight to obtain the target rendered image in the (N+1)th rendering, wherein the first weight is greater than the third weight and the second weight is less than the fourth weight, and N≥1.
9. A rendering apparatus, characterized in that, include: The acquisition module is used to acquire the volume data of the medical image to be rendered and the area lighting parameters of the physically based volume rendering method. The calculation module is used to calculate the directional light parameters of the volume rendering method based on ray projection based on the area light parameters, wherein the similarity between the directional light parameters and the area light parameters is greater than or equal to a similarity threshold. The first rendering module is used to render the medical image volume data based on the directional light parameters using a volume rendering method of ray projection to obtain a first rendered image. The second rendering module is used to render the medical image volume data based on the area light parameters using a physically based volume rendering method to obtain a second rendered image. The hybrid rendering module is used to perform hybrid rendering based on the first rendered image and the second rendered image to obtain the target rendered image.
10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the method as described in any one of claims 1 to 8.
11. A computer storage medium, characterized in that, The computer-readable storage medium stores a computer program, characterized in that, when the computer program is executed by a processor, it implements the method as described in any one of claims 1 to 8.