Nodes/ComfyUI-TeaNodes/EqualizeCLAHE
ComfyUI Node

EqualizeCLAHE

Give your ControlNet preprocessors a fair fight

By TeaCrab·Created 3 years ago·Updated 5 months ago· 5
EqualizeCLAHE
  • image
  • size
  • IMAGE
clip_limit64.0
grid_size8

ControlNet preprocessors - Canny, depth, lineart - are glorified edge and structure detectors, and they're only as good as the contrast they're given. A flat, evenly-lit image produces weak, broken maps. EqualizeCLAHE fixes that by running contrast-limited adaptive histogram equalization on your image first, so the preprocessor sees a histogram that's actually spread out instead of bunched up in the midtones.

That's the whole pitch, and it's from the author's own README: when the histogram is smoothly distributed, ControlNet preprocessors have an easier time, and it works especially well after you've removed the background. It's one node in the small ComfyUI-TeaNodes pack by TeaCrab (MIT, in the TeaNodes/Image menu).

What CLAHE actually does

Plain histogram equalization can blow out an image that has one very bright region and one very dark one. CLAHE splits the image into a grid of tiles, equalizes each tile's histogram independently, and then clamps how much contrast each tile is allowed to add (the clip limit) - so local contrast goes up without noise getting amplified into static. The "adaptive" part is why it rescues shadow detail on an unevenly lit photo, which is exactly the case that defeats a global brightness slider.

It's implemented on top of kornia.enhance.equalize_clahe, which runs on your GPU tensor in the same step as the rest of the graph - no CPU round-trip, no PIL detour.

The inputs that matter

  • image - what you're flattening.
  • clip_limit - how much contrast each tile may add. Default 64, range 0–255. Higher = punchier but noisier.
  • grid_size - the number of tiles per side. Default 8, range 1–64. More tiles = more local adaptation, but also more potential for halos around edges.
  • size - a TUPLE (default 1024×1024). This one's subtle: leave it alone and it's a no-op, but if you wire it to something else, the node rescales clip_limit and grid_size so the effect stays consistent on larger inputs. It's a "signal my image is big, not a target resolution" input.

Output is the equalized IMAGE, which you usually run straight into a ControlNet preprocessor.

Where it bites

CLAHE amplifies grain. On a clean generated image it's great; on a noisy phone photo it can bring up sensor noise into the edges map. If your Canny map starts looking like a glitter bomb, back the clip_limit off toward 10–20. You'll also see the usual local-contrast halo around strong edges at high grid_size.

Installing it

From ComfyUI Manager, search ComfyUI-TeaNodes, or:

cd ComfyUI/custom_nodes
git clone https://github.com/TeaCrab/ComfyUI-TeaNodes

restart, done. No model files. kornia is already in ComfyUI core, which is the only reason a pack this small can ship CLAHE in ~40 lines - the pack's own requirements only adds the author's regex_spm helper.

If your ControlNet results feel mushy on flat backgrounds, try this before you swap preprocessors. It's the cheapest improvement you'll make all day.

CategoryTeaNodes/Image

Inputs (4)

NameTypeDefaultDescription
imageIMAGE
sizeTUPLE1024,1024
clip_limitFLOAT64.00–255
grid_sizeINT81–64

Outputs (1)

NameTypeDescription
IMAGEIMAGE