compose
Class info¶
Classes¶
| Name | Children | Inherits |
|---|---|---|
| MotionAccumulator framesheet.compose Incremental :func:`motion_map` (frames fed in order, not kept in memory). |
🛈 DocStrings¶
Image composition with Pillow: contact sheet, motion heatmap, pixel diffs.
DIFF_THRESHOLD
module-attribute
¶
Per-channel difference (0-255) below which a pixel counts as unchanged.
DrawOp
module-attribute
¶
A layout operation: {"op": "rect" | "outline" | "text", ...} (see :func:draw_ops).
MAX_SHEET_WIDTH
module-attribute
¶
Vision models downscale larger images; keep the sheet at or below this width.
MotionAccumulator
¶
Incremental :func:motion_map (frames fed in order, not kept in memory).
Source code in src/framesheet/compose.py
auto_tile
¶
Largest tile that keeps columns tiles within :data:MAX_SHEET_WIDTH.
change_mask
¶
L image: per-pixel max channel difference between two RGB frames.
contact_sheet
¶
contact_sheet(
frames: Sequence[Image],
labels: Sequence[str],
*,
title: str,
subtitle: str,
tile: int | None = None,
columns: int | None = None,
highlight: Sequence[int] = (),
bands: Sequence[str] | None = None,
overlay: Callable[[int, tuple[int, int]], Sequence[DrawOp]] | None = None,
footer: Callable[[int], tuple[int, Sequence[DrawOp]]] | None = None,
) -> Image
Grid of frames, each with a timestamp label band above it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
frames
|
Sequence[Image]
|
Full-resolution frames (all the same size). |
required |
labels
|
Sequence[str]
|
One label per frame (e.g. |
required |
title
|
str
|
Header line (input name). |
required |
subtitle
|
str
|
Second header line (frames, span, how the duration was found). |
required |
tile
|
int | None
|
Longest side of a tile in pixels (default: as large as fits 1568 px). |
None
|
columns
|
int | None
|
Grid columns (default: roughly 4:3 sheet). |
None
|
highlight
|
Sequence[int]
|
Frame indices whose label gets the accent colour (first/last). |
()
|
bands
|
Sequence[str] | None
|
Optional second label line per frame (active marks), drawn in an extra
:data: |
None
|
overlay
|
Callable[[int, tuple[int, int]], Sequence[DrawOp]] | None
|
|
None
|
footer
|
Callable[[int], tuple[int, Sequence[DrawOp]]] | None
|
|
None
|
Source code in src/framesheet/compose.py
default_columns
¶
Columns that give a landscape (at least ~4:3) sheet for tiles of tile_aspect (w/h).
Source code in src/framesheet/compose.py
diff_stats
¶
Share of changed pixels and the bounding box (device px) of the change.
Source code in src/framesheet/compose.py
draw_ops
¶
draw_ops(draw: ImageDraw, ops: Sequence[DrawOp], dx: int = 0, dy: int = 0) -> None
Execute layout ops (same format as the npm package's DrawOp), offset by dx, dy.
rect/outline boxes are inclusive (x0, y0, x1, y1); text is anchored at
its top-left (align: right = at its top-right).
Source code in src/framesheet/compose.py
font
cached
¶
Pillow's bundled font: identical on every platform, so output is deterministic.
heatmap
¶
heatmap(
frames: Sequence[Image],
*,
title: str,
subtitle: str,
max_side: int = 1280,
min_side: int = 800,
boxes: Sequence[tuple[int, int, int, int]] = (),
) -> Image
Coloured motion overlay on a dimmed, desaturated first frame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
frames
|
Sequence[Image]
|
Full-resolution frames. |
required |
title
|
str
|
Header line. |
required |
subtitle
|
str
|
Second header line. |
required |
max_side
|
int
|
Longest side of the image area (frames are downscaled to fit). |
1280
|
min_side
|
int
|
Small inputs are upscaled until their longest side reaches this. |
800
|
boxes
|
Sequence[tuple[int, int, int, int]]
|
Device-px boxes to outline (e.g. the overall changed region). |
()
|
Source code in src/framesheet/compose.py
heatmap_from
¶
heatmap_from(
first: Image,
motion: Image,
*,
title: str,
subtitle: str,
max_side: int = 1280,
min_side: int = 800,
boxes: Sequence[tuple[int, int, int, int]] = (),
) -> Image
:func:heatmap from a precomputed motion map (L image) and the first frame.
Source code in src/framesheet/compose.py
motion_map
¶
L image: per-pixel max change between consecutive frames and vs. the first.