Edge refinement: manual matte editing
Automatic background removal produces a good matte most of the time, but ID photos are judged at the hairline and shoulders—exactly where neural networks hesitate. Edge Refine is a brush tool on the Enhance step that lets you move the cutout boundary locally, with matting math running in your browser after each stroke. This page explains how to use it and what happens under the hood.
Where to find it
Upload and crop on the home page first (see our background removal guide if you skipped that). When the portrait looks roughly framed, open Enhance. In the tool strip, select the wand icon labelled Edge Refine. Adjust brush size and strength with the sliders below the canvas.
Two directions: foreground vs. background
Foreground mode (default)
Use when the automatic mask ate part of you—missing hair wisps, a shaved shoulder, or an ear tip. Paint along the edge where flesh or hair should return. On release, the tool re-estimates foreground colour inside your stroke and blends it back into the display image while respecting the alpha matte.
Background mode
Toggle with the ⇄ button. Use when background specks remain—old wall colour inside the collar, a halo between hair and white, or a shadow blob the model left inside the silhouette. Painting pushes the boundary outward and samples background colour into the fringe.
What happens when you release the mouse
Edge Refine is stroke-based, not pixel-persistent ink. When you press down, the app snapshots the current canvas. As you drag, it builds a soft circular mask along your path. On pointer-up:
- The tool finds a tight rectangle around your brush stroke (plus padding) so only that patch is processed.
- It reads the original matte RGB and alpha captured at upload—the same data returned from background removal.
- Inside the patch, a fast foreground estimation algorithm (blur fusion, ported from our server-side matting code) recalculates RGB values along semi-transparent edge pixels.
- The result is blended into the display image with strength scaled by brush opacity and by how “edge-like” each pixel is (mid-alpha pixels change more than fully opaque or fully transparent ones).
- The stroke is pushed onto an undo stack (up to 15 steps). Redo and reset are available.
This design avoids the black/white fringe you get from painting directly on JPEG pixels: each stroke recomputes from the matte source instead of stacking filter effects.
Step-by-step workflow
- Zoom in on the problem edge (hair, ear, collar, shoulder).
- Set brush size slightly wider than the problem zone; start strength around 50%.
- Choose foreground mode if you need to add subject back; background mode to remove leftover wall.
- Paint in short strokes along the boundary—not filled blobs—and release after each pass.
- Check at 100% zoom and at fit-to-screen; halos often show only when zoomed out.
- Use Smooth or Brighten brushes separately if skin tone needs help; they do not move the matte edge.
- When satisfied, continue to Results and export—refinements are baked into the enhanced image.
Practical tips
- Hair — multiple light foreground strokes beat one heavy pass; over-painting looks like a helmet.
- White shirts on white backgrounds — switch to background mode at the collar line to delete grey fringe.
- Beards and glasses rims — refine before heavy smoothing; blur tools can smear fine edge work.
- Undo is your friend — Ctrl+Z / Cmd+Z works; if a stroke made things worse, undo and halve the strength.
Limits
Edge Refine needs the original matte from background removal. If you skipped removal or the upload failed, the tool stays disabled. It adjusts appearance along the existing boundary—it cannot invent a face that was never captured. For a completely wrong segmentation, retake the photo with a plainer background rather than brushing for minutes.