Principle · How it works

How a digital camera measures light

Follow light through a CMOS sensor and see how a black-and-white pattern becomes a mosaic of RAW measurements.

Light, charge and RAW codes
Incident light ↓MicrolensColour filterSilicon photodiode
Charge → voltage → digital code
RAW mosaicOne code per photosite

What does the camera record?

These black-and-white stripes from the Colour test chart are each one pixel wide. Imagine a projected image with one sensor column per stripe. With a repeating grid of red, green and blue filters (a Bayer array) aligned as in the example below, red filters sit over white stripes and blue filters sit over black. The sensor records one RAW code per site. The filter pattern tells the processor which kind of measurement each code represents.

Eight alternating white and black columns, starting with white
Eight columns of the chart’s one-pixel stripe target, enlarged.

How a photosite collects light

A photosite is one light-sensitive position on the sensor. A microlens directs light towards its photodiode. Between them, a colour filter lets through different fractions of light at different wavelengths. In the silicon, absorbed photons can generate electrons that the photodiode collects during the exposure.

Think of each filter and photodiode as having a combined sensitivity curve. The curve tells you how strongly photons at each wavelength contribute to the expected electron count. The red, green and blue curves overlap. Each photosite sums these contributions into one charge. Different spectra can therefore leave the same charge at a single photosite. The image processor uses measurements through different filters to estimate colour.

What passes through a colour filter?

Imagine a uniform patch illuminating three neighbouring photosites. During one exposure, each site receives an average of 200 photons around 460 nm, 400 around 540 nm and 600 around 620 nm. Suppose the green-filtered site collects an electron from 10%, 50% and 8% of the photons in those bands, respectively. That gives 20 + 200 + 48 = 268 electrons on average.

One patch, three filter responses. Model values per exposure.
BandPhotonsbluegreenred
460 nm200120 e⁻20 e⁻2 e⁻
540 nm40040 e⁻200 e⁻40 e⁻
620 nm6006 e⁻48 e⁻330 e⁻
Expected electrons166 e⁻268 e⁻372 e⁻

Here φ is the photon arrival rate per nanometre at one photosite, before its filter. η is the mean number of collected electrons per incident photon for filter c, and tₑₓₚ is the exposure duration. The table replaces the wavelength integral with three bands and gives their photon counts already summed over the exposure.

The same light gives different expected charges under different filters. The red-filtered site even responds to some of the green-band photons. These are illustrative efficiencies. A real sensor integrates over the whole spectrum, and repeated exposures fluctuate around the expected charge.

How charge becomes a RAW code

Consider a four-transistor CMOS pixel with an electronic rolling shutter. To start an exposure, the sensor clears the photodiode and closes the transfer gate so newly collected electrons stay in the diode. Near the end of the exposure it resets and samples a separate sense node, also called the floating diffusion. The row driver then pulses the transfer-gate voltage TX. This lowers the barrier and moves the charge to the sense node. The time between clearing the photodiode and starting this transfer sets the exposure. The width of the TX pulse gives the stored charge time to move.

Exposure

The gate voltage keeps an electrical barrier in place. The photodiode collects electrons.

Charge transfer

The pulse lowers the barrier. Electrons move to the sense node and lower its voltage.

Readout timing
  1. Reset sense nodeSet its reference voltage. The photodiode is still collecting charge.
  2. Sample referenceRead the reset level with TX still low.
  3. Pulse TXDrive TX high to transfer the charge, then low to isolate the node again.
  4. Sample signalRead the lower voltage after transfer.
Simplified cross-section. The dashed arrow points from the row driver to the gate. The solid arrow between the photodiode and sense node shows electron flow through the silicon.

The column circuit reads the buffered sense-node voltage twice, once after reset and once after transfer. With complete transfer and an approximately constant sense-node capacitance, the drop at the node is

Here Nₑ is the transferred electron count, q is the magnitude of one electron’s charge and C₍FD₎ is the node capacitance. A larger charge packet gives a larger voltage drop. Subtracting the two readings suppresses the reset noise shared by both. This is correlated double sampling. An analogue-to-digital converter (ADC) digitises the signal. When the subtraction is digital, the circuit digitises both readings first.

A reading in darkness can still have an offset. The black level is the reference code for zero light signal. If black reads 64 and a patch reads 164, the signal above black is 100 codes.

Where the ISO setting acts

At fixed shutter time and aperture, changing ISO leaves the amount of light reaching the sensor unchanged. The ISO setting can control analogue gain before the ADC, digital scaling after it, or a combination, depending on the camera and mode. Analogue gain changes the voltage the ADC sees for the same collected charge. Digital scaling starts with the codes the ADC has already produced. If two highlights both clipped to the same code at the ADC, scaling those codes cannot separate them.

Compare ISO gain before and after the ADC

Each row of the comparison table starts with the same exposure and the same charge in the photodiode. The control shows gain relative to the model’s base ISO. A gain of 2× represents a one-stop increase. The photodiode holds up to 8,000 electrons. At base ISO the ADC adds 0.4 code steps of signal per electron above the black code of 64.

At 5,500 electrons, select 2×. Both paths finish at 4,095. Now increase Expected photoelectrons by one step to 5,600. In the Before ADC row, the ADC code stays at 4,095. In After ADC it rises from 2,264 to 2,304, even though the 12-bit result still reads 4,095. Those two ADC codes still distinguish the highlights. A processor that has them can lower the digital gain and recover that difference. If only the clipped result was saved, the difference is lost.

The graph compares the two responses at the ADC before rounding. The table shows where the code changes from the ADC to the output. The 12-bit output is a limit of this example. A real camera may keep the unscaled codes in RAW and apply digital gain later, or use a wider representation for processing.

Where does ISO gain clip the signal?
Full well 8,000 e⁻ · ADC max 4,095 · black code 64At base ISO, both paths have the same ADC response.
0600012000020474095ADC codeExpected photoelectronsSame exposure in both paths · 5,500 e⁻ stored.Photodiode full well limits the analogue path at ≈8,000 e⁻ expected. Input noise estimate: 74.2 e⁻ RMS.
Two ways to apply the same ISO gain
Gain appliedADC codeBefore output limit12-bit result
Before ADC226422642264
After ADC226422642264
Before ADC: the converter stays within range. After ADC: the scaled code fits in the 12-bit output.

In what order does the sensor read the frame?

In a common CMOS design, the sensor selects a row and sends its signals down the column lines. Each column has an ADC, so sites in the selected row can be digitised in parallel. The camera assembles those codes at their row and column positions in the RAW mosaic.

Why a moving edge can tilt

With a rolling shutter, each row starts and ends its exposure a little later than the previous row. If a vertical edge moves to the right while the sensor exposes rows from top to bottom, the lower rows catch the edge farther to the right. Reversing the exposure order reverses the tilt. The edge is already tilted in the RAW measurements.

If the edge moves at v pixels per second and the row interval is Δt seconds, adjacent rows place the edge v × Δt pixels apart. Within each row the edge smears by the distance it moves during that row’s exposure. Shortening the exposure at the same row interval reduces smear while leaving the tilt intact. If the light itself pulses, rows can also record different brightnesses, producing bands.

A global shutter exposes all rows over the same interval and holds their measurements for readout. The camera can still read them row by row. By then the measurements are fixed, so their order of delivery has no effect on where the edge appears.

Move Capture time towards the start. The white line marks the selected time, the green bars show exposure, and the striped bars show readout. Each row appears on the right when its readout finishes.

Return to the completed frame and increase Time per row. The rolling shutter starts successive exposures farther apart, so the edge leans more even though every exposure still lasts 4 ms. Reverse Readout direction to reverse the lean. Then switch to Global shutter and try both controls again. The order and timing of delivery change while all rows capture the same edge position.

This model shows eight rows. In rolling mode, each exposure ends as that row begins readout. In global mode, all exposures end together and the sensor holds the values for readout.

How the sensor builds a frame
Sets the delay between exposure starts and the readout time per row.Exposure: 4 ms per row. The edge moves right at 2.5 px per ms.
Exposure Readout Selected time8 of 8 rows delivered.Scene edge at x = 138.0 px.Final frame: bottom of edge shifts 70 px right relative to top. Motion blur per row: 10 px.

Why identical exposures give different codes

Even a steady light delivers a fluctuating number of photons. In the simple shot-noise model, a site that collects 100 electrons on average fluctuates by about 10 electrons RMS. At 400 electrons, the fluctuation rises to about 20 electrons, while the signal rises fourfold. The relative fluctuation falls from 10% to 5%. Below saturation, the experiment reports √(Nₑ + 3²) electrons RMS. The variances of independent shot noise and the model’s 3-electron read noise add. This is an input-referred estimate, expressed in electrons before amplification. A fixed pattern that persists across dark frames can come from different site or readout offsets. A pattern that grows with uniform illumination can come from differences in sensitivity.

Where does each colour get sampled?

The colour-filter array assigns a filter type to each position. Read the tiles from the top left. In the Bayer tile shown here, the first row is red–green and the second is green–blue. That starting phase is RGGB.

Bayer · 2×2
Quad Bayer · 4×4
X-Trans · 6×6
Each square is one photosite. Each tile repeats across the sensor.

Bayer samples green at two of every four sites. Crop off the leftmost column and the tile starts with green–red above blue–green (GRBG).

Quad Bayer groups four neighbouring photosites of the same colour. If the camera combines each group into one sample, the result has a Bayer pattern at half the original width and height. X-Trans distributes all three filter types across each row and column of a six-by-six tile. The position of the nearest measurement for a given colour therefore depends on the layout.

Shift the stripes and read the mosaic

One chart stripe covers one sensor column. Each site measures light through its own filter. In this model a black stripe gives the black level of 64. A white stripe adds 800 codes, so the site reads 864. The model uses ideal filters and sharp stripes. In a real camera, the optics and the area of a photosite can soften the pattern.

Follow the black stripe down to the outlined blue site. Then set Stripe alignment to Shifted by one photosite. The stripe above that column changes from black to white. The filter stays in place.

Shift the image over a fixed Bayer tile
Projected stripes
WhiteBlack
Fixed filters and RAW codes
R864
G64
G864
B64
Blue site: black stripe → RAW 64.

The blue site now records 864 instead of 64. Both sites in that column record the same code because the model’s white stripe gives the same signal through each filter. The next article follows the outlined site through the image signal processor (ISP) and shows how it estimates the two missing components.

References