Nodes/tri3d-comfyui-nodes/Luminosity match v5.1.0
ComfyUI Node

Luminosity match v5.1.0

Force one region's lighting to match another's

By TRI3D-LC·Created 3 years ago·Updated about a year ago· 27
Luminosity match v5.1.0
  • image_reference
  • image_mask_reference
  • image_recolor
  • image_mask_recolor
  • IMAGE
factor_mean_L1.00
factor_sigma_L1.00

Luminosity match is the node that makes a recolored or regenerated region stop looking like a sticker. You give it a reference region and a target region, each paired with its own mask, and it renormalizes the target's lightness so its mean and spread match the reference. The result is a target region that's lit like the reference - same average brightness, same contrast spread - which is precisely what sells a recolored garment or a head-swap as part of the same photo.

The mechanism is a masked statistics transfer in LAB space. For each masked region it computes the mean and standard deviation of the L (lightness) channel, then scales the target's L values: target_L → (target_L - mean_target) * factor_sigma_L * (sigma_ref / sigma_target) + mean_ref * factor_mean_L. The two factors are the dials - at 1.0/1.0 it's a straight moment-match, and you can lean on them to over- or under-apply. The A/B color channels are left alone; this node only touches lightness, so hue is untouched. (The pack's separate tri3d-recolor-mask-* nodes handle the color axes; this one handles the lighting.)

Inputs that matter

  • image_reference + image_mask_reference - the region whose lighting you want to copy.
  • image_recolor + image_mask_recolor - the region you want to fix.
  • factor_mean_L (default 1.0) - how hard to push the target's mean toward the reference's. 0 leaves brightness alone; 2 overshoots.
  • factor_sigma_L (default 1.0) - the same idea for contrast spread. Lower it if the match comes out too contrasty.

Output

One IMAGE - the image_recolor with its L channel renormalized, masks dissolved back into the frame.

Where it fits

It's the finishing step of the pack's LAB recolor workflow: recolor the garment in the color space you want, then run luminosity match against a reference region (the original lighting) so the recolor inherits the correct shading instead of flat color. Same pattern for fixing a head that's too dark or too bright against the body it was pasted onto. In both cases it's the difference between "color changed" and "looks photographed."

Install and gotchas

Standard pack install:

cd ComfyUI/custom_nodes
git clone https://github.com/TRI3D-LC/tri3d-comfyui-nodes
# restart ComfyUI

Or ComfyUI Manager (search "tri3d"). Keep the folder named tri3d-comfyui-nodes. OpenCV/numpy only - no model, no GPU.

  • Both masks are IMAGE type (not MASK), and they're thresholded at 127 internally - a soft mask becomes hard-edged, so don't rely on feathered masks for smooth results.
  • An empty mask means a divide-by-zero → NaN, and the node doesn't guard it. If the output comes out all-grey or corrupted, your mask probably covered nothing.
  • It operates on single frames; feed it one image at a time rather than a batch and you'll know exactly what got matched.

Honestly, this is one of the pack's quietly best nodes. It's a two-line stats transfer wrapped in a friendly interface, but it's the tool that makes recolors and swaps look lit, and in this pack's try-on world that's most of the battle.

CategoryTRI3D

Inputs (6)

NameTypeDefaultDescription
image_referenceIMAGE
image_mask_referenceIMAGE
image_recolorIMAGE
image_mask_recolorIMAGE
factor_mean_LFLOAT1.000–10
factor_sigma_LFLOAT1.000–10

Outputs (1)

NameTypeDescription
IMAGEIMAGE