Nodes/Eric_Image_Processing_Nodes/LB-CLAHE (Learning-Based)
ComfyUI Node

LB-CLAHE (Learning-Based)

CLAHE contrast enhancement that tunes its own settings

By EricRollei·Created 9 months ago·Updated 8 months ago· 9
LB-CLAHE (Learning-Based)
  • image
  • enhanced_image
  • processing_info
auto_tunetrue
manual_clip_limit2.0
manual_grid_sizeauto_scale

CLAHE - Contrast Limited Adaptive Histogram Equalization - is one of the oldest reliable tricks in image processing for pulling detail out of flat, low-contrast images without blowing out the rest of the frame. It's been in OpenCV forever and shows up constantly in photo restoration and medical/scientific imaging. This node's twist ("LB" for learning-based) is that it can pick its own tile size and clip limit instead of making you guess, which is the part that actually trips people up when they use CLAHE manually.

How it works

Plain histogram equalization stretches contrast across the whole image at once, which works badly whenever different regions have very different lighting - it'll blow out a bright sky to fix a dark foreground, or vice versa. CLAHE fixes this by splitting the image into a grid of tiles and equalizing each tile's histogram independently, then blending across tile boundaries so you don't get visible seams. The "contrast limited" part caps how much any tile's histogram can be stretched (the clip limit) - without that cap, flat regions with almost no variation get their tiny amount of noise amplified into visible contrast, which is CLAHE's classic failure mode. This node's auto_tune mode analyzes the image and picks the clip limit and grid size for you instead of leaving you to guess.

The inputs and outputs that matter

  • image - required.
  • auto_tune (default true) - let the node pick clip limit and grid size based on its own analysis of the image. This is the main thing you're choosing between: automatic vs. manual.
  • manual_clip_limit (optional, 0.1–10, default 2) - only used when auto_tune is off. Conservative around 1.0, balanced around 2.0, strong up near 4.0 - go higher and you risk amplifying noise in flat regions.
  • manual_grid_size (optional, default auto_scale) - also auto_tune-off only: fine_8x8 for small tiles that preserve local detail, balanced_16x16, coarse_32x32 for more global-feeling contrast enhancement, or auto_scale to size the grid based on the image's actual dimensions.
  • Outputs: enhanced_image and processing_info.

How to install it

Search Eric_Image_Processing_Nodes in ComfyUI Manager, or manually:

cd ComfyUI/custom_nodes
git clone https://github.com/EricRollei/Eric_Image_Processing_Nodes
cd Eric_Image_Processing_Nodes
pip install -r requirements.txt

Restart ComfyUI. CLAHE is a classical filter - no model weights to fetch, nothing downloads on first use. Only the pack's core requirements (numpy, opencv-python, scikit-image, scipy, PyWavelets) apply here.

Common issues & troubleshooting

Noise got amplified in flat areas (sky, shadows). That's CLAHE's textbook failure mode when the clip limit is too high for how flat/noisy that region actually is. If you're on manual settings, lower manual_clip_limit; if you're on auto_tune, it may be misjudging this particular image - try manual with a conservative clip limit instead.

Barely any visible contrast improvement. Either the clip limit is too low, or the grid is too coarse for the local contrast variation in your image. Try fine_8x8 manually if auto_scale isn't giving you enough local adaptation.

Visible tile-boundary seams. This shouldn't normally happen - CLAHE's whole design blends across tile edges - but if you're seeing hard boundaries at a grid interval, it's a sign the grid size is mismatched to the image content in an unusual way. Try auto_scale or a different manual grid size.

Not sure whether to trust auto_tune. It's a reasonable default and the right first thing to try - but if you have a specific look in mind (subtle vs. aggressive), manual mode with manual_clip_limit gives you direct control that auto-tuning can't guarantee will match your taste.

CategoryEric's Nodes/Advanced Enhancement

Inputs (4)

NameTypeDefaultDescription
imageIMAGE
auto_tuneBOOLEANtrueAutomatically tune parameters based on image analysis: • True: Use machine learning-based optimization • False: Use default parameters
manual_clip_limitoptFLOAT2.00.1–10Manual clip limit (used when auto_tune is False): • 1.0: Conservative enhancement • 2.0: Balanced enhancement • 4.0: Strong enhancement
manual_grid_sizeoptCOMBOauto_scaleManual grid size (used when auto_tune is False): • fine_8x8: Fine detail preservation (small tiles) • balanced_16x16: Balanced processing (medium tiles) • coarse_32x32: Global contrast enhancement (large tiles) • auto_scale: Automatically scale grid size based on image dimensions

Outputs (2)

NameTypeDescription
enhanced_imageIMAGE
processing_infoSTRING