ComfyUI Node

OpenCV Denoise

Smooth out noise without smearing the edges

By mudknight·Created 8 months ago·Updated 2 months ago· 1
OpenCV Denoise
  • full_pipe
  • image
  • full_pipe
  • image
deviceGPU
sigma_r0.01
sigma_color8.0
bilateral_diameter128

Sometimes the noise isn't the problem - the grain is. Diffusion output can come out with fine speckle, especially at low steps, and the obvious fix (a generic blur) destroys edges along with the noise. OpenCV Denoise is this pack's targeted answer: it runs OpenCV's edge-preserving filter followed by a bilateral filter, which is the classic computer-vision recipe for "reduce noise but keep the sharp edges."

Here's the mechanism, and it's worth understanding because it explains every knob. The first pass is OpenCV's edgePreservingFilter - it smooths flat regions while detecting and protecting edges, so lines and boundaries survive. The second pass is a bilateralFilter, which averages neighboring pixels but weights by intensity difference, meaning pixels across a hard edge barely influence each other. Both filters know where the edges are, unlike a Gaussian blur. The node converts your image to uint8, runs both filters per frame, and converts back.

The inputs that matter

  • device (default GPU) - this is the one to get right. On GPU it uses OpenCV's OpenCL path (cv2.ocl.setUseOpenCL); on CPU, the tooltip warns it's limited to a single core. The author's own description is blunt: GPU strongly recommended. A 1MP image with a big bilateral_diameter on CPU is a coffee-break length.
  • sigma_r (default 0.01) - edge-preserving filter strength. Higher filters more noise at the expense of detail; the tooltip says 0.01 is recommended.
  • sigma_color (default 8) - bilateral color-space sigma. Higher values cause more gradient banding - that's the tooltip warning you not to crank it.
  • bilateral_diameter (default 128, range 0–256) - the pixel neighborhood for the bilateral pass. 128 or 256 recommended; higher smooths better but is significantly slower. This is the main speed knob.

Inputs are either a direct image or a full_pipe (it pulls the image out of the pipe's image slot if no direct image is given - a genuine error if neither is present). Outputs are full_pipe (with the denoised image written back in) and image.

Installing it

In mudknight-utils - ComfyUI Manager (search comfyui-mudknight-utils) or:

cd ComfyUI/custom_nodes
git clone https://github.com/mudknight/comfyui-mudknight-utils

This node is why opencv-python is in the pack's requirements - Manager installs it automatically. If OpenCL isn't available on your GPU, OpenCV silently falls back, which is worth knowing when the node runs slowly.

Where people get burned

The biggest real-world caveat: this is a restoration filter, not a denoiser for diffusion artifacts. Run it on a noisy render before upscaling and it helps; run it expecting to fix structural glitches (melted hands, duplicated anatomy) and it'll do nothing, because those aren't noise. If you're using it before a model upscaler, keep sigma_r and sigma_color near the defaults - heavy denoising feeds an upscaler a smoothed image and it can't invent back the texture you removed.

Categorymudknight/image

Inputs (6)

NameTypeDefaultDescription
deviceCOMBOGPUGPU highly recommended, CPU limited to single-core
sigma_rFLOAT0.010.01 is recommended, higher values will filter more noise at the expense of detail.
sigma_colorFLOAT8.08 is recommended, higher values cause more gradient banding
bilateral_diameterINT1280–256Pixel neighbourhood diameter for the bilateral filter. 128 or 256 are recommended — higher values produce better smoothing but are significantly slower.
full_pipeoptFULL_PIPE
imageoptIMAGE

Outputs (2)

NameTypeDescription
full_pipeFULL_PIPE
imageIMAGE