clahe — 2D gray op

• Data kinds: image → image

• Call: fullseye.apply(img, "clahe", a=0.5, b=0.5) (the 2-D model is one image plus two scalar knobs a,b∈[0,1])

clahe: input → output

*The figure is the actual output on a synthetic 128×128 input. Left: input, right: output. Point clouds are drawn as a top-down scatter (brightness = z), 1-D series as a line plot, volumes as the maximum-intensity projection along z, videos as the middle frame, complex images as magnitude; return values that are not pictures are shown as the values themselves.*

Sweeping knob a (0.1 / 0.5 / 0.9, the other knob at its default):

▸ clahe: knob a sweep (docs site)

Sweeping knob b (0.1 / 0.5 / 0.9, the other knob at its default):

▸ clahe: knob b sweep (docs site)

On other images (synthetic scene / photo / coins. Top row: inputs, bottom row: their outputs. Knobs at default):

▸ clahe: other inputs (docs site)

*The 4th column is a colour (H,W,3) input. This op handles colour without crossing channels (it does not convolve the colour channel as a third spatial axis).*

Usage

Contrast-Limited Adaptive Histogram Equalization (tiled, bilinearly blended).

• a — number of tiles nb = 2 + int(3a) (the image is split into nb×nb)

• b — clip limit. Given as the factor 256**b relative to the mean count per bin (b=0 → 1 times = a completely flattened histogram = a straight tone map = zero enhancement; b=1 → 256 times = the maximum 1 bin can take, so clipping has no effect = plain AHE; b=0.5 → 16 times. OpenCV's default clipLimit=40 is roughly b=0.665).

★2026-09-02 (this fix): until then b was completely dead (measured:

max|clahe(x,0.5,0.0) - clahe(x,0.5,1.0)| == 0.0 exactly). The "C" in CLAHE is the C of contrast limited, and the clip limit is precisely what separates AHE from CLAHE, so the implementation was AHE, not CLAHE — the name was lying. Here the clip limit was implemented and assigned to b, and the factor was chosen so that b=1 is the end that is bit-identical to the old implementation (the upper limit at which no clipping occurs = 256 times, the number of bins).

Tiles PARTITION the image (linspace boundaries, so the last tile absorbs the H % nb / W % nb remainder), each tile's clip-limited CDF is its local tone map, and every pixel blends the maps of its (up to) 4 nearest tile centres with bilinear weights — the standard CLAHE interpolation (Zuiderveld 1994).

2026-08-30: interpolation added (KNOWN_ISSUES #4 — the old implementation flattened each tile independently, which produced discontinuities at tile boundaries (a grid visible to the naked eye)). In the neighbourhood of a tile centre that tile's CDF still dominates as is, so this is a continuous version of the same family of mappings as the old implementation.

Detailed usage guide

• gallery2d_gray_arith family guide

References (sample data, literature)

• Sample-data catalog (download URLs / licences) — 2-D uses skimage.data (BSD/public domain) plus synthetic images; 3-D lists download URLs for real data sources (Stanford, PDS, …).

• Operator provenance and references — the sources of the research/methods this op family came from.

• The canonical algorithm (author, year) and its uses are named in the family usage guide above.

Try it in Studio

The program below has been verified to run (same input as the figure). In Studio's help this block becomes buttons that load and run it on the spot.

clahe 0.50 0.50

▸ Load this pipeline  ·  Load & run

Runnable examples (verified samples that actually call this op)

• gallery2d_gray_arith — py -3.11 examples/gallery2d_gray_arith.py

• poc_dehazing — py -3.11 examples/poc_dehazing.py

Ops the type connects to (they accept image as input)

identity · gaussian · mean_box · bilateral · unsharp · median · min_filter · max_filter

Same category (gray)

gamma · quantize_uniform · quantize_lloyd_max · quantization_error · dither_ordered · dither_floyd_steinberg · companding_mu_law · banding_map


*Provenance: ops.py — 2D operator registry. This per-op note is generated by tools/opdocs.py md (do not hand-edit).*

© 2026 Kazufumi Furuse — Fullseye operator documentation. Licensed under Apache-2.0.