Frame detection and centering, in depth
The long version of How it works › Finding the frame: one picture, from what the camera sends to “move the film 70 steps forward”, with the reasoning behind each threshold. The picture comes from the live view if the camera has one, a real shot otherwise; from section 3 on, both are handled alike unless said.
| File | What it does |
|---|---|
detect.rs |
Where the frame is in one picture (detect_frame, or detect_frame_with with a measured base); how far the film moved between two (measure_shift); the bare base in a picture of it (measure_base). Pure image analysis, no hardware. |
operations.rs |
film_base: measures the base before a calibration. calibrate: links pixels to motor steps. annotate: draws what the detector saw. |
centering.rs |
center_frame: the detect → move → detect loop. scan_strip: the whole strip, and the check of each photo. |
camera.rs |
frame_at_rest: the film in the live view once it has stopped moving. |
The plots come from the real detector run on synthetic shots (see Reproducing the figures). They predate the live view: where a figure says “shoot”, read “look at the film”.
1. The big picture
Section titled “1. The big picture”
Everything is one-dimensional. The film runs left to right (the image x axis) and the motor only moves it along x, so the detector needs one number: how far the frame’s center is from the image’s center, in pixels. The film gate fixes the vertical position.

Sign convention everywhere: offset_px = frame center − image center. Negative is left
of center, positive right.
2. Getting a picture to analyse
Section titled “2. Getting a picture to analyse”Through the live view
Section titled “Through the live view”frame_at_rest() in camera.rs reads the live view (about 20 frames a
second on the X-T5, 1024 px wide):
-
Skip the first quarter of a second. The camera shows what it saw a moment ago, and the film has only just stopped.
-
Wait for the film to be at rest. Each frame is compared with the one before (
profile_change()indetect.rs): the largest change in a column’s mean brightness, after removing any change of the whole picture (a flickering lamp changes every column alike). Under 0.1, the film is at rest.Moving film shifts whole pixels, changing a frame’s edge columns by far more. A room shaking the camera by a tenth of a pixel changes the window’s edge columns by 0.02 to 0.05 (measured on the prototype): not film moving, and a tighter limit never let it pass.
-
Three frames at rest, then the mean of the next five. A frame that differs from the one before restarts the count. The mean has less noise, placing the frame more finely.
Nothing at rest within 10 seconds, or the live view stops: the scan ends with an error. Film is never moved on a picture that can’t be trusted.
No shot is taken. The picture is brightness only, 0.0 (black) to 1.0 (white); the black bars above and below a 3:2 picture lie outside the rows the detector reads (section 4).
In a real shot
Section titled “In a real shot”Without a live view, and to check every kept shot, Gphoto2ShotCamera::preview() in
camera.rs, with image.rs:
- reads the JPEG’s brightness only, averaged in 2×2, 4×4 or 8×8 blocks to bring a 40 Mpx shot down to just above the wanted size;
- resizes to 1024 px wide, keeping the aspect ratio;
- converts to 32-bit floats from 0.0 (black) to 1.0 (white).
Colour isn’t needed: on a backlit strip, only how much light gets through matters. And 1024 px is plenty: a 2 mm gap between 35mm frames is still around 40 px wide.
3. What a frame edge looks like
Section titled “3. What a frame edge looks like”
On a negative, bright scenes made the film dark, and unexposed film (between frames, along the edges) is clear base that lets the most light through. So gaps are the brightest columns, and the same brightness top to bottom, with no picture in them. Those two properties, as bright as the base and evenly bright, are the whole detector.
Slides (positives) are the reverse: unexposed slide film is nearly opaque, so gaps are
the darkest columns. The detector flips the image (1.0 − value) and then treats both
alike.
4. From a 2-D picture to two 1-D curves
Section titled “4. From a 2-D picture to two 1-D curves”_profiles() shrinks the picture to two numbers per column, using only the middle half
of the rows: the bright sprocket holes and film edges would make every column look partly
like a gap.

For every column x, inside that band:
mean[x]is the average brightness: how bright the column is;std[x]is the standard deviation: how uneven it is, top to bottom.
The orange column crosses picture: mean 0.46, std 0.156. The red one is in a gap: mean 0.90, std 0.008, almost flat. All 1024 columns give two curves. This shot also has a clear sky (x ≈ 300–380) and a thin shadow (x ≈ 600–650), the two things most easily mistaken for a gap:

5. Which columns are gap columns?
Section titled “5. Which columns are gap columns?”base = np.percentile(median_of_9(mean), 99) # brightness of bare filmgap_cols = (mean > base - 0.04) & (std < 0.02) # bright enough AND even enoughbase, the reference brightness, is never hard-coded. It is the film’s own, from the
surest source to the least:
- Measured at the calibration (next section): the base’s level and grain.
- Learned as the scan goes, if not measured: from the gaps on either side of each frame found with both edges.
- Guessed from the picture, if neither yet: the 99th percentile of the column means, “the brightest columns, ignoring a few outliers”.
For the guess, lines thinner than 9 columns are taken out first: each column is replaced by the median of the 9 around it, for this number only. Live view sharpening leaves a column or two brighter than anything on the film beside every sharp dark edge (the window’s sides, dense bars in a picture). With many such edges, those fringes made the brightest hundredth: the level came out 0.04 too high and no gap was found.
The film’s base, measured
Section titled “The film’s base, measured”Guessing fails on a frame with no gap in view (its brightest part is taken for the base),
and 0.02 was set on still photos: a live view is grainier. So calibration starts by
measuring the base of the film to be scanned (measure_base() in
detect.rs):
| Measured in | How | What it gives |
|---|---|---|
| A blank frame | unexposed film filling the window | the base’s level, its grain (how uneven a column is), and the light across the picture (level column by column: lamp and lens are never quite even) |
| A gap picked by hand | a rectangle drawn on the live view inside a gap | level and grain. For film the lab returned cut, with no blank frame |
| Nothing | skipped | the base is learned as the scan goes (2 above) |
With a measured base, the two tests become:
gap_cols = (mean > level_at(x) - 0.04) & (std < max(0.02, 1.5 * grain))level_at(x) is the light across the picture if a blank frame was measured, the single
level otherwise. A measure refuses anything not all bare film (a blank frame with a picture
in it, a rectangle over a gap’s edge).
The measure belongs to one film, one exposure and one lamp. A colour negative’s orange base is less clear than a black-and-white one. On the prototype the base read 0.54, 0.58 and 0.60 to 0.64 over one afternoon of setup changes (it held to 0.003 otherwise). So:
- Scan with manual exposure, or the level moves with every picture.
- One calibration for each film: a scan asks for one made for the roll it is given.
- An out-of-date measure is not silently replaced by a guess. Nothing on a film is
clearer than its base, so something more than
0.04brighter than the measured base (base_out_of_date()) means the measure is another film’s. The scan stops and asks, and guesses only once you say so. (All darker proves nothing: a dense frame with no gap in view looks the same.)
Photos are read without the measure: their tones are not the live view’s.
Each column must pass both tests. Plotting every column of the shot above by its two numbers shows why:

| Region | mean vs base | std | Gap? | Why |
|---|---|---|---|---|
| Real gap | ≈ base | ~0.01 | Yes | clear base, nothing in it |
| Clear sky | 0.05+ below | low (even) | No: fails test 1 | dense on the negative: uniform, but darker than bare base |
| Thin shadow | ≈ base | 0.03+ | No: fails test 2 | as clear as base in places, but its detail makes it uneven |
| Ordinary picture | well below | high | No: fails both |
6. From gap columns to gaps
Section titled “6. From gap columns to gaps”_runs() and _bridge() turn gap_cols into (start, end) ranges in three passes:

- Holes narrower than 3 px are filled. One noisy column shouldn’t split a gap in two.
- A break of at most 6 px is bridged when it is grain, not picture: every column as bright as the base and at most 0.04 uneven (twice the gap column limit). In a live view bare base sits near the 0.02 limit (0.015, some columns 0.03), so a speck of dust used to cut a gap in two and lose its edge. (The figure shows passes 1 and 3.)
- Runs narrower than max(4 px, 1% of the width) (10 px at 1024) are dropped: dust or a bright scratch, not a gap.
Empty check: 90% or more gap columns means no film in view (past the end of the
strip): status empty.
7. From gaps to a frame
Section titled “7. From gaps to a frame”A frame runs from the end of one gap to the start of the next. Uncalibrated, that is
all: two gaps in a row, at least 30% of the image width apart. Calibrated, the detector
knows the frame width (W) and gap width (g), and is far more careful about edges.
An edge is where dense picture borders a bright run
Section titled “An edge is where dense picture borders a bright run”On a well-exposed negative every bright run is a gap, its ends frame edges. On a thin one, dark parts of the scene are as clear as bare base: they merge with a gap into one wide run, or form clear bands whose ends are just where the picture slowly gets denser.
So at each end of each run, the detector counts the rows where the 4 columns just outside are dense (over 0.04 darker than the base). If none are, it looks up to 8 columns further: a live view shows a soft fringe of 3 to 8 columns, as bright as the base but too uneven for the run, with dense picture right after. The edge goes at the first dense column found.
A frame’s edge is a straight line top to bottom, showing wherever the picture beside it has any density. On real thin negatives a frame edge is dense in 60 to 100% of the rows, a clear band’s fading end in 35% or less. The limit is 50%.

Two more rules:
- The window is not a frame. Beyond the window’s edge it is black, like dense picture. A run starting within 1% of the picture’s width of the lit area’s edge gets nothing from that side.
- A run wider than 1.5 gaps may belong to the neighbour: a gap merged with clear picture. Dense picture bordering it may be the previous or next frame’s, putting this one a gap’s width further. Both readings are kept for the rest of the evidence to decide.
That gives two lists: where this frame may start, and where it may end. For when only one side can be used (section 8), two kinds of edges are told apart:
- A gap seen from both sides: dense picture on both sides of a run, a gap’s width apart (within 25%). Nothing in a picture looks like that top to bottom: the surest edges.
- An edge that is not seen: dense picture on one side only, a gap’s width (within 25%) from the run’s other end. The run is the gap; the other frame starts (or ends) at its far end, too clear to show it: a thin frame beginning as clear as the base, beside a denser neighbour.
Both edges: status ok
Section titled “Both edges: status ok”frames = [(x0, x1) for x0 in starts for x1 in ends if |(x1 − x0) − W| ≤ 5% of W]Every start is tried with every end, not just neighbours, so a false edge inside the picture is skipped:

±5% is about ±1.8 mm on a 36 mm frame: loose enough for cameras that space frames slightly differently, tight enough to reject coincidences. Of several candidates (a frame and half the next), the one closest to the image center wins:
x0, x1 = min(frames, key=lambda f: abs((f[0] + f[1]) / 2 - center))offset_px = (x0 + x1) / 2 − centerframe_width_px = x1 − x08. Only one edge visible: the fallback
Section titled “8. Only one edge visible: the fallback”At a strip’s start, with a window hiding one gap, or on a thin negative, edges may show on
one side only. A start puts the frame’s center at start + W/2, an end at end − W/2. A
reading counts only if it puts the frame within 15% of the frame width from the image
center:

After an advance (or lining up by hand) the frame should be roughly centered: a reading far off is more likely a false edge. The readings must agree within 2% of the frame width, or nobody can tell which is right.
Except that a gap seen from both sides wins. If one of its edges gives a believable reading, the others are not asked: an edge inside a picture (where it turns as clear as the base, say) can mimic a frame’s end, and used to veto the right reading.
An edge that is not seen only counts here, as one reading among others: never paired to
call a frame ok, and nothing is derived from it.
Pass: status partial (the readings’ average). Fail: status none, and the scan asks you
to line the frame up, often on a very thin roll: with no density at any edge nearby, there
is nothing to see.
The whole decision tree
Section titled “The whole decision tree”
9. Calibration: pixels ↔ motor steps
Section titled “9. Calibration: pixels ↔ motor steps”The detector gives pixels; the motor wants steps. calibrate() in
operations.rs measures the ratio once per setup, and what the rig
loses between motor and film. A positive move pushes the picture left or right depending
on the camera’s mounting; keeping the sign means the scanner doesn’t care which.
Four looks, two distances
Section titled “Four looks, two distances”Shooting, moving 200 steps, shooting again and dividing reads 5% too low on the prototype: at rest the film relaxes, and the first steps of any move only take that up. A loss of 10 steps is 5% of 200, under 2% of 600.
So calibration moves twice and uses the difference (each picture a look through the live view, section 2, or a real shot without one):
- forwards 100 steps, further than any play, so the film starts from a known state;
- picture A, forwards 200 steps, picture B;
- forwards 600 steps, picture C;
- backwards 200 steps, picture D; then the film is brought back to about where it started.

px_per_step = (shift_BC − shift_AB) / (600 − 200) # the loss cancels outdead_steps = 200 − |shift_AB / px_per_step| # lost at the start of a moveplay_steps = 200 − |shift_CD / px_per_step| # lost on turning roundOn the prototype: 0.4625 px per step over 200 steps alone, 0.4867 over 600 alone, 0.491 from both, which agrees with the film itself (38 mm between two frames in the picture). The rig loses 6 to 14 steps at the start of a move, 45 to 53 on turning round.
Measuring a shift (measure_shift)
Section titled “Measuring a shift (measure_shift)”Each shift uses the whole brightness profile: each shot’s column means (as in step 4, but all rows), slid over each other to find the lag where they are most alike:

Alike means correlated: at each lag, shared columns only, each minus its own average and scaled by its own spread, so the score is 1 when one is the other made brighter or more contrasted. Lags sharing under half the columns aren’t tried, capping a shift at half the window: 600 steps move the picture about 300 px of 1000.
The plain sum of products this replaced grows with the overlap, favouring small lags. On a thin negative, flat but for a gap or two, it read 71 px for a move of 142 and 124 px for 396: 0.74 px a step where the film moved 0.51, and frames 1148 px wide in a 1024 px picture. Most pictures have enough contrast for that not to matter.
Two refinements:
- Sub-pixel peak. The best lag is a whole number; a parabola through the peak and its
two neighbours (
y0, y1, y2) gives the true top:lag += 0.5 · (y0 − y2) / (y0 − 2·y1 + y2). - Ignoring the mask. The pressure frame’s window is a dark border that doesn’t move
with the film and would pull the match towards “no shift”.
_lit_columns()keeps only columns lit in both shots, minus a 1% margin each side:

The frame found in each shot isn’t used: over 600 steps the frame nearest the center changes, and on a thin negative it may not be a frame at all.
Frame and gap width
Section titled “Frame and gap width”The calibration also stores frame_width_px and gap_px for steps 7 and 8:
frame_width_px = px_per_mm × frame_mmgap_px = px_per_mm × (pitch_mm − frame_mm)px_per_mm is read off the film’s height in the picture: the pressure frame’s window
is exactly a frame tall (24 mm for 35mm, standard or panoramic; 56 mm for 120), so:
px_per_mm = film_height_px ÷ height_mmfilm_height_px() in detect.rs measures it in calibration’s first
look: the tallest stretch of lit rows, a row being lit when its brightest few pixels are
(gaps keep a row lit however dense the picture). It assumes the camera is level with the
film: a leaning window reads taller.
The motor gives a rougher answer, |px_per_step| × steps_per_mm with the drive’s
steps_per_mm on paper: 1 to 2.5% under the height’s on the prototype, 5% on a thin roll.
It is the fallback when the window’s top or bottom is out of the picture, and the
cross-check. More than 10% apart, the height stands (it is what the detector sees) and the
calibration warns: the film slipped (calibrate again), or the window isn’t a frame tall.
The window must be exactly as tall as the frame, as this repository’s parts are. A taller or shorter window of your own gives the wrong scale and frame width.
Neither is measured between two gaps: on a thin negative, any two bright bands can pass for the gaps. On the prototype that gave 954 px, then 510 px, for a frame of 758.
Worked example (35mm): the film is 533 px tall in a 1024 px live view, so
px_per_mm = 533 / 24 ≈ 22.2: a 36 mm frame is ≈ 800 px and the 2 mm gap ≈ 44 px; a
panoramic frame 22.2 × 65 ≈ 1443 px. The motor (px_per_step = 0.510,
steps_per_mm = 2038 / 47.5 ≈ 42.9) says 21.9: close enough.
Live view or shots: a calibration is used the way it was made
Section titled “Live view or shots: a calibration is used the way it was made”The calibration file records "source": "live" or "shot". A scan refuses the other kind
(“Calibrate again: the camera is now used with its live view”): a live frame and a shot may
not show the film at the same scale. A file with no source was made in shots, before the
live view.
10. Centering: closing the loop
Section titled “10. Centering: closing the loop”center_frame() in centering.rs:

The correction: the film must move −offset_px; divided by px_per_step, that’s
steps. Frame at −32 px with px_per_step = 0.455: steps = round(32 / 0.455) = +70.
Why a loop? Calibration is never perfect, gears have play, film can slip. Each look checks the last move and the next correction fixes what’s left: usually 0 or 1, at most four.
Through the live view a look costs under a second and no shot; without one, each look is a real shot and the last is kept.
Where the frame is wanted. Normally offset 0. When photos come out shifted from the live view (next section), the loop aims at the opposite shift, measuring from that target, so the photo is centered.
Tolerance: 4 px, about 0.2 mm on the film in a 1024 px shot of a 36 mm frame.
Play: always arrive from the same side
Section titled “Play: always arrive from the same side”The 28BYJ-48’s gearbox, and the sprocket’s teeth in the perforations, have play. When the motor reverses, the first steps only take it up, so a backwards correction would fall short.
move_settled() in arduino.rs ends every move going forwards: a
backwards move of n steps becomes n − overshoot, then +overshoot. The loss happens
once each way and cancels out. The overshoot is 1.5 times the play calibration measured
(30 steps if unmeasured), so always more than the play.

A forwards move gets the steps lost at its start (dead_steps) added. Otherwise a
correction of a few pixels asks for fewer steps than the rig loses, and the film doesn’t
move.
The scanner counts what the film was asked to move, not what the motor turned, so the learned frame spacing is unaffected. The app’s arrows move the film the same way.
11. Over a whole strip
Section titled “11. Over a whole strip”scan_strip() repeats: advance one frame, center_frame(), shoot. Four more ideas sit on
top.
Checking the photo (live view only)
Section titled “Checking the photo (live view only)”Through the live view, the frame is centered in one picture and photographed in another. The photo counts, so the frame is looked for in its JPEG, scaled to 1024 px (section 2).
- Both edges found (
ok), more than 8 px off-center: the film is moved by what the photo shows, and the photo deleted and retaken. The log says “the photo came out +20 px off-center, taking it again”. Once only: the second photo is kept as it is. - Frame not clear (
partial,none), or no JPEG: the photo is kept and the live view’s answer stands. - Lined up by hand: never corrected; shot where it was put.
Learning the shift. Each checked photo gives where it shows the frame minus where the
live view showed it. PhotoShift takes the median of the last five, and the next frames
are centered at minus that. A camera whose photos come out 20 px from its live view costs
one retake on a roll’s first frame, and none after.
Without a live view there is nothing to check: the kept photo is the picture the frame was centered in.
Learning the film’s base (BaseLearner)
Section titled “Learning the film’s base (BaseLearner)”When calibration didn’t measure the base, the scan learns it: after each frame found with
both edges (one edge isn’t sure enough), the gaps beside it are measured like a gap
picked by hand (learn_base()), and the next frames use the median of the last five.
Until then, the base is section 5’s guess. A measured base is never replaced.
Learning the frame spacing (PitchTracker)
Section titled “Learning the frame spacing (PitchTracker)”
The advance starts at the format’s nominal pitch (38 mm = 1630 steps for 35mm). Each time a centered frame follows another, the real distance between them is recorded, and the next advance is the median of the last five. A spacing more than 25% off nominal (a slip, a button pressed) is ignored. After a few frames, they land centered on the first shot.
Blank frames and the end of the strip
Section titled “Blank frames and the end of the strip”A position counts as nothing here when:
- the detector says
empty, or - it says
noneand ≥ 70% of the view is bare-film runs (a thin negative stays under 45%; past the end of the strip it’s about 85%), or - centering pulled the film backwards by more than half a frame: it found the frame it had already shot, so nothing new is ahead.
The first time, the scan assumes a blank frame and looks one frame further. Twice in a row is the end of the strip, and the scan stops.
When to ask for help
Section titled “When to ask for help”| Result | What the scan does |
|---|---|
centered |
shoot, move on |
uncertain, within 16 px (4× tolerance) |
shoot anyway, log “only roughly centered” |
uncertain, more than 16 px off |
pause: “won’t center, calibration may be stale”; you line it up with the buttons |
failed |
pause: “frame not found”; you line it up |
| the film is clearer than its measured base | pause: the measure is not this film’s; you choose to go on with a guess, or stop and calibrate again |
12. Seeing what the detector saw
Section titled “12. Seeing what the detector saw”With a live view, the app draws the findings below on every live frame. Check framing
looks once the film is at rest and writes the result in the activity list; without a live
view it takes a shot and shows it. rollscan preview saves the picture with the findings
drawn by annotate():

The distance between the thick green line and the white line is the offset. A faint box where you’d expect a gap is a gap the detector didn’t believe; the table in step 5 usually says why.
13. All the knobs
Section titled “13. All the knobs”| Constant | Value | Where | Meaning |
|---|---|---|---|
BASE_MARGIN |
0.04 | detect | a gap column is within this of the base brightness |
GAP_MAX_STD |
0.02 | detect | …and at most this uneven, top to bottom |
GRAIN_MARGIN |
1.5 | detect | with measured grain: a gap column may be this many times as uneven |
BLANK_SPREAD |
0.1 | detect | a blank frame’s columns are within this of one another |
MIN_PICKED |
4 × 16 | detect | columns and rows a gap picked by hand must have |
BaseLearner::WINDOW |
5 | centering | frames the base is learned from, when it wasn’t measured |
NEARLY_EVEN_STD |
0.04 | detect | a break in a gap is bridged if as bright as the base and at most this uneven |
MAX_BREAK |
6 | detect | …and the break is at most this many columns wide |
EMPTY_FRACTION |
0.9 | detect | this share of gap columns means no film |
MIN_FRAME_FRACTION |
0.3 | detect | uncalibrated: a frame is at least this share of the width |
WIDTH_TOLERANCE |
0.05 | detect | a start and an end frame a picture within ±5% of the calibrated width |
EDGE_PROBE |
4 | detect | columns looked at just outside a run |
EDGE_REACH |
8 | detect | …or up to this many columns further out, past a soft fringe |
DENSE_SHARE |
0.5 | detect | a run’s end is a frame edge if dense in this share of the rows |
WIDE_RUN |
1.5 | detect | a run wider than this many gaps may border the neighbouring frame |
GAP_TOLERANCE |
0.25 | detect | a run this close to the gap’s width, dense on one side, is the gap |
MAX_GAP_FRACTION |
0.15 | detect | …or, without a gap width in the calibration, wider than this share of the frame |
LONE_GAP_RANGE |
0.15 | detect | edges on one side only must put the frame this close to center |
LONE_GAP_AGREEMENT |
0.02 | detect | several such readings must agree to this |
MASK_LEVEL |
0.04 | detect | columns darker than this are the pressure-frame mask |
MAX_OFFSET_PX |
4 | centering | centered when within this many pixels |
MAX_CORRECTIONS |
4 | centering | corrections before giving up |
RETAKE_PX |
8 | centering | live view: a photo further off-center is retaken |
PhotoShift::WINDOW |
5 | centering | live view: photos the live view to photo shift is learned from |
REST_CHANGE |
0.1 | camera | two live frames differ by less than this: the film is at rest |
REST_FRAMES |
3 | camera | frames in a row that must show it at rest |
AVERAGE_FRAMES |
5 | camera | frames at rest averaged into the analysed picture |
Rest::REAL.settle |
0.25 s | camera | live frames skipped after a move |
Rest::REAL.limit |
10 s | camera | longest wait for the film to be seen at rest |
MOSTLY_BARE |
0.7 | centering | this share of bare film, frame not found: nothing here |
BACKLASH |
30 | arduino | backwards overshoot when the play wasn’t measured (else 1.5 × the play) |
TAKE_UP_STEPS |
100 | arduino | calibration’s first move forwards, longer than any play |
CAL_STEPS |
200 | operations | calibration’s short move; the long one is three times that |
MIN_CAL_SHIFT_PX |
10 | operations | calibration refuses a smaller shift (motor not turning?) |
HEIGHT_AGREEMENT |
0.10 | operations | beyond this from the motor’s scale, the height’s is kept with a warning |
All brightness values are on the 0–1 scale, after the slide flip.
14. Reproducing the figures
Section titled “14. Reproducing the figures”All figures come from
images/frame-detection/make_figures.py. It runs
the Python the app was ported from, kept in reference/, on
synthetic strips from reference/tests/synth.py.
The code on this page is that Python too: it reads more easily than the loops of
detect.rs, and tools/parity.py checks the two
find the same thing. (The Python has no measured base: it guesses the base from each
picture, and that is what the check compares.)
The script needs Python; uv fetches what it imports:
uv run --no-project --with matplotlib --with numpy --with pillow --with pyserial \ python docs/images/frame-detection/make_figures.pyAny real shot can be explored the same way, from the reference/ folder:
from film_scanner.detect import load_gray, _profiles, detect_frameimg = load_gray("shot.jpg")mean, std = _profiles(img, "negative") # plot these twoprint(detect_frame(img, "negative", expected_width_px=758, gap_px=42))