Mask: Edge Smoother
Smooth Mask Edges Without Melting the Shape
- mask
- guide
- mask
A plain Gaussian blur on a mask smears the edge - the selection expands and softens everywhere, and the halo you were trying to kill just moves around. JHPixelProMaskEdgeSmoother uses bilateral filtering instead, which smooths the flat areas of the mask while respecting the edge. You get a cleaner contour, not a mushier one. If you've ever fought a cutout halo by dragging a blur radius back and forth, this is the fix.
The genuinely clever part is the optional guide input: feed it the original IMAGE and the filter becomes edge-aware against the photo itself - joint bilateral filtering. Mask edges align to real image detail - hair, clothing seams, the actual silhouette - instead of the mask's own crude boundary. That's the difference between a "cleaned up" mask and one that actually follows the subject. This is one of those "oh, that's what it's for" nodes.
Inputs:
mask- the MASK to smooth.sigma_spatial(default 4) - spatial blur radius, 0.1..64.sigma_range(default 0.1) - the intensity-difference threshold. Smaller preserves more edge; larger smooths across weak boundaries.iterations(default 1) - filter passes, 1..5.guide(optional IMAGE) - the joint-bilateral guide.
Output: a single smoothed MASK.
One dependency note that matters: joint bilateral needs cv2.ximgproc, which comes from opencv-contrib. The pack's requirements install opencv-python-headless by default, so the node degrades gracefully to plain bilateral filtering if contrib isn't present - it won't crash, you just lose the guide benefit. To get the full effect, install opencv-contrib-python>=4.8.0 in your ComfyUI environment (the README and requirements.txt both point at this).
Install is the shared pack install:
cd ComfyUI/custom_nodes
git clone https://github.com/jetthuangai/ComfyUI-JH-PixelPro.git
cd ComfyUI-JH-PixelPro
pip install -r requirements.txt
Restart and it's under ComfyUI-JH-PixelPro/mask, or use ComfyUI Manager → search "ComfyUI-JH-PixelPro".
Troubleshooting: sigma_range is the knob that trips people. On a [0,1] mask scale, 0.1 is already fairly permissive - start there and drop toward 0.01 if edges get too soft. And the guide only helps if the image and mask actually line up; a misaligned or differently-cropped guide makes things worse, not better. The README notes the node is meant to sit after SAM/YOLO/rembg and before compositing - treat it as the last mask step, right before the composite.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| mask | MASK | — | |
| sigma_spatial | FLOAT | 4.00.1–64 | — |
| sigma_range | FLOAT | 0.1000.001–1 | — |
| iterations | INT | 11–5 | — |
| guideopt | IMAGE | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| mask | MASK | — |