Technical Architecture & Standards
Client-Side Matting & Compositing Methodology
How MatteBG delivers full-resolution cutouts, deterministic marketplace framing, and lossless exports using open web standards.
1. End-to-End Local Pipeline
MatteBG separates image matting and studio compositing into four deterministic client-side stages so every edit remains non-destructive and reproducible:
- Full-Resolution Decode: Input PNG, JPG, WebP, or AVIF files are decoded into an immutable native RGBA pixel buffer via
createImageBitmap. - Client-Side Neural Segmentation: An ONNX salient-object matting model (FP16 high-definition or Quint8 fast mode) computes an 8-bit soft alpha matte via WebGPU when a compatible GPU adapter is present, falling back automatically to WebAssembly CPU execution otherwise.
- Non-Destructive Alpha Mask Editing: Keep and Erase brush strokes interpolate along pointer paths with smoothstep radial feathering and update only the 8-bit alpha buffer while keeping original RGB pixels untouched. Snapshots are tracked in an immutable 25-step Undo/Redo stack.
- Deterministic Marketplace Framing & Export: A tight non-transparent bounding box is computed from the refined alpha channel, scaled to honor exact preset fill ratios (such as 85% subject fill on a 2000×2000 Amazon canvas), layered over the chosen backdrop and shadow pass, and encoded to PNG, JPG, WebP, or a client-side ZIP archive.
2. Marketplace Framing Geometry
Rather than relying on arbitrary margins, fixed marketplace presets scan the subject alpha channel above a noise threshold to isolate the true foreground extent. For square and 4:3 catalog presets (Amazon 2000×2000, Shopify 2048×2048, Etsy 2700×2025, Depop 1080×1080), the subject is uniformly scaled without aspect distortion to fit the target fill ratio and centered cleanly. Portrait presets (LinkedIn / Resume 800×800) anchor the bottom edge of the subject flush with the canvas bottom to prevent floating shoulders.
3. Referenced Open Web & Imaging Standards
MatteBG relies on open, published technical specifications rather than proprietary server-side black boxes:
Enables direct GPU-accelerated tensor inference inside the browser sandbox for low-latency foreground matting.
Provides deterministic, portable CPU fallback execution for neural inference when a WebGPU adapter is unavailable.
Defines lossless 8-bit RGBA alpha transparency encoding used for transparent cutouts and clipboard transfers.
Powers interactive Keep/Erase alpha mask editing, multi-layer backdrop rendering, directional shadows, and full-resolution export.
Open, interoperable model representation enabling quantized foreground segmentation networks to execute locally across browsers.