palette_quantize — GFX2D post op

• Data kinds: rgb → rgb

• Call: import fullseye as fs; fs.ledger.palette_quantize(rgb, colors=None, scheme='okabe_ito') (to call the implementation directly, import gfx2d; gfx2d.palette_quantize(rgb, colors=None, scheme='okabe_ito'); from the registry, opsgfx2d.get("palette_quantize"))

Usage

Map every pixel to its nearest palette colour in Euclidean RGB.

colors is an (K, 3) array or a list of palette role names; the default is the whole Okabe–Ito set plus black and white, so the result stays legible under a colour vision deficiency.

The search is exhaustive, so the assignment is optimal for this metric and each pixel's error equals its distance to the nearest palette entry — there is no approximation to bound. The suite checks optimality by brute force and checks that an image whose colours already lie in the palette comes back unchanged, bit for bit.

Euclidean distance in (possibly sRGB-encoded) RGB is not perceptual distance. That is a documented choice, not an oversight: a perceptual metric needs a colour-appearance model this module does not own, and quantising in an unstated space would be worse than quantising in a stated one.

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.

Runnable examples (verified samples that actually call this op)

• gfx2d_scene — py -3.11 examples/gfx2d_scene.py

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

srgb_to_linear · linear_to_srgb · blend_mode · light_mask · normal_map_decode · bloom · vignette · chromatic_aberration

Same category (post)

bloom · vignette · chromatic_aberration · film_grain · color_lut · color_grade · dither


*Provenance: gfx2d.py — GFX2D 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.