双边滤波
Bilateral filter in FlowCV
- 图像输入
- 图像输出
Every other blur has the same dirty secret: it smears edges. The bilateral filter is the one that says "smooth the flat parts, leave the boundaries alone," and FlowCV's 双边滤波 node (class FCV_Bilateral) wraps it with just three knobs. If you're smoothing a photo or a mask and you care about outlines surviving, this is the filter you'd actually reach for.
It's the most expensive of the pack's four filters, and it earns the price: the output looks like a gentle beauty pass rather than a blur. That makes it useful for cleaning up generated images, softening noise before masking, or prepping a face for further processing without turning it into a blob.
How it works
cv2.bilateralFilter() weights each neighbor twice. First, spatial distance - like a Gaussian blur, near pixels count more. Second, intensity distance: pixels whose color is very different from the center get heavily downweighted. The result is that pixels on the same side of an edge smooth together, while pixels across the edge barely influence each other. Flat regions become smooth; edges stay crisp.
The three inputs are the whole control surface, and the tooltips describe them well:
- 滤波直径 (diameter, default 9) - the neighborhood size. Bigger = stronger smoothing (and slower). Must be odd; the node bumps even values up.
- 颜色标准差 (color sigma, default 75) - how different in color a neighbor must be before it's ignored. Higher = more tolerant of color differences = more smoothing across edges.
- 空间标准差 (spatial sigma, default 75) - how far apart in space pixels can be and still influence each other. Higher = smoother.
The two sigmas are the real tuning levers. For edge-preserving smoothing you generally want the color sigma above the spatial sigma; drop the color sigma if edges are vanishing.
Wiring it up
CVIMAGE in, CVIMAGE out - standard for the pack. It's a natural pre-step before FCV_Canny or thresholding on real-world photos, or as a standalone cleanup before FCV_CVToIMAGE hands the result to a preview or the rest of ComfyUI.
Installing
Bundled in FlowCV, so one install covers the whole pack. ComfyUI Manager, search "FlowCV"; or:
cd ComfyUI/custom_nodes
git clone https://github.com/Koren-cy/FlowCV
Restart ComfyUI. Dependencies are just opencv-python, numpy, pyserial - no models, nothing heavy. The README notes the project migrated to ComfyUI_For_Academic; treat this repo as archived but functional.
Gotchas
Bilateral filtering is the slowest blur in the pack - on large images, keep 滤波直径 modest or you'll watch the queue spin. And it's a tuned tool: the 75/75 defaults are a reasonable start but you'll almost always nudge the color sigma to fit your image's contrast. Standard pack quirk: an error prints a Chinese message to the console and returns the input unchanged, so a no-op output means check the terminal.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| 图像输入 | CVIMAGE | 输入的openCV格式图像 | |
| 滤波直径 | INT | 93–50 | 滤波器的直径,必须为奇数。值越大,滤波效果越强 |
| 颜色标准差 | FLOAT | 751–200 | 颜色空间的标准差,值越大,颜色差异越大的像素会被平均 |
| 空间标准差 | FLOAT | 751–200 | 坐标空间的标准差,值越大,距离越远的像素会相互影响 |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| 图像输出 | CVIMAGE | 双边滤波处理后的图像 |