Computational Photography
Four pipelines, all in Packages/ORIXCameraKit/Sources/ORIXImaging/Computational/, all operating on gamma-encoded values in 32-bit float. They are ORIX Camera's own; none uses or imitates Apple's private processing.
Shared type: FloatImage, three planar float arrays (R, G, B, 0…1), with conversions from BGRA buffers and CGImages and to 8-bit buffers and 16-bit CGImages.
1. FrameAccumulator: long exposure and light trails
| Mode | Per frame | Result |
|---|---|---|
mean |
sum += frame (vDSP_vadd) |
sum / (255 · N) |
lighten |
sum = max(sum, frame) (vDSP_vmax) |
sum / 255 |
Frames are converted row by row from 8-bit to float into a small scratch buffer, so the working memory is three float planes: 12 bytes per pixel (25 MB at 1080p, 100 MB at 4K). Frames of another size or format are rejected.
In the app: the shutter starts the accumulation with a frame limit of seconds × frame rate; the monitor shows result() converted to 8 bits about every 450 ms; reaching the limit, or pressing the shutter again, finishes it. Fewer than two frames is reported as a failure.
Honest naming. Averaging N short exposures approximates one exposure N times longer for motion and noise; it does not gather more light per frame and it cannot recover highlights a single frame clipped. The tool's description says "A computed long exposure, not a long shutter."
Resolution. Output is at the live stream's resolution.
Tests: mean of constants; maximum of constants; rejected sizes; a moving light draws a ring under lighten while never darkening any pixel; mean blurs the moving light and leaves a static patch unchanged; the 16-bit output keeps sub-code-value precision (100.5/255 survives).
2. StackDenoiser: night stack
The first frame is the reference. Each later frame s is merged per pixel and per channel:
d = s − r r = reference
w = τ² / (τ² + d²) τ = 0.06 by default
num += w · s den += w (both start at r and 1)
result = num / denWhere the scene is static, d is only noise, w ≈ 1, and the result approaches a plain average: noise standard deviation falls roughly with √N. Where something moved, d is large, w → 0, and the reference pixel survives: no ghost.
Frames can be shifted by whole pixels before merging; rows and columns that fall outside are left out of the sums.
Tests: eight noisy copies of a static image gain more than 6.5 dB PSNR (ideal averaging gives 9 dB); a square moving across five frames leaves no ghost where a plain mean would; a shifted frame merges in place.
3. ImageAligner: registration
VNTranslationalImageRegistrationRequest gives the translation that maps a frame onto the reference; the app rounds it to whole pixels.
Plausibility guard. A shift larger than 8 % of the frame side is rejected (maxShiftFraction). During development, a periodic test texture made Vision return a 131-pixel shift for a 4-pixel displacement: registration can lock onto the wrong structure. A rejected frame is skipped and counted, never merged at a wrong offset. If fewer than two frames remain, the capture fails with "The frames could not be aligned. Hold the camera steady or use a tripod."
Only translation is corrected. Rotation and parallax are not: these modes are for a tripod or steady hands.
4. ExposureFusion: bracket fusion
Mertens, Kautz and Van Reeth (2007). For each exposure k a weight map:
W_k = C_k^wc · S_k^ws · E_k^we + 10⁻⁶
C = |Laplacian of luma| contrast
S = standard deviation of R, G, B saturation
E = Π_c exp(−(c − 0.5)² / (2σ²)), σ = 0.2 well-exposednessWeights are normalised across exposures. Each weight map becomes a Gaussian pyramid; each channel of each exposure becomes a Laplacian pyramid; the fused pyramid is the weighted sum level by level; collapsing it gives the result, clipped to 0…1. Blending per frequency band is what prevents seams and halos where the weights change.
Pyramid operators: 5 × 5 binomial blur and resampling with vImage. The Laplacian level is defined as G_l − up(G_{l+1}) with the same up used when collapsing, so reconstruction is exact for any resampling filter; a test confirms it to 10⁻⁴.
Memory. Sources are held as 8-bit RGBA and float planes are produced one at a time. Measured peak for three exposures (orix-bench fusion, /usr/bin/time -l): 542 MB at 6 MP, 720 MB at 8 MP, 929 MB at 12 MP. CameraModel.fusionPixelBudget therefore limits the working size by physical memory: 4 MP under 5 GB, 6 MP under 7 GB, 8 MP under 11 GB, 12.5 MP above. Brackets are decoded at reduced size when they exceed the budget.
In the app: captureBracket requests −N, 0, +N EV (or −N, +N if only two frames are allowed) at 12 MP or less; frames are aligned to the middle exposure; unalignable frames are dropped; at least two must remain. The work runs in a detached task.
Tests: identical inputs return the input (PSNR above 50 dB); a scene with a dark half and a bright half, shot under and over, shows texture in both halves after fusion and in only one half of each source; size mismatches and empty input throw.
Saving multi-frame results
saveComputed turns the float result into a 16-bit image, rotates it upright (the capture angle, baked into pixels), and encodes HEIC at quality 0.95, or 16-bit TIFF when "16-bit TIFF for computational captures" is on. The capture summary (frame count, duration, bracket, frames skipped) is stored in the EXIF user comment and in the library index.
Evaluated, not shipped
| Technique | Why not in 1.0 |
|---|---|
| Focus stacking | needs per-frame focus bracketing on a device, sharpness maps and alignment under focus breathing; cannot be validated without hardware |
| Panorama | needs feature matching, homography estimation, seam finding and exposure matching; a fabricated or fragile result would be worse than none |
| Full-resolution long exposure | would require bursts of full-size stills; left for after device measurements |