Recolor mask LAB space v5.1.0
The color-match node with per-channel dials
- image_reference
- image_mask_reference
- image_recolor
- image_mask_recolor
- IMAGE
The recolor family in this pack is really one idea with three dial settings. The HSV version is the set-and-forget one; this LAB-space version is the one you reach for when "match it exactly" isn't what you want, because it adds six factor sliders that let you decide how aggressively each color dimension gets remapped.
LAB is the right color space for this job, honestly. The L channel is lightness, A is the green–red axis, B is the blue–yellow axis - so unlike HSV, "darker but same color" and "more saturated but same lightness" are independently controllable. That's why this node gives you six factors (mean + sigma for each channel) while the HSV version gives you none.
How it works
Identical skeleton to the HSV node: it computes the mean and standard deviation of each channel inside the reference mask and the target mask, then remaps the target with a z-score transfer. The difference is the per-channel factors. For each of L, A, and B:
target = ((target - mu_target) / sigma_target) * (sigma_ref * factor_sigma) + (mu_ref * factor_mean)
Set a factor to 1 and that channel is fully matched to the reference. Set factor_mean_L to 0.5 and the target only moves halfway toward the reference's mean, giving you a partial shift. Set a factor_sigma below 0 and the code keeps the target's own standard deviation instead - a documented escape hatch for "match the mean but don't touch the variance."
The inputs that matter
The four image inputs are the same as the HSV sibling - image_reference, image_mask_reference, image_recolor, image_mask_recolor. The interesting part is the six factors (all FLOAT, 0–10, default 1):
factor_mean_L/factor_sigma_L- lightness.factor_mean_Lbelow 1 makes the result darker relative to the reference.factor_mean_A/factor_sigma_A- the green–red axis. This is your practical color-shift dial.factor_mean_B/factor_sigma_B- the blue–yellow axis.
Output: the recolor'd IMAGE, everything outside the target mask untouched.
Installing it
Standard for the pack:
cd ComfyUI/custom_nodes
git clone https://github.com/TRI3D-LC/tri3d-comfyui-nodes
cd tri3d-comfyui-nodes
pip install -r requirements.txt
or ComfyUI Manager → "tri3d-comfyui-nodes", restart, under TRI3D.
Common issues
- Results look flat - you're matching lightness too hard. Back
factor_sigma_Loff toward 0 (or negative) so the target keeps its own contrast. - Colors shift in an unexpected direction - remember A and B are opponent axes, not RGB. "More red" is an A increase, but the result is only as good as the reference region's stats; a reference mask with mixed colors averages out to grey-ish.
- Tiny or near-empty masks - dividing by a near-zero standard deviation produces noise or blown colors. Keep the masked regions substantial.
Where this node beats its siblings: when you want controlled matching - e.g., match a garment's color but keep your lighting - the factor dials are exactly the control the HSV and RGB versions lack. For pure "make it identical," the plain recolor-mask (HSV) or RGB variant is simpler.
Inputs (10)
| Name | Type | Default | Description |
|---|---|---|---|
| image_reference | IMAGE | — | |
| image_mask_reference | IMAGE | — | |
| image_recolor | IMAGE | — | |
| image_mask_recolor | IMAGE | — | |
| factor_mean_L | FLOAT | 1.000–10 | — |
| factor_sigma_L | FLOAT | 1.000–10 | — |
| factor_mean_A | FLOAT | 1.000–10 | — |
| factor_sigma_A | FLOAT | 1.000–10 | — |
| factor_mean_B | FLOAT | 1.000–10 | — |
| factor_sigma_B | FLOAT | 1.000–10 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |