Palette Transfer
The color-palette node with every knob, and the one to learn first
- image
- target_colors
- IMAGE
This is the flagship of the ComfyUI-Color_Transfer pack, and the node that makes the README's one-liner true: it "replaces the dominant colors in an image with a target color palette." You give it a photo and a handful of RGB swatches, it re-paints the photo so its colors come from your swatches. Same sofa, five wallpapers - that's the whole use case, and it's the one node that can do it without touching a diffusion model.
How it actually works
Under the hood it's a tidy three-step recipe, all on CPU:
- Cluster. It runs KMeans on your image's pixels to find the dominant colors - exactly as many as there are in your palette.
- Match. Each dominant color is snapped to the nearest color in your palette, using a distance metric you choose.
- Rebuild. Every pixel is replaced with its cluster's assigned palette color. Optional blur smooths out the posterized edges.
The result is intentionally flat - it's a posterized, palette-faithful version of your image, not a subtle tint. That's the honest trade-off of the whole cluster-and-map approach, and the reason you'll usually blend it back into the original if you want a "graded" look rather than a "recolored" look.
The inputs that matter
- image - anything with an IMAGE type: a
LoadImage, a VAE-decoded latent, an upscaler output. - target_colors - a
COLOR_LIST, almost always from this pack's ColorPalette node (a plain text list of(R,G,B)tuples). - color_space (
RGB/HSV/LAB) - where clustering and matching happen.LABis the color-science honest choice and usually looks the most natural;RGBis the plain default;HSVplays better if you care about hue over brightness. - cluster_method (
Kmeans/Mini batch Kmeans) - full KMeans is more accurate, MiniBatch is faster and lighter on memory. At palette sizes you'll realistically use (3–8 colors), the accuracy gap is small. - distance_method - six options (Euclidean, Manhattan, Cosine Similarity, HSV Distance, RGB Weighted Distance, RGB Weighted Similarity). Euclidean is the sensible default; RGB Weighted Distance weights by human luminance perception (0.299/0.587/0.114), which is the one to try if plain Euclidean keeps picking the wrong swatch.
- gaussian_blur (0–27, default 3) - the one "gotcha" knob: despite the name it applies a median blur (
cv2.medianBlur), which is actually the better choice for killing the salt-and-pepper noise posterization creates. Set it to 0 for a clean cut-out look.
The single output is an IMAGE, wired straight into PreviewImage, SaveImage, or on into more post-processing.
Where it fits
Think end-of-workflow, after decode. AI images come out oversaturated and over-contrasty by default (there's a running complaint about that in the photorealism crowd), and this node is a legitimate non-AI way to pull them back into a deliberate palette - brand colors, film-look LUTs you've hand-picked as swatches, a consistent tone across a whole batch so every frame of a set matches. The r/comfyui folks who mention this pack frame it exactly that way: a deterministic color-grading tool for normalizing color across many images, not a style-transfer toy.
Install and gotchas
From ComfyUI Manager search "Color_Transfer", or:
cd ComfyUI/custom_nodes
git clone https://github.com/45uee/ComfyUI-Color_Transfer
Restart, done. No models, no keys. The pack's real dependencies are scikit-learn, opencv-python, and POT; the README specifically calls out running pip install scikit-learn if you hit an import error. scipy and scikit-image come along with ComfyUI itself. Two practical notes: an empty target_colors list passes your image through unchanged (handy as a bypass), and this is a small solo-dev pack, so don't expect a changelog culture - if a knob misbehaves, the source is one file and it's readable.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| target_colors | COLOR_LIST | — | |
| color_space | COMBO | RGB | 3 options: RGB, HSV, LAB |
| cluster_method | COMBO | Kmeans | 2 options: Kmeans, Mini batch Kmeans |
| distance_method | COMBO | Euclidean | 6 options: Euclidean, Manhattan, Cosine Similarity, HSV Distance, RGB Weighted Distance, RGB Weighted Similarity |
| gaussian_blur | INT | 30–27 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |