ComfyUI Node

Extract Palette

Pull the five dominant colors out of any photo

By 45uee·Created 2 years ago·Updated 5 months ago· 42
Extract Palette
  • image
  • Color palette
num_colors5
cluster_methodMini batch Kmeans

ExtractPalette is the reverse of everything else in ComfyUI-Color_Transfer. Every other node in the pack takes colors in and recolors an image; this one takes an image and hands you its dominant colors back as a COLOR_LIST. If the pack is a color-grading toolkit, this is the eyedropper that tells you what you're actually working with - and it's the missing half of the pack's most useful pipeline.

What it does

Give it an image, a count, and a clustering method, and it runs KMeans over the pixels to find the num_colors most representative colors in the frame. The output is a Color palette (COLOR_LIST) - the exact same type ColorPalette produces, which means it plugs straight into the target_colors input of every transfer node in the pack.

Three inputs, one of which you'll actually touch:

  • image - any IMAGE. One honest caveat: if you feed it a batch, it only looks at the first frame (image[0]). Fine for single shots, slightly surprising if you expected it to summarize a video.
  • num_colors (1–50, default 5) - how many dominant colors you want. 5 is the sweet spot for "what's this scene about?"; 8–10 gives a richer palette for a more detailed recolor; 50 is overkill for anything but a swatch book.
  • cluster_method (Kmeans / Mini batch Kmeans, default Mini batch) - the usual accuracy-versus-speed trade. For extraction, MiniBatch is fine; you're summarizing, not doing fine segmentation.

The pipeline it unlocks

The genuinely clever way to use this node is as the front end of a "match this photo's mood" workflow:

  1. LoadImage a reference shot → ExtractPalette → a transfer node's target_colors.
  2. LoadImage the image you want recolored → the same transfer node's image.
  3. Watch your target inherit the reference's dominant palette.

You get the vibe of the reference without ever hand-typing a swatch - and because the transfer nodes cluster to however many colors the palette has, the sizes line up naturally. It's also the fastest way to learn a look: run ExtractPalette on a photo you love, read the RGB values, and suddenly you can see exactly which five colors do the heavy lifting. That's genuinely useful for color grading AI output, which has a well-known tendency to oversaturate - extract the palette and you can see the model's actual color habits.

You can also preview the extracted palette by feeding the COLOR_LIST into a ColorPalette node (which will just echo it) or by wiring it into a palette transfer and viewing - the pack has no dedicated swatch renderer, so you confirm colors the indirect way.

Install and quirks

Same pack-wide install - ComfyUI Manager search "Color_Transfer", or:

cd ComfyUI/custom_nodes
git clone https://github.com/45uee/ComfyUI-Color_Transfer

Restart after cloning. No models, no keys, CPU-only math. The pack depends on scikit-learn, opencv-python, and POT; if import fails, the README's fix is pip install scikit-learn. Like the rest of this small solo-dev pack, it's unflashy but does what it says - the only real surprise is the batch handling, so if you plan to extract from video frames, split them first.

CategoryColor Transfer/Palette Transfer

Inputs (3)

NameTypeDefaultDescription
imageIMAGE
num_colorsINT51–50
cluster_methodCOMBOMini batch Kmeans2 options: Kmeans, Mini batch Kmeans

Outputs (1)

NameTypeDescription
Color paletteCOLOR_LIST