3D Vision & Scene Understanding
Depth, NeRFs and Gaussian splatting.
A photograph flattens the world: every point along a ray through the lens lands on the same pixel. Recovering the third dimension takes geometry (two views constrain each other through a single matrix), statistics (depth errors grow with the square of distance) and, since 2020, scene representations optimized through differentiable rendering: neural radiance fields and 3D Gaussian splatting.
What you’ll learn
- Write the pinhole projection with intrinsics and extrinsics, and count its degrees of freedom.
- Derive the epipolar constraint and the essential and fundamental matrices, prove the singular-value characterization of essential matrices, and estimate them robustly.
- Derive depth from disparity for rectified stereo, and its quadratic error growth.
- Derive NeRF's volume-rendering quadrature and 3D Gaussian splatting's projection and compositing, and compare the two representations.
The pinhole camera
A pinhole camera maps a world point to camera coordinates (the rotation and translation are the extrinsics) and projects through the optical center onto the image plane. In homogeneous coordinates, with the intrinsic matrix :
Dividing by depth is what makes the map lossy: with , , so every point () of a ray lands on the same pixel, and image size falls like . A single image cannot determine depth without prior knowledge. Learned monocular depth supplies that knowledge from data and recovers relative depth well, but metric scale only through cues, such as familiar object sizes, that the training data share. Geometry needs a second view.
Two views: epipolar geometry
Take two calibrated cameras, with a scene point's coordinates in the two camera frames related by , and normalized image points , which are proportional to . The relation says that , and , all expressed in camera 2's frame, are linearly dependent: they lie in one plane, the epipolar plane through both camera centers and the scene point.
Coplanarity means a zero triple product. Write the cross product as a matrix, , and divide out the unknown depths:
In pixel coordinates , substitute :
Geometrically, is the epipolar line in image 2 on which the match of must lie, so matching becomes a one-dimensional search. All epipolar lines pass through the epipoles, the images of the other camera's center, with and . Hence , and has degrees of freedom; has 5 (3 for the rotation and 2 for the direction of translation, whose scale is unobservable).
(⇒) Multiplying by a rotation preserves singular values, so find those of . Using and :
So the singular values are twice and , with null vector . (⇐) Take an SVD ; flipping the sign of a third singular vector, which multiplies the zero singular value, makes . Factor into a skew-symmetric matrix and a rotation:
is skew-symmetric, hence some , and is a rotation. There are four factorizations (, and or ); the one that places reconstructed points in front of both cameras is the true relative pose.
Estimation. Each correspondence gives one equation , linear in the nine entries of . The eight-point algorithm (Longuet-Higgins, 1981) stacks eight or more into , takes the right singular vector of with the smallest singular value, and projects the result to rank 2 by zeroing its smallest singular value, the nearest rank-2 matrix in Frobenius norm. Hartley (1997) showed that first translating and scaling each image's points (centroid at the origin, mean distance ) makes this simple method accurate: raw pixel coordinates in the hundreds sit beside homogeneous 1s and make badly conditioned. With calibrated cameras, Nistér's five-point solver (2004) estimates directly.
Real matches include outliers, so the solver runs inside RANSAC (Fischler & Bolles, 1981): fit a random minimal sample, count the correspondences that agree, keep the best fit. To draw at least one all-inlier sample of size with probability , when a fraction of the matches are inliers, takes
Stereo depth, and why far is hard
After rectification, which warps both images by homographies so that epipolar lines become matching horizontal rows, two cameras with focal length (in pixels) and parallel optical axes a baseline apart see a point at depth at horizontal positions that differ by the disparity :
Put the left camera at the origin and the right one at . By similar triangles:
Matching errors are roughly constant in pixels, . Propagate them to depth:
Depth error grows with the square of distance and shrinks with baseline and focal length. Disparity is an inverse depth, and points beyond cannot be told apart from points at infinity.
A stereo rig has px and m, and matching is accurate to px. What is the depth uncertainty at m, in meters?
Show the answer
1.19 m
m, against about 7 cm at 5 m: sixteen times worse at four times the distance. Beyond m the disparity is below the matching error. Doubling the baseline halves every one of these errors.
Finding is the hard part: matching patches along each row with a cost such as normalized cross-correlation, regularized for smoothness. Semi-global matching (Hirschmüller, 2008) aggregates costs along several one-dimensional paths and remains a strong classical method; learned methods build a cost volume over candidate disparities and regress with deep networks. With many cameras or frames, stereo becomes structure from motion: detect and match features, estimate camera poses incrementally, and refine all cameras and points jointly by bundle adjustment (Triggs et al., 2000). COLMAP (Schönberger & Frahm, 2016) is the standard open pipeline, and it supplies the camera poses that NeRF and Gaussian splatting assume.
Neural radiance fields
NeRF (Mildenhall et al., 2020) represents a scene as a function , an MLP that maps a 3-D position and a viewing direction to an emitted color and a volume density. Density depends on position only and color on both, so geometry is shared across views while reflections can change with the viewpoint. A pixel's color is the expected color along its camera ray :
Split the ray at samples with gaps , and assume and constant on each interval. There , so each interval's contribution is exact:
Transmittance multiplies across intervals. With the opacity :
This is front-to-back alpha compositing. Every step is differentiable, so is fit by gradient descent on the photometric loss over rays from posed photographs. The weights also give an expected depth, .
Two details made it work. MLPs are biased toward low frequencies (spectral bias; Rahaman et al., 2019), so each input coordinate is lifted with a Fourier positional encoding with for position and for direction; Tancik et al. (2020) explain with the neural tangent kernel why such features let networks fit high frequencies. And sampling is hierarchical: a coarse network's weights define a distribution along the ray from which a fine network draws extra samples near surfaces. The cost was the drawback: hundreds of network evaluations per pixel, and one to two days of training per scene in the original; multiresolution hash encodings (Instant-NGP; Müller et al., 2022) cut training to minutes or less.
Three samples along a ray have opacities , front to back. What weight does the third sample's color get in the pixel?
Show the answer
C.
, so the weight is . The three weights , and sum to ; the remaining is the transmittance past the last sample, usually filled by a background color.
3D Gaussian splatting
3D Gaussian splatting (Kerbl et al., 2023) keeps NeRF's image formation but makes the scene explicit: millions of anisotropic 3-D Gaussians, each with a mean , a covariance , an opacity and a view-dependent color stored as spherical-harmonic coefficients (degree 3: 16 per color channel), initialized from structure-from-motion points. Rendering rasterizes them instead of marching rays through a network.
Optimizing entrywise could leave the positive semidefinite cone. Parametrize it instead by a rotation (from a unit quaternion) and per-axis scales :
Affine maps send Gaussians to Gaussians: if , then . Perspective projection is not affine, so linearize it at the mean, with the world-to-camera rotation and the projection's Jacobian there, and keep the image-plane block (EWA splatting; Zwicker et al., 2001):
Each Gaussian becomes a 2-D "splat". Sort the splats by depth and composite front to back, with the same rule as NeRF's quadrature:
A tile-based rasterizer (-pixel tiles and one global sort) renders this in real time, at least 30 frames per second at 1080p in the paper, and it is differentiable, so all Gaussian parameters are optimized on an plus D-SSIM photometric loss. Adaptive density control clones small Gaussians in under-reconstructed regions, splits large ones, and prunes those that become nearly transparent.
| Aspect | NeRF (2020) | 3D Gaussian splatting (2023) |
|---|---|---|
| Representation | implicit: an MLP queried at any point | explicit: a set of Gaussians with positions, shapes, opacities and colors |
| Rendering | ray marching, many network evaluations per pixel | rasterization of depth-sorted splats |
| Speed | slow in the original; much faster with hash grids | real time once optimized |
| Memory | small: the network's weights | large: often hundreds of megabytes for millions of Gaussians |
| Editing and geometry | hard to edit; geometry implicit in | primitives can be moved or deleted; surfaces remain approximate |
Beyond view synthesis, these representations are becoming tools for scene understanding. Features distilled from 2-D models into the 3-D field give semantic, language-queryable scenes, and feed-forward networks now predict 3-D structure directly from one or a few images without per-scene optimization: DUSt3R (Wang et al., 2024), for example, regresses per-pixel 3-D point maps from an image pair without known camera intrinsics.
Key takeaways
- Pinhole projection: , with 11 degrees of freedom; dividing by depth loses it, so one view needs priors and geometry needs two.
- Two views satisfy with (rank 2, 7 degrees of freedom); essential matrices are exactly those with singular values . Estimate them with the normalized eight-point or five-point solver inside RANSAC.
- Rectified stereo gives and : depth error grows quadratically with distance.
- NeRF renders an MLP field with the quadrature , ; Gaussian splatting composites projected Gaussians, , with the same rule at real-time rates.
Check yourself
In the interactive lesson these are scored with your confidence, and what you miss comes back for review.
How many degrees of freedom does the fundamental matrix have, and why?
- 9: one per entry
- 8: nine entries, up to scale
- 7: nine entries, up to scale, with
- 5: rotation and translation direction
Show the answer
C. 7: nine entries, up to scale, with
Overall scale removes one degree of freedom and the rank-2 constraint another, leaving 7. The essential matrix, for calibrated cameras, has 5: 3 for the rotation and 2 for the direction of translation.
Why does Hartley's eight-point algorithm translate and scale the image points before solving ?
- To enforce the rank-2 constraint
- To remove outliers
- Because is only defined for unit vectors
- To make the linear system well conditioned: raw pixel coordinates in the hundreds next to homogeneous 1s give entries spanning many orders of magnitude
Show the answer
D. To make the linear system well conditioned: raw pixel coordinates in the hundreds next to homogeneous 1s give entries spanning many orders of magnitude
Rows of contain products such as next to entries equal to 1, so small pixel noise is hugely amplified in the smallest singular vector. Normalizing (centroid at the origin, mean distance ) balances the entries; Hartley (1997) showed it made the linear method nearly as accurate as the best iterative methods of the time.
In NeRF, why does the density depend only on position, while the color depends on position and viewing direction?
- To make rendering faster
- So that geometry is shared by all views while view-dependent effects, such as specular highlights, can vary
- Because viewing directions cannot be positionally encoded
- Because density is learned by a separate network
Show the answer
B. So that geometry is shared by all views while view-dependent effects, such as specular highlights, can vary
If density could change with the viewing direction, the network could explain each training image with its own geometry and generalize poorly to new views. Tying to position enforces one consistent scene, while direction-dependent color models reflections.
Why does 3D Gaussian splatting parametrize each covariance as ?
- It guarantees that stays symmetric positive semidefinite while gradient descent updates and freely
- It makes every Gaussian isotropic
- Alpha compositing requires it
- It gives each covariance fewer than three parameters
Show the answer
A. It guarantees that stays symmetric positive semidefinite while gradient descent updates and freely
Gradient steps on the six entries of a symmetric matrix can leave the positive semidefinite cone and produce invalid Gaussians. Every is positive semidefinite, and a unit quaternion plus three scales still covers all six degrees of freedom of a covariance.
Further reading
- R. Hartley & A. Zisserman, Multiple View Geometry in Computer Vision (Cambridge, 2nd ed., 2004).
- H. C. Longuet-Higgins, "A computer algorithm for reconstructing a scene from two projections," Nature 293 (1981).
- R. I. Hartley, "In defense of the eight-point algorithm," IEEE Transactions on Pattern Analysis and Machine Intelligence 19(6) (1997).
- B. Mildenhall, P. P. Srinivasan, M. Tancik, J. T. Barron, R. Ramamoorthi & R. Ng, "NeRF: Representing scenes as neural radiance fields for view synthesis," ECCV (2020).
- B. Kerbl, G. Kopanas, T. Leimkühler & G. Drettakis, "3D Gaussian splatting for real-time radiance field rendering," ACM Transactions on Graphics 42(4) (2023).