Nodes/ComfyUI_pixel_snapping/Powerful Color Alignment
ComfyUI Node

Powerful Color Alignment

Make the swapped-in person stop looking pasted on

By flywhale-666·Created 8 months ago·Updated 7 months ago· 58
Powerful Color Alignment
  • target_image
  • reference_image
  • aligned_image
strength1.00

The telltale sign of a face swap or a body composite isn't the geometry - it's the light. The person comes back with different skin tones, a different white balance, a slightly wrong exposure, and suddenly the whole image reads "pasted on." The instinct is to re-roll the generation until it matches. Don't. Powerful Color Alignment fixes the pixels directly: it matches the swapped-in person's colors to the reference image, deterministically, in a fraction of a second, with no model and no seed.

It's the fifth node in the flywhale-666/ComfyUI_pixel_snapping pack, and it's aimed squarely at the post-swap / post-composite cleanup job. What separates it from a plain "match mean color" node is that it's region-aware - it figures out which parts of the two images are the same scene (the background) and matches those hard, while only gently adjusting the parts that are genuinely different (the person). That distinction is what stops the whole image from turning into a flat beige smear.

How it works

It's a color transfer in CIELAB space, which is the perceptually-uniform color space you want when matching what the eye sees rather than raw RGB. The node builds a smooth weight map using four very large Gaussian blurs - at roughly 45%, 32%, 22% and 15% of image size - so region boundaries fade naturally instead of cutting. It auto-detects the "same region" (background) versus the "different region" (subject), matches the background channels strongly and the subject more lightly, and clips the transfer at the 5th and 95th percentiles so outliers don't blow out the result.

Two details in there matter in practice. It's saturation-weighted, so gray and desaturated areas barely shift their color channels - a gray background stays gray instead of picking up a cast, which is a classic failure of naive color matching. And the strength slider (0 to 2.0) blends the result: 1.0 is the standard pass, below that you get a subtle touch, above that it drags colors harder for severe mismatches. The README's intended sweet spot is 1.0, with 1.1–2.0 reserved for bad color casts.

Inputs and output

It takes exactly three things:

  • target_image - the image to fix (your post-swap composite).
  • reference_image - what to match against (the original, un-swapped image).
  • strength - 0.0 off, 1.0 standard, up to 2.0 for hard correction.

Output is a single aligned_image. That's it. Wire it between your composite step and your preview, or batch it for uniform toning across a set.

Install

Same pack drill as the others. ComfyUI Manager, search "Pixel Snapping", or:

cd ComfyUI/custom_nodes
git clone https://github.com/flywhale-666/ComfyUI_pixel_snapping
cd ComfyUI_pixel_snapping
pip install -r requirements.txt

Then fully restart ComfyUI. This node only needs OpenCV and numpy, so it's the cheapest node in the pack to run.

Where people get burned

  • Wrong direction - target_image and reference_image are easy to flip, and the result looks wrong in a way that's easy to miss. Target = the image being corrected.
  • Overshooting strength - cranking past ~1.3 starts fighting the subject's actual skin tone, not just the lighting. If 1.0 doesn't do it, the problem is often a geometric mismatch too - align first with the pack's Pixel Snapping node, then color-match.
  • Expecting it to fix shading, not color - it transfers color statistics, not lighting direction. A subject lit from the left pasted into right-lit scene still reads wrong; color alignment can only take you so far.

This is exactly the kind of cheap deterministic fix the community keeps re-inventing: color match is the underrated step in the post-processing toolkit, and it's almost always better than re-rolling a generation because "the colors are off." Powerful Color Alignment just gives you the region-aware version of it in one node.

Categoryimage/color

Inputs (3)

NameTypeDefaultDescription
target_imageIMAGE
reference_imageIMAGE
strengthFLOAT1.000–2

Outputs (1)

NameTypeDescription
aligned_imageIMAGE