ComfyUI Node

CsCPaletteEditor

Recolor a flat image by swatch number — without touching a brush

By 852wa·Created 2 years ago·Updated 2 years ago· 53
CsCPaletteEditor
  • images
  • palette
  • index_maps
  • images
  • palette
  • mask
seed0
hue_random_enablefalse
hue_shift0.00
saturation_random_enablefalse
saturation_scale1.00
value_random_enablefalse
value_scale1.00
lock_color_num0,
mask_enablefalse
invert_maskfalse
operations[]

CsCPaletteEditor is the recolor half of the ComfyUI-ColorshiftColor pack. Wire in the three things ColorshiftColor gives you - the quantized images, the palette, and the index_maps - and this node edits the palette in HSV space, then rebuilds every pixel from the index map. Because the segmentation was decided up front, you can shift the whole image's hue, drain the saturation, or darken one region, and the flat edges stay razor sharp the entire time. No masks, no lasso, no repainting.

The name is doing real work: you edit a palette and the image follows automatically.

The inputs that matter

The three required wires come straight out of ColorshiftColor: images, palette, index_maps. From there it's sliders plus two strings:

  • hue_shift (−180 to 180) - rotates hue in degrees. This is the "make the whole thing blue instead of red" knob.
  • saturation_scale and value_scale (0–5, default 1) - multiply saturation and brightness. 1 leaves them alone; 0.2 is nearly grayscale.
  • lock_color_num (default "0,") plus mask_enable - protect specific swatches from everything above. Enter numbers from the palette preview, comma-separated, e.g. 0,1,4. With mask_enable off, nothing is locked. invert_mask flips the protection to "only these change."
  • operations - the power tool: a JSON list that pins exact colors per swatch, overriding the sliders. Format below.

Each slider group also has its own random toggle - hue_random_enable, saturation_random_enable, value_random_enable - with a shared seed at the top. Flip hue random on and each run picks a different shift in the ±180 range - instant variant batches, and the seed makes them reproducible. It's the most fun setting in the pack for churning out recolors of the same base image.

The operations JSON

The sliders are global; operations is per-swatch. It's a JSON list, exactly as shown in the README:

[{"index": 0, "color": [0.0, 0.0, 1.0]}]

That pins swatch 0 to pure blue. There's also an "hsv" variant ({"index": 1, "hsv": [0.6, 0.8, 0.9]}) if you'd rather specify hue/sat/value directly, and you can comma-separate multiple objects to set several swatches at once. The README warns that the index numbers have to line up with the numbering in palette_preview - and with lock_color_num if you're mixing both.

What comes out

  • images - the recolored flat image.
  • palette - the edited palette. Feed it back into ColorshiftColor's palette_override and the two nodes form a loop: quantize, edit, re-quantize against your new palette.
  • mask - a per-pixel float mask of the regions that were locked (or unlocked, if you inverted). Handy when you want the protected areas as a real mask for something downstream.

Install & gotchas

Same pack, same install: search "ComfyUI-ColorshiftColor" in ComfyUI Manager, or clone https://github.com/852wa/ComfyUI-ColorshiftColor into ComfyUI/custom_nodes, then make sure scikit-learn is present (pip install scikit-learn). Restart ComfyUI. No models, no API keys.

Two things bite people:

  • The index_maps input is typed MASK but carries integer labels (0, 1, 2...), not alpha floats. Treat it as an index map and don't panic when it looks odd in a mask preview.
  • If dragging sliders changes nothing, check mask_enable and lock_color_num - a non-empty lock list with the mask on is exactly how you freeze everything by accident.
CategoryImage/Color

Inputs (14)

NameTypeDefaultDescription
imagesIMAGE
palettePALETTE
index_mapsMASK
seedoptINT00–18446744073709550000
hue_random_enableoptBOOLEANfalse
hue_shiftoptFLOAT0.00-180–180
saturation_random_enableoptBOOLEANfalse
saturation_scaleoptFLOAT1.000–5
value_random_enableoptBOOLEANfalse
value_scaleoptFLOAT1.000–5
lock_color_numoptSTRING0,
mask_enableoptBOOLEANfalse
invert_maskoptBOOLEANfalse
operationsoptSTRING[]

Outputs (3)

NameTypeDescription
imagesIMAGE
palettePALETTE
maskMASK