Nodes/ComfyUI_Nimbus-Pack/Auto Levels (Image)
ComfyUI Node

Auto Levels (Image)

Auto-contrast for flat, washed-out AI images

By sergekatzmann·Created 3 years ago·Updated 8 months ago· 7
Auto Levels (Image)
  • image
  • IMAGE
black_point1.0
white_point99.0
channel_independenttrue

Sometimes a generation comes out flat - hazy, low-contrast, like it's behind a sheet of gauze. This node is the one-click fix for that. It's Photoshop's "Auto Levels" as a ComfyUI node: it looks at the image's histogram, finds the darkest and brightest bits, and stretches everything so the shadows go properly dark and the highlights go properly bright. Washed-out becomes punchy, no manual curve-dragging. In the menu it's Auto Levels (Image).

It's a genuinely useful little post node that nobody talks about, mostly because "levels" is unglamorous. But if your outputs look milky, this fixes it in one node.

How it works

Histogram stretching. The node clips a small percentage off each end of the tonal range and then rescales what's left to span the full 0–255. black_point is the percentile it treats as pure black and white_point the percentile it treats as pure white - so the defaults (1 and 99) mean "clip the darkest 1% of pixels to black, the brightest 1% to white, and stretch the rest between." Anything hiding in that milky middle gets pushed out toward the extremes.

The important switch is channel_independent. When it's on (the default), each RGB channel is stretched separately, which also corrects color casts - a blue-tinted image gets neutralized, like an auto white balance. When it's off, the stretch is applied globally to luminance only, so contrast improves but the colors stay exactly as they were.

The inputs and outputs that matter

  • image - the image in.
  • channel_independent (boolean, default on) - the real decision. On = fixes color casts too. Off = contrast only, colors untouched.
  • black_point / white_point - how aggressively to clip each end. Defaults 1 and 99 are gentle; push black_point up to 3–5 for punchier, deeper shadows.

Output: a single corrected IMAGE.

Installing it

ComfyUI Manager: search ComfyUI_Nimbus-Pack, install, restart. It's a small pack, so if it doesn't show up, clone it:

cd ComfyUI/custom_nodes
git clone https://github.com/sergekatzmann/ComfyUI_Nimbus-Pack.git
pip install -r ComfyUI_Nimbus-Pack/requirements.txt

Restart. Pure NumPy/PIL, no models, nothing heavy. The requirements.txt is for the pack's video node.

Common issues & troubleshooting

The colors shifted and you didn't want that. That's channel_independent doing its white-balance thing. Stretching each channel on its own will neutralize a color cast, which is great when the image is genuinely tinted and annoying when the tint was intentional (a warm sunset, a moody blue scene). Turn channel_independent off to keep your colors and only fix contrast.

Shadows got crushed / highlights blew out. Your clip points are too aggressive. Bring black_point back toward 0–1 and white_point toward 99–100. The further black_point climbs, the more dark detail you throw away permanently.

Nothing much happened. If the image already uses the full tonal range, there's nothing to stretch - auto-levels only helps images that are compressed into a narrow band. This is a fix for flat, hazy, or faded images, not every image.

Where to put it. Run it near the end, after upscaling and before saving - it's a finishing touch on pixels, not something to feed back into a sampler.

CategoryNimbus-Pack/Image Enhancement

Inputs (4)

NameTypeDefaultDescription
imageIMAGE
black_pointFLOAT1.00–49Percentage of darkest pixels to clip to black
white_pointFLOAT99.051–100Percentage of brightest pixels to clip to white
channel_independentBOOLEANtrueCalculate levels per channel (rebalances color) or globally (maintains color balance)

Outputs (1)

NameTypeDescription
IMAGEIMAGE