Sharpen Mask Regions
Claw back a crisp edge after a mask gets blurred
- masks
- MASKS
Resize a mask - upscale it, downscale it, run it through any interpolation step - and its edges soften a little every time, the same way a photo softens when you scale it. SaltMaskSharpeningFilter is the fix: an unsharp-style sharpening pass applied to the mask itself, pulling those edges back toward crisp.
What it does
Just one optional parameter beyond the required masks input: strength (integer, default 1, range 1–12). Higher values push the sharpening harder, exaggerating the contrast at the mask's edges so a boundary that got mushy through resizing reads as sharp again. The output is the sharpened MASKS.
Where you'd use it
This is the opposite move from SaltMaskSmoothRegion in this same pack, and they solve opposite problems - smooth when a mask is too jagged, sharpen when it's gone soft. The most common trigger is exactly what's described above: you resized a mask (to match a different resolution, after an upscale step) and the edges came out blurrier than the original. A light sharpening pass afterward reclaims some of that precision before you use the mask for something that actually needs a clean boundary, like a crop or a compositing step. It's also a reasonable touch-up after CLIPSeg or another auto-generated mask comes back with edges that are a bit mushier than you'd like, when full re-thresholding feels like overkill.
Installing it
ComfyUI Manager: search SaltAI-Open-Resources. Or manually:
cd ComfyUI/custom_nodes
git clone https://github.com/get-salt-AI/SaltAI
Restart ComfyUI. No models, no extra dependencies.
Common issues
Push strength too close to its max (12) and you're liable to introduce ringing or blocky artifacts right at the mask's edge - the same overshoot problem you get from over-sharpening a photograph, just happening in mask-value space instead of pixel-color space. If your edges start looking jagged or stepped rather than crisp, back the strength down. This node also can't invent detail that isn't there - if a mask boundary is genuinely ambiguous or low-confidence (a rough auto-generated mask, not just a resized one), sharpening will make that ambiguity look more confident without actually making it more correct. For a mask that's wrong rather than just soft, fix the mask itself - with SaltMaskThresholdRegion or by regenerating it - rather than trying to sharpen your way out of a bad boundary.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| masks | MASK | — | |
| strengthopt | INT | 11–12 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| MASKS | MASK | — |