C02 · From light to pixels
Sensor measurements and ISP
One channel is measured and two estimated. Before comparing colours, establish what sensor codes mean.
Background if needed
Theory
From electrons to codes
An absorbed photon can create an electron. Readout adds noise and offset; ADC maps signal to finite codes. Shot noise depends on mean signal. Black and white levels are needed before comparing codes across modes; black level is not scene light.
Subtracting is not dividing
A dark frame estimates offset; a flat field estimates relative sensitivity. Subtract offset before correcting response. A defective photosite needs another estimate; flat field cannot repair a missing measurement. Here parameters are exact and noiseless, so full correction is reversible.
Compare three modes on one channel. Without correction the code contains an offset; subtraction leaves response scaling; division restores the original magnitude. Calibration precedes channel comparison and mixing. For clarity this experiment displays three aligned planes; real RAW correction often acts on individual mosaic sites before reconstruction.
Offset and shading
Compare no correction, black subtraction and full correction. Inspect centre and corner.
Exact values are in the point inspector
RGB linear → sRGB; display range 0…1
- Selected channel: subtract offset
- Working range × response
- Divide
Exact values are in the point inspector
RGB linear → sRGB; display range 0…1
Inspect the selected point
What the plot shows
Full correction restores original values in a noiseless model. Real division by weak response also amplifies noise.
Parameters and details
The artificial black level is known exactly; response falls toward the corners. Offset subtraction and flat-field division solve different problems. Full correction is reversible without noise; dividing by a weak response would also amplify noise.
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.
Measured or estimated?
A typical Bayer 2 × 2 block contains red, two green and blue filters. This distributes measurements spatially; it does not provide three complete RGB values per site. Real filters have broad, overlapping spectral responses.
Demosaicing estimates missing values: nearest neighbour is simple, bilinear averaging smooths and a directional estimate may preserve an edge better. None knows the hidden scene; fine patterns can become false colour. This example has known truth, exposing the error.
One measured channel, three output channels
Switch R, G, B at one point. Identify the measured channel, then compare estimates on straight and diagonal edges.
Exact values are in the point inspector
RGB linear → sRGB; display range 0…1. Color shows the measured channel; other channels are unknown. Pattern: no measurements.
Exact values are in the point inspector
RGB linear → sRGB; display range 0…1
Inspect the selected point
What the plot shows
The measured channel stays unchanged. Two others are estimated from genuine neighbouring measurements, not unknown zeros.
Parameters and details
RGGB is one CFA layout. Missing mosaic components are marked unmeasured, not as measured zeros. The bilinear variant averages the nearest available samples of the requested colour; borders use only existing samples. The directional variant changes only green estimation by choosing the lower difference; this is a teaching heuristic, not an industrial ISP.
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.
White balance does not finish processing
Channel gains may neutralize one reference, but camera sensitivities differ from standard coordinates. Colour transformation, tone treatment and display encoding are also needed. Teaching sequence: measurement → correction → reconstruction → white balance and colour → tone and encoding.
Real ISPs combine or reorder some stages. RAW is not always Bayer, and JPEG no longer contains the original mosaic. Finished RGB cannot honestly be relabelled as its original photosite measurements.
White balance and a colour matrix
Choose None and change illumination. White balance removes the cast but the sensor channels remain mixed. Add the matrix and compare with the reference. Select a colour and switch channels to follow the three contributions.
Exact values are in the point inspector
RGB linear → sRGB; display range 0…1
Exact values are in the point inspector
RGB linear → sRGB; display range 0…1
Inspect the selected point
What the plot shows
Per-channel scaling and mixing three channels solve different problems. Together they restore colour in this exactly known model; a real camera requires measured coefficients.
Parameters and details
Authored linear model: illumination scales channels differently and the sensor mixes neighbouring components. White balance reverses the scaling; a separate matrix reverses mixing. These known coefficients cannot calibrate a real camera. No sRGB encoding has been applied yet.
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.
Do not confuse estimates with measurements
A missing green channel is selected at a diagonal edge with another CFA phase. Predict whether copying one neighbour or averaging will have less error. Change method and compare against known truth. Then select a measured channel: it must stay unchanged.
Exact values are in the point inspector
RGB linear → sRGB; display range 0…1. Color shows the measured channel; other channels are unknown. Pattern: no measurements.
Exact values are in the point inspector
RGB linear → sRGB; display range 0…1
Inspect the selected point
What the plot shows
The measured channel stays unchanged. Two others are estimated from genuine neighbouring measurements, not unknown zeros.
Parameters and details
RGGB is one CFA layout. Missing mosaic components are marked unmeasured, not as measured zeros. The bilinear variant averages the nearest available samples of the requested colour; borders use only existing samples. The directional variant changes only green estimation by choosing the lower difference; this is a teaching heuristic, not an industrial ISP.
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
Do not confuse estimates with measurements
Which estimation rule produces this result at the edge?
Exact values are in the point inspector
RGB linear → sRGB; display range 0…1. Color shows the measured channel; other channels are unknown. Pattern: no measurements.
Exact values are in the point inspector
RGB linear → sRGB; display range 0…1
Exact values are in the point inspector
RGB linear → sRGB; display range 0…1
Compare your result with the reference.
Inspect the selected point
What the plot shows
The measured channel stays unchanged. Two others are estimated from genuine neighbouring measurements, not unknown zeros.
Parameters and details
RGGB is one CFA layout. Missing mosaic components are marked unmeasured, not as measured zeros. The bilinear variant averages the nearest available samples of the requested colour; borders use only existing samples. The directional variant changes only green estimation by choosing the lower difference; this is a teaching heuristic, not an industrial ISP.
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.
Test your explanation
Question 1 of 5
Measurement is 0.30, black level 0.10, working range × response 0.50. Corrected result?
Exact values are in the point inspector
RGB linear → sRGB; display range 0…2
Exact values are in the point inspector
RGB linear → sRGB; display range 0…1
Exact values are in the point inspector
RGB linear → sRGB; display range 0…1. Color shows the measured channel; other channels are unknown. Pattern: no measurements.
Exact values are in the point inspector
RGB linear → sRGB; display range 0…1
Exact values are in the point inspector
RGB linear → sRGB; display range 0…1
Choose one answer. It is checked immediately.
Limitations and references
Limits of this example
Synthetic mosaic. Directional estimation is a local green heuristic, not Malvar or an industrial ISP. No RAW import or real-camera calibration.