Nodes/comfyui_dygen/DY Image Cluster
ComfyUI Node

DY Image Cluster

Flatten noisy regions into flat dominant colors

By dymokomi·Created 2 years ago·Updated 2 years ago· 1
DY Image Cluster
  • image
  • IMAGE
radius0

DY Image Cluster is the pack's quiet sleeper: an image in, a flatter image out, zero knobs beyond a single radius. If DY Image Quantize gives you a global color count, this is its local, neighborhood-level cousin - and it does something Quantize can't.

The idea: instead of reducing the palette of the whole image, it replaces every pixel with the most common color in the square around it. Smooth areas stay smooth, but noisy or textured regions collapse toward whatever shade dominates locally. The practical effect is a flat, almost cell-shaded look that keeps more of the original structure than a blunt posterize does - grain melts away, gradients turn into soft steps, and the image starts to look deliberately "blocky-clean" rather than just color-reduced.

How it works

Under the hood it's Pillow's ImageFilter.ModeFilter(size=radius). "Mode" here is the statistical mode - the most frequent value in a radius × radius window - not a mode of an image. It's a real, long-standing Pillow filter that most people have never touched, which is probably why the author named the node "Cluster": each pixel gets pulled toward the dominant color of its local neighborhood, so pixels effectively cluster around local color centers.

That's also where the trap lives: radius is a window size, not a blur radius. A radius of 0 is the pixel itself (no change), 3 means a 3×3 neighborhood, 10 means a 10×10 box. Because it's a sliding-window mode computation, cost grows fast with radius - crank it to 50 on a 1024×1024 and you'll watch the progress bar sit there. The sweet spot is small: 2–8 gives you that tidy flattening, 15+ starts eating detail wholesale and getting slow.

Like the rest of this pack, only the first image in a batch is processed, and the output is a plain IMAGE you can wire anywhere.

The one input

  • radius (0–100, default 0) - neighborhood size. 0 does nothing; keep it small.

Install

Part of dymokomi/comfyui_dygen by Dy Mokomi. ComfyUI Manager → search "comfyui_dygen", or:

cd ComfyUI/custom_nodes
git clone https://github.com/dymokomi/comfyui_dygen

Restart. No extra dependencies - Pillow, numpy, and torch, all already present. No models, no downloads.

Where you'd actually use it

Cluster is the pack's alternative to quantize for a specific aesthetic. Pair it with a prior DYImageQuantize pass if you want even flatter regions, or run it before DYImagePalette to get a cleaner palette - fewer scattered specks means fewer throwaway colors in the extraction. It's also just a satisfying one-node "make my noisy render look like a cel" trick to keep in your back pocket. Don't expect it to replace Quantize's crisp posterization; it's the softer, more organic sibling, and for that job it's quietly excellent.

CategoryDyGen/effects

Inputs (2)

NameTypeDefaultDescription
imageIMAGE
radiusINT00–100

Outputs (1)

NameTypeDescription
IMAGEIMAGE