palette_quantize — GFX2D post op

データ種: rgbrgb

呼び出し: import gfx2d; gfx2d.palette_quantize(rgb, colors=None, scheme='okabe_ito') (または opsgfx2d.get("palette_quantize"))

使い方

各画素を RGB のユークリッド距離で最も近いパレット色に置き換える。

> 以下の詳細説明は原文のままです —— 要約と見出しは訳出済み。

`colors is an (K, 3) array or a list of :mod: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.

参考(サンプルデータ・文献)

• サンプルデータ カタログ(DL URL / ライセンス) — 2-D は skimage.data(BSD/public)+ 合成、3-D は実データ源(Stanford/PDS 等)の DL URL。

• 演算子の来歴・参考文献 — この op 族の元になった研究/手法の出典。

• アルゴリズムの正典(著者・年)と用途は上記ファミリ使い方ガイドに記載。

実行できる例(この op を実際に呼ぶ検証済みサンプル)

gfx2d_scenepy -3.11 examples/gfx2d_scene.py

型が繋がる次の op(rgb を入力に取れる)

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

同カテゴリ(post)

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


*Provenance: gfx2d.py — GFX2D operator registry. この per-op ノートは tools/opdocs.py md が自動生成(手編集しない)。*

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