ComfyUI Extension: ComfyUI_MaskSmoothing
Run ComfyUI workflows without the setup
No installs, no CUDA version roulette, no GPU sitting idle on your bill. Bring a workflow and run it in the browser.
A ComfyUI custom node that smooths mask contours using the Fourier Descriptor algorithm.
Looking for a different extension?
Custom Nodes (0)
README
ComfyUI Custom Node: Mask Fourier Smoothing
A ComfyUI custom node that smooths mask contours using the Fourier Descriptor algorithm. It takes a mask as input, applies low-pass filtering in the frequency domain, and outputs a smoothed mask.

Example
| Input Mask | Smoothed Mask (descriptors=32) | |---|---| | Jagged, noisy contour | Clean, smooth contour |
Installation
- Clone or copy this folder into your ComfyUI
custom_nodes/directory:
cd /path/to/ComfyUI/custom_nodes
git clone https://github.com/bemoregt/ComfyUI_CustomNode_MaskSmoothing.git
- Install dependencies:
pip install -r custom_nodes/ComfyUI_CustomNode_MaskSmoothing/requirements.txt
- Restart ComfyUI.
The node will appear under mask/processing → Mask Fourier Smoothing.
Usage
Connect a MASK output to the node's mask input. Adjust num_descriptors to control the smoothing strength.
[Load Image] ──► mask ──► [Mask Fourier Smoothing] ──► smoothed_mask ──► [Preview Mask]
Parameters
| Parameter | Default | Range | Description |
|---|---|---|---|
| mask | — | — | Input mask (MASK type) |
| num_descriptors | 32 | 4 – 512 | Number of Fourier frequency components to keep. Lower = smoother contour. Higher = closer to original. |
How It Works
The algorithm follows these steps:
- Binarize the input mask (threshold at 0.5)
- Extract contours using
cv2.findContours - Encode contour points as complex numbers:
z = x + j·y - Apply FFT to obtain the Fourier Descriptors
- Low-pass filter: keep only the lowest
num_descriptorsfrequency components (zero out the rest) - Apply inverse FFT to reconstruct the smoothed contour
- Fill the reconstructed contour to produce the output mask
The key insight is that high-frequency Fourier components correspond to sharp corners and jagged edges, while low-frequency components capture the overall smooth shape. By discarding high-frequency components, the contour is effectively smoothed.
Dependencies
numpyopencv-pythontorch
License
MIT License
Run ComfyUI workflows without the setup
No installs, no CUDA version roulette, no GPU sitting idle on your bill. Bring a workflow and run it in the browser.