Nodes/ComfyUI-CN-Pre/Levels (Black/White/Gamma)
ComfyUI Node

Levels (Black/White/Gamma)

Levels (Black/White/Gamma) — the familiar photo-editing tone tool, for any image

By OKIE5·Created 10 months ago·Updated 10 months ago· 0
Levels (Black/White/Gamma)
  • image
  • image
black_point0.000
white_point1.000
gamma1.00
per_channel
bp_r0.000
wp_r1.000
gm_r1.00
bp_g0.000
wp_g1.000
gm_g1.00
bp_b0.000
wp_b1.000
gm_b1.00

This one's a bit of an outlier in a pack otherwise built around ControlNet preprocessing - it lives under Image/Adjust rather than CtrlNet/Pre, and it works on any image, not specifically a control map. If you've ever used the Levels tool in Photoshop, GIMP, or basically any photo editor, this is that same tool, exposed as a ComfyUI node: black point, white point, gamma, done.

How Levels actually works

The core idea is a simple range remap followed by a curve. black_point and white_point (both 0-1, defaulting to 0 and 1) define the input range that gets stretched to fill the full output range - anything at or below black_point becomes pure black, anything at or above white_point becomes pure white, and everything between gets linearly stretched to fill the gap. That's the classic Levels move for fixing a washed-out, low-contrast image: pull the black point up and the white point down, and the existing tonal range gets stretched out to use the full spectrum. gamma (0.1-5, default 1) then applies a power curve on top of that stretched result - values below 1 brighten midtones without touching black or white, values above 1 darken them, the standard gamma-correction move for fine-tuning brightness without crushing your endpoints.

per_channel is the toggle that turns this from a global tone tool into a color-correction tool. Leave it off and black_point/white_point/gamma apply uniformly across the whole image. Turn it on and three independent sets of the same three controls unlock - bp_r/wp_r/gm_r for red, bp_g/wp_g/gm_g for green, bp_b/wp_b/gm_b for blue - letting you correct a color cast by pulling one channel's range differently than the others. That's genuinely the more powerful mode if your image has a color problem (too warm, too cool, a weird tint) rather than just a contrast problem, since a global Levels adjustment can't fix an imbalance between channels on its own.

Inputs and outputs

Required: image, black_point, white_point, gamma, per_channel, plus the nine per-channel fields (bp_r/wp_r/gm_r, bp_g/wp_g/gm_g, bp_b/wp_b/gm_b) that only matter when per_channel is on - leave them at default otherwise. No optional inputs. Output: image (IMAGE), a single, standard image output rather than the control_image naming the pack's other nodes use - another small sign this node is meant for general use, not exclusively ControlNet work.

When to reach for this over CN-Pre-Normalize

This pack has two tone-adjustment nodes solving overlapping problems with different vocabularies: CN Pre: Normalize uses gamma/gain/bias framing and lives specifically in the ControlNet preprocessing category, while this one uses the black-point/white-point/gamma framing every photo editor uses and works on any image. If you're adjusting a control map and thinking in terms of "boost the signal" or "shift the whole thing brighter," Normalize's gain/bias language probably fits better. If you're thinking in terms of "the shadows are too gray" or "there's a color cast," Levels' per-channel black/white points are the more natural tool - and it's the one to reach for outside a ControlNet context entirely, since Normalize doesn't offer per-channel control at all.

Installing it

Search ComfyUI-CN-Pre in ComfyUI Manager, or manually: cd ComfyUI/custom_nodes && git clone https://github.com/OKIE5/ComfyUI-CN-Pre, then restart. As with the rest of this pack, the README is a one-line stub that says nothing about this node specifically - but it's a pure math node with no model dependency, so there's nothing to download and very little that can go wrong at the install stage.

Where people get burned

The main trap with any Levels-style tool: setting black_point above white_point, or setting them too aggressively close together, which crushes most of your image to flat black or white with nothing in between. If output looks posterized or blown out, back both points off toward their defaults (0 and 1) and adjust more gently. And if you turn on per_channel and results look worse rather than better, double-check you actually meant to enable per-channel correction - for a straightforward contrast fix with no color-cast problem, the global controls alone do the job and per-channel just adds three more variables to accidentally mistune.

CategoryImage/Adjust

Inputs (14)

NameTypeDefaultDescription
imageIMAGE
black_pointFLOAT0.0000–1
white_pointFLOAT1.0000–1
gammaFLOAT1.000.1–5
per_channelCOMBO2 options: false, true
bp_rFLOAT0.0000–1
wp_rFLOAT1.0000–1
gm_rFLOAT1.000.1–5
bp_gFLOAT0.0000–1
wp_gFLOAT1.0000–1
gm_gFLOAT1.000.1–5
bp_bFLOAT0.0000–1
wp_bFLOAT1.0000–1
gm_bFLOAT1.000.1–5

Outputs (1)

NameTypeDescription
imageIMAGE