From 7d7e26a397f81679158c8a501e396e4f30a8aac1 Mon Sep 17 00:00:00 2001 From: selikhov Date: Sat, 3 Oct 2026 02:29:15 +0300 Subject: [PATCH] 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 --- crates/voelin-media/src/studio/segment.rs | 7 ++++--- docs/studio.md | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/crates/voelin-media/src/studio/segment.rs b/crates/voelin-media/src/studio/segment.rs index 8b68c55..8d1bf18 100644 --- a/crates/voelin-media/src/studio/segment.rs +++ b/crates/voelin-media/src/studio/segment.rs @@ -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; diff --git a/docs/studio.md b/docs/studio.md index 2985ecf..77f85c9 100644 --- a/docs/studio.md +++ b/docs/studio.md @@ -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.