ComfyUI Node

Ideogram Element Palette

A 5-Color Palette, Because Ideogram 4 Says So

By SurrealByDesign·Created 2 months ago·Updated 2 months ago· 3
Ideogram Element Palette
  • image
  • element_palette_json
  • palette_preview
num_colors5
min_delta_e10.0

IdeogramElementPalette is the same extraction pipeline as IdeogramPaletteExtractor, but with the training wheels bolted on for one specific job: building the per-element palettes inside Ideogram 4's compositional_deconstruction prompt schema.

Here's the context you need. Ideogram 4's global style_description accepts a big palette (up to 16 colors), but each element in a regional prompt - the "compositional deconstruction" objects with their own bounding boxes - only takes a palette of up to 5 colors. If you hand Ideogram a per-element palette that's too long, the structured prompt is malformed and you get a worse render or a rejection. This node's whole reason to exist is that you can't set num_colors above 5 on it, so you physically can't produce an over-long element palette. The limit is enforced in the node signature itself, not in a validator you have to remember to run.

What it does

Same k-means clustering, same Delta-E (perceptual LAB distance) dedup as the main extractor, same graceful gray #808080 fallback on a bad image. The differences are the clamp (1–5 colors, default 5) and the output name. It's the palette node you pair with IdeogramElementBuilder - extract a region's palette, wire it into the builder's color_palette input, and each area of your scene carries its own reference colors.

Inputs are the familiar trio: image, num_colors (1–5, default 5), min_delta_e (default 10.0). Outputs: element_palette_json (a JSON array of hex strings, max 5) and palette_preview (the swatch strip IMAGE).

Where you'd actually use it

Regional control is Ideogram 4's native superpower - bounding boxes with per-element colors is genuine spatial conditioning no other open model gives you out of the box. The honest catch: for this to matter you need a multi-element prompt, which means several IdeogramElementBuilders feeding an IdeogramElementCollector. If you're doing a one-subject, no-boxes prompt, the global IdeogramPaletteExtractor is the one you want. Reach for this node when the scene has distinct regions - sky, valley, traveler - each deserving its own color identity.

A subtler point: extraction is whole-frame, not region-aware. If you want the palette of just the subject area, use IdeogramMaskedPaletteExtractor (mask the subject, get its true colors) and pipe that into the element builder instead. The masked node and this one are designed to work as a pair.

Installing it

Comes with the pack - one install, fifteen nodes. ComfyUI Manager: search "Ideogram Palette and Prompt Tools". Or:

cd ComfyUI/custom_nodes
git clone https://github.com/SurrealByDesign/ComfyUI-Ideogram-Palette-and-Prompt-Tools

Restart ComfyUI. The one extra dependency is scikit-learn (Manager handles it, or pip install scikit-learn). torch/numpy/Pillow are intentionally not pinned - they ship with ComfyUI, and the author doesn't want a reinstall to nuke your CUDA-matching torch. Nodes live under Ideogram/Palette; needs Python ≥ 3.10, tested on ComfyUI 0.24.0 / Python 3.12.

Gotchas

  • It's still a global extractor under the hood. If the subject only occupies a quarter of the frame, its colors can get drowned out by the background. That's what the masked variant is for.
  • Five is a real ceiling, not a suggestion. Ideogram's element schema maxes out there. If you truly need more distinct colors in one region, that's a sign to split the region into two elements.
  • Order matters. The JSON array is emitted dominance-first; Ideogram consumes it in order, so a small accent color will naturally land last. If you care which color leads, run the output through IdeogramPaletteOverride and reorder.

Troubleshooting

  • Element palette looks like the global palette? Check you wired the right node - it's easy to grab the extractor instead.
  • #808080 gray? Degenerate image or extraction error. Confirm the image loaded and has real content.
  • No menu entry? Console will show an import error, almost always missing scikit-learn.
CategoryIdeogram/Palette

Inputs (3)

NameTypeDefaultDescription
imageIMAGE
num_colorsINT51–5
min_delta_eFLOAT10.00–100

Outputs (2)

NameTypeDescription
element_palette_jsonSTRING
palette_previewIMAGE