OpenCV edgePreservingFilter_0
Smooth skin or flatten colors without killing the edges
- src
- dst
- nparray
This is the node in this pack you'll actually reach for. edgePreservingFilter_0 smooths an image while keeping its edges crisp - the same family of job as a bilateral filter, but with two faster implementations and two knobs that are surprisingly easy to reason about. It's the difference between "blurred to mush" and "skin that's been softened but the jawline survived," and it's a deterministic, millisecond, no-model operation of exactly the kind the ComfyUI post-processing layer is supposed to be: a cheap pixel op instead of a diffusion pass.
How it works
The idea is two sigma values controlling two kinds of averaging. sigma_s is spatial - how large a neighborhood gets smoothed. Crank it up and flat areas merge over wider regions. sigma_r is the range (color) parameter - how different two colors have to be before they're treated as separate and kept apart. Small sigma_r preserves fine detail; large sigma_r starts merging distinct colors, which is where the "flattened, almost cartoon" look creeps in. flags picks the algorithm: 1 for RECURS_FILTER (the recursive, faster one) or 2 for NORMCONV_FILTER (normalized convolution, generally higher quality, slower). For most work you start at 1 and only switch if you see artifacts.
Good first values: sigma_s around 40–60 and sigma_r around 0.1–0.2 for gentle skin smoothing; push sigma_r higher (0.4+) for the flat-color look. You'll tune both by eye in a couple of minutes.
Inputs and output
src- yourNPARRAY(viaImage2Nparray).flags-1or2, the algorithm choice.sigma_s- spatial smoothness,FLOAT.sigma_r- color-range smoothness,FLOAT.dst- optional out-parameter. Skip it; the README's advice applies, and leaving it unplugged is the intended use.
Single nparray output - smoothed image, out through Nparrays2Image.
Install
In opencv-comfyui (geroldmeisinger). ComfyUI Manager → search OpenCV, or:
cd ComfyUI/custom_nodes
git clone https://github.com/geroldmeisinger/opencv-comfyui
pip install opencv-python-contrib
Restart ComfyUI. requirements.txt is opencv-contrib-python, numpy, torch; nothing to download.
Gotchas
The whole pack only handles batch_size==1, so keep an ImageFromBatch (length=1) around for batched inputs. And don't feed it a grayscale NPARRAY unless you're sure - this function wants an 8-bit color image, and a single-channel input can throw the img.type() == CV_8UC1 family of assertion errors. _0/_1 are the usual identical overloads.
Honest verdict: of all the auto-generated nodes in this pack, this one earns its keep. Skin smoothing, pre-print flattening, building a clean base for further processing - it's a legitimate everyday tool, and it does in one node what a lot of people cobble together with blurs and masks.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| src | NPARRAY | — | |
| flags | INT | — | |
| sigma_s | FLOAT | — | |
| sigma_r | FLOAT | — | |
| dstopt | NPARRAY | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| nparray | NPARRAY | — |