2D Gaussian Splat Evaluation
Compute the 2D Gaussian splat value at a pixel.
3D Gaussian Splatting represents scenes as millions of 3D Gaussians. When projected to 2D, each becomes an elliptical Gaussian:
G(x,y)=exp(−2σx2(x−μx)2−2σy2(y−μy)2)
where:
- (x,y) is the pixel position
- (μx,μy) is the Gaussian center
- (σx,σy) are the standard deviations (scale)
This axis-aligned version is simplified - real 3DGS uses full 2D covariance for rotated ellipses.
Example:
gaussian_splat((0, 0), (0, 0), (1, 1))
1.0
-
At center (0,0) of Gaussian centered at (0,0): dx² = (0-0)²/(2×1²) = 0 dy² = (0-0)²/(2×1²) = 0
-
G = exp(-(0+0)) = exp(0) = 1.0 Maximum value at center.
Constraints:
- pixel: (x, y) query position
- center: (μx, μy) Gaussian center
- sigma: (σx, σy) standard deviations
- Return Gaussian value, rounded to 4 decimal places
To compute the 2D Gaussian splat value at a pixel, you are just evaluating the Gaussian formula at a given (x,y) using the provided mean and standard deviations. The core of the task is plugging numbers into the exponent and applying exp in a numerically safe way.
1. Background Knowledge
A 2D Gaussian (or 2D normal) is a smooth bell-shaped function over the plane. In this simplified, axis-aligned form, the value at pixel (x,y) is:
G(x,y)=exp(−2σx2(x−μx)2−2σy2(y−μy)2)Here:
- (\mux,\muy) is the center of the splat in image coordinates.
- σx,\sigmay control the spread (scale) horizontally and vertically.
- The value is in (0,1]: it is 1 at the center and decays smoothly as you move away.
In neural rendering / Gaussian splatting, millions of such Gaussians are projected into the image plane; each one contributes a soft footprint (splat) to nearby pixels. Rendering is then done by accumulating these contributions (often with blending or alpha compositing), but this problem isolates just the evaluation of one splat at one pixel.
2. Algorithm / Approach
This is a direct formula evaluation problem:
- Compute horizontal and vertical offsets from the Gaussian center.
- Normalize by the standard deviations σx,\sigmay.
- Build the exponent term (sum of squared normalized distances, with −21 factor).
- Apply the exponential function.
This matches a common pattern: evaluate a parametric function at a given input. No loops or advanced data structures are needed.
3. Step-by-Step Strategy
Assume you are given:
- x, y (pixel coordinates)
- mu_x, mu_y (Gaussian center)
- sigma_x, sigma_y (standard deviations; strictly positive)
Steps:
- Compute offsets:
dx = x - mu_x
dy = y - mu_y
Continue the full explanation
You're reading the free preview. Unlock the complete walkthrough, the code editor, test runner and reference solution with Premium.
Editor locked
The code editor is locked for Pro problems. It is only available for free problems. Please upgrade to gain access to the code editor for all problems.