Mask Editing
Draw and refine face masks using paint, eraser, and polygon tools for precise blending boundaries.
Introduction
Mask editing is the process of defining exactly which pixels belong to the swapped face region. A mask is a grayscale image where white areas represent the face to be replaced and black areas represent the background that should remain untouched. Clean mask boundaries are critical for natural-looking results.
Recaster provides three manual editing tools -- the Paint tool, the Eraser tool, and the Polygon tool -- that you can combine with the auto-segmentation feature for fast, accurate masking.
Paint Tool
The Paint tool lets you add mask coverage by painting directly on the canvas. Click and drag to paint white areas onto the mask, indicating regions that will be included in the face swap.
Adjusting Brush Size
The brush size determines the width of the painted stroke. You can adjust it in several ways:
- Use the brush size slider in the Tool Panel on the left side of the editor.
- Press
[to decrease the brush size or]to increase it.
Brush Size Strategy
Painting Techniques
For the best results when painting masks:
- Zoom in when working on edges. Use the scroll wheel to zoom into the area you are refining.
- Use smooth strokes along the face boundary rather than short, choppy dabs. This produces cleaner edges.
- Follow the natural contour of the face. The mask should trace along the jawline, around the hairline, and below the chin.
- Avoid covering hair unless you specifically want the swapped face to include hair from the source. Hair blending is one of the most visible artifacts in a face swap.
Eraser Tool
The Eraser tool removes mask coverage by painting black areas onto the mask. Use it to clean up over-painted regions, remove mask from background areas, or trim edges after auto-segmentation.
The eraser shares the same brush size controls as the paint tool. Press E to quickly switch to the Eraser, then press B to switch back to the Paint brush.
Common Use Cases
- Removing background bleed -- After auto-segmentation, the mask may extend slightly into the background. Use the eraser to clean these edges.
- Excluding ears -- In many face swaps, keeping the original ears looks more natural. Erase the mask from the ear regions.
- Hair boundary cleanup -- The most common refinement task. Erase any mask that covers hair strands that should remain from the destination face.
- Removing occlusions -- If a hand, microphone, or other object partially covers the face, erase the mask from those areas so the original pixels show through.
Polygon Editing
The Polygon tool lets you define mask regions by placing points that form a closed shape. This is particularly useful for creating precise, geometric mask boundaries that would be difficult to achieve with the brush tool alone.
Activate the Polygon tool
Place points along the face boundary
Close the polygon
Adjust points
When to Use Polygons
Undo and Redo
Every paint stroke, erase stroke, and polygon edit is recorded in the undo history. You can step backward and forward through your changes at any time:
| Action | macOS | Windows / Linux |
|---|---|---|
| Undo | Cmd + Z | Ctrl + Z |
| Redo | Shift + Cmd + Z | Shift + Ctrl + Z |
Undo History Limit
Auto-Save Behavior
The Face Editor automatically saves all changes to the face image file when you:
- Navigate to a different face in the Face Browser.
- Close the Face Editor to return to the Face Browser.
- Close the application.
Both the painted mask data and polygon vertex positions are saved as part of the DFLIMG metadata embedded in the face image file. This means your mask edits travel with the file and are preserved across sessions.
No Manual Save Required
Keyboard Shortcuts
Quick reference for all mask editing shortcuts:
| Shortcut | Action |
|---|---|
B | Select Paint (Brush) tool |
E | Select Eraser tool |
P | Select Polygon tool |
[ | Decrease brush size |
] | Increase brush size |
Cmd/Ctrl + Z | Undo last action |
Shift + Cmd/Ctrl + Z | Redo last action |
Scroll Wheel | Zoom in / out |
Middle Mouse Drag | Pan canvas |
Space + Drag | Pan canvas (alternative) |
Best Practices
Start with Auto-Segmentation
Let the BiSeNet model create a baseline mask, then refine it with manual tools. This is significantly faster than painting the entire mask from scratch.
Work at High Zoom
Zoom in to at least 200% when cleaning up mask edges. Small imperfections that are invisible at low zoom can become obvious in the final merged output.
Focus on Problem Faces
Not every face needs manual editing. Use the Face Browser overlays to spot faces with poor masks, then focus your editing time on those specific frames.
Check Mask Coverage
After editing, toggle the mask overlay in the Face Browser to verify coverage. The mask should cover the entire face region without extending into the background or hair.
Was this page helpful?