A geometric-optical phenomenon restoration method based on kernel density estimation algorithm
By using kernel density estimation algorithms and ray tracing technology, the problems of jagged edges and contrast imbalance in the reconstruction of geometric optical phenomena were solved, achieving high-fidelity and smooth visualization of optical phenomena and improving the simulation realism in complex media.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- BEIHANG UNIV
- Filing Date
- 2026-03-04
- Publication Date
- 2026-06-05
Smart Images

Figure CN122156429A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of three-dimensional optical technology, and in particular to a method for reconstructing geometric optical phenomena based on a kernel density estimation algorithm. Background Technology
[0002] High-fidelity reproduction of geometric optical phenomena is of great significance in the field of optical simulation, as it can intuitively demonstrate the propagation and refraction of light in complex media.
[0003] In existing technologies, numerical simulations based on ray tracing or simplified modeling based on physical equations are used to generate and visualize geometric optical phenomena. However, firstly, when converting discrete ray data to a continuous intensity distribution, simple nearest neighbor or linear interpolation is often used, resulting in obvious jagged edges or noise in the reconstruction results, especially in edge and detail areas, making it difficult to achieve a smooth transition and affecting visual realism and subsequent analysis accuracy. Secondly, most methods do not adequately handle the dynamic range of light density changes, with high-density areas prone to saturation and low-density areas losing information. The lack of an effective nonlinear mapping mechanism leads to an imbalance in intensity distribution contrast and unclear detail levels, affecting the overall presentation of the phenomenon. Finally, the construction of refraction models often relies on idealized assumptions, such as homogeneous media or simple interfaces, making it difficult to simulate complex refraction behavior in non-homogeneous, multi-interface, or dynamic media, thus limiting the application range and simulation fidelity of the methods in real-world, variable optical scenarios.
[0004] Therefore, a method for reconstructing geometric optical phenomena based on kernel density estimation algorithm is provided to solve the above problems. Summary of the Invention
[0005] The purpose of this invention is to provide a method for reconstructing geometric optical phenomena based on kernel density estimation algorithm. By using kernel density estimation, nonlinear mapping and ray tracing technology, it can achieve high-fidelity, smooth and continuous visualization and reconstruction of optical phenomena with dynamic range adaptability from discrete ray data.
[0006] To achieve the above objectives, this invention provides a method for reconstructing geometric optical phenomena based on a kernel density estimation algorithm, comprising the following steps: S1: By transforming coordinates, the points of impact of discrete ray rays in three-dimensional space are projected onto a two-dimensional plane to obtain the coordinates of the two-dimensional plane. ; S2: Transform continuous two-dimensional plane coordinates through affine transformation Mapping to pixel indices yields a two-dimensional pixel grid. ; S3: Convert discrete points into a continuous intensity distribution using multiple kernel function diffusion methods; S4: The final intensity value is obtained by nonlinearly compressing the kernel function diffusion result using the arctangent function. ; S5: Final intensity value obtained through single-channel to RGB pseudo-color mapping Display; S6: Perform ray tracing and build a ray refraction model; S7: Based on the light refraction model and pseudo-color mapping rules, the light direction is mapped to the imaging plane coordinates to obtain the dataset. .
[0007] Preferably, step S1 specifically includes the following steps: S11: Calculate the first in three-dimensional space using the radial projection method. The x-coordinate of the projection of the discrete ray hit point x-axis Specifically set as follows: ; in, Indicates the projection direction. Represents a symbolic function. This represents the x-coordinate of the reference point on a two-dimensional plane. This represents the depth coordinates of the reference point on a two-dimensional plane. Indicates the first The x-coordinate of the point of impact of a discrete ray in three-dimensional space Indicates the first The depth coordinates of the point of impact of a discrete ray in three-dimensional space; S12: Calculate the i-th element in three-dimensional space using the linear projection method. The ordinate of the projection of the discrete ray hit points y-axis Specifically set as follows: ; in, This represents the ordinate of the reference point on the two-dimensional plane. Indicates the first The vertical coordinates of the points where discrete rays hit each other in three-dimensional space.
[0008] Preferably, in step S2, the affine transformation includes linear scaling and center translation, and the column index of the two-dimensional pixel grid. and row index Set them to: ; ; in, Indicates the image width. Indicates the image height.
[0009] Preferably, step S3 specifically includes the following steps: S31: Construct a local diffusion region using the rhombus kernel diffusion method, with the following specific construction conditions: ; in, Indicates distance from Manhattan. Represents the x-coordinate of a two-dimensional pixel. Represents the ordinate of a two-dimensional pixel; Within the local diffusion region, pixel intensities are accumulated according to a linear decay rule, using a weighting function. Calculate the weights of two-dimensional pixels using the weighting function. Specifically set as follows: ; Weighting function Equivalent kernel function Specifically set as follows: ; in, This indicates taking the maximum value; here, it represents the trajectory of taking the maximum value. Indicates the attenuation coefficient; S32: Construct a diffusion region in a specific direction using the rectangular kernel diffusion method, with the geometric constraints specifically set as follows: ; Within a diffusion region in a specific direction, pixel intensities are accumulated according to a linear decay rule, using a weighting function. Calculate the weights of two-dimensional pixels using the weighting function. Specifically set as follows: ; S33: Sample the two-dimensional pixel grid using a two-dimensional kernel density estimation method, and sample the set of points. Construct a continuous distribution, and the estimation form is specifically set as follows: ; in, This indicates the distribution of two-dimensional pixels at position. The probability density at that location, This represents the total number of two-dimensional pixels. The kernel function representing the two-dimensional kernel density estimation method Smoothing parameters in the horizontal axis direction, The kernel function representing the two-dimensional kernel density estimation method Smoothing parameters in the ordinate direction, Represents the x-coordinate of the sampling point. Represents the ordinate of the sampling point; Kernel function of two-dimensional kernel density estimation method Specifically set as follows: ; in, This represents an exponential function.
[0010] Preferably, in step S4, the kernel function diffusion result is nonlinearly compressed using the arctangent function to obtain the final intensity value. The final strength value Specifically set as follows: ; in, This represents the result of kernel function diffusion. Indicates the scale parameter.
[0011] Preferably, in step S5, the final intensity value is obtained through a single-channel to RGB pseudo-color mapping. Display the pseudo-color mapping results. Specifically set as follows: ; in, Including cyan and green, low-intensity areas are mapped as cyan, and high-intensity areas gradually transition to green.
[0012] Preferably, step S6 specifically includes the following steps: S61: Construct a uniform matrix array model of the light source using a regular two-dimensional array. The position of each light source Specifically defined as: ; in, The x-coordinate represents the light source. The vertical coordinate represents the light source. Indicates the total number of rows of light sources. Indicates the total number of columns for the light source. Indicates the center distance between adjacent light sources; S62: Generate the initial direction of the ray through random sampling of spherical coordinates, and the direction vector of the initial direction of the ray. Specifically set as follows: ; in, Indicates azimuth. Indicates the polar angle; S63: Based on geometric optics assumptions, calculate the intersection points of light rays with the scene during their propagation using ray tracing methods. Specifically set as follows: ; in, Indicates the starting point of the light ray. It represents the distance a ray of light travels from its origin along its direction. S64: At the interface of the medium, calculate the direction of refraction using the vector form of Snell's law. , direction of refraction Specifically set as follows: ; ; in, Indicates relative refractive index, This represents the direction vector of the incident ray. Indicates the angle of incidence of light. Indicates the angle of refraction of light. Represents the interface normal vector. Indicates the refractive index of the incident medium. This represents the refractive index of the reflecting medium.
[0013] Preferably, in step S7, the dataset The incident ray direction vector at the point where the ray intersects the screen. and hit point The set is obtained through manual recording.
[0014] Therefore, the geometric optical phenomenon reconstruction method based on the kernel density estimation algorithm described above, as used in this invention, has the following beneficial effects: (1) This scheme introduces a variety of kernel function diffusion methods to convert discrete light hit points into a smooth continuous intensity distribution, which effectively reduces the jaggedness and noise caused by traditional interpolation methods and improves the visual realism of image edges and detail areas and the accuracy of subsequent analysis. (2) This scheme uses the arctangent function to nonlinearly compress the diffusion result of the kernel function, maps the intensity range to a finite interval, and realizes the gradual visualization from low intensity to high intensity through pseudo-color mapping, thereby avoiding intensity saturation and information loss, and enhancing the contrast and sense of hierarchy of the overall distribution. (3) Based on ray tracing technology, this scheme combines regular light source arrays and random sampling of spherical coordinates to generate light rays. It uses Snell's law in vector form to accurately calculate the refraction direction, which can simulate complex refraction behavior in non-uniform media, multi-interface and dynamic media, and improve the realism and applicability of the method in actual optical simulation.
[0015] The method of the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. Attached Figure Description
[0016] Figure 1 This is a flowchart of a geometric optical phenomenon reconstruction method based on a kernel density estimation algorithm according to the present invention. Detailed Implementation
[0017] The method of the present invention will be further described below with reference to the accompanying drawings and embodiments.
[0018] Unless otherwise defined, the methodological or scientific terms used in this invention shall have the ordinary meaning as understood by one of ordinary skill in the art to which this invention pertains.
[0019] The terms "comprising" or "including" as used in this invention mean that the element preceding the term encompasses the element listed after the term, and do not exclude the possibility of encompassing other elements. Terms such as "inner," "outer," "upper," and "lower" indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings, and are only for the convenience of describing the invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, they should not be construed as limitations on the invention. When the absolute position of the described object changes, the relative positional relationship may also change accordingly. In this invention, unless otherwise explicitly specified and limited, the term "attached" and similar terms should be interpreted broadly. For example, it can refer to a fixed connection, a detachable connection, or an integral part; it can refer to a direct connection or an indirect connection through an intermediate medium; it can refer to the internal communication of two elements or the interaction relationship between two elements. Those skilled in the art can understand the specific meaning of the above terms in this invention according to the specific circumstances.
[0020] Example like Figure 1 As shown, this invention provides a geometric optical phenomenon reconstruction method based on the kernel density estimation algorithm (KDE algorithm), which can map discrete ray hit point data in three-dimensional space to a two-dimensional plane and generate an intensity distribution image with a resolution of 128×128.
[0021] Includes the following steps: S1: By transforming coordinates, the points of impact of discrete ray rays in three-dimensional space are projected onto a two-dimensional plane to obtain the coordinates of the two-dimensional plane. ; Step S1 specifically includes the following steps: S11: Calculate the first in three-dimensional space using the radial projection method. The x-coordinate of the projection of the discrete ray hit point x-axis Specifically set as follows: ; in, Indicates the projection direction. Represents a symbolic function. This represents the x-coordinate of the reference point on a two-dimensional plane. This represents the depth coordinates of the reference point on a two-dimensional plane. Indicates the first The x-coordinate of the point of impact of a discrete ray in three-dimensional space Indicates the first The depth coordinates of the point of impact of a discrete ray in three-dimensional space; This mapping method is not orthogonal projection, but a signed radial projection method, which will... Points in the plane are compressed onto a one-dimensional axis according to their radial distance from the reference point, while simultaneously passing through... The symbols distinguish left and right directions.
[0022] S12: Calculate the i-th element in three-dimensional space using the linear projection method. The ordinate of the projection of the discrete ray hit points y-axis Specifically set as follows: ; in, This represents the ordinate of the reference point on the two-dimensional plane. Indicates the first The vertical coordinates of the points where discrete rays hit each other in three-dimensional space; This direction does not introduce nonlinear transformations; it only represents the height difference or vertical displacement.
[0023] S2: Transform continuous two-dimensional plane coordinates through affine transformation Mapping to pixel indices yields a two-dimensional pixel grid. This makes the original location Mapping continuous coordinates within an interval to discrete pixel index intervals ; In step S2, the affine transformation includes linear scaling and center translation, and the column index of the two-dimensional pixel grid. and row index Set them to: ; ; in, Indicates the image width. This represents the image height; in this embodiment, the image width... and image height All are set to 128.
[0024] S3: Convert discrete points into a continuous intensity distribution using multiple kernel function diffusion methods; Step S3 specifically includes the following steps: S31: Construct a local diffusion region using the rhombus kernel diffusion method, with the following specific construction conditions: ; in, Indicates distance from Manhattan. Represents the x-coordinate of a two-dimensional pixel. Represents the ordinate of a two-dimensional pixel; Within the local diffusion region, pixel intensities are accumulated according to a linear decay rule, using a weighting function. Calculate the weights of two-dimensional pixels using the weighting function. Specifically set as follows: ; Weighting function Equivalent kernel function Specifically set as follows: ; in, This indicates taking the maximum value; here, it represents the trajectory of taking the maximum value. Indicates the attenuation coefficient; This method features high computational efficiency, simple structure, and anisotropy, making it suitable for rapidly constructing local response regions.
[0025] S32: Construct a diffusion region in a specific direction using the rectangular kernel diffusion method, with the geometric constraints specifically set as follows: ; Within a diffusion region in a specific direction, pixel intensities are accumulated according to a linear decay rule, using a weighting function. Calculate the weights of two-dimensional pixels using the weighting function. Specifically set as follows: ; This method emphasizes the forward region and has a clear directionality.
[0026] S33: Sample the two-dimensional pixel grid using a two-dimensional kernel density estimation method, and sample the set of points. Construct a continuous distribution, and the estimation form is specifically set as follows: ; in, This indicates the distribution of two-dimensional pixels at position. The probability density at that location, This represents the total number of two-dimensional pixels. The kernel function representing the two-dimensional kernel density estimation method Smoothing parameters in the horizontal axis direction, The kernel function representing the two-dimensional kernel density estimation method Smoothing parameters in the ordinate direction, Represents the x-coordinate of the sampling point. Represents the ordinate of the sampling point; Kernel function of two-dimensional kernel density estimation method Specifically set as follows: ; in, Represents an exponential function; This method samples on a regular grid to obtain a smooth, continuous density distribution.
[0027] S4: The final intensity value is obtained by nonlinearly compressing the kernel function diffusion result using the arctangent function. ; In step S4, to avoid numerical instability caused by an excessively large density value range, the kernel function diffusion result is nonlinearly compressed using the arctangent function to obtain the final intensity value. The final strength value Specifically set as follows: ; in, This represents the result of kernel function diffusion. Indicates the scale parameter; This mapping can Mapped to It exhibits good robustness.
[0028] S5: Final intensity value obtained through single-channel to RGB pseudo-color mapping Display; In step S5, the final intensity value is obtained through a single-channel to RGB pseudo-color mapping. Display the pseudo-color mapping results. Specifically set as follows: ; in, Including cyan and green, low-intensity areas are mapped to cyan, while high-intensity areas gradually transition to green, thus highlighting the spatial distribution of high-density areas.
[0029] S6: Perform ray tracing and build a ray refraction model; Step S6 specifically includes the following steps: S61: Construct a uniform matrix array model of the light source using a regular two-dimensional array. The position of each light source Specifically defined as: ; in, The x-coordinate represents the light source. The vertical coordinate represents the light source. Indicates the total number of rows of light sources. Indicates the total number of columns for the light source. Indicates the center distance between adjacent light sources; S62: Generate the initial direction of the ray through random sampling of spherical coordinates, and the direction vector of the initial direction of the ray. Specifically set as follows: ; in, Indicates azimuth. Indicates the polar angle; S63: Based on geometric optics assumptions, calculate the intersection points of light rays with the scene during their propagation using ray tracing methods. Specifically set as follows: ; in, Indicates the starting point of the light ray. It represents the distance a ray of light travels from its origin along its direction. S64: At the interface of the medium, calculate the direction of refraction using the vector form of Snell's law. , direction of refraction Specifically set as follows: ; ; in, Indicates relative refractive index, This represents the direction vector of the incident ray. Indicates the angle of incidence of light. Indicates the angle of refraction of light. Represents the interface normal vector. Indicates the refractive index of the incident medium. This represents the refractive index of the reflecting medium. When the condition for total internal reflection is met, the direction of reflection is used instead of the direction of refraction.
[0030] S7: Based on the light refraction model and pseudo-color mapping rules, the light direction is mapped to the imaging plane coordinates to obtain the dataset. .
[0031] In step S7, the dataset The incident ray direction vector at the point where the ray intersects the screen. and hit point The set is obtained through manual recording.
[0032] Therefore, the present invention adopts the above-mentioned geometric optical phenomenon restoration method based on kernel density estimation algorithm, which realizes smooth and high dynamic range visualization of the three-dimensional discrete ray hit point to two-dimensional high-fidelity intensity distribution, effectively overcomes the jaggedness, noise and contrast imbalance problems of traditional methods, and improves the realism and adaptability of complex optical refraction phenomenon simulation.
[0033] Finally, it should be noted that the above embodiments are only used to illustrate the method of the present invention and not to limit it. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can still be made to the method of the present invention, and these modifications or equivalent substitutions should not cause the modified method to deviate from the spirit and scope of the method of the present invention.
Claims
1. A method for reconstructing geometrical optical phenomena based on a kernel density estimation algorithm, characterized in that, Includes the following steps: S1: By transforming coordinates, the points of impact of discrete ray rays in three-dimensional space are projected onto a two-dimensional plane to obtain the coordinates of the two-dimensional plane. ; S2: Transform continuous two-dimensional plane coordinates through affine transformation Mapping to pixel indices yields a two-dimensional pixel grid. ; S3: Convert discrete points into a continuous intensity distribution using multiple kernel function diffusion methods; S4: The final intensity value is obtained by nonlinearly compressing the kernel function diffusion result using the arctangent function. ; S5: Final intensity value obtained through single-channel to RGB pseudo-color mapping Display; S6: Perform ray tracing and build a ray refraction model; S7: Based on the light refraction model and pseudo-color mapping rules, the light direction is mapped to the imaging plane coordinates to obtain the dataset. .
2. The method for reconstructing geometric optical phenomena based on kernel density estimation algorithm according to claim 1, characterized in that, Step S1 specifically includes the following steps: S11: Calculate the first in three-dimensional space using the radial projection method. The x-coordinate of the projection of the discrete ray hit point x-axis Specifically set as follows: ; in, Indicates the projection direction. Represents a symbolic function. This represents the x-coordinate of the reference point on a two-dimensional plane. This represents the depth coordinates of the reference point on a two-dimensional plane. Indicates the first The x-coordinate of the point of impact of a discrete ray in three-dimensional space Indicates the first The depth coordinates of the point of impact of a discrete ray in three-dimensional space; S12: Calculate the i-th element in three-dimensional space using the linear projection method. The ordinate of the projection of the discrete ray hit points y-axis Specifically set as follows: ; in, This represents the ordinate of the reference point on the two-dimensional plane. Indicates the first The vertical coordinates of the points where discrete rays hit each other in three-dimensional space.
3. The method for reconstructing geometric optical phenomena based on kernel density estimation algorithm according to claim 2, characterized in that, In step S2, the affine transformation includes linear scaling and center translation, and the column index of the two-dimensional pixel grid. and row index Set them to: ; ; in, Indicates the image width. Indicates the image height.
4. The method for reconstructing geometric optical phenomena based on kernel density estimation algorithm according to claim 3, characterized in that, Step S3 specifically includes the following steps: S31: Construct a local diffusion region using the rhombus kernel diffusion method, with the following specific construction conditions: ; in, Indicates distance from Manhattan. Represents the x-coordinate of a two-dimensional pixel. Represents the ordinate of a two-dimensional pixel; Within the local diffusion region, pixel intensities are accumulated according to a linear decay rule, using a weighting function. Calculate the weights of two-dimensional pixels using the weighting function. Specifically set as follows: ; Weighting function Equivalent kernel function Specifically set as follows: ; in, This indicates taking the maximum value; here, it represents the trajectory of taking the maximum value. Indicates the attenuation coefficient; S32: Construct a diffusion region in a specific direction using the rectangular kernel diffusion method, with the geometric constraints specifically set as follows: ; Within a diffusion region in a specific direction, pixel intensities are accumulated according to a linear decay rule, using a weighting function. Calculate the weights of two-dimensional pixels using the weighting function. Specifically set as follows: ; S33: Sample the two-dimensional pixel grid using a two-dimensional kernel density estimation method, and sample the set of points. Construct a continuous distribution, and the estimation form is specifically set as follows: ; in, This indicates the distribution of two-dimensional pixels at position. The probability density at that location, This represents the total number of two-dimensional pixels. The kernel function representing the two-dimensional kernel density estimation method Smoothing parameters in the horizontal axis direction, The kernel function representing the two-dimensional kernel density estimation method Smoothing parameters in the ordinate direction, Represents the x-coordinate of the sampling point. Represents the ordinate of the sampling point; Kernel function of two-dimensional kernel density estimation method Specifically set as follows: ; in, This represents an exponential function.
5. The method for reconstructing geometric optical phenomena based on kernel density estimation algorithm according to claim 4, characterized in that, In step S4, the kernel function diffusion result is nonlinearly compressed using the arctangent function to obtain the final intensity value. The final strength value Specifically set as follows: ; in, This represents the result of kernel function diffusion. Indicates the scale parameter.
6. The method for reconstructing geometric optical phenomena based on kernel density estimation algorithm according to claim 5, characterized in that, In step S5, the final intensity value is obtained through a single-channel to RGB pseudo-color mapping. Display the pseudo-color mapping results. Specifically set as follows: ; in, Including cyan and green, low-intensity areas are mapped as cyan, and high-intensity areas gradually transition to green.
7. The method for reconstructing geometric optical phenomena based on kernel density estimation algorithm according to claim 6, characterized in that, Step S6 specifically includes the following steps: S61: Construct a uniform matrix array model of the light source using a regular two-dimensional array. The position of each light source Specifically defined as: ; in, The x-coordinate represents the light source. The vertical coordinate represents the light source. Indicates the total number of rows of light sources. Indicates the total number of columns for the light source. Indicates the center distance between adjacent light sources; S62: Generate the initial direction of the ray through random sampling of spherical coordinates, and the direction vector of the initial direction of the ray. Specifically set as follows: ; in, Indicates azimuth. Indicates the polar angle; S63: Based on geometric optics assumptions, calculate the intersection points of light rays with the scene during their propagation using ray tracing methods. Specifically set as follows: ; in, Indicates the starting point of the light ray. d represents the distance the ray travels from the starting point along the ray direction, and d represents the direction vector of the ray. S64: At the interface of the medium, calculate the direction of refraction using the vector form of Snell's law. , direction of refraction Specifically set as follows: ; ; in, Indicates relative refractive index, This represents the direction vector of the incident ray. Indicates the angle of incidence of light. Indicates the angle of refraction of light. Represents the interface normal vector. Indicates the refractive index of the incident medium. This represents the refractive index of the reflecting medium.
8. The method for reconstructing geometric optical phenomena based on kernel density estimation algorithm according to claim 7, characterized in that, In step S7, the dataset The incident ray direction vector at the point where the ray intersects the screen. and hit point The set is obtained through manual recording.