Hardware + RAW · Open Source Computational Imaging · Hardware + Physical RAW 2026

Portable Automated Macro-Stitching Film Digitizer

An automated sub-$160 macro-stitching scanner combining dual-axis microstepping, a 10-stage physical 12-bit Bayer-RAW optical-density model, and a LAN streaming VLM architecture.

TL;DR

Desktop analog film digitization forces a trade-off between lab turnaround, bulky copy stands, and $500–$1,500 dedicated scanners. Inside a $158.11 hardware BOM, I built an automated 4×4 macro-stitching scanner producing 4104×3447 4K-class scans (<0.1 mm homing, <5 px seams, 0 frame drops across 2-hour 68.4 °C thermal soak) paired with a physical 12-bit Bayer-RAW optical-density pipeline and a per-tile LAN streaming FastAPI + VLM backend.

4104×3447 4K Scans
<0.1 mm / <5 px Seam
10-Stage 12-Bit RAW
$158.11 BOM · 0 Drops
Complete portable macro-stitching enclosure on the bench beside the live One-Click Scan web UI (5.0 V rail readout, custom control electronics, and stitched 4×4 preview).
CHAPTER 01 · OPTO-MECHANICS & TIMING ARCHITECTURE

Why 4×4 Macro-Stitching and Split Timing Beat Single-Shot Scanners

Capturing a full 35 mm frame in one shot inside a compact box introduces severe edge field curvature and chromatic aberration. Adding a 10 mm extension tube to a 25 mm f/1.4 C-mount lens on a 12 MP Sony IMX477 (1.55 µm pixel pitch) sets working distance to 8.75 cm (8.73 cm bench / 8.5 cm enclosure) at M = 0.4× (15.7 × 11.7 mm tile FoV). To avoid stacking two full X–Y stages, the upper gantry translates the camera (X) while the lower stage moves the film (Y) at 1/16 microstepping (0.625 µm/step).

Because Linux scheduling jitter corrupts stepper timing, we split control across two planes: a Raspberry Pi 4 (:5000) sends synchronous 115,200-baud coordinate packets to an STM32F401RE hardware ISR (<10 ms command latency, 500 ms settle delay before shutter ACK), powered by star-topology rails (12.462 V battery, 5.150 V logic, ≤50 mV p-p ripple, AMS1117-3.3 solving CMOS V_IH = 0.7 VDD logic-level matching on A4988 drivers).

Three-zone hardware and streaming software architecture: opto-mechanical enclosure & power rails → STM32F401RE + Raspberry Pi 4 (:5000) edge control plane → PC FastAPI (:8000) VLM bootstrap & 2-worker Bayer-RAW pipeline.
Interior Optical Stack
Backlit 35 mm slide beneath the 25 mm f/1.4 C-mount macro lens + 10 mm tube and Y-stage.
Live One-Click Scan Web UI
16/16 streamed raw tiles, first_three_vote VLM classification, and final stitched positive.
CHAPTER 02 · PHYSICAL 12-BIT BAYER-RAW RESTORATION

Inside the 10-Stage Optical-Density & Dye-Unmixing Pipeline

Naive 255 − x RGB inversion destroys color negatives because the orange coupler mask compresses blue/green dynamic range, film dyes behave logarithmically in optical density, and spectral crosstalk shifts hues nonlinearly. Our 10+ stage physical model (Post_Processing_Negative/) works strictly in linear 12-bit Bayer RAW: per-tile flat-fielding → base transmission T = I_lin / I_base → optical density D = −ln(T) → 3×3 dye-crosstalk unmixing matrix M → expm1 positive inversion (g = [1.35, 1.20, 1.10]) → Lab zoned tone curves, paired with an Agentic VLM Router (29 unit tests) that classifies negative, positive, and instant film via majority vote.

Real 5-stage physical restoration on the 40-tile Norway negative benchmark (raw grid → stitched RAW → optical-density inversion → white balance → restored positive) paired with NumPy RGB density histograms, 1:1 harbor detail crops, and the exact 3×3 unmixing matrix.
CHAPTER 03 · TWO ENGINEERING PIVOTS & CLOUD-VS-EDGE BENCHMARKS

Why Synthetic DNGs Broke Physics—and Why Bandwidth Beat AWS Lambda

Two empirical audits reshaped the entire architecture. First, measuring all 24 physical neighbor tile pairs captured serpentine lead-screw backlash and brought final 4K seam alignment to < 5 px (< 0.1 mm homing). Second, auditing the legacy 13496×11784 Pi-stitched synthetic DNG proved it contained 26.7% below-black numeric zeros and 12.2% clipped backlight, breaking optical-density math. Pivoting to streaming native 4056×3040 per-tile DNGs with first-three-tile global bootstrapping fixed RAW validity while overlapping scanning with 2-worker compute.

Benchmarking cloud vs. local compute exposed an equally clear systems lesson: AWS Lambda warm compute itself is fast (0.851 s CloudWatch duration, 1.08 s 5-run mean, 98 MB RAM; 3.57 s cold start), but uploading 16 × 18.5 MB RAW frames (320.9 MB @ 10 Mbps) burns 256.72 s (> 4.2 minutes) on WAN transfer alone. Moving the FastAPI pipeline to local LAN delivered < 1 s direct previews, 1–3 s/tile RAW fast previews, and < 30 s/tile full physical restoration on a $158.11 BOM.

Left: all 24 measured hardware tile-pair offsets (forward/reverse serpentine rows and vertical columns). Right: DNG audit showing 26.7% below-black zeros and 12.2% saturation in legacy stitched DNGs vs. ~0% in streamed single-tile IMX477 DNGs.
Log-scale Cloud vs. Edge latency breakdown (256.72 s WAN upload vs. local LAN streaming), verified hardware telemetry scorecard (68.4 °C / 0 drops over 2 h), and $158.11 purchased hardware BOM.
CHAPTER 04 · HONEST FAILURE ANALYSIS & X-RAY POSTMORTEM

Diagnosing Real CineStill 400D Hotspots and Underside PCB Solder Bridges

Running real CineStill 400D film end-to-end (4104×3447) validated crisp < 5 px rebate text and polarity recovery while transparently exposing localized magenta circles where raw LED backlight dies saturated the sensor—pointing straight to a thicker optical diffuser and locking global fixed_stats across all 16 tiles. On the electronics side, TruView 12 X-ray inspection caught bridged underside solder pads on the STM32WB5MMG footprint, prompting a reliable STM32F401RE dev-board fallback for the working prototype.

Real Hardware CineStill 400D Diagnostics
Single-tile raw capture beside the 4×4 stitched scan with numbered alignment & hotspot pins.
TruView 12 PCB X-Ray Inspection
X-ray postmortem exposing bridged underside solder balls on the STM32WB5MMG footprint.
Technical Stack
Computational Imaging12-Bit Bayer RAWFastAPI StreamingVLM AgentsSTM32 + Raspberry Pi