Color Patch Merge
Turn noisy AI gradients into clean flat-color regions, two ways
- image
- mask
- OUTPUT
- ALPHA
Color Patch Merge is the "let's make this look like it was drawn by a human with an opinion" node in the pack. It takes an image and aggressively groups similar neighboring colors, replacing each cluster with its local average until you're left with solid patches instead of noisy micro-gradients. Reach for it when an AI render has that telltale "soft fuzzy every-color-is-slightly-different" look and you want flat, confident regions - poster-art, sticker-style, cell-shading, or just cleaning up a background that should be one color but isn't.
Two merging strategies
The Merge Solution combo switches between two genuinely different algorithms, and the widgets grey out to match (the frontend handles that, which is thoughtful):
- Smooth - runs a bilateral filter sized by Neighborhood (diameter, 3–31, default 3). Bilateral smoothing kills texture and gradient noise while keeping edges, so you get "cleaner image" rather than "posterized image." This is the safe, subtle option.
- Unify - iterative region growing. It builds contiguous color patches and merges them toward averages, driven by Iterations (1–16, default 2) and Minimum Area (2–1024, default 20). More iterations = larger, more uniform regions; small regions below Minimum Area get protected, and high-gradient edges are preserved. This is the actual posterizer - crank iterations and you get hard cel-shaded plates.
Merge Tolerance (0–1, default 0.05) decides how different two colors can be and still count as the same group - the "how far apart do colors get to be before you stop pretending they match" dial. And Use Lab (default on) converts RGB to CIELAB before grouping, which is the right call for perception: Euclidean distance in RGB doesn't match how different colors actually look, and Lab is closer to human vision. Leave it on.
Inputs and outputs
- image (IMAGE) - what you're flattening.
- mask (MASK, optional) - restricts the color analysis and merging to a region. Handy when you want to flatten a background without touching a face.
- OUTPUT (IMAGE) - the processed image.
- ALPHA (MASK) - a mask output for the processed region; wire it onward if you're chaining into a save or composite.
Where it fits
This is a post-VAE-decode cleanup node, same as its siblings Achromatic Stabilizer (fixes grey noise) and Color Patch Flatten (homogenizes HSV within a tolerance). The three overlap slightly, so the naming is worth understanding: Flatten pulls values toward the mean within tolerance; Merge actively clusters adjacent regions into solid patches. For the "flat design" look you want Merge. For "make this clean without losing detail" you want Smooth or Flatten, gently.
Install & gotchas
Part of ComfyUI-Image-Process: clone https://github.com/wakaura-asaho/comfyui-image-process into ComfyUI/custom_nodes, pip install -r comfyui-image-process/requirements.txt, restart - or use ComfyUI Manager. It's marked experimental in the code, so expect the occasional sharp edge: the Unify path on large images with high iterations can get slow (it's iterative region-growing in Python/numpy, not GPU), and Lab conversion adds cost. Watch the edges - aggressive Unify turns thin color gradients into stair-stepping, which is either the aesthetic you wanted or a reason to dial tolerance down. No model files, but it does need modern ComfyUI (frontend ≥ 1.37, base ≥ 0.12).
Inputs (8)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | The image to be processed. | |
| merge_tolerance | FLOAT | 0.050–1 | How different colors can be to stay in the same group. |
| neighborhood | INT | 33–31 | The neighborhood size (diameter) for the bilateral filter. Used for 'Smooth' merging solution. |
| min_area | INT | 202–1024 | The minimum area size for color patches. Used for 'Unify' merging solution. |
| iterations | INT | 21–16 | Number of growth iterations for color patches. More iterations result in larger, more uniform color regions. Used for 'Unify' merging solution. |
| use_lab | BOOLEAN | true | Convert RGB space to Lab colors. |
| merge_solution | COMBO | Smooth | How to handle the color merging. |
| maskopt | MASK | Optional alpha channel mask. |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| OUTPUT | IMAGE | — |
| ALPHA | MASK | — |