Rendering method of distance field and electronic equipment
Through the rendering method of distance field, the three-dimensional grid model is used to divide the distance field in knee replacement surgery, which solves the problem of unreal-time image feedback in the prior art, and achieves high-precision and real-time surgical navigation.
Patent Information
- Application Number
- CN202411997495.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-31
- Publication Date
- 2025-05-06
AI Technical Summary
The prior art is difficult to meet the real-time nature of intraoperative image feedback in knee replacement surgery, the physical accuracy of three-dimensional textures is difficult to meet the requirements of the surgical navigation module, and the single shape change of the mesh Boolean operation takes a long time, making it difficult to meet the needs of real-time tracking and display.
Through the rendering method of the distance field, the distance field is divided by a three-dimensional grid model to realize the classification and display of colors of pixel points in the rendered image, so as to mark different areas of the target object. This method can ensure the real-time performance of intraoperative image feedback due to the fast rendering speed and calculation speed of distance fields and three-dimensional grids.
Real-time image feedback in knee replacement surgery is achieved, the accuracy and simplicity of surgical navigation is improved, and the high requirements for real-time and accuracy in the surgery are met.
Smart Images

Figure CN119941962A_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of rendering technology, and in particular, relates to a distance field rendering method and electronic device. Background Art
[0002] The knee joint is an important weight-bearing joint of the lower limbs, and its function and structure are the most complex of the human joints. Knee joint degeneration is a common disease among the elderly and those who do heavy manual labor. When the knee joint is severely degenerated, knee replacement is required. Knee replacement first requires the doctor to partially remove the bone according to the damaged bone area and the predetermined implant shape and size. Without computer assistance, the removal effect depends entirely on the doctor's clinical experience. Computer preoperative planning, real-time tracking and display during surgery can help doctors perform more accurate and simpler bone removal operations.
[0003] Among them, preoperative planning requires that the areas to be removed and to be retained be accurately separated. Intraoperative real-time tracking and display require the computer to track the doctor's operations in real time and provide feedback on the current status of the knee joint. Currently, triangular meshes or volume data based on three-dimensional textures are mostly used in clinical practice to represent human tissues including the knee joint. The physical accuracy of volume data depends on the size of the three-dimensional texture, which is usually difficult to meet the accuracy requirements in the surgical navigation module. The mesh can accurately express the model, and its shape transformation can also be achieved through Boolean operation simulation or real-time imaging. However, a single shape change of the mesh Boolean operation takes a long time, which is difficult to meet the real-time requirements of intraoperative feedback, while real-time imaging places higher requirements on hardware. Summary of the invention
[0004] The embodiments of the present application provide a distance field rendering method and electronic device, which can use a three-dimensional grid model to divide the distance field into regions, and realize the classification and display color of pixel points in the rendered image to mark different areas of the target object. Since the rendering speed and calculation speed of the distance field and the three-dimensional grid are fast, it helps to ensure the real-time nature of intraoperative image feedback.
[0005] A first aspect of an embodiment of the present application provides a distance field rendering method, comprising: obtaining a three-dimensional grid model and a first distance field of a target object, wherein each sub-grid in the three-dimensional grid model corresponds to a type of attribute information; rendering the first distance field to obtain a rendered image of the first distance field, wherein the display color of each pixel point of the rendered image of the first distance field is determined based on the attribute information of the sub-grid to which each pixel point belongs.
[0006] In some embodiments of the first aspect, it also includes: obtaining the display color of each pixel point, wherein obtaining the display color of each pixel point includes: determining the number of intersections of each pixel point, wherein the number of intersections of each pixel point refers to the number of intersections of the projection light of each pixel point and the first distance field; determining the display color of each pixel point according to the number of intersections of each pixel point and the attribute information of the sub-grid to which each pixel point belongs.
[0007] In some implementations of the first aspect, determining the display color of each pixel point according to the number of intersections corresponding to each pixel point and the attribute information of the sub-grid to which each pixel point belongs includes: if the number of intersections of the pixel point is greater than 0, for the pixel point, using the incident point of its projection light in the first distance field as the initial sampling point, and sampling according to the sampling step along the ray direction of the projection light until the sampling point satisfies: the sampling point is located on the surface of the distance field model of the target object, or the sampling point crosses the exit point of the projection light in the first distance field, or the sampling number exceeds a preset sampling number; for the pixel point whose sampling point is located on the surface of the distance field model of the target object, using the color associated with the attribute information of the sub-grid to which the pixel point belongs as the display color of the pixel point.
[0008] In some embodiments of the first aspect, the method further includes: if the number of intersections of the pixel point is 0; or the sampling point crosses the exit point of the projection light in the first distance field; or the sampling number exceeds a preset sampling number, then a preset color is used as the display color of the pixel point.
[0009] In some embodiments of the first aspect, the sampling is performed according to a sampling step along the ray direction of the projection light, including: determining a sampling method for the sampling point, the sampling method including a first method and a second method; wherein the sampling step adopted by the first method is the minimum distance between the sampling point and the surface of the distance field model of the target object; the sampling step adopted by the second method is a target step, and the target step is the distance between the sampling point and the exit point divided by the remaining number of iterations, and the remaining number of iterations is the difference between the preset sampling number and the sampling number; sampling is performed along the ray direction of the projection light according to the sampling step corresponding to the sampling method adopted by the sampling point.
[0010] In some implementations of the first aspect, determining the sampling method of the sampling point includes: determining a first threshold; if the sampling point is located inside the target object, or the minimum distance between the sampling point and the surface of the distance field model of the target object is greater than the first threshold, determining the first method as the method adopted by the sampling point.
[0011] In some implementations of the first aspect, determining the sampling method of the sampling point includes: if the sampling number is greater than a second threshold, and the number of times the first method is continuously used when sampling the sampling point is greater than a third threshold, determining the second method as the method adopted by the sampling point.
[0012] In some implementations of the first aspect, the method further includes: acquiring a fourth threshold, where the fourth threshold is associated with at least one of a size of the first distance field, a physical size corresponding to a single voxel of the first distance field, and a preset value; if the minimum distance between the sampling point and the surface of the distance field model of the target object is less than the fourth threshold, then the sampling point is located on the surface of the distance field model of the target object.
[0013] In some implementations of the first aspect, a sampling point depth of each first sampling point is obtained, where each first sampling point is the sampling point on the projection light of the pixel point corresponding thereto; for each sub-grid having a first grid fragment in the three-dimensional grid model, the number of grid fragments whose sampling depth of each first sampling point is greater than the depth of each first grid fragment is determined as the depth number; and attribute information of the sub-grid to which each pixel point belongs is determined according to the depth number; wherein the first grid fragment is the grid fragment through which the projection light of the pixel point corresponding thereto passes.
[0014] In some embodiments of the first aspect, determining the attribute information of the sub-grid to which each pixel point belongs according to the number of depths includes: if there is a single sub-grid whose depth number is an odd number in the three-dimensional grid model, using the attribute information of the sub-grid as the attribute information of the sub-grid to which the corresponding pixel point belongs; if there is no sub-grid whose depth number is an odd number in the three-dimensional grid model, determining the attribute information of the sub-grid to which the pixel point corresponding to each first sampling point belongs according to the positional relationship between the each first sampling point and the each first grid fragment.
[0015] In some embodiments of the first aspect, after displaying the rendered image, the method further includes: acquiring a second distance field of a force-applying object, wherein the force-applying object is used to cut the target object; performing a Boolean subtraction operation on the first distance field and the second distance field to obtain a result distance field, wherein the result distance field is used to characterize a model obtained after the force-applying object cuts the target object.
[0016] In some implementations of the first aspect, each voxel in the result distance field corresponds to a first distance, and the first distance refers to the minimum distance between each voxel in the result distance field and the surface of the distance field model of the target object; the method further includes: if it is determined to stop cutting the target object, converting the result distance field into a three-dimensional mesh model, determining a second distance according to a position of the three-dimensional mesh in the three-dimensional mesh model, and the second distance refers to the minimum distance between the voxel corresponding to each position in the three-dimensional mesh model and the surface of the distance field model of the target object; updating the first distance corresponding to the voxel in the result distance field whose difference between the first distance and the second distance is greater than a fifth threshold to the second distance.
[0017] A second aspect of an embodiment of the present application provides a distance field rendering device, comprising: a data acquisition unit, used to acquire a three-dimensional grid model and a first distance field of a target object, wherein each sub-grid in the three-dimensional grid model corresponds to a type of attribute information; a rendering unit, used to render the first distance field to obtain a rendered image of the first distance field, wherein the display color of each pixel point of the rendered image of the first distance field is determined based on the attribute information of the sub-grid to which each pixel point belongs.
[0018] A third aspect of an embodiment of the present application provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the steps of the distance field rendering method as described in any one of the first aspects are implemented.
[0019] A fourth aspect of an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the distance field rendering method are implemented.
[0020] A fifth aspect of an embodiment of the present application provides a computer program product. When the computer program product is run on an electronic device, the electronic device executes the steps of the above-mentioned distance field rendering method.
[0021] In an implementation of the present application, the target object is represented based on the distance field, and the distance field is divided into regions according to the attribute information of the sub-grids in the three-dimensional grid model, so that the pixels in the rendered image are classified and displayed in colors to mark different areas of the target object. Since the rendering speed and calculation speed of the distance field and the three-dimensional grid are fast, it helps to ensure the real-time nature of the intraoperative image feedback. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0023] Figure 1 is a two-dimensional schematic diagram of a distance field provided in an embodiment of the present application;
[0024] Figure 2 It is a schematic diagram of the implementation process of the distance field rendering method provided in an embodiment of the present application;
[0025] Figure 3 This is a schematic diagram of a first specific implementation process of determining a display color provided in an embodiment of the present application;
[0026] Figure 4 It is a schematic diagram of a second specific implementation process of determining a display color provided in an embodiment of the present application;
[0027] Figure 5 This is a schematic diagram of a specific implementation process of sampling provided in an embodiment of the present application;
[0028] Figure 6 It is a schematic diagram of a specific process of determining the attribute information of a sub-grid provided in an embodiment of the present application;
[0029] Figure 7 is a first schematic diagram of a grid model provided in an embodiment of the present application;
[0030] Figure 8 is a second schematic diagram of a grid model provided in an embodiment of the present application;
[0031] Fig. 9 is a third schematic diagram of a grid model provided in an embodiment of the present application;
[0032] Fig.10 It is a schematic diagram of a specific implementation process of light stepping provided in an embodiment of the present application;
[0033] Fig.11 It is a structural schematic diagram of a distance field rendering device provided in an embodiment of the present application;
[0034] Fig.12 It is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0035] In order to make the purpose, technical solutions and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not intended to limit the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work are protected by the present application.
[0036] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, wholes, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or combinations thereof.
[0037] In the description of the present application specification and the appended claims, the terms "first", "second", "third", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance.
[0038] References to "one embodiment" or "some embodiments" etc. described in the specification of this application mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Therefore, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.
[0039] Preoperative planning requires that the areas to be removed and to be retained be accurately separated. Intraoperative real-time tracking and display require the computer to track the doctor's operation in real time and provide feedback on the current status of the knee joint. Currently, triangular meshes or volume data based on three-dimensional textures are mostly used in clinical practice to represent human tissues including the knee joint. The physical accuracy of volume data depends on the size of the three-dimensional texture, which is usually difficult to meet the accuracy requirements in the surgical navigation module. The mesh can accurately express the model, and its shape transformation can also be achieved through Boolean operation simulation or real-time imaging. However, a single shape change of the mesh Boolean operation takes a long time, which is difficult to meet the real-time requirements of intraoperative feedback, while real-time imaging places higher requirements on hardware.
[0040] In view of this, the present application proposes a distance field rendering method, which can use a three-dimensional grid model to divide the distance field into regions, and realize the classification and display color of pixel points in the rendered image to mark different areas of the target object. Since the rendering and calculation speeds of the distance field and the three-dimensional grid are fast, it helps to ensure the real-time nature of intraoperative image feedback.
[0041] First, some professional terms involved in this application are explained.
[0042] 1. 3D mesh model: It is composed of one or more 3D sub-meshes of a certain size and shape and is used to represent objects.
[0043] 2. Distance field: A three-dimensional texture that represents a specific object. Each voxel in the three-dimensional texture corresponds to a signed distance from its center point to the surface of the distance field model, and the distance value is the distance value in the real physical space. If the center point is inside the distance field model, the distance is negative, and if it is outside the distance field model, the distance is positive. At the same time, this three-dimensional texture has real physical information (for example, the physical size corresponding to each voxel, the position of the origin of the three-dimensional texture in the mesh model coordinate system), and the physical information can be used to convert the coordinates of any point from the three-dimensional texture coordinate system to the mesh model coordinate system. Among them, the distance field model represents a specific object. The surface of the distance field model refers to the surface of the distance field model, which represents the surface of a specific object. For ease of understanding, please refer to Figure 1 , Figure 1 A two-dimensional schematic diagram showing the distance field of a spherical object. Figure 1 Each square in the image can represent a three-dimensional voxel, and the bounding box composed of all voxels is called the distance field. Figure 1 The circular area in the middle is the distance field model, which is used to represent spherical objects within the distance field. Figure 1 The outline of the circular area is called the distance field model surface, which represents the surface of a spherical object.
[0044] In order to illustrate the technical solution of the present application, a specific embodiment is provided below for illustration.
[0045] Please refer to Figure 2 , Figure 2 A schematic diagram of the implementation process of a distance field rendering method provided in an embodiment of the present application is shown, and the method can be applied to an electronic device. The electronic device can be a computer, a medical device, a tablet computer or other smart device, and the present application does not limit this.
[0046] Specifically, the distance field rendering method may include the following steps S201 to S202.
[0047] Step S201: Acquire a three-dimensional mesh model and a first distance field of a target object, wherein each sub-mesh in the three-dimensional mesh model corresponds to a type of attribute information.
[0048] In the implementation of the present application, the target object refers to an object for which image rendering is required, and may refer to a human body part such as a knee joint, a shoulder joint, an elbow joint, or an animal or other object. The first distance field refers to the distance field of the target object.
[0049] The three-dimensional mesh model of the target object is composed of one or more sub-meshes of a certain size and shape. Each sub-mesh can represent a physical area of the target object. Each sub-mesh can correspond to a type of attribute information, which can be used to identify the category of the sub-mesh. The category of the sub-mesh is related to the characteristics or type of the physical area represented by the sub-mesh. The attribute information between different sub-meshes can be the same or different.
[0050] In some embodiments of the present application, a medical image of the target object can be obtained, and a three-dimensional mesh model and a first distance field can be reconstructed based on the medical image. Specifically, the three-dimensional data of the target object can be obtained from medical imaging methods such as computed tomography (CT) and magnetic resonance imaging (MRI), and the original three-dimensional mesh model and the first distance field can be reconstructed from the three-dimensional data. The user can use the mesh editing tool to divide the original three-dimensional mesh model to obtain sub-grids with attribute information, and number each sub-grid, using the number as a label to distinguish different sub-grids.
[0051] It should be noted that the embodiments of the present application do not limit the method of acquiring three-dimensional data, reconstructing the three-dimensional mesh model and the first distance field.
[0052] Step S202 : rendering the first distance field to obtain a rendered image of the first distance field, wherein a display color of each pixel of the rendered image of the first distance field is determined based on attribute information of a sub-grid to which each pixel belongs.
[0053] In the implementation manner of the present application, the rendered image refers to a two-dimensional image obtained by the rendering operation of the first distance field. The parameters used in the rendering operation may include conversion parameters of the world coordinate system and the model coordinate system, camera parameters, resolution of the rendered image, etc. These parameters can be set according to actual needs, and this application does not limit this.
[0054] In an embodiment of the present application, the attribute information of the sub-grid to which each pixel belongs can reflect the characteristics or type of the physical area represented by the pixel. For each pixel, the display color that the pixel needs to display in the rendered image can be determined based on the attribute information of the sub-grid to which it belongs, so as to mark different physical areas of the target object by display color. According to the display color of each pixel, the first distance field can be rendered to obtain a rendered image of the first distance field. It can be understood that the rendered image can be displayed, which can specifically refer to display through the display screen of the electronic device itself, or it can refer to the electronic device controlling an external device for display, and this application does not limit this.
[0055] Two scenarios are used as examples for explanation.
[0056] Scenario 1: The attribute information is the surgical classification label corresponding to the sub-grid. The surgical classification labels may include but are not limited to to be retained and to be cut. Among them, to be retained refers to the part that needs to be retained during the operation, and to be cut refers to the part that needs to be cut during the operation. The sub-grid to be retained can be further divided into a surface sub-grid to be retained and an internal sub-grid to be retained, which is used to characterize its position in the target object, and then feedback whether it is over-resected during the operation. According to the surgical classification label of the sub-grid to which each pixel belongs, the display color of each pixel is determined, and according to the display color, the first distance field is rendered to obtain a rendered image of the first distance field, so that in the rendered image, the area to be retained and the area to be cut of the target object are represented by different display colors, and then the doctor can refer to the rendered image for cutting surgery.
[0057] Scenario 2: The attribute information is the grid color corresponding to the sub-grid, and the grid color is divided according to the normal tissue area and the lesion area. For example, the grid color of the normal tissue area is green, and the grid color of the lesion area is red. The normal tissue area represents the healthy area in the target object. The lesion area represents the area where the lesion exists in the target object. According to the grid color of the sub-grid to which each pixel belongs, the display color of each pixel is determined, and according to the display color, the first distance field is rendered to obtain a rendered image of the first distance field, so that the normal tissue area and the lesion area of the target object in the rendered image are represented by different display colors, and then the doctor and the patient can understand the lesion situation inside the target object. Further, the lesion area can be divided into a benign lesion area and a malignant lesion area, and the benign lesion area and the malignant lesion area can also correspond to different grid colors, for example, the grid color of the benign lesion area is yellow and the grid color of the malignant lesion area is red. Since the benign lesion area generally does not require immediate treatment, and the malignant lesion area usually requires immediate treatment, it is convenient for doctors and patients to determine the treatment plan by displaying in different colors.
[0058] Of course, the rendered image can be applied to other scenes besides the above two scenes, and the attribute information may include not only labels and mesh colors, but also other information such as mesh materials, which is not limited in this application.
[0059] In an implementation of the present application, the target object is represented based on the distance field, and the distance field is divided into regions according to the attribute information of the sub-grids in the three-dimensional grid model, so that the pixels in the rendered image are classified and displayed in colors to mark different areas of the target object. Since the rendering speed and calculation speed of the distance field and the three-dimensional grid are fast, it helps to ensure the real-time nature of the intraoperative image feedback.
[0060] In the embodiments of the present application, the rendering operation of the rendered image of the first distance field may be implemented in different ways.
[0061] In some embodiments of the present application, the distance field rendering method further includes: obtaining the display color of each pixel. Figure 3 As shown, obtaining the display color of each pixel may include: step S301 to step S302.
[0062] Step S301 : determining the number of intersections of each pixel point, where the number of intersections of each pixel point refers to the number of intersections between the projection light of each pixel point and the first distance field.
[0063] Ray marching includes the processes of ray casting and ray marching. The rendered image is regarded as an image taken by a camera, and the projected ray is a beam of light emitted from the camera position to the direction of the pixel. When casting rays, for each ray emitted by a pixel, the number of intersections between the projected ray and the first distance field can be determined. There are three cases for the number of intersections: (1) no intersection; (2) one intersection, that is, the incident point and the exit point coincide; (3) two intersections, that is, the incident point and the exit point do not coincide. The number of intersections for different pixels can be the same or different.
[0064] Step S302, determining the display color of each pixel point according to the number of intersections of each pixel point and the attribute information of the sub-grid to which each pixel point belongs.
[0065] In an embodiment of the present application, the number of intersections can reflect whether the pixel point passes through the first distance field, thereby reflecting whether the pixel point is used to represent a specific physical area on the target object, and the attribute information of the sub-grid to which each pixel point belongs can reflect the characteristics or type of the physical area. Based on the number of intersections of each pixel point and the attribute information of the sub-grid to which each pixel point belongs, the display color of each pixel point can be determined so as to mark different physical areas of the target object by displaying the color.
[0066] Specifically, in some embodiments of the present application, Figure 4As shown, determining the display color of each pixel point according to the number of intersection points corresponding to each pixel point and the attribute information of the sub-grid to which each pixel point belongs may include: step S401 to step S402.
[0067] Step S401, if the number of intersections of a pixel point is greater than 0, for the pixel point, the incident point of its projection light in the first distance field is used as the initial sampling point, and sampling is performed along the ray direction of the projection light according to the sampling step length until the sampling point satisfies that the sampling point is located on the surface of the distance field model of the target object, or the sampling point crosses the exit point of the projection light in the first distance field, or the sampling number exceeds the preset sampling number.
[0068] The preset sampling number refers to the maximum number of samplings, which can be set according to empirical values. The preset sampling number should be greater than or equal to the size of the diagonal of the first distance field, for example, the size of the diagonal of the first distance field is rounded up.
[0069] That is to say, in the case of intersections, ray stepping can be performed. During ray stepping, for each pixel point, the incident point of the corresponding first distance field is used as the starting point of the sampling point, and sampling is continuously performed along the ray direction of the projected light until the sampling point is located on the surface of the target object, crosses the exit point, or the sampling number exceeds the preset sampling number.
[0070] Sampling along the ray direction of the cast ray at a sampling step size is also called ray stepping.
[0071] The present application does not limit the light stepping method, and it can be implemented using the first method or the second method.
[0072] The sampling step length used in the first method is the minimum distance between the sampling point and the surface of the distance field model of the target object. The sampling step length used in the second method is the target step length, which is the distance between the sampling point and the exit point divided by the remaining number of iterations, and the remaining number of iterations is the difference between the preset number of sampling times and the number of sampling times. When the second method is used continuously, the sampling step length of each time remains unchanged. When the first method is used between two second methods, the sampling step length of the second method can be the same or different.
[0073] In some implementations of the present application, the first method and the second method may be combined to achieve the desired result.
[0074] Specifically, Figure 5 As shown, sampling is performed along the ray direction of the projected light according to the sampling step length, which may include: step S501 to step S502.
[0075] Step S501, determining a sampling method of a sampling point, where the sampling methods include a first method and a second method.
[0076] Specifically, in the first mode, since the first distance field is represented by a three-dimensional texture, there is only the minimum distance from the center of each voxel to the surface of the distance field model of the target object. In the process of ray stepping, the sampling point is not located at the center of the voxel in most cases. In order to improve the accuracy, the minimum distance from the center of the voxel around the sampling point to the surface of the distance field model of the target object can be linearly interpolated to obtain the distance from the sampling point to the surface of the target object, and this distance is used as the sampling step length.
[0077] In the second mode, the target distance is the distance between the sampling point and the exit point of the projected light divided by the remaining number of iterations, and the remaining number of iterations is the difference between the preset sampling number and the sampling number.
[0078] In some embodiments of the present application, after the incident point is used as the initial sampling point, the first method can be used as the sampling method for the first sampling.
[0079] In some embodiments of the present application, determining a sampling method for a sampling point may include: determining a first threshold; if the sampling point is located inside the target object, or the minimum distance between the sampling point and the surface of the distance field model of the target object is greater than the first threshold, determining the first method as the method adopted by the sampling point.
[0080] In some embodiments of the present application, determining the sampling method of the sampling point may include: if the sampling frequency is greater than a second threshold, and the number of consecutive times the first method is used when sampling the sampling point is greater than a third threshold, then determining the second method as the method used by the sampling point.
[0081] The first threshold is initialized to 0 when sampling for the first time, and is updated after being determined as the second mode. The updated first threshold is greater than the value of the sampling step corresponding to the second mode. The second threshold and the third threshold can be set according to empirical values. The second threshold can be half of the preset number of sampling times.
[0082] Step S502 , sampling is performed along the ray direction of the projection light according to the sampling step corresponding to the sampling method adopted by the sampling point.
[0083] Based on the sampling step corresponding to the sampling method adopted by the sampling point, sampling can be performed along the ray direction of the projected light until the sampling point satisfies that the sampling point is located on the surface of the distance field model of the target object, or the sampling point crosses the exit point of the projected light in the first distance field, or the sampling number exceeds the preset sampling number. This application does not limit the determination method for sampling termination, and some determination methods are provided below.
[0084] ①The sampling point is located on the surface of the distance field model of the target object:
[0085] In some embodiments of the present application, the method further includes: obtaining a fourth threshold, and if the minimum distance between the sampling point and the distance field model surface of the target object is less than the fourth threshold, the sampling point is located on the distance field model surface of the target object. The fourth threshold is associated with at least one of the size of the first distance field, the physical size corresponding to a single voxel of the first distance field, and a preset value.
[0086] Specifically, the preset value may be a preset empirical value. In some implementations, the fourth threshold is calculated as follows: multiply the size of the first distance field by 0.0001, take the minimum value of the product obtained and the preset value (which may be set to 0.013), and multiply the minimum value by the physical size corresponding to a single voxel of the first distance field to obtain the fourth threshold. For example, if the physical size corresponding to a single voxel of the first distance field is 10 mm, and the size of the first distance field is a three-dimensional texture of 512×512×512, then its fourth threshold is equal to 0.13. If the physical size corresponding to the voxel of the first distance field is 5 mm, and the size is 128×128×128, then its fourth threshold is equal to 0.064.
[0087] ②The sampling point crosses the exit point of the projection ray in the first distance field:
[0088] During ray casting, for each projection ray emitted by a pixel, the intersection position of the projection ray and the first distance field can be determined. If there is one intersection point, the incident point and the exit point coincide, and the intersection position is the exit point position. If there are two intersection points, the incident point and the exit point do not coincide, and the one farthest from the camera position is the exit point, from which the exit point position can be obtained. Based on the position of the sampling point and the position of the exit point, it can be determined whether the sampling point crosses the exit point of the projection ray in the first distance field.
[0089] ③The sampling times exceed the preset sampling times:
[0090] The sampling number is initialized to 0, and after each sampling, the sampling number is increased by 1. By comparing the sampling number with the preset sampling number, it can be determined whether the sampling number exceeds the preset sampling number.
[0091] Step S402: for a pixel whose sampling point is located on the surface of the distance field model of the target object, the color associated with the attribute information of the sub-grid to which the pixel belongs is used as the display color of the pixel.
[0092] Specifically, the colors associated with various attribute information can be set by the user or use the default colors preset by the system. The colors associated with different attribute information can be different, so as to facilitate doctors to distinguish different physical areas.
[0093] In some embodiments of the present application, for a pixel point whose sampling point is located on the surface of the distance field model of the target object, it is necessary to determine which subgrid the pixel point belongs to, and obtain the color corresponding to the attribute information as the display color of the pixel point according to the attribute information of the subgrid. Then, the sampling point is colored by the Blinn-Phone emission model to be rendered according to the display color of the pixel point.
[0094] Specifically, Figure 6 As shown, determining the attribute information of the sub-grid to which each pixel point belongs may include: step S601 to step S603.
[0095] Step S601 , obtaining the sampling point depth of each first sampling point, where each first sampling point is a sampling point on the projection ray of the pixel point corresponding thereto.
[0096] The sampling point depth may be the depth in the coordinate system of the three-dimensional network model, that is, the coordinate system where the mesh fragment depth is located. If the sampling point is located on the surface of the distance field model of the target object, the depth of the sampling point in the coordinate system where the mesh fragment depth is located (that is, the depth of the sampling point and the depth of the mesh fragment should be in the same coordinate system) may be first obtained as the sampling point depth.
[0097] Step S602: for each sub-grid having the first grid fragment in the three-dimensional grid model, determine the number of grid fragments whose sampling depth of each first sampling point is greater than the depth of each first grid fragment as the depth number.
[0098] Each sub-grid may include a number of grid fragments. A first grid fragment is a grid fragment through which the projection light of the corresponding pixel passes. For a single pixel, if the projection light passes through a grid fragment of a sub-grid, then the sub-grid has a first grid fragment, and the number of depths of the sub-grid can be determined at this time. The number of depths of the sub-grid is the number of grid fragments whose sampling depths of each first sampling point are greater than the depths of each first grid fragment. The fragment depth of the first grid fragment is the depth of the first grid fragment in the coordinate system of the three-dimensional network model.
[0099] Specifically, the grid fragment (i.e., the first grid fragment) through which the projection light of a single pixel passes is taken out to obtain the sub-grid fragment set corresponding to the pixel. The grid fragments are sorted from small to large according to the depth, and the sampling point depth and the fragment depth of each first grid fragment are compared. For the sub-grid with the first grid fragment, the total number of grid fragments whose sampling point depth is greater than the first grid fragment can be recorded, which is referred to as the depth number.
[0100] Since the target object will be continuously cut during the operation, and there are slight errors between the distance field model and the three-dimensional mesh model of the target object, the surface points of the distance field model of the target object may be located at any position inside, outside, or on the surface of the three-dimensional mesh model, that is, the sampling point may be located at the front side of all mesh fragments (the sampling point depth is less than the fragment depth of all first mesh fragments), the back side of all mesh fragments (the sampling point depth is greater than the fragment depth of all first mesh fragments), or any position inside the mesh fragment set.
[0101] Step S603: Determine the attribute information of the sub-grid to which each pixel belongs according to the number of depths.
[0102] If there is a single sub-grid with an odd number of depths in the three-dimensional grid model, the attribute information of the sub-grid is used as the attribute information of the sub-grid to which the corresponding pixel belongs. Specifically, for a single pixel, if there is a single sub-grid with an odd number of depths, the attribute information of the sub-grid can be used as the attribute information of the sub-grid to which the pixel belongs, and then the display color presented by the pixel is the color associated with the attribute information of the target sub-grid.
[0103] Theoretically, there are no multiple subgrids with an odd number of depths. If for a single pixel, there are multiple target subgrids with an odd number of depths, it means that it is in an unknown situation, and a preset color can be used as the display color. The preset color can be used to characterize the pixel as a non-target object. For example, the preset color can be black, and then the pixel is displayed as black.
[0104] If there is no sub-grid with an odd number of depths in the three-dimensional grid model, the attribute information of the sub-grid to which the pixel corresponding to each first sampling point belongs is determined based on the positional relationship between each first sampling point and each first grid fragment. Specifically, for a single pixel, if the first sampling point is located in front of all first grid fragments, the first sampling point is located in the sub-grid corresponding to the first first grid fragment in the ray direction of the projected light. If the first sampling point is located in the back of all first grid fragments, the first sampling point is located in the sub-grid corresponding to the last first grid fragment in the ray direction of the projected light. If it is neither of the above two cases, the sub-grid corresponding to the first grid fragment closest to the first sampling point is used as the sub-grid to which the pixel belongs.
[0105] Figure 7-Figure 9 It is a simple two-dimensional schematic diagram that illustrates how to determine the subgrid to which a sampling point belongs. Figure 7-Figure 9Each subgrid in represents a closed 3D grid in 3D space, and one edge corresponds to several grid fragments in 3D space. P0-P6 represent sampling points in the first distance field in different cases. The intersection of the projected ray and the edge of the subgrid corresponds to the intersection of the projected ray and a grid fragment, and the information of each intersection is contained by the grid fragment.
[0106] Figure 7 This is the most common mesh model. There is no gap between sub-meshes, and each sub-mesh has only 2 mesh fragments on the projection ray. In this case, P0 and P1 belong to sub-mesh 0, P2 belongs to sub-mesh 1, and P3 and P4 belong to mesh 2.
[0107] Figure 8 There are gaps between the subgrids, and each subgrid has only two grid fragments on the projection ray. At this time, P0-P2 belong to subgrid 0, and P3-P5 belong to subgrid 1.
[0108] Fig. 9 There is no gap between the subgrids, but there are subgrids with more than 2 grid fragments on the projection ray. At this time, P0-P1 and P3-P4 are located in subgrid 0, and P2 is located in subgrid 1.
[0109] In other embodiments of the present application, if the number of intersections of a pixel is 0, or the sampling point passes the exit point of the projection light in the first distance field, or the sampling number exceeds a preset sampling number, the preset color is used as the display color of the pixel.
[0110] For easier understanding, please refer to Fig.10 , Fig.10The light stepping process provided by the present application is shown. After the stepping starts, the intersection of the projected light of each pixel point and the first distance can be determined to find the incident point and the exit point of the projected light in the first distance field. If the number of intersections is 0, that is, there is no intersection, the preset color can be used as the display color of the corresponding pixel point. If the number of intersections is greater than 0, that is, there is an intersection, the incident point can be used as the initial sampling point, the sampling step and the first threshold are initialized to zero, the first method is used as the sampling method for the first sampling, and sampling is performed along the ray direction of the projected light. By judging whether the sampling point is located on the surface of the distance field model of the target object, if so, the attribute information of the sub-grid to which it belongs can be determined, and the color associated with the attribute information is used as the display color of the corresponding pixel point to render the first distance field. If the sampling point is not located on the surface of the distance field model of the target object, it is judged whether the sampling point is located inside the target object. If so, the target update method is determined to be the first method. If the sampling point is not located inside the target object, it is judged whether the minimum distance between the sampling point and the surface of the distance field model of the target object is greater than the first threshold. If so, the target update method is determined to be the first method. If the minimum distance between the sampling point and the surface of the distance field model of the target object is less than or equal to the first threshold, it is determined whether the sampling point crosses the exit point, or whether the sampling times exceed the preset sampling times. If the sampling point crosses the exit point, or the sampling times exceed the preset sampling times, the preset color can be used as the display color of the corresponding pixel. If the sampling point does not cross the exit point, or the sampling times do not exceed the preset sampling times, it is determined whether the sampling times are greater than the second threshold, and whether the number of times the first method is used continuously is greater than the third threshold. If so, it is determined to be the second method, otherwise, sampling is performed according to the first method. If it is determined to be the second method, the target distance can be calculated, and the first threshold is updated, and then sampling is performed according to the target distance.
[0111] In the implementation of the present application, the first method and the second method are combined to achieve the desired display color for different physical areas of the target object, and the high efficiency of the ray marching algorithm is maintained, and the robustness of the algorithm is increased, which can effectively reduce the occurrence of aliasing. Combined with the positional relationship between the sampling point and the grid element, it is possible to accurately determine which subgrid the sampling point corresponding to each pixel belongs to, and then accurately give the desired display color to different physical areas of the target object.
[0112] In addition, the application also supports the process of simulating surgical cutting.
[0113] Specifically, in some embodiments of the present application, the distance field rendering method may further include: obtaining a second distance field of an execution object, where the execution object may be used to cut the target object, such as a saw. Performing a Boolean subtraction operation on the first distance field and the second distance field to obtain a result distance field, where the result distance field is used to represent a model obtained after the execution object cuts the target object.
[0114] The bottom shape and physical size of the second distance field are consistent with the execution object used by the doctor, and its height should be greater than the diagonal of the bounding box of the target object's 3D model. Each time a cut is made, the placement of the execution object is consistent with the cutting direction, and all areas above the execution object are considered to be the areas that need to be cut and are also being cut. Therefore, the subtraction Boolean operation of the first distance field and the second distance field can be used to simulate surgical cutting.
[0115] The purpose of the Boolean subtraction operation is to remove the intersection area of the subtracted distance field model and the subtracted distance field model from the distance field model to be subtracted. The general calculation method of the Boolean subtraction operation is that the signed distance of any point to the result distance field model is equal to the maximum of the signed distance of the point to the subtracted distance field model and the negative signed distance of the point to the subtracted distance field model.
[0116] Specifically, for each voxel in the first distance field, the coordinates of the center point in the real physical space can be calculated, which are referred to as real physical space points. Subsequently, the corresponding point of the real physical space point in the second distance field is found. The first value (the minimum distance value from the texture center to the surface of the target object distance field model) corresponding to each voxel in the first distance field is updated to the maximum value of the first value and the opposite number of the target, and the opposite number of the target is the opposite number of the minimum distance from the corresponding point of the second distance field to the surface of the second distance field model. It should be noted that when the corresponding point of the second distance field is not located at the center of any second distance field voxel, the distance from the point to the second distance field model can be obtained by interpolation using the distance values stored in the voxels around the point.
[0117] Taking into account that there is a certain error in the actual distance from the center point corresponding to each voxel to the surface of the distance field model, in order to further enhance the robustness of the algorithm, in some embodiments of the present application, the method further includes: if it is determined to stop cutting the target object, converting the result distance field into a three-dimensional mesh model, determining the second distance according to the position of the three-dimensional mesh in the three-dimensional mesh model, and updating the first distance corresponding to the voxel in the result distance field whose difference between the first distance and the second distance is greater than a fifth threshold to the second distance.
[0118] The second distance refers to the minimum distance between the voxels corresponding to each position in the three-dimensional grid model and the surface of the distance field model of the target object.
[0119] Specifically, at the moment when the execution object stops cutting (the execution object moves away from the target object), the Matching Cubes algorithm is first used to convert the result distance field into a three-dimensional mesh model. Since the first distance corresponding to the voxels around the surface of the distance field model of the target object is more accurate than the first distance stored by the voxels far away from the surface of the distance field model of the target object, and the conversion process of converting the result distance field into the three-dimensional mesh model mainly refers to the first distance stored by the voxels around the surface of the distance field model of the target object, the second distance between the voxels corresponding to each position in the three-dimensional mesh model and the surface of the distance field model of the target object obtained after conversion to the three-dimensional mesh model is closer to the true value. When the first distance of the result distance field is updated, the specific method is: determine whether the difference between the first distance and the second distance stored by each voxel is greater than the fifth threshold value. If it is greater, it means that the first distance stored by the voxel has a large error (usually the voxel far away from the surface of the distance field model of the target object), and then update it to the second distance. Otherwise, it means that the first distance stored by the voxel is more accurate and is not updated. After completing the distance value update voxel by voxel, the updated distance field can be obtained.
[0120] It should be noted that the fifth threshold may be set according to an empirical value, for example, set to 2-3, so as to ensure that the texture around the surface of the target object is not updated as much as possible.
[0121] In the implementation of the present application, the surgical operation during the operation can be simulated by Boolean operation of the distance field, and the changing distance field can be continuously obtained to realize the feedback during the operation. Since the Boolean operation of the distance field is very fast, the real-time feedback during the operation can be effectively guaranteed. In addition, by updating the distance value of the result distance field, the updated distance field can be made closer to the standard distance field, and its shape is guaranteed to be consistent with the real target object to a great extent.
[0122] It should be noted that, for the sake of simplicity of description, the aforementioned method embodiments are all expressed as a series of action combinations, but those skilled in the art should know that the present application is not limited to the described order of actions, because according to the present application, certain steps can be performed in other orders.
[0123] like Fig.11 FIG. 1 is a schematic structural diagram of a distance field rendering device 1100 provided in an embodiment of the present application. The distance field rendering device 1100 is configured on an electronic device.
[0124] Specifically, the distance field rendering device 1100 may include:
[0125] A data acquisition unit 1101 is used to acquire a three-dimensional grid model and a first distance field of a target object, wherein each subgrid in the three-dimensional grid model corresponds to a type of attribute information;
[0126] The rendering unit 1102 is configured to render the first distance field to obtain a rendered image of the first distance field, wherein a display color of each pixel of the rendered image of the first distance field is determined based on attribute information of a sub-grid to which each pixel belongs.
[0127] In some embodiments of the present application, the distance field rendering device 1100 further includes a color determination unit, which is specifically used to: determine the number of intersections of each pixel point, where the number of intersections of each pixel point refers to the number of intersections between the projection light of each pixel point and the first distance field;
[0128] The display color of each pixel is determined according to the number of intersections of each pixel and the attribute information of the sub-grid to which each pixel belongs.
[0129] In some embodiments of the present application, the color determination unit is specifically configured to: if the number of intersections of the pixel point is greater than 0, for the pixel point, use the incident point of its projection light in the first distance field as the initial sampling point, and perform sampling according to the sampling step along the ray direction of the projection light until the sampling point satisfies: the sampling point is located on the surface of the distance field model of the target object; or the sampling point crosses the exit point of the projection light in the first distance field; or the sampling number exceeds a preset sampling number; for the pixel point whose sampling point is located on the surface of the distance field model of the target object, use the color associated with the attribute information of the sub-grid to which the pixel point belongs as the display color of the pixel point.
[0130] In some embodiments of the present application, the color determination unit may be specifically used to: if the number of intersections of the pixel point is 0; or the sampling point crosses the exit point of the projection light in the first distance field; or the sampling number exceeds a preset sampling number, then use the preset color as the display color of the pixel point.
[0131] In some embodiments of the present application, the color determination unit may be specifically used to: determine a sampling method for the sampling point, the sampling method including a first method and a second method; wherein the sampling step length adopted by the first method is the minimum distance between the sampling point and the surface of the distance field model of the target object; the sampling step length adopted by the second method is the target step length, and the target step length is the distance between the sampling point and the exit point divided by the remaining number of iterations, and the remaining number of iterations is the difference between the preset number of sampling times and the sampling number; and sampling is performed along the ray direction of the projection light according to the sampling step length corresponding to the sampling method adopted by the sampling point.
[0132] In some embodiments of the present application, the color determination unit may be specifically used to: determine a first threshold; if the sampling point is located inside the target object, or the minimum distance between the sampling point and the surface of the distance field model of the target object is greater than the first threshold, determine that the first mode is the mode adopted by the sampling point.
[0133] In some embodiments of the present application, the color determination unit may be specifically used to: if the sampling number is greater than a second threshold, and the number of consecutive times the first method is used when sampling the sampling point is greater than a third threshold, then determine that the second method is the method used by the sampling point.
[0134] In some embodiments of the present application, the color determination unit may be specifically configured to: obtain a fourth threshold value, where the fourth threshold value is associated with at least one of a size of the first distance field, a physical size corresponding to a single voxel of the first distance field, and a preset value; if the minimum distance between the sampling point and the surface of the distance field model of the target object is less than the fourth threshold value, then the sampling point is located on the surface of the distance field model of the target object.
[0135] In some embodiments of the present application, the distance field rendering device 1100 may further include an attribute information determination unit, which is used to: obtain the sampling point depth of each first sampling point, where each first sampling point is the sampling point on the projection light of the pixel point corresponding to it; for each sub-grid in the three-dimensional grid model where there is a first grid fragment, determine the number of grid fragments whose sampling depth of each first sampling point is greater than the depth of each first grid fragment as the depth number; determine the attribute information of the sub-grid to which each pixel point belongs based on the depth number; wherein the first grid fragment is the grid fragment through which the projection light of the pixel point corresponding to it passes.
[0136] In some embodiments of the present application, the attribute information determination unit is specifically used to: if there is a single sub-grid with an odd number of depths in the three-dimensional grid model, then use the attribute information of the sub-grid as the attribute information of the sub-grid to which the corresponding pixel point belongs; if there is no sub-grid with an odd number of depths in the three-dimensional grid model, then determine the attribute information of the sub-grid to which the pixel point corresponding to each first sampling point belongs based on the positional relationship between the each first sampling point and the each first grid fragment.
[0137] In some embodiments of the present application, the distance field rendering device 1100 may further include a cutting simulation unit, which is used to: obtain a second distance field of an execution object, where the execution object is used to cut the target object; perform a Boolean subtraction operation on the first distance field and the second distance field to obtain a result distance field, where the result distance field is used to represent a model obtained after the execution object cuts the target object.
[0138] In some embodiments of the present application, each voxel in the result distance field corresponds to a first distance, and the first distance refers to the minimum distance between each voxel in the result distance field and the surface of the distance field model of the target object; the distance field rendering device 1100 may also include a distance field updating unit, which is used to: if it is determined to stop cutting the target object, convert the result distance field into a three-dimensional mesh model, determine a second distance according to the position of the three-dimensional mesh in the three-dimensional mesh model, and the second distance refers to the minimum distance between the voxel corresponding to each position in the three-dimensional mesh model and the surface of the distance field model of the target object; update the first distance corresponding to the voxel in the result distance field whose difference between the first distance and the second distance is greater than a fifth threshold to the second distance.
[0139] It should be noted that, for the convenience and simplicity of description, the specific working process of the distance field rendering device 1100 can be referred to Figures 1 to 10 The corresponding process of the method will not be repeated here.
[0140] like Fig.12 , which is a schematic diagram of an electronic device 12 provided in an embodiment of the present application. Specifically, the electronic device 12 may include: a processor 120, a memory 121, and a computer program 122 stored in the memory 121 and executable on the processor 120, such as a distance field rendering program. When the processor 120 executes the computer program 122, the steps in the above-mentioned distance field rendering method embodiments are implemented, such as Figure 1 Alternatively, when the processor 120 executes the computer program 122, the functions of each module / unit in the above-mentioned device embodiments are realized, for example Fig.11 The functions of the data acquisition unit 1101 and the rendering unit 1102 are shown.
[0141] The computer program may be divided into one or more modules / units, which are stored in the memory 121 and executed by the processor 120 to complete the present application. The one or more modules / units may be a series of computer program instruction segments capable of completing specific functions, which are used to describe the execution process of the computer program in the electronic device 12.
[0142] For example, the computer program may be divided into: a data acquisition unit and a rendering unit. The specific functions of each unit are as follows: a data acquisition unit, used to acquire a three-dimensional grid model and a first distance field of a target object, wherein each subgrid in the three-dimensional grid model corresponds to a type of attribute information; a rendering unit, used to render the first distance field to obtain a rendered image of the first distance field, wherein the display color of each pixel point of the rendered image of the first distance field is determined based on the attribute information of the subgrid to which each pixel point belongs.
[0143] The electronic device 12 may include, but is not limited to, a processor 120 and a memory 121. Those skilled in the art will appreciate that Fig.12 It is only an example of the electronic device 12 and does not constitute a limitation of the electronic device 12. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, the electronic device 12 may also include input and output devices, network access devices, buses, etc.
[0144] The processor 120 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), off-the-shelf programmable gate arrays or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.
[0145] The memory 121 may be an internal storage unit of the electronic device 12, such as a hard disk or memory of the electronic device 12. The memory 121 may also be an external storage device of the electronic device 12, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the electronic device 12. Further, the memory 121 may also include both an internal storage unit of the electronic device 12 and an external storage device. The memory 121 is used to store the computer program and other programs and data required by the electronic device 12. The memory 121 may also be used to temporarily store data that has been output or is to be output.
[0146] It should be noted that, for the convenience and brevity of description, the structure of the electronic device 12 can also refer to the specific description of the structure in the method embodiment, which will not be repeated here.
[0147] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by 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 embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.
[0148] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0149] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example 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 performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0150] In the embodiments provided in the present application, it should be understood that the disclosed devices / equipment and methods can be implemented in other ways. For example, the device / equipment embodiments described above are merely schematic, for example, the division of the modules or units is only a logical function division, and there may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0151] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0152] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0153] If the integrated module / unit is implemented in the form of 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, the present application implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium. It should be noted that the content contained in the computer-readable medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electric carrier signals and telecommunication signals.
[0154] The embodiments described above are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.
Claims
1. A distance field rendering method, characterized in that: include: Acquire a three-dimensional mesh model and a first distance field of the target object, wherein each sub-mesh in the three-dimensional mesh model corresponds to a type of attribute information; The first distance field is rendered to obtain a rendered image of the first distance field, wherein a display color of each pixel of the rendered image of the first distance field is determined based on attribute information of a sub-grid to which each pixel belongs.
2. The distance field rendering method according to claim 1, characterized in that: Also includes: Obtaining the display color of each pixel, wherein obtaining the display color of each pixel includes: Determine the number of intersections of each pixel point, where the number of intersections of each pixel point refers to the number of intersections between the projection light of each pixel point and the first distance field; The display color of each pixel is determined according to the number of intersections of each pixel and the attribute information of the sub-grid to which each pixel belongs.
3. The distance field rendering method according to claim 2, characterized in that: Determining the display color of each pixel point according to the number of intersection points corresponding to each pixel point and the attribute information of the sub-grid to which each pixel point belongs, including: If the number of intersections of the pixel is greater than 0, for the pixel, the incident point of its projection ray in the first distance field is used as the initial sampling point, and sampling is performed along the ray direction of the projection ray according to the sampling step until the sampling point satisfies: The sampling points are located on the surface of the distance field model of the target object; or the sampling point passes over the exit point of the projection ray in the first distance field; Or the sampling times exceed the preset sampling times; For a pixel point where the sampling point is located on the surface of the distance field model of the target object, a color associated with the attribute information of the sub-grid to which the pixel point belongs is used as the display color of the pixel point.
4. The distance field rendering method according to claim 3, characterized in that: Also includes: If the number of intersections of the pixel points is 0; Alternatively, the sampling point passes over the exit point of the projection ray in the first distance field; Or, the sampling times exceed the preset sampling times. The preset color is used as the display color of the pixel.
5. The distance field rendering method according to claim 3, characterized in that: The sampling is performed along the ray direction of the projection light according to the sampling step length, including: Determine a sampling method of the sampling point, wherein the sampling method includes a first method and a second method; The sampling step length adopted in the first method is the minimum distance between the sampling point and the surface of the distance field model of the target object; The sampling step length used in the second method is the target step length, and the target step length is the distance between the sampling point and the emission point divided by the remaining number of iterations, and the remaining number of iterations is the difference between the preset sampling number and the sampling number; Sampling is performed along the ray direction of the projection light according to the sampling step corresponding to the sampling method adopted by the sampling point.
6. The distance field rendering method according to claim 5, characterized in that: The determining of the sampling method of the sampling point includes: determining a first threshold; If the sampling point is located inside the target object, Alternatively, the minimum distance between the sampling point and the surface of the distance field model of the target object is greater than the first threshold, Then the first method is determined to be the method adopted by the sampling point.
7. The distance field rendering method according to claim 5, characterized in that: The determining of the sampling method of the sampling point includes: If the sampling number is greater than the second threshold, and the number of times the first method is continuously used when sampling the sampling point is greater than the third threshold, Then the second method is determined to be the method adopted by the sampling point.
8. The distance field rendering method according to any one of claims 3 to 7, characterized in that: The attribute information for determining the subgrid to which each pixel belongs includes: Acquire the sampling point depth of each first sampling point, where each first sampling point is the sampling point on the projection ray of the pixel point corresponding to it; For each subgrid having the first grid fragment in the three-dimensional grid model, determining the number of grid fragments whose sampling depth of each first sampling point is greater than the depth of each first grid fragment as the depth number; Determining attribute information of the subgrid to which each pixel belongs according to the number of depths; The first grid element is the grid element through which the projection light of the corresponding pixel point passes.
9. The distance field rendering method according to any one of claims 1 to 7, characterized in that: Also includes: Acquire a second distance field of an execution object, where the execution object is used to cut the target object; A Boolean subtraction operation is performed on the first distance field and the second distance field to obtain a result distance field, where the result distance field is used to represent a model obtained after the execution object cuts the target object.
10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the steps of the distance field rendering method according to any one of claims 1 to 9 are implemented.