颜色匹配器 / Color Matcher
Make one image wear another's colors (without the pain)
- reference_image
- moving_image
- 颜色匹配后图像
- 匹配信息
Color Matcher takes two images - a "reference" and a "moving" one - and reshapes the moving image's color distribution until it looks like it was shot under the same conditions as the reference. It's the classic color-grading trick for making a composite feel seamless: paste a subject into a scene and the subject instantly gives itself away by having different white balance, different warmth, different contrast. This node attacks that mismatch directly.
It's part of the RUI-Nodes pack ("Rui-Node🐶"), a bilingual Chinese/English collection, and it's the kind of tool that quietly saves you in two situations: unifying a batch of frames so they all share one tone, and matching a pasted element to its new background. It's not a miracle worker - it can't invent lighting direction - but for the "this paste looks obvious" problem, it's often exactly what you need before you reach for a heavier color-grading stack.
How it works
You pick a match_method and the node does the math per color channel:
histogram- full per-channel histogram matching: it maps the moving image's pixel-value distribution onto the reference's cumulative distribution. This gives the tightest tone match, but the tooltip is honest that if the two images have very different content, it can push in color casts.mean_std- a much gentler approach that only aligns each channel's mean and standard deviation. It won't nail the look as precisely, but it's far less likely to look wrong.none- skips matching entirely; useful as a control to compare against.
The one other knob, blend_factor, is where the polish lives. It blends between the original and the fully-matched result: 1.0 is full match, 0.0 is untouched. When a full histogram match looks overcooked, dropping to 0.5–0.8 usually lands in the natural zone - the author's tooltip literally recommends that.
Inputs: reference_image (the tone donor, never modified), moving_image (the one that changes). Outputs: 颜色匹配后图像 (the matched result) and 匹配信息, a string log of which method and blend factor were used per batch item - handy if you're comparing runs.
Installing it
Install the pack once and this node comes along:
cd ComfyUI/custom_nodes
git clone https://github.com/rui40000/RUI-Nodes
cd RUI-Nodes
pip install -r requirements.txt
or via ComfyUI Manager, search "RUI-Nodes", install, restart. Base requirements (torch, numpy, Pillow, requests) are nothing special; this node itself only needs numpy and torch.
Where people get burned
The main trap is expecting histogram matching to survive content mismatch. If your reference is a landscape and your moving image is a close-up of a person, the per-channel remap can throw weird casts into skin tones. That's what blend_factor is for - treat histogram + full strength as "try first," and back off before you reach for a different node.
Second, batches must match in size - both inputs need the same batch count, or the node asserts out. If you're matching a single reference against a 10-frame batch, feed the reference as a repeated single-frame batch. And like most of this pack, the numbers are the whole story: when the output looks wrong, the 匹配信息 string tells you exactly what was computed.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| reference_image | IMAGE | 参考图:提供目标色调,本身不会被改动。 | |
| moving_image | IMAGE | 待校色图:它的颜色分布会被改造成参考图的样子。 | |
| match_method | COMBO | histogram | 匹配算法: histogram = 逐通道直方图匹配,色调贴合最紧, 但两图内容差异大时容易出偏色 mean_std = 只对齐均值与标准差,效果温和、不易翻车 none = 不做匹配,仅用于对照原图 |
| blend_factor | FLOAT | 1.000–1 | 匹配强度:结果在原图与完全匹配之间线性混合。 0 = 保持原样,1 = 完全套用参考图色调。 匹配过头显得失真时降到 0.5~0.8 往往更自然。 |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| 颜色匹配后图像 | IMAGE | — |
| 匹配信息 | STRING | — |