Image understanding, generation, and 3D reconstruction · Neural rendering and 3D reconstruction · VIS018 · Model
Neural Radiance Fields (NeRF, original)
NeRF optimizes a continuous scene representation from calibrated images and renders novel viewpoints. The original method fits one mostly static scene at a time;
In CodeSplash
Documented in the Academy only. There's no Set up button.
- Availability
- Explained here
- Code example
- Component demo, not a trained model
- Who ran it
- CodeSplash's run and the reference's record
- CodeSplash's run
- The reference's example ran in Python and R here, and they agree.
- The reference's record
- Python: Ran in the reference's review. The report doesn't record which version of the code ran. R: Reviewed but not run: R wasn't available to the reference's authors.
Purpose
NeRF optimizes a continuous scene representation from calibrated images and renders novel viewpoints. The original method fits one mostly static scene at a time; it is not automatically a general pretrained 3D understanding model or a method for recovering unknown camera poses.
Question / hypotheses
Can a calibrated set of images constrain a continuous radiance field that renders genuinely held-out views? This is a modeling/evaluation question, not a formal null-hypothesis test.
Architecture / computational structure
An MLP maps position to volume density and a feature vector; view direction helps predict emitted color. Positional encoding represents higher frequencies. Hierarchical samples along camera rays are integrated using differentiable volume rendering, with coarse and fine networks in the original design.
Assumptions
Calibrated overlapping views should constrain a static scene with compatible appearance. Sparse views, inaccurate poses, motion, specular/translucent materials and out-of-bounds viewpoints can create artifacts. Good training-image reconstruction does not imply correct unseen geometry.
Formula / computational definition
, and . Here is density, a ray interval and RGB color. Fit photometric error between rendered and observed pixel colors.
Parameters and notation
Notation: Here r is a camera ray, i an ordered sample interval, sigma_i volume density, delta_i interval length, c_i sample RGB and T_i cumulative transmittance. The sum leaves residual transmittance for a background term; finite ray bounds and density units must be consistent.
Learned or estimated: Scene-specific MLP weights for density and radiance, and original coarse/fine networks. Camera parameters are treated as known in the original formulation; extensions may estimate them separately.
Hyperparameters and effects: Ray batch size, near/far bounds, sample counts, positional-encoding frequencies, network depth/width and optimizer. Higher sampling improves quadrature at cost; frequencies affect detail and aliasing. Scene coordinates and exposure normalization matter.
Fitting, fine-tuning, and adaptation
Fit the scene networks against image reconstruction loss and hold out camera views. Continuing optimization on added views is scene refinement, not necessarily transfer learning. For a related-scene warm start, adjust coordinate frames and cautiously refit density/color weights with small rates; re-evaluate previously observed views to detect forgetting or geometric drift.
How to use and calibrate
Hold out complete camera views and, for transfer claims, complete scenes; report calibration, coordinate units and capture overlap. Use held-out-view PSNR/SSIM and a documented perceptual metric, plus depth/geometry checks where ground truth exists. Report rendering time, sample count, training cost and pose assumptions; avoid evaluating on training viewpoints only.
Example application
Render new viewpoints of a static photographed object or small scene. This is a proposed use case, not a claim of validated performance on supplied real data.
Interpretation / pitfalls
Watch out
Scene fitting may achieve high training-view fidelity with incorrect geometry. Rendering quality, camera accuracy and geometric validity need separate checks. A correct component calculation does not validate the full architecture, checkpoint or deployment pipeline.
Python and R code examples
Scope: NeRF discrete volume rendering for one ray with a background term; supplied densities/colors substitute for the learned radiance field. Use the shared setup. Dependencies: NumPy / base R. Validation: Python executed; R unexecuted.
Full-model route: Python: original NeRF code or a verified renderer. R: native tensor/autodiff implementation or bridge. The NumPy/base-R example exactly computes discrete ray compositing from supplied density/color samples.
Python and R
The reference's own programs, shown as written. A component demo shows one central piece of the method; it doesn't train a full model.
Component demo, not a trained model — NeRF discrete volume rendering for one ray with a background term; supplied densities/colors substitute for the learned radiance field. Use the shared setup.
Shared setup for this chapter
import numpy as np
from itertools import permutations
def softmax(x):
x=np.asarray(x,dtype=float)
e=np.exp(x-x.max(axis=-1,keepdims=True))
return e/e.sum(axis=-1,keepdims=True)
def bilinear(a,y,x):
y=float(np.clip(y,0,a.shape[0]-1)); x=float(np.clip(x,0,a.shape[1]-1))
y0=int(np.floor(y)); x0=int(np.floor(x))
y1=min(y0+1,a.shape[0]-1); x1=min(x0+1,a.shape[1]-1)
dy=y-y0; dx=x-x0
return (1-dy)*((1-dx)*a[y0,x0]+dx*a[y0,x1])+dy*((1-dx)*a[y1,x0]+dx*a[y1,x1])
sigma=np.array([.3,1.2,.7]); delta=np.array([.5,.5,1.])
rgb=np.array([[1.,0.,0.],[0.,1.,0.],[0.,0.,1.]])
alpha=-np.expm1(-sigma*delta)
trans=np.exp(-np.r_[0,np.cumsum(sigma*delta)[:-1]])
weights=trans*alpha; background=np.exp(-np.sum(sigma*delta))
color=weights@rgb+background*np.ones(3)
assert np.isclose(weights.sum()+background,1) and np.all((color>=0)&(color<=1))
print('ray weights:',weights,'background:',background,'RGB:',color)
Component demo, not a trained model — NeRF discrete volume rendering for one ray with a background term; supplied densities/colors substitute for the learned radiance field. Use the shared setup.
Shared setup for this chapter
softmax <- function(x) {
if(is.null(dim(x))) {e<-exp(x-max(x)); return(e/sum(e))}
t(apply(x,1,function(v) {e<-exp(v-max(v)); e/sum(e)}))
}
bilinear <- function(a,y,x) {
y<-min(max(y,0),nrow(a)-1); x<-min(max(x,0),ncol(a)-1)
y0<-floor(y); x0<-floor(x); y1<-min(y0+1,nrow(a)-1); x1<-min(x0+1,ncol(a)-1)
dy<-y-y0; dx<-x-x0
(1-dy)*((1-dx)*a[y0+1,x0+1]+dx*a[y0+1,x1+1])+dy*((1-dx)*a[y1+1,x0+1]+dx*a[y1+1,x1+1])
}
sigma<-c(.3,1.2,.7); delta<-c(.5,.5,1)
rgb<-diag(3); alpha<--expm1(-sigma*delta)
trans<-exp(-c(0,head(cumsum(sigma*delta),-1)))
weights<-trans*alpha; background<-exp(-sum(sigma*delta))
color<-as.vector(weights%*%rgb)+background
stopifnot(abs(sum(weights)+background-1)<1e-12,all(color>=0 & color<=1))
print(list(ray_weights=weights,background=background,RGB=color))
Sources
- Source 1arxiv.org
- Source 2github.com
From the CodeSplash reference, entry VIS018.