Nodes/FlowCV/均值滤波
ComfyUI Node

均值滤波

Mean filter in FlowCV

By Bit-Walker·Created about a year ago·Updated 7 months ago· 3
均值滤波
  • 图像输入
  • 图像输出
核大小X5
核大小Y5

If you just want everything to get softer and you don't care about the math, this is the node. FlowCV's 均值滤波 (class FCV_Blur) is a plain mean filter - it slides a box over the image and replaces each pixel with the average of its neighbors. It's the blunt instrument of the filter family: simple, fast, and it blurs everything equally, including edges.

In the pack's filter lineup, the honest summary is: FCV_Blur is the quick-and-dirty smoother, FCV_Gaussian is the better-behaved cousin you'll usually prefer, FCV_Median is the salt-and-pepper specialist, and FCV_Bilateral is the one that smooths without wrecking edges. Mean filtering is still useful when you want maximum smoothing per unit of compute, or when you're building a pipeline where exact Gaussian weights don't matter.

How it works

It's a direct cv2.blur() call: for each pixel, take the kernel window (X by Y), average all the values in it, and write that average back. The window slides across the whole image, so the result is locally flat - which is exactly why edges blur: a bright object next to a dark background just averages into mush at the boundary.

Two inputs control it, and they're the whole thing:

  • 核大小X (kernel size X, default 5) - horizontal window width.
  • 核大小Y (kernel size Y, default 5) - vertical window height.

Bigger values = more blur, and you can make the box rectangular (e.g. X=1, Y=9) to blur only along one axis. Unusually for this pack, there's no odd-number enforcement - cv2.blur accepts any kernel size, so the node doesn't bother fixing it up.

Wiring it up

In goes a CVIMAGE (OpenCV BGR numpy array), out comes a CVIMAGE. It slots naturally as a pre-filter before FCV_Canny (edge detection is far less noisy on a smoothed input) or before FCV_Threshold on a grainy image - though for noise specifically, FCV_Median is usually the better call. Preview or convert with FCV_CVToIMAGE.

Installing

It ships in FlowCV, so install the pack once. ComfyUI Manager, search "FlowCV"; or:

cd ComfyUI/custom_nodes
git clone https://github.com/Koren-cy/FlowCV

Restart ComfyUI. Dependencies: opencv-python, numpy, pyserial, nothing else, no model files. The README carries a "migrated to ComfyUI_For_Academic" note, so this repo is in archive mode - it works, it's just not actively developed.

Gotchas

Mean blur smears edges; if you need smoothing and edge preservation, reach for FCV_Bilateral instead. And remember the pack-wide behavior: on an error it prints a Chinese message to the console and returns the input unchanged - if nothing seems to happen, the terminal is where the answer lives.

CategoryopenCV/滤波

Inputs (3)

NameTypeDefaultDescription
图像输入CVIMAGE输入的openCV格式图像
核大小XINT51–99均值滤波核在X方向的大小
核大小YINT51–99均值滤波核在Y方向的大小

Outputs (1)

NameTypeDescription
图像输出CVIMAGE均值滤波处理后的图像