Nodes/deforum-comfy-nodes/Image Color Match | Deforum
ComfyUI Node

Image Color Match | Deforum

Make your frames wear the reference's palette

By deforum·Created about a year ago·Updated 3 months ago· 29
Image Color Match | Deforum
  • images
  • reference_image
  • IMAGE
strength0.50
method
preserve_luminancetrue

The single most useful trick in the color-grading toolbox: take an image that looks right, and transfer its palette onto images that don't. Image Color Match does exactly that - you feed it your generated frames plus a reference image, and the frames come out wearing the reference's colors.

This is the "don't re-roll a generation because the colors are off" tool. If your animation's frames have drifted - some too warm, some too cold, the whole sequence losing the mood of your first good frame - a statistics transfer is deterministic and instant, where a re-generation is neither. It's also the standard fix for compositing: when an element or a tile doesn't sit in its surroundings' light, color-match it to the surroundings instead of fighting the sampler. The KB's post-processing essay calls this the honest alternative to regenerating, and it's right.

How it works

Two methods, picked by the method dropdown:

  • mean_std - the classic Reinhard-style transfer: it matches each channel's mean and standard deviation from the target to the reference. Global, smooth, usually all you need.
  • histogram - a per-channel histogram match (CDF-based), which reproduces the reference's full tonal distribution rather than just its mean and spread. Stronger, and can go further off the rails on noisy frames.

strength (default 0.5, range 0–1) blends the matched result back with the original via a lerp, so you can dial in how much of the reference's look you actually want. 0.5 is a sensible starting point; full strength can look obviously "graded."

preserve_luminance (default true) is the knob you'll be glad exists: it restores the target's original luminance after matching, so you get the reference's colors without inheriting its exposure. Turn it off only if you genuinely want the reference's brightness too.

The batch behavior

The images input is a batch, and frames are matched against the reference frame-by-frame: frame i is matched to reference_image[min(i, ref_count-1)]. Feed a single reference frame and every target frame matches to it (the standard case). Feed a reference sequence and each frame gets its own reference - which is how you keep a long animation anchored to a palette that's allowed to change over time.

Gotchas

Batch sizes can differ, and the reference's device/dtype gets normalized internally, but matching assumes reasonably comparable content - matching a close-up to a landscape reference gives you the palette, not magic. And histogram mode on per-frame noise is where you'll see weird banding; if a sequence flickers, drop to mean_std or lower strength.

Installing it

Part of deforum-comfy-nodes, the official Deforum ComfyUI pack. ComfyUI Manager: search "deforum" (comfyui-deforum), install, restart. Manual:

cd ComfyUI/custom_nodes
git clone https://github.com/deforum-art/deforum-comfy-nodes

Restart ComfyUI after. No extra dependencies or model files - torch does the math in-process. Load errors after upgrades usually mean an orphaned deforum pip package; pip uninstall deforum and restart.

CategoryDeforum/Image

Inputs (5)

NameTypeDefaultDescription
imagesIMAGE
reference_imageIMAGE
strengthFLOAT0.500–1
methodCOMBO2 options: mean_std, histogram
preserve_luminanceBOOLEANtrue

Outputs (1)

NameTypeDescription
IMAGEIMAGE