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

Recolor mask LAB space manual v5.1.0

Skip the reference image, dial the target mean and sigma yourself

By TRI3D-LC·Created 3 years ago·Updated about a year ago· 27
Recolor mask LAB space manual v5.1.0
  • image_input
  • mask_input
  • IMAGE
factor_mean1.00
factor_sigma1.00

Every other node in the recolor family works the same way: steal the color statistics from a reference masked region and stamp them onto a target region. This one is the odd one out, and it's oddly freeing. Recolor mask LAB space manual has no reference image at all - instead you type the target mean and standard deviation you want, and it renormalizes the masked region of a single image to those numbers.

When would you want that? When there's no reference to steal from. You know a garment should be a specific lightness - or you want to lift shadows, or normalize a washed-out region to a fixed brightness across a whole batch. It's a parametric brightness/saturation tool wearing a color-node costume.

How it works

The math is the same z-score remap as the other LAB nodes, minus the reference side. It converts your image to LAB, computes the mean and standard deviation of the L channel inside the mask, and rescales:

L = ((L - L_mean) / L_std) * (sigma * sigma_orig) + (mean * mean_orig)

There's a quirk worth knowing: the formula multiplies your inputs by the original stats rather than replacing them. So factor_mean and factor_sigma behave as multipliers on the existing values - 1.0 leaves the region unchanged, 2.0 roughly doubles the brightness mean, 0.5 halves it. That's why the defaults are 1.0, not "some target value": they're scaling factors, not absolute targets, despite the node's name.

Only the L channel is touched. A and B pass through untouched, which means this node shifts lightness only - it won't change hue or saturation on its own. Only the masked region changes; everything outside the mask keeps its original pixels.

The inputs that matter

  • image_input - the image to adjust.
  • mask_input - the region to adjust (an IMAGE mask; any pixel above ~127 counts as "in").
  • factor_mean (FLOAT, 0–10, default 1) - scales the target mean of the L channel.
  • factor_sigma (FLOAT, 0–10, default 1) - scales the standard deviation (contrast) of the L channel.

Output: the adjusted IMAGE.

Installing it

Standard pack install:

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

  • "Manual" but it's multiplicative - the most common confusion. If you set factor_mean expecting it to be the final brightness value, you'll be surprised. Values are multipliers on the region's own stats; start at 1.0 and nudge.
  • No color change at all - that's the design. This node only drives L. For hue/saturation adjustment, use the LAB-space node with a reference or the HSV one.
  • Flat result - pushing factor_sigma far below 1 crushes contrast in the masked region; keep it near 1 unless flattening is the goal.

It's a niche tool, but in the right spot - normalizing the same garment across many frames, or deliberately flattening a region before an inpaint - it's the only node in the pack that does it.

CategoryTRI3D

Inputs (4)

NameTypeDefaultDescription
image_inputIMAGE
mask_inputIMAGE
factor_meanFLOAT1.000–10
factor_sigmaFLOAT1.000–10

Outputs (1)

NameTypeDescription
IMAGEIMAGE