Nodes/tri3d-comfyui-nodes/Recolor mask RGB space v5.1.0
ComfyUI Node

Recolor mask RGB space v5.1.0

The blunt-force color match in the pack's recolor family

By TRI3D-LC·Created 3 years ago·Updated about a year ago· 27
Recolor mask RGB space v5.1.0
  • image_reference
  • image_mask_reference
  • image_recolor
  • image_mask_recolor
  • IMAGE

The recolor family in this pack lets you match the color of one masked region to another, and the only real difference between the members is the color space they do it in. This one does it in raw RGB - the simplest, bluntest, and usually least flattering of the three. It's here for the cases where you genuinely want channel-by-channel equality with the reference and don't care about the perceptual side effects.

To be direct about it: for most garment color matching you'll get better results from the HSV or LAB variants, because they separate "color" from "brightness" and don't smear the match across correlated channels. RGB matching treats red, green, and blue as independent axes, which they aren't, perceptually. So why does this node exist? Sometimes you want exact numeric parity - a technical color match, not a perceptual one - and sometimes the reference and target are close enough that RGB is fine and simpler to reason about.

How it works

Same z-score transfer as the others, in RGB. For each of the three channels it computes mean and standard deviation inside the reference mask and inside the target mask, then remaps the target channel:

target = ((target - target_mean) / target_std) * ref_std + ref_mean

No factor sliders, no modulo tricks - it's the plainest implementation in the family. Everything outside the target mask is preserved, and the changed region is blended back into the original.

The inputs that matter

  • image_reference - the image whose color statistics you're stealing.
  • image_mask_reference - mask over the reference's colored region.
  • image_recolor - the image to change.
  • image_mask_recolor - mask over the region to change.

Output: the recolor'd IMAGE.

Installing it

Part of TRI3D-LC/tri3d-comfyui-nodes:

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

  • Colors come out looking off even when the numbers match - that's RGB matching in a nutshell. The three channels shift together and brightness rides along with saturation, so a "matched" region can look brighter or flatter than you intended. If that bothers you, the LAB variant gives you independent control.
  • Red hue shifts badly - RGB has no hue dimension, so reds and pinks get pulled whichever way the channel means dictate. The HSV node's hue-wrapping exists precisely for this.
  • Tight masks make it worse - with small regions, per-channel standard deviations get noisy and the transfer amplifies that. Bigger, cleaner masks give more stable results.

Reach for this one when you want the reference's exact channel statistics and don't mind the perceptual cost - or when you're matching something where the "correct" result is defined numerically. Otherwise the HSV (recolor-mask) or LAB (recolor-mask-LAB_space) variants will treat your eyes better.

CategoryTRI3D

Inputs (4)

NameTypeDefaultDescription
image_referenceIMAGE
image_mask_referenceIMAGE
image_recolorIMAGE
image_mask_recolorIMAGE

Outputs (1)

NameTypeDescription
IMAGEIMAGE