voelin-media: say how the background mask is really sampled

The segment docs promised a bilinear, feathered mask; the frame path
samples the nearest mask pixel and relies on the mask's own soft edge.
Say so, here and in docs/studio.md, rather than promise a smoothing that
is not there: a model's sharper mask will want it, and that is the place
to add it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
selikhovandClaude Opus 5.5 committed 2026-10-03 02:29:15 +03:00
1 parent c41624e82d
commit 979fdced2c
2 files changed
+6 -4

No files matched your search

+4 -3
View File
@@ -4,8 +4,9 @@
//! is — on a thread of its own and at a lower rate than the video, because
//! segmentation costs far more than a frame does and a mask is still good
//! enough a few frames later. The frame path takes the newest mask through a
//! latest-wins handoff, upsamples and feathers it, and mixes the person over a
//! background it makes with [`blur_rgba`], an image or a colour.
//! latest-wins handoff, samples it up to the frame (nearest: the mask's own
//! soft edge is the feathering) and mixes the person over a background it
//! makes with [`blur_rgba`], an image or a colour.
//!
//! The blur is a three-pass box blur (which approximates a Gaussian closely
//! enough that nobody sees the difference at these radii), separable and with
@@ -75,7 +76,7 @@ impl Mask {
self.data.resize(width as usize * height as usize, 0);
}
/// The mask value at a point of a `width` x `height` frame, bilinear.
/// The mask value at a point of a `width` x `height` frame (nearest).
fn sample(&self, x: u32, y: u32, width: u32, height: u32) -> u8 {
let fx = (u64::from(x) * u64::from(self.width) / u64::from(width.max(1))) as u32;
let fy = (u64::from(y) * u64::from(self.height) / u64::from(height.max(1))) as u32;
+2 -1
View File
@@ -115,7 +115,8 @@ Anything but `keep` runs a `BackgroundFilter` on the source's own thread: the
segmenter gets a copy reduced to 256 pixels wide on a thread of its own and
makes a mask at 10 fps (a mask a few frames old is still right, and
segmentation costs far more than a frame); the frame path takes the newest
mask latest-wins, samples it up and mixes the subject over the backdrop. The
mask latest-wins, samples it up (nearest; the edge is only as soft as the
mask's own) and mixes the subject over the backdrop. The
blur is a three-pass box blur (close to a Gaussian), separable, with a
running sum so its cost does not grow with the radius, in bands on a worker
pool over pooled buffers.