C01 · From light to pixels
Light, optics and the camera
Before pixels, light passes through a scene, a lens and an exposure interval. What is measured?
Theory
From the object through the lens to the sensor
We begin with an object and the light it reflects. A lens collects some rays and forms an inverted image on a sensor. The sensor is a grid of light-sensitive cells, each collecting light over a small area. Numbers appear only after measuring that light.
Light first. Numbers next.
Light from each point of an object passes through different parts of a lens. The lens directs those rays toward one point on the other side. The sensor must sit there; otherwise it receives a spot instead of a sharp point.
The object is three small light sources. Select point 1, 2 or 3 and follow its rays. Move the sensor to the sharp image plane. Then close the aperture: the spot shrinks, but less light arrives too.
The sensor is away from the sharp image plane: one point spreads over a spot 1.6 photosites wide.
Each photosite accumulates the light falling inside its area during the exposure.
Accumulated light → numberLight from points 1, 2 and 3 in the selected photosite: 0.325 + 0 + 0 ≈ 0.325. Multiply by 255 and round → 83 out of 255.
Ray-colored outlines show which photosites receive light from the selected point. Select any photosite: the readout adds the light from all three sources and rounds it to a number. A photosite does not know whether the object is a point, tree or face; it only measures the light it receives. A grid of these measurements becomes a raster image.
What this model simplifies
This is a geometric thin converging lens: focal length 1, object distance 3 and sharp image distance 1.5. The image is inverted. We move the sensor plane rather than the object. All lengths are model units; cameras usually move lenses instead. The diagram shows three rays in a cross-section, while an entire bundle passes through the circular aperture. Dashed extensions beyond the sensor show where rays would meet without it. A fixed set of pupil rays estimates each photosite's accumulated light. Small changes at cell boundaries reflect that numerical approximation.
Diffraction, aberrations, noise and color filters are omitted. Light, exposure and sensitivity use relative units; the numbers are not actual photon or electron counts. We round the linear signal to 0–255 to demonstrate digitization separately; this is not an exact RAW or JPEG model. Display brightness is encoded as sRGB for readability, while reported numbers remain linear. An ideal focused point is drawn as a small circle so it stays visible.
A point becomes a footprint
An idealized projection maps a scene point to the sensor. Focus, aperture, motion and diffraction spread its light into a point spread function, or PSF. Blur below is actually calculated from its weights.
A Gaussian is a teaching model, not an exact defocus disc or diffraction pattern. Normalization to 1 preserves light while the footprint fits inside the frame. Zero continuation loses light that leaves the frame.
The ray diagram explained where a footprint comes from. Now isolate its effect: each left cell is light from one site; the middle weights give its fraction reaching the selected right cell. Select the footprint's centre and edge: contributions change but the addition rule does not. We will later call this convolution.
Where does a point's light land?
Start with a point. Change PSF width, then compare a circular footprint with smear. Select the result to inspect contributions.
Exact values are in the point inspector
Grayscale 0…1: black to white.
Exact values are in the point inspector
Grayscale 0…1: black to white.
Inspect the selected point
What the plot shows
Each curve point is a pixel value on the marked horizontal line. Select another image row to move the graph. Compare edge width and preservation of detail.
- Input
- Output
A wider footprint lowers the peak, but normalized weights still sum to 1. Light is spread, not created.
- Total input light
- 1
- Total light inside frame
- 1
Parameters and details
A PSF distributes one point's light among its neighbours. Weights sum to 1; outside the scene is zero. The line models uniform motion blur, not a path recovered from a photograph.
Select an image point. Arrows move it; Home and End reach row edges. Viewing does not change the calculation.
Changing the example requires JavaScript and Canvas. Computed images remain available above.
Collection and amplification
A photosite has area and collects charge during exposure. Longer usually means more photons but more motion blur. A larger aperture admits more light and changes depth of field; focal length changes projection scale. Gain scales already acquired signal.
Capacity is finite: saturation maps distinct bright signals to one value. A stationary PSF assumes identical blur across the field; real lens corners, moving objects and rolling shutters can violate that. Test one cause at a time.
Select a dark cell: the calculation shows expected charge and one actual random measurement. Exposure changes the expectation before photon arrivals; gain acts after collection. Then select a bright cell and raise exposure to saturation: gain cannot restore the lost distinctions.
Collect light or amplify it?
Increase exposure, reset it, then increase gain. Compare expected and collected electrons at one point.
Exact values are in the point inspector
Grayscale 0…1: black to white.
- Expected electrons
- Random arrivals, capacity 64
- Gain and read noise
- Clip and round to a code
- Code on the 0–1 scale
Exact values are in the point inspector
Grayscale 0…1: black to white.
Inspect the selected point
What the plot shows
Exposure changes photon count before saturation. Gain scales acquired signal and drives codes toward clipping sooner.
Parameters and details
Teaching model: a 64-electron well, Poisson arrivals, well saturation, gain, read noise and 8-bit quantization. This order is explicit; real cameras are more complex. Seed fixes the noise realization.
Select an image point. Arrows move it; Home and End reach row edges. Viewing does not change the calculation.
Changing the example requires JavaScript and Canvas. Computed images remain available above.
Practice
Test the idea under another condition. Follow the task above the images; point inspection helps explain the result. This exploration is not scored.
Diagnose smear at an edge
This scene starts with horizontal smear. Find an edge perpendicular to the smear, then switch to a round footprint. Which edge was affected more? Compare transition width, not just overall softness.
Exact values are in the point inspector
Grayscale 0…1: black to white.
Exact values are in the point inspector
Grayscale 0…1: black to white.
Inspect the selected point
What the plot shows
Each curve point is a pixel value on the marked horizontal line. Select another image row to move the graph. Compare edge width and preservation of detail.
- Input
- Output
A wider footprint lowers the peak, but normalized weights still sum to 1. Light is spread, not created.
- Total input light
- 160.1703
- Total light inside frame
- 144.1581
Parameters and details
A PSF distributes one point's light among its neighbours. Weights sum to 1; outside the scene is zero. The line models uniform motion blur, not a path recovered from a photograph.
Select an image point. Arrows move it; Home and End reach row edges. Viewing does not change the calculation.
Changing the example requires JavaScript and Canvas. Computed images remain available above.
Games
Test your explanation
Question 1 of 5
Two bright regions filled the sensor well. Can reducing gain distinguish them?
Exact values are in the point inspector
Grayscale 0…1: black to white.
Exact values are in the point inspector
Grayscale 0…1: black to white.
Exact values are in the point inspector
Grayscale 0…1: black to white.
Exact values are in the point inspector
Grayscale 0…1: black to white.
Choose one answer. It is checked immediately.
Limitations and references
Limits of this example
Synthetic 2D scene, stationary PSF and illustrative sensor well. No ray tracing, RAW import or recovery of real motion.