Nodes/comfyui-fvmtools/Palette From Image
ComfyUI Node

Palette From Image

Steal a color palette from any reference image — no scikit-learn required

By ping1979ping·Created 5 months ago·Updated about a month ago· 0
Palette From Image
  • image
  • palette_string
  • color_1
  • color_2
  • color_3
  • color_4
  • color_5
  • color_6
  • color_7
  • color_8
  • primary
  • secondary
  • accent
  • neutral
  • metallic
  • palette_preview
  • source_annotated
  • palette_info
num_colors5
extraction_mode
ignore_backgroundtrue
ignore_skintrue
sample_region
saturation_threshold0.10
include_neutralstrue
include_metallicstrue
seed0

Color Palette Generator invents palettes from color theory. This node steals them from reality. Drop in any image - a mood board, a photo of a scene you like, an outfit reference - and it clusters the pixels with K-Means, maps each cluster to a named color, and hands you the same output shape as its sibling: a palette_string for Prompt Color Replace plus individual color and role outputs. It's the "build the wardrobe from the reference image" move for character work, and it costs nothing extra because the K-Means is implemented in pure numpy. No scikit-learn dependency to fight with.

The three extraction modes

  • dominant - sorts clusters by pixel count. You get the colors that actually fill the image. Simple, and often the most faithful to the source.
  • vibrant - sorts by saturation instead. Same clusters, re-ordered toward the vivid ones. Good when the reference is muted but you want the feel of it, louder.
  • fashion_aware - greedy max-hue-distance selection. This is the interesting one: it tries to pick colors that are distinct from each other in hue, which is what you want for an outfit where each garment needs to read as a different color rather than five shades of the same one.

Two booleans do real work for fashion use: ignore_background and ignore_skin (both default on). Skin tones and backgrounds are exactly the pixels that dominate a portrait's histogram and the least useful for deciding what the character should wear. Turn these on for outfit extraction and the palette stops being "beige, tan, more beige."

The knobs that matter

  • sample_region - full, center_crop, upper_half, or lower_half. When your reference is a full-body shot and you only care about the top's colors, sample the upper_half. Obvious once you see it, transformative for wardrobe work.
  • num_colors - 2–8, default 5. Five maps cleanly to the five semantic roles (primary/secondary/accent/neutral/metallic).
  • saturation_threshold - minimum saturation a color needs to count. 0.1 default filters out near-grays.
  • include_neutrals / include_metallics - keep the desaturated grays and the gold/silver names in play. For a night-out look you might drop neutrals; for streetwear you'll want them.
  • seed - K-Means initialization is seeded, so the same image + same seed gives the same palette. If you want variety, change the seed rather than the image.

Outputs mirror the generator exactly - palette_string, color_1color_8, the five role outputs, palette_preview (swatch), plus one extra: source_annotated, the original image with color regions highlighted, so you can see which pixels produced which palette entry. palette_info explains the extraction.

Installing

Identical to its sibling - zero dependencies beyond numpy:

cd ComfyUI/custom_nodes
git clone https://github.com/ping1979ping/comfyui-FVMtools

Restart ComfyUI. No models, no downloads. This whole color corner of the pack is the "just works" zone.

Where it trips people up

The named-color mapping is approximate - the node maps each cluster to the closest of its 161 named colors, so a weird pixel-average can come back as a color that looks wrong on screen even though the cluster was right. Check source_annotated before trusting the names, and remember saturation_threshold and sample_region are the levers that fix most bad extractions. Also: a heavily filtered or HDR reference (all pink neon or crushed shadows) will extract a palette that reflects the filter, not the scene. For palette theft, plain references beat stylized ones.

CategoryFVM Tools/Color

Inputs (10)

NameTypeDefaultDescription
imageIMAGE
num_colorsINT52–8
extraction_modeCOMBO3 options: dominant, vibrant, fashion_aware
ignore_backgroundBOOLEANtrue
ignore_skinBOOLEANtrue
sample_regionCOMBO4 options: full, center_crop, upper_half, lower_half
saturation_thresholdFLOAT0.100–1
include_neutralsBOOLEANtrue
include_metallicsBOOLEANtrue
seedINT00–4294967295

Outputs (17)

NameTypeDescription
palette_stringSTRING
color_1STRING
color_2STRING
color_3STRING
color_4STRING
color_5STRING
color_6STRING
color_7STRING
color_8STRING
primarySTRING
secondarySTRING
accentSTRING
neutralSTRING
metallicSTRING
palette_previewIMAGE
source_annotatedIMAGE
palette_infoSTRING