Qu

histeq

Builtin index · Images

result = histeq(img) (alias of imequalize)

Input: img · Output: result

What it is

img is an Image of any size, color or grayscale. Global histogram equalization: builds a BT.601-luma cumulative distribution and remaps intensities to spread across the full range. RGB-preserving via luma-ratio remapping โ€” not a grayscale-only fallback.

Overloads

One call shape — this function is not overloaded.

CodeInputOutputDescription
result = histeq(img) (alias of imequalize)
img Imagenot documented yet
result Image
Returns a new Image, same dimensions as img.

Examples

From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.

m = [80, 90, 85, 95; 88, 92, 84, 91; 86, 89, 93, 87; 90, 85, 88, 92]
img = image_from_matrix(m)

eq = histeq(img)
eq2 = imequalize(img)                          # same result, other name

imshow(eq)

noisy_g = imnoise(img, "gaussian", sigma=0.05, seed=1)
noisy_sp = imnoise(img, "salt_pepper", density=0.1, seed=2)
imshow(noisy_sp)
print(eq.width, eq2.width, noisy_g.width, noisy_sp.width)
output
4 4 4 4
a synthetic field with one bright patch

from images

How it works

and synthetic noise (ยง contrast/rotation/noise pass, 2026-08-24). See image::Image's own doc comments (the "Contrast/intensity adjustment..." section, right after label_components) for the full per-function algorithm and design-decision writeups this comment block only summarizes. imequalize(img) (alias histeq) โ€” global histogram equalization: RGB-preserving via BT.601-luma CDF remapping, NOT a grayscale-only fallback (the higher-quality option this feature was asked to prefer when time allowed).

From the note above this builtin in the interpreter, where the reasoning was written down as it was built.