sourcery
sourcery · effectsSOURCERY — a two-input region-transplant recolorizer video PROCESSOR. It edge-detects video A (top) and video B (bottom), segments each edge map into bounded regions (the connected non-edge areas walled off by the detected edges), then for every region in A finds the B region most similar in SHAPE (angles + geometry) first and SIZE second, and paints A's region with B's colors placed at the SAME relative position inside the shape (a corner of A samples the matching corner of B). A B shape may be reused by many A regions and EVERY part of A maps to some region (tiny/culled regions and the edge walls are absorbed into their nearest surviving region, so the output has no holes — the whole-screen background becomes one giant region filled by some B shape). Two global controls move all the transferred color: SKEW rotates the hue of every filled pixel (bipolar, 0.5 = no shift), ROT rotates the sampling frame inside each region (bipolar, 0.5 = no rotation). The look is a shifting stained-glass / photomosaic where A's edge structure is the cell boundaries and each cell is a warped fragment of B chosen by shape similarity; region boundaries are intentionally BLOCKY (segmentation runs at a coarse 128×96 grid, nearest-upscaled) while the colors are full-res sharp. For real-time performance the shape/segmentation stage is temporally amortized (recomputed every few frames) while the color fill sampling live B runs every frame; on live noisy video at low threshold the regions shimmer/boil frame-to-frame (a disclosed v1 limitation). The CCL, moments, Hu shape descriptors, z-score match and rel→uvB transform are a 1:1 mirror of the pure, unit-tested $lib/video/sourcery-core; the two THRESHOLD knobs (each + a CV input) gate A/B segmentation. Patch a structural source into A and a colorful source into B; with nothing in B the module passes A through (hue-skewed only).
the faceplate
inputs
| id | cable | what it does |
|---|---|---|
a | video | Video input A (top) — its edge map defines the CELL BOUNDARIES: each connected non-edge area becomes a region that gets painted. With nothing patched here the output is black. A's structure flows the cell layout live. RGB video stream |
b | video | Video input B (bottom) — its edge map is segmented into candidate SHAPES and its live full-res color is the paint. Each A region samples the B region matched to it (by shape then size) at the same relative position. With nothing patched in B the module passes A through (hue-skewed only). RGB video stream |
thresholdA | cv | CV input that modulates ThrA — the edge gradient trigger for A's segmentation. Raising it keeps only the strongest contours (fewer, larger A cells); lowering it lets faint gradients wall off more, smaller cells. Linear-scaled into 0..1. control voltage (CV); modulates thresholdA (additive offset — ±1 CV sweeps the full range, centered on the knob) |
thresholdB | cv | CV input that modulates ThrB — the edge gradient trigger for B's segmentation (the pool of candidate shapes A matches against). Linear-scaled into 0..1. control voltage (CV); modulates thresholdB (additive offset — ±1 CV sweeps the full range, centered on the knob) |
colorSkew | cv | CV input that modulates Skew — rotates the hue of every transferred pixel. Linear-scaled into 0..1 (0.5 = no shift). control voltage (CV); modulates colorSkew (additive offset — ±1 CV sweeps the full range, centered on the knob) |
rotate | cv | CV input that modulates Rot — rotates the sampling frame inside each region, swirling the transplanted color. Linear-scaled into 0..1 (0.5 = no rotation). control voltage (CV); modulates rotate (additive offset — ±1 CV sweeps the full range, centered on the knob) |
outputs
| id | cable | what it does |
|---|---|---|
out | video | The recolored video frame: A's edge-bounded cells each painted with the relative-position colors of their shape-matched B region, globally hue-skewed. A normal downstream video texture. RGB video stream |
params
| id | label | range | default | curve |
|---|---|---|---|---|
thresholdA | ThrA | 0..1 | — | linear |
thresholdB | ThrB | 0..1 | — | linear |
colorSkew | Skew | 0..1 | — | linear |
rotate | Rot | 0..1 | — | linear |
controls
| control | what it does |
|---|---|
| Skew | Skew (0..1, default 0.5 = identity): global hue rotation of every transferred color, mapped bipolarly to +/-180 degrees (0.5 = no shift, 0 = -180, 1 = +180). Saturation and value pass through untouched. |
| Rot | Rot (0..1, default 0.5 = no rotation): rotates the intra-region sampling frame, mapped bipolarly to +/-pi radians, so the color content swirls within each cell while the cell boundaries stay put. |
| ThrA | ThrA (0..1, default 0.2): the normalised Sobel gradient magnitude at or above which an A pixel is a wall. 0 floods the frame with walls (many tiny cells); 1 keeps almost nothing (one big cell); 0.2 catches salient contours without low-contrast noise. Applied at segmentation time, so under amortization a twist shows on the next recompute. |
| ThrB | ThrB (0..1, default 0.2): the same edge trigger for B's segmentation — sets how finely B is broken into candidate shapes for the match. Higher = fewer, bolder B shapes. |
source
sourcery.ts on GitHub.