Mask Fourier Smoothing — ComfyUI Custom Node
Smooth out jagged mask edges using Fourier Descriptor algorithm — a classic signal processing
technique applied to contour shapes.
What it does
This node takes a mask as input, extracts its contour, applies FFT-based low-pass filtering
in the frequency domain, and reconstructs a clean, smooth mask. No blur, no dilation — just
mathematically smooth edges.
How it works
The contour points are encoded as complex numbers (x + jy) and transformed via FFT. By
keeping only the low-frequency Fourier components and discarding the high-frequency ones
(which represent sharp corners and noise), the inverse FFT reconstructs a naturally smoothed
contour.
Parameters
- num_descriptors (default: 32, range: 4–512) — Controls how many frequency components are
kept. Lower = smoother. Higher = closer to original.
Use cases
- Cleaning up hand-painted masks from inpainting workflows
- Smoothing segmentation masks before feeding into ControlNet
- Removing jagged artifacts from any binary mask
Installation
custom_nodes/
└── ComfyUI_MaskSmoothing/
![[Custom node] Mask Smoothing Node](https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/6447e571-787a-4faf-aa2e-84ac1eb9d1ef/width=1320/ScrShot 9.jpeg)