Nodes/ComfyUI-SBTools/Match Color Balance (SBTools)
ComfyUI Node

Match Color Balance (SBTools)

Fix a green cast without touching the mood — Match Color Balance does temperature and tint

By Amatsukast·Created 5 months ago·Updated 21 days ago· 2
Match Color Balance (SBTools)
  • target_image
  • target_alpha
  • reference_image
  • reference_alpha
  • IMAGE
  • RGB
  • ALPHA
methodMKL
channel_modeBoth
strength1.00

Your render came back with a color cast - too blue, too green, slightly sick-looking skin. The crude fix is a blanket white balance that shifts everything and flattens the whole frame. Match Color Balance is the finer tool: it matches only the color balance of a reference image - the temperature (warm/cool) and tint (green/magenta) - while leaving the rest of the color structure alone. It's the middle sibling in this pack's Match trio: Match Color does the full color distribution, Match Luminance does brightness, this one does the white-balance layer.

Think of it as "make my shot feel like it was shot under the same light as this reference," without rewriting the palette. If you're compositing a cutout onto a scene, or matching a batch of renders to one graded hero frame, this is the node that removes the "obviously composited" green ring around your subject.

How it works

Both methods work in Lab color space, specifically on the a and b channels - the two that encode hue and saturation rather than lightness. That's the whole point: lightness is untouched, so exposure and contrast stay put and only the color cast moves.

  • MKL (default) - the same optimal-transport approach as Match Color, matching the mean and covariance of the a/b channels. Precise, statistically thorough.
  • Shift - a median-based uniform shift. It computes the median color cast in the target and reference and shifts the target to close the gap. Simpler and blunter, but sometimes exactly right when MKL overcomplicates things.

channel_mode lets you pick which axis to correct:

  • Both - temperature and tint together. Default.
  • Temperature Only - just the warm/cool axis (blue ↔ yellow).
  • Tint Only - just the green ↔ magenta axis.

That last option is your friend for fluorescent-light green casts, or when you only want to kill a magenta shift in skin without warming the whole image. And strength (0–5, default 1) blends the result; go below 1 for a subtle correction and above 1 if you're deliberately pushing a look.

Inputs and outputs

Required: target_image, plus method, channel_mode, strength. Optional: target_alpha and reference_alpha MASK inputs, which restrict the color-statistics calculation to a masked region - useful when you want to match only the subject's cast, not the background's.

Like its sibling, reference_image is required - leave it disconnected and the node errors out. The outputs are IMAGE (corrected result), plus RGB and ALPHA as separated channels.

Installing it

Standard pack install - ComfyUI Manager → search "ComfyUI-SBTools" → Install, or:

cd ComfyUI/custom_nodes
git clone https://github.com/Amatsukast/ComfyUI-SBTools.git
cd ComfyUI-SBTools
pip install -r requirements.txt

The MKL method pulls in kornia, so make sure the requirements actually installed (the Manager path does it automatically). Restart ComfyUI after.

Troubleshooting

  • Result barely changes - check that strength isn't at 0, and that the reference actually has a color cast to transfer. Matching to a neutral gray reference is a valid "remove the cast entirely" trick, by the way.
  • Skin looks waxy - dial strength down to 0.4–0.7. Full balance matching on the a/b channels can over-smooth the color variation in skin that reads as healthy.
  • It's shifting the wrong axis - use Tint Only or Temperature Only to isolate what you actually want to fix.
  • "reference_image is required" error - same gotcha as Match Color; connect the reference first.

One honest caveat: the README lists this node as "in development," so treat results as workable rather than production-perfect - but for the white-balance class of problem, it does the job and it does it without disturbing your exposure.

CategorySBTools/Image

Inputs (7)

NameTypeDefaultDescription
target_imageIMAGEImage to be color balance matched (RGB or RGBA).
methodCOMBOMKLMatching algorithm (Shift: median-based uniform shift, MKL: optimal transport with covariance).
channel_modeCOMBOBothWhich Lab channels to shift (Both: temperature+tint, Temperature Only: warmth/coolness, Tint Only: green/magenta).
strengthFLOAT1.000–5Color balance matching strength (0=no change, 1=full match, >1=overcorrection).
target_alphaoptMASKOptional alpha channel for target image (overrides target_image 4th channel if present).
reference_imageoptIMAGEReference image for color balance (RGB only, alpha channel is ignored).
reference_alphaoptMASKOptional alpha channel for reference image (overrides reference_image 4th channel if present).

Outputs (3)

NameTypeDescription
IMAGEIMAGE
RGBIMAGE
ALPHAMASK