Nodes/opencv-comfyui/OpenCV fastNlMeansDenoising_1
ComfyUI Node

OpenCV fastNlMeansDenoising_1

The twin nobody can tell apart (and why that's fine)

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

First, the thing you'll actually notice: fastNlMeansDenoising_1 is, as far as the ComfyUI graph is concerned, indistinguishable from fastNlMeansDenoising_0. Same inputs, same output, same function underneath (cv2.fastNlMeansDenoising), same gray-area behavior. The _0/_1 suffixes exist because the pack is auto-generated from OpenCV's type stubs, and OpenCV declares overloads for the same function - the generator dutifully made a node for each. When the two overloads produce identical schemas, you get two nodes that do the same thing. Pick either one; nobody will ever know which you used, and no workflow cares.

So this page is mostly a pointer to its twin: for what the algorithm does, how h, templateWindowSize and searchWindowSize behave, and the grayscale gotcha, read the fastNlMeansDenoising_0 article. The short version: non-local means denoising averages each pixel with similar-looking pixels across the whole image rather than just its neighbors, so it removes grain while keeping edges crisp - a deterministic, millisecond-range alternative to blurring the image or re-rolling it through the sampler.

The one thing worth repeating

The input src is an nparray and it must be single-channel 8-bit. Feed it a three-channel BGR array and you'll hit the img.type() == CV_8UC1 assertion the README documents. Run your image through cvtColor with code 6 (BGR2GRAY) first. If you'd rather not give up color at all, reach for fastNlMeansDenoisingColored_0 - same family, keeps the channels, adds an hColor knob.

Installing it

Part of the geroldmeisinger/opencv-comfyui pack, so it installs with all ~600 siblings at once. ComfyUI Manager → search opencv-comfyui, or:

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

then restart. The pack needs opencv-contrib-python, numpy and torch. Watch for the known startup failure Cannot import name 'guidedFilter' from 'cv2.ximgproc' - that's two conflicting OpenCV installs fighting, and fixing it means consolidating to one.

And remember the pack-wide rules: nparrays in BGR 0–255, converted in via Image2Nparray and out via Nparrays2Image, and batch size must be 1 (use ImageFromBatch with length 1 if it isn't).

The honest bottom line: if you need grayscale denoising, either twin works. Save yourself the decision and just use whichever you find first.

Categoryimage/OpenCV

Inputs (5)

NameTypeDefaultDescription
srcNPARRAY
hFLOAT
templateWindowSizeINT
searchWindowSizeINT
dstoptNPARRAY

Outputs (1)

NameTypeDescription
nparrayNPARRAY