ComfyUI Node

Levels

The photo-editor tonal control ComfyUI was missing

By isekai-sh·Created 9 months ago·Updated 8 months ago· 3
Levels
  • image
  • image
black_point0.00
white_point1.00
gamma1.00

IsekaiLevels is the Levels adjustment from every photo editor ever, transplanted into ComfyUI: a black point, a white point, and a gamma slider. It fixes the two most common complaints about generated images - washed-out contrast and muddy midtones - with the three controls that photo editors have used for decades. If you've ever decoded an image and thought "the blacks aren't black," this is the node.

How it works

The math is the standard levels transform, applied per-pixel:

  1. Take the image's pixel values (0–1) and subtract the black_point (0–0.99, default 0), then divide by the range between white_point (0.01–1, default 1) and black_point. This remaps the tonal range so that black_point becomes 0 and white_point becomes 1.
  2. Apply gamma correction: the values are raised to 1/gamma. Gamma above 1 darkens midtones; below 1 brightens them.

In plain terms: raise black_point to crush shadows toward true black, lower white_point to pull highlights down, and use gamma to lift or sink the midtones without moving the extremes. The three knobs work together - black/white points set the endpoints, gamma sculpts everything between them.

A small note: the implementation applies this to all channels at once (the RGB image, not per-channel), so it's the "master" levels from Photoshop, not the full channel-by-channel version. You can't independently grade the red channel here. For a quick contrast fix that's fine; for serious color work you'd want the per-channel tool.

The inputs

  • image - the image to adjust.
  • black_point - 0–0.99, default 0.
  • white_point - 0.01–1, default 1.
  • gamma - 0.1–3, default 1.

Output is a single image tensor. It's an early-grade node - levels first, then color adjustments on top.

Installing it

Part of isekai-comfy-node:

ComfyUI Manager: search "isekai" → install isekai-comfy-node → restart. Manually:

cd ComfyUI/custom_nodes
git clone https://github.com/isekai-sh/isekai-comfy-node
cd isekai-comfy-node
pip install -r requirements.txt

Restart and it's under Isekai → Image/Blend. Pillow and requests; no models, no downloads.

Common issues

The standard trap is expecting levels to be a contrast slider. It's not - it's a range remap. If you set black_point to 0.5 expecting "more contrast," you've just crushed a huge chunk of your shadows to pure black. The right mental model: the points define where the tonal range starts and ends, and gamma does the midtone shaping. Go gently.

And because this runs through 8-bit PIL, aggressive stretches (especially widening the range on a low-contrast source) will expose banding in smooth gradients. Moderate adjustments are invisible; dramatic ones show the bit depth. Levels at 0.05–0.1 tweaks is the sweet spot.

CategoryIsekai/Image/Blend

Inputs (4)

NameTypeDefaultDescription
imageIMAGE
black_pointoptFLOAT0.000–0.99
white_pointoptFLOAT1.000.01–1
gammaoptFLOAT1.000.1–3

Outputs (1)

NameTypeDescription
imageIMAGE