Nodes/opencv-comfyui/OpenCV fastNlMeansDenoisingColored_0
ComfyUI Node

OpenCV fastNlMeansDenoisingColored_0

FastNlMeansDenoisingColored_0

By geroldmeisinger·Created about a year ago·Updated about a year ago· 35
OpenCV fastNlMeansDenoisingColored_0
  • src
  • dst
  • nparray
h
hColor
templateWindowSize
searchWindowSize

This is the one from the non-local means family that you'll actually reach for in a photo pipeline, because it works on color images and that's what you usually have. fastNlMeansDenoisingColored_0 wraps cv2.fastNlMeansDenoisingColored: the same patch-averaging trick as the grayscale fastNlMeansDenoising nodes, but it operates on the BGR image directly and denoises the luminance while leaving chroma mostly alone. That split is the whole point - noise lives mostly in brightness, so you can smooth it without dragging color through the mud.

If you're new to the algorithm: instead of averaging each pixel with its immediate neighbors like a blur (which is what smears edges), it averages each pixel with other pixels that look like it anywhere in the frame. Grain gets averaged away; the sharp edge in your subject does not. It's slower than a blur because it's searching the image, but it's the edge-preserving denoise people mean when they say "clean it up without losing detail."

The inputs that matter

  • src (NPARRAY) - the image, BGR and 0–255, exactly what Image2Nparray hands you (it does the RGB→BGR flip for you).
  • h (FLOAT) - the luminance filter strength. OpenCV's suggested starting point for color images is around 10 (higher = smoother, softer).
  • hColor (FLOAT) - how much color noise to remove. Start small - this is the "don't smear the chroma" knob. Set it to 0 to denoise luminance only.
  • templateWindowSize (INT) - patch size, odd, 3–7 range. Bigger = softer and slower.
  • searchWindowSize (INT) - how far the search for similar patches goes (default 21). This is the real cost knob.
  • dst (NPARRAY, optional) - an out-parameter. Leave it unplugged, per the README's advice.

Output is one nparray, same size and depth as the input. Run it through Nparrays2Image to get back a Comfy IMAGE.

Installing it

One of ~600 nodes in geroldmeisinger/opencv-comfyui, so it installs with the pack. ComfyUI Manager → search opencv-comfyui, or:

cd ComfyUI/custom_nodes
git clone https://github.com/geroldmeisinger/opencv-comfyui

then restart. Requirements: opencv-contrib-python, numpy, torch. If ComfyUI won't start with Cannot import name 'guidedFilter' from 'cv2.ximgproc', you have conflicting OpenCV installs - consolidate to one consistent opencv-contrib-python.

Pack-wide gotchas apply: nparrays in BGR 0–255 in and out (Image2Nparray / Nparrays2Image), and batch size 1 only - hit "Only images with batch_size==1 are supported" and you need ImageFromBatch with length 1 upstream.

When to use it

The classic use is de-noising a generated frame before upscaling - clean the grain at base resolution so your upscaler doesn't amplify it into snakeskin. It's deterministic and effectively free, which is exactly the point of the post-processing layer: try the millisecond filter before you ever consider a second diffusion pass. It's also a fine fit for "de-AI" work where you've added grain and then decided the middle ground is too noisy - this takes the edge off without erasing the texture entirely.

Categoryimage/OpenCV

Inputs (6)

NameTypeDefaultDescription
srcNPARRAY
hFLOAT
hColorFLOAT
templateWindowSizeINT
searchWindowSizeINT
dstoptNPARRAY

Outputs (1)

NameTypeDescription
nparrayNPARRAY