Nodes/NN-custom-nodes/Image Adjust Contrast/Brightness
ComfyUI Node

Image Adjust Contrast/Brightness

Brightness and contrast that behave themselves

By bandifiu·Created about a month ago·Updated about a month ago· 0
Image Adjust Contrast/Brightness
  • image
  • image
contrast0.00
brightness0.00

"Image Adjust Contrast/Brightness" is the smallest honest tool in the bandifiu/ComfyUI-NN-custom-nodes image family: two sliders, one image in, one image out. It exists because flat, washed-out output is the most common reason people reach for img2img when a two-slider node would have fixed it in a millisecond.

What it is

A focused node for the two most-used adjustments in any editor. contrast and brightness are the only controls, which makes it the tidy alternative to the pack's combined NNImageAdjust when you don't need saturation or channel work cluttering the canvas.

How it works

The implementation is worth understanding because the two sliders do different kinds of math, and mixing them up is how people wreck an image:

  • brightness is additive: a constant offset is added to every pixel, so a +0.1 shifts the whole histogram right, blacks included. That's why it flattens contrast and clips highlights - adding light to an already-black pixel makes it gray, not "exposed." Use it for small global exposure nudges.
  • contrast is multiplicative around the mean: the node computes the average luminance of the image, then scales every pixel's distance from that average by 1 + contrast. Positive values push shadows darker and highlights brighter (a pop); negative values compress everything toward the average (a flat, milky look). Because it pivots on the image's own mean, it doesn't blow out the way naive pixel * factor contrast does.

Both operate on the 0–1 float tensor and the result is clamped to [0, 1], so extreme values just clip rather than producing NaN garbage.

The practical difference this makes: "my image is too dark" is almost always a contrast problem (lift shadows, keep the highlight detail) or a gamma problem - not an additive brightness problem. Crank additive brightness and you wash the whole thing. This node gives you the contrast pivot, which is the one you actually want most of the time.

The inputs

  • image - any IMAGE tensor, batches pass through untouched.
  • contrast - −0.5 to +0.5, default 0. +0.1 to +0.2 is a gentle, safe pop.
  • brightness - −0.5 to +0.5, default 0. Small values only.

Single image output, same shape as the input. When both sliders are at zero the node passes the image through untouched, so you can park it in a workflow as a permanent tuning stage.

When to reach for it

When output looks flat or dark and the fix is global and deterministic. This is exactly the "reach for the cheap primitive before the expensive generative one" case from the post-processing playbook - a contrast pivot costs nothing and can't rewrite faces, which is more than you can say for an img2img fix. It's also the right first tool when you're grading a batch of images that all came out similarly washed; the same two settings apply to every frame.

Where it doesn't apply: reference-based matching (that's NNContrastAdjustRef in the same pack, which pulls contrast statistics from a second image), or channel-specific tint fixes (that's NNImageAdjustColor). And if you need a curve rather than a linear pivot - lifting shadows without touching highlights - neither this node nor its siblings do gamma; that's a different pack's territory.

Installing

It's one node in the bandifiu/ComfyUI-NN-custom-nodes pack:

cd ComfyUI/custom_nodes
git clone https://github.com/bandifiu/ComfyUI-NN-custom-nodes

Restart ComfyUI (or install via Manager searching "NN-custom-nodes"). No models, no heavy deps - just torch, numpy, pillow, and tomli on older Python. The pack is GPL-3.0 and uses ComfyUI's newer V3 backend node API, so the source reads as io.ComfyNode subclasses with no classic registration dicts.

The subtle trap: the two sliders both max at 0.5 but feel very different in use. A 0.5 contrast is aggressive; a 0.5 brightness is catastrophic. Start at ±0.05 for brightness and ±0.1 for contrast and tune from there.

CategoryNN/image

Inputs (3)

NameTypeDefaultDescription
imageIMAGE
contrastFLOAT0.00-0.5–0.5
brightnessFLOAT0.00-0.5–0.5

Outputs (1)

NameTypeDescription
imageIMAGE