Apply CLAHE
Boost Flat Contrast, Then Fix the Colors It Mangles
- image
- IMAGE
Hazy, flat, low-contrast source image? CLAHE is the classic fix: it's adaptive histogram equalization that brightens local contrast without blowing out the whole frame the way global equalization does. This node applies it to your image in one shot, and it does exactly what it says. It also has a color bug baked in, and you should know about it before you spend an hour chasing ghost colors.
It's part of ComfyUI-off-suite, Off-Live's small personal utility pack. The pack is unmaintained-looking (quiet since mid-2024) and this node is a poster child for "works, but read the fine print."
What you plug in
- image - the IMAGE to enhance.
- clip_limit - the contrast cap for CLAHE, default
1.2. Higher = more aggressive contrast. For mild fixing, stay near 1–2; pushing past ~3 starts to look crunchy. - grid_size - the tile size for the adaptive part, default
8. Smaller tiles = more local adaptation (and more risk of over-sharpening noise); bigger tiles behave closer to plain equalization.
Output is a single IMAGE. Mechanically it converts each frame to LAB color space, applies CLAHE only to the L (lightness) channel - which is the right idea, since you want contrast, not hue changes - then merges back.
The color bug, confirmed in the source
Here's where it gets honest. The code calls cv2.cvtColor(source, cv2.COLOR_BGR2LAB) and back with COLOR_LAB2BGR - but the tensor it's feeding in is RGB (that's what ComfyUI hands you). It treats your RGB data as if it were BGR, so the channels get scrambled. I tested a pure-red pixel through the exact code path: it comes out magenta, with blue where red should be. The L-channel CLAHE itself is fine; the color mapping around it is wrong.
Practical upshot: apply it, and expect reds and blues to shift. If you're CLAHE-ing a face for a detail pass, skin tones may take on an odd cast. The fix is cheap - drop a channel-swap or a color-correction node after it - but it's the kind of thing that will drive you mad if you don't know it's coming. For grayscale or near-monochrome input, this node is effectively fine, because there's little R/B difference to swap.
When it's worth reaching for
Low-light phone shots, scanned documents feeding an OCR/img2img step, or any flat, hazy source where you want the model to see texture the histogram is currently hiding. It's a preprocessing node: put it between your image load and your sampler or ControlNet preprocessor, and it earns its keep. For already-punchy images, skip it - CLAHE on a good image just makes it worse.
Install
cd ComfyUI/custom_nodes
git clone https://github.com/Off-Live/ComfyUI-off-suite
# or: ComfyUI Manager → search "ComfyUI-off-suite"
No extra dependencies - OpenCV is bundled with ComfyUI. If you run it and the output looks color-shifted, that's not you doing something wrong; it's the node. Add the channel correction and move on.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| clip_limit | FLOAT | 1.20 | — |
| grid_size | INT | 8 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |