Sensor Lab
How small is it worth making a pixel? Shrinking pixels raises the sampling limit, but lens diffraction blurs the image first and each pixel collects fewer photons. Grow them and detail beyond Nyquist folds back as moiré and false colour. This lab simulates the whole imaging chain of a 128 × 128 sensor and measures it the way a camera lab would, so you can put numbers on that trade-off.
| Method | CPSNR | false colour | MTF50 | MTF@Nyq |
|---|---|---|---|---|
| Bilinear | — | — | — | — |
| Malvar–He–Cutler | — | — | — | — |
| Hamilton–Adams | — | — | — | — |
- Bilinear
- Averages the nearest samples of each colour. Blurs, and turns every luminance edge near the R/B Nyquist into colour fringes.
- Malvar–He–Cutler
- Bilinear plus a gain-weighted Laplacian of the channel actually measured at the pixel: 5×5 linear filters, sharper, fewer fringes.
- Hamilton–Adams
- Interpolates green along the smoother of the horizontal and vertical gradients, then fills R and B as colour differences. Keeps edges, can zipper on noise.
Scored against a noise-free 3-chip capture through the same optics (inner 120 × 120 px). MTF from the slanted edge captured with the same noise. CPSNR in the linear domain, peak = scene white.
Each point is a full noise-free slanted-edge capture through the current CFA and demosaic, run in a worker. SNR is the model value at 18 % grey for a fixed exposure time, so stopping down or shrinking pixels costs photons. Shaded band: 1 ≤ Q ≤ 2.
H(f) = Σc wc Dλc(ρ) · J(ρ) · cos(πfxd)cos(πfyd) · sinc(afx)sinc(afy)
D(ρ) = 2⁄π[acos ν − ν√(1−ν²)], ν = ρλN/p
J(ρ) = 2J1(πbρ)/(πbρ), b = Δz/N
Bands at 610 / 535 / 465 nm. Sampling every 4th fine sample is done by summing the 16 spectral replicas into the 128² spectrum, which is exactly how aliasing arises.
μe = η · Hλ · (2.8/N)² · (ap)²
y = ⌊K(min(𝒫(μe)+𝒫(μd), μe,sat) + σrε) + σpostε + y0⌉
σy² = K²(σd² + μd) + σq² + K(μy − μy,dark)
Full well 1700 e⁻/µm² of photodiode, base gain maps full well to full scale, post-gain noise 2.5 e⁻ at ISO 100 (so high ISO lowers input-referred read noise but cuts headroom). No PRNU/DSNU, no microlenses, ideal colour filters.
xe(y) = a + b y ← least squares on per-row LSF centroids (2 passes)
ESF4×(d), d = (x − xe(y)) cos θ, bins of ¼ px
MTF(f) = |𝔉[w · ∂ESF]| / |𝔉[w · ∂ESF](0)| / (sinc(2fΔ) sinc(fΔ))
Edge angle is estimated from the image, not assumed. Tukey window on the LSF; division by the derivative and binning transfer functions. Luminance of the demosaiced output, as in sfrmat.
What the simulation does
The scene is drawn in R, G and B bands on a grid four times finer than the pixels. Each band (610, 535, 465 nm) is multiplied by the diffraction OTF of a circular pupil, then by geometric defocus, the four-spot split of a birefringent OLPF and a square photodiode aperture. Sampling at the pixel centres is done in the frequency domain by summing 16 spectral replicas, so aliasing is not an approximation: it is the sampling itself. The RAW frame then picks up Poisson shot noise, dark signal, full-well clipping, read noise before and after the gain and ADC quantisation; black level and white balance are removed and three algorithms demosaic it.
Resolution is measured with the ISO 12233 slanted edge, estimating the edge angle from the image. Noise is measured as an EMVA 1288 photon-transfer curve from pairs of flat fields, recovering conversion gain and read noise. node scripts/test-sensor.ts checks the Airy first zero (1.22λN), measured vs theoretical MTF, the ½ slope in the shot-noise regime and the recovered gain.
What is simplified
- The lens is aberration-free and diffraction-limited; defocus is a geometric blur circle rather than a Hopkins wavefront model, so small focus errors blur less than they would in reality.
- Colour filters are ideal box bands. No pixel crosstalk, microlenses, colour-correction matrix or fixed-pattern noise (PRNU, DSNU).
- Scene content above the simulation grid's own Nyquist (2 cyc/px) is not represented. The pixel-aperture sinc suppresses that region strongly, but not to zero.
- The FFT assumes periodic boundaries, so the frame edges mix with the opposite side. The MTF ROI is kept away from them.
- The slanted-edge ESF window (±36 px) clips the long tails of a diffraction LSF, which can read up to ~0.03 above theory at low frequency, a bias real measurements share.