Image rendering method and apparatus, electronic device, and storage medium
View Patent ↗The disclosure provides an image rendering method and apparatus, an electronic device, and a storage medium. The image rendering method includes: obtaining target camera association information and target light source association information; determining target voxel association information of each voxel in a target object based on the target camera association information, the target light source association information, and a pre-trained target object attribute determination model; and rendering a target structure image corresponding to the target object based on the target voxel association information of each voxel.
1 . An image rendering method, comprising:
obtaining camera association information and light source association information;
determining voxel association information of each voxel in an object based on the camera association information, the light source association information, and a pre-trained object attribute determination model, wherein the voxel association information comprises light quantity information of a voxel, and the light quantity information comprises a reflection brightness value of light rays irradiating on the voxel and a refraction brightness value of the light rays refracted from an interior of the voxel; and
rendering a structure image corresponding to the object based on the voxel association information of each voxel.
2 . The method according to claim 1 , wherein the camera association information comprises a camera position and orientation information, and the light source association information comprises a light source position and a lighting direction of a light source.
3 . The method according to claim 2 , wherein determining the voxel association information of each voxel in the object based on the target camera association information, the light source association information, and the pre-trained object attribute determination model comprises:
determining at least one to-be-processed sampling point on each light ray, by processing, based on a preset sampling point determination procedure, the camera association information and the light source association information;
obtaining to-be-selected voxel association information corresponding to each sampling point, by processing the at least one to-be-processed sampling point based on the object attribute determination model; and
determining the voxel association information of each voxel based on the to-be-selected voxel association information corresponding to each sampling point.
4 . The method according to claim 1 , wherein the voxel association information further comprises color information of the voxel.
5 . The method according to claim 1 , wherein rendering the structure image corresponding to the object based on the voxel association information of each voxel comprises:
determining internal structure information corresponding to the object based on the voxel association information of each voxel; and
rendering the structure image corresponding to the object based on the internal structure information.
6 . The method according to claim 1 , further comprising:
obtaining the object attribute determination model through training;
wherein obtaining the object attribute determination model through training comprises:
obtaining a plurality of training samples, wherein each training sample comprises a to-be-trained association parameter and a theoretical rendered image corresponding to the to-be-trained association parameter, and the to-be-trained association parameter comprises a to-be-trained camera parameter and a to-be-trained light source parameter;
obtaining an actual rendered image corresponding to the to-be-trained association parameter, by inputting, for each training sample, to-be-trained association parameter in a current training sample into a to-be-trained object attribute determination model;
determining an error value based on the actual rendered image and a theoretical rendered image in the current training sample;
calculating a preset loss function in the to-be-trained object attribute determination model based on the error value, and performing parameter correction on the to-be-trained object attribute determination model; and
obtaining the object attribute determination model, by converging the preset loss function as a training objective.
7 . The method according to claim 6 , wherein obtaining the actual rendered image corresponding to the to-be-trained association parameter, by inputting the to-be-trained association parameter in the current training sample into the to-be-trained object attribute determination model comprises:
determining information of at least one to-be-trained sampling point corresponding to the to-be-trained association parameter;
obtaining to-be-trained color information and to-be-trained light quantity information which are outputted by the to-be-trained object attribute determination model and correspond to the at least one to-be-trained sampling point, by inputting the information of the at least one to-be-trained sampling point into the to-be-trained object attribute determination model; and
rendering, based on the to-be-trained color information and the to-be-trained light quantity information, an actual rendered image corresponding to the object.
8 . An electronic device, comprising:
at least one processor; and
a storage means, configured to store at least one program, wherein when the at least one program is executed by the at least one processor, the at least one processor is caused to:
obtain camera association information and light source association information;
determine voxel association information of each voxel in an object based on the camera association information, the target light source association information, and a pre-trained object attribute determination model, wherein the voxel association information comprises light quantity information of a voxel, and the light quantity information comprises a reflection brightness value of light rays irradiating on the voxel and a refraction brightness value of the light rays refracted from an interior of the voxel; and
render a structure image corresponding to the object based on the voxel association information of each voxel.
9 . The electronic device according to claim 8 , wherein the camera association information comprises a camera position and orientation information, and the light source association information comprises a light source position and a lighting direction of a light source.
10 . The electronic device according to claim 9 , wherein the at least one processor is caused to determine the voxel association information of each voxel in the object based on the camera association information, the light source association information, and the pre-trained object attribute determination model comprises being caused to:
determine at least one to-be-processed sampling point on each light ray, by processing, based on a preset sampling point determination procedure, the camera association information and the light source association information;
obtain to-be-selected voxel association information corresponding to each sampling point, by processing the at least one to-be-processed sampling point based on the object attribute determination model; and
determine the voxel association information of each voxel based on the to-be-selected voxel association information corresponding to each sampling point.
11 . The electronic device according to claim 8 , wherein the voxel association information further comprises color information of the voxel.
12 . The electronic device according to claim 8 , wherein the at least one processor is caused to render the structure image corresponding to the object based on the voxel association information of each voxel comprises being caused to:
determine internal structure information corresponding to the object based on the voxel association information of each voxel; and
render the structure image corresponding to the object based on the internal structure information.
13 . The electronic device according to claim 8 , wherein the at least one processor is further caused to
obtaining the object attribute determination model through training;
wherein the at least one processor is caused to obtain the object attribute determination model through training comprises being caused to:
obtain a plurality of training samples, wherein each training sample comprises a to-be-trained association parameter and a theoretical rendered image corresponding to the to-be-trained association parameter, and the to-be-trained association parameter comprises a to-be-trained camera parameter and a to-be-trained light source parameter;
obtain an actual rendered image corresponding to the to-be-trained association parameter, by inputting, for each training sample, to-be-trained association parameter in a current training sample into a to-be-trained object attribute determination model;
determine an error value based on the actual rendered image and a theoretical rendered image in the current training sample;
calculate a preset loss function in the to-be-trained object attribute determination model based on the error value, and perform parameter correction on the to-be-trained object attribute determination model; and
obtain the object attribute determination model, by converging the preset loss function as a training objective.
14 . The electronic device according to claim 13 , wherein the at least one processor is caused to obtain the actual rendered image corresponding to the to-be-trained association parameter, by inputting the to-be-trained association parameter in the current training sample into the to-be-trained object attribute determination model comprises being caused to:
determine information of at least one to-be-trained sampling point corresponding to the to-be-trained association parameter;
obtain to-be-trained color information and to-be-trained light quantity information which are outputted by the to-be-trained object attribute determination model and correspond to the at least one to-be-trained sampling point, by inputting the information of the at least one to-be-trained sampling point into the to-be-trained object attribute determination model; and
render, based on the to-be-trained color information and the to-be-trained light quantity information, an actual rendered image corresponding to the object.
15 . A non-transitory computer-readable storage medium, storing a computer program, wherein the program, when executed by a processor, implements:
obtaining camera association information and target light source association information;
determining voxel association information of each voxel in an object based on the camera association information, the light source association information, and a pre-trained object attribute determination model, wherein the voxel association information comprises light quantity information of a voxel, and the light quantity information comprises a reflection brightness value of light rays irradiating on the voxel and a refraction brightness value of the light rays refracted from an interior of the voxel; and
rendering a structure image corresponding to the object based on the voxel association information of each voxel.
16 . The non-transitory computer-readable storage medium according to claim 15 , wherein the camera association information comprises a camera position and orientation information, and the light source association information comprises a light source position and a lighting direction of a light source.
17 . The non-transitory computer-readable storage medium according to claim 16 , wherein determining the voxel association information of each voxel in the object based on the camera association information, the light source association information, and the pre-trained object attribute determination model comprises:
determining at least one to-be-processed sampling point on each light ray, by processing, based on a preset sampling point determination procedure, the camera association information and the light source association information;
obtaining to-be-selected voxel association information corresponding to each sampling point, by processing the at least one to-be-processed sampling point based on the object attribute determination model; and
determining the voxel association information of each voxel based on the to-be-selected voxel association information corresponding to each sampling point.
18 . The non-transitory computer-readable storage medium according to claim 15 , wherein the voxel association information further comprises color information of the voxel.