Color Levels (MD)
Levels, the histogram tool that fixes more than you'd think
- image
- mask
- image
Levels is the most powerful single node in this pack, and also the one with the most intimidating input list. mdColorLevels is GIMP's Levels tool - the histogram-based remap - with per-channel control, gamma, clamping, and an auto option. Learn it once and it quietly replaces half of your other color nodes.
What levels actually does
A levels adjustment maps an input range to an output range using three things: an input low/high (which pixels count as "black" and "white"), a gamma (the midtone curve between them), and an output low/high (what those extremes map to). Underneath it's a per-pixel transfer function - fully deterministic, instant, no model. The classic move: an image whose histogram doesn't touch the edges (all tones in the middle) is "flat." Set input low/high to the histogram's real edges and the image instantly gains contrast - that's the manual version of the auto-stretch node in this pack, with far more control.
The inputs that matter
Most of the list is one concept applied in two places:
- Channel - Value (luminance, the default and the one you'll use 90% of the time), or Red/Green/Blue for per-channel work, or Alpha if you want to adjust transparency.
- Input_low / Input_high (0-255) - the "black point" and "white point." Dragging Input_low up crushes shadows; dragging Input_high down compresses highlights.
- Input_gamma (0.1-10) - the midtone curve. Above 1 lifts midtones, below 1 darkens them. This is the "brighten without blowing highlights" control.
- Auto_input - computes Input_low/high from the image's actual histogram. The lazy correct way to start; then refine by hand.
- Output_low / Output_high, Interpolation (Linear / Non-Linear / Perceptual), and the two clamp toggles are the fine print - leave them at defaults until you have a specific reason.
- image in, image out, optional mask.
How it beats the alternatives
Where brightness/contrast is a blunt offset+pivot, levels gives you exact control over which tones move. Crush shadows with Input_low, lift midtones with gamma, and your highlights barely move. It's also the correct tool for the "histogram is clipped" problem - the washed-out render where everything lives between 0.3 and 0.7. Our post-processing notes list gamma and sigmoid as the fixes for "flat," and levels is the multi-purpose form of exactly that. Per-channel levels (Channel → Red) is how you fix a color cast by hand when auto white balance overshoots.
Installing
Standard:
cd ComfyUI/custom_nodes
git clone https://github.com/MdONeilsl/ComfyUI-MdColorMod
or ComfyUI Manager → "MdColorMod", restart. Empty requirements.txt, pure torch, no downloads, GPL-3.0. New pack with a thin footprint - the manual clone always works if Manager can't see it.
Inputs (12)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | Input image tensor. | |
| Channel | COMBO | Value | Which channel to apply the levels adjustment. |
| Interpolation | COMBO | Non-Linear | Type of interpolation for the level mapping. |
| Input_low | FLOAT | 00–255 | Lower bound for input levels (0-255). |
| Input_high | FLOAT | 2550–255 | Upper bound for input levels (0-255). |
| Input_gamma | FLOAT | 1.000.1–10 | Gamma correction applied to the input range. |
| Input_clamp | BOOLEAN | false | Clamp input values to the specified range before mapping. |
| Output_low | FLOAT | 00–255 | Lower bound for output levels (0-255). |
| Output_high | FLOAT | 2550–255 | Upper bound for output levels (0-255). |
| Output_clamp | BOOLEAN | false | Clamp output values to the specified range after mapping. |
| Auto_input | BOOLEAN | false | Automatically determine input low/high from image content. |
| maskopt | MASK | Optional mask to restrict the adjustment area. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | The levels-adjusted image. |