Nodes/ComfyUI-ArchiGraph/Blur Median πŸ¦β€πŸ”₯
ComfyUI Node

Blur Median πŸ¦β€πŸ”₯

Kill salt-and-pepper noise without smearing the edges

By vincentfsΒ·Created 2 years agoΒ·Updated 9 months agoΒ· 3
Blur Median πŸ¦β€πŸ”₯
  • nparrays
  • dst
β—„ksize3β–Ί

Gaussian and box blurs average pixels, and averaging is the problem when you have salt-and-pepper noise - a single bright speck drags the whole neighborhood up with it. Median blur replaces each pixel with the median of its neighborhood, which removes isolated specks entirely while leaving real edges mostly intact. If you've ever looked at a noisy edge map and thought "I want the noise gone but the lines kept," this is the node.

The inputs

Only two, which tells you everything about how specialized it is:

  • nparrays: an NPARRAY from the pack's To Nparray node.
  • ksize (default 3): the aperture size - kernel is ksizeΓ—ksize, and it must be odd and greater than 1. 3, 5, 7… there's no x/y split here, no sigma, no border type. Median blur is square by design.

Where it belongs

The recipe this node exists for: image β†’ To Nparray β†’ Median Blur β†’ Canny (or threshold). Scanned plans, old photos, and render passes with visible compression artifacts all carry speckle that Canny will happily trace as fake edges. A median pass at ksize 3 or 5 strips the specks while keeping the line work sharp - a box blur of the same size would soften the lines you're trying to detect.

The tradeoff: median blur is slower than box blur and can't be computed with a sliding separable kernel, so on large images or big ksize values it's the least "free" of the pack's three blurs. And it doesn't do anything special for gaussian-style noise - for that, use the Gaussian node. Pick by noise type: speckle β†’ median, general grain β†’ gaussian, cheap pre-detect smoothing β†’ plain blur.

Output

dst, the filtered NPARRAY, same shape. Straight into the next OpenCV node or out through To Image.

Install

ComfyUI Manager β†’ search ComfyUI-ArchiGraph, or:

cd ComfyUI/custom_nodes
git clone https://github.com/vincentfs/ComfyUI-ArchiGraph

Restart and run the pack's install script once for the OpenCV dependency. Nothing else to fetch.

Gotchas

  • ksize must be odd; a value of 2 will error or misbehave. The slider steps by 2 so it's hard to hit an even number, but if you're typing it in, don't.
  • At ksize 7+ on a big image, this gets slow. If your denoise pass is the bottleneck, drop to 3 and add a second pass instead.
  • It's square-only - there's no anisotropic median here, so you can't blur in one direction only.

When your edges look like they've been sneezed on, median is the first thing to try. It's the rare blur that makes your detector's job easier rather than harder.

CategoryπŸ¦β€πŸ”₯ ArchiGraph/πŸ“€ OpenCV

Inputs (2)

NameTypeDefaultDescription
nparraysNPARRAYβ€”
ksizeINT33–99Aperture linear size; it must be odd and greater than 1, e.g. 3, 5, 7 ...

Outputs (1)

NameTypeDescription
dstNPARRAYβ€”