Nodes/ComfyUI-Darkroom/Auto White Balance
ComfyUI Node

Auto White Balance

Remove the color cast without touching the temperature slider

By jeremieLouvaert·Created 5 months ago·Updated 3 days ago· 101
Auto White Balance
  • image
  • image
methodShades of Gray
minkowski_p6.0
strength1.00

Your image is too warm, or too cool, or just off in a way you can't name. You could fiddle with the White Balance node's temperature slider for five minutes - or you could let the image tell you what the correct white balance is. Auto White Balance estimates the scene's illuminant from the image itself and corrects the cast automatically. No temperature input, no guesswork. It's the "fix the obvious cast" button, done properly.

How it works - the four classical methods

The node implements the four classic illuminant-estimation algorithms from the color-science literature, all in the method dropdown:

  • Gray World - assumes the average of the whole image is gray. Any deviation from neutral gets corrected. Fast, simple, and wrong exactly when the scene is genuinely dominated by one color (a field of grass, a sunset).
  • White Patch - assumes the brightest pixel is white (it uses the 97th percentile to dodge hot speculars). Good for scenes with a real white object in them.
  • Shades of Gray - the default, and the robust one. It's a Minkowski norm generalization that sits between Gray World and White Patch: instead of pure average or pure max, it takes a power-mean that's tunable with minkowski_p (default 6, which the author calls "robust"). It gets most real-world scenes right without blowing up on color-dominant images.
  • Gray Edge - a Minkowski norm applied to gradients rather than pixels. It assumes the average color change in the image is gray, which is the most assumption-light method and often the best - but it's noisier on flat or low-detail images.

Whichever method estimates the illuminant, the correction is a von Kries diagonal applied in linear light - each channel gets scaled so neutral objects read neutral - and it preserves overall brightness rather than yanking exposure around.

The inputs

  • method - pick your estimator. Start with Shades of Gray (the default); try Gray Edge if the result is still casty.
  • minkowski_p (1–16) - the Minkowski norm exponent. It only applies to Shades of Gray and Gray Edge (the tooltip is explicit that Gray World and White Patch ignore it). Lower p behaves more like Gray World; higher p behaves more like White Patch. 6 is the sane default.
  • strength - the blend back to the original, 0–1. The author's own framing is worth trusting here: this is a robust classical estimator, not a neural matcher, so it fixes obvious casts but can under- or over-correct on tricky scenes. strength at 0.5–0.8 is often the sweet spot.

Output is a single image.

Where it fits - and the gotcha

It's a Raw-subcategory node: run it early, right after exposure, before you start grading. The natural pairing is this node when you don't know the cast, White Balance when you know exactly what temperature you want.

The gotcha is that it's content-adaptive - it reads the whole image to make its decision. That puts it on the pack's "NOT allowed in the LUT bake chain" list, alongside everything else that estimates per-image. If you bake a LUT, apply Auto White Balance to the photo after extraction, not inside the chain.

Installing it

Part of the full ComfyUI-Darkroom pack:

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

Or search "Darkroom" in ComfyUI Manager. Needs scipy, opensimplex, rawpy, exifread, Pillow. Restart and it's under AKURATE/Darkroom/Raw. Pure numpy, no learned weights, no GPU, no API - just the classical algorithms done right.

When it works, it feels like magic - one node and the cast is gone. When it doesn't, drop to Gray Edge or dial strength back, and if you're still fighting, the manual White Balance node is right there next to it.

CategoryAKURATE/Darkroom/Raw

Inputs (4)

NameTypeDefaultDescription
imageIMAGE
methodoptCOMBOShades of GrayIlluminant estimator. Gray World=avg-is-gray; White Patch=brightest-is-white (97th pct); Shades of Gray=Minkowski generalization (robust default); Gray Edge=Minkowski on gradients (often best classical).
minkowski_poptFLOAT6.01–16Minkowski norm p. Applies to Shades of Gray and Gray Edge only (ignored by Gray World and White Patch). ~6 is robust.
strengthoptFLOAT1.000–1Blend between original (0) and corrected (1)

Outputs (1)

NameTypeDescription
imageIMAGE