post op• 資料種類:image2d → image2d
• 呼叫:import gfx2d; gfx2d.dither(img, levels=2, method='ordered', matrix_size=4)(或 opsgfx2d.get("dither"))
在保持局部平均的前提下,把每通道量化到 `levels` 個取值。
> 以下的詳細說明為原文 —— 摘要與標題已翻譯。
`method`:
• `"ordered" — Bayer threshold matrix of side matrix_size` (a power of
two, 2..16). The mean error has a closed-form bound: for a uniform
patch the output mean is within `0.5 / (matrix_size**2 * (levels-1))` of
the input, because the fraction of thresholds crossed is the input
fraction rounded to the nearest `1/matrix_size**2`. At the defaults
(4, 2 levels) the bound is 0.03125; the suite checks it holds for 101 grey
levels x 3 matrix sizes, with zero violations.
• `"floyd_steinberg"` — error diffusion with the 7/3/5/1 sixteenths of
Floyd & Steinberg 1976, serial and directional.
Which method preserves the mean better depends on the image, and this
docstring will not pretend otherwise. Measured on a 128-step horizontal
ramp: ordered is exact (0.0) at 2, 3 and 4 levels and drifts to 1.1e-3
at 8 levels, while Floyd-Steinberg is 7.3e-4 at 2 levels and improves to
4.1e-5 at 16. Ordered wins where the level lattice divides the ramp, error
diffusion wins where it does not.
Accepts `(H, W) or (H, W, 3|4)`; an alpha channel is quantised too,
because a dithered sprite with a smooth alpha is exactly the case that
motivates this.
Output values lie on the lattice `k / (levels - 1)`.
• 範例資料目錄(下載 URL / 授權) —— 2-D 用 skimage.data(BSD/公有領域)加合成圖,3-D 給出真實資料源(Stanford/PDS 等)的下載 URL。
• 運算子來歷與參考文獻 —— 該運算子族所依據的研究/方法出處。
• 演算法的正典(作者・年份)與用途見上面的族使用指南。
• gfx2d_scene — py -3.11 examples/gfx2d_scene.py
image2d 作為輸入)post)bloom · vignette · chromatic_aberration · film_grain · color_lut · color_grade · palette_quantize
*Provenance: gfx2d.py — GFX2D 運算子登記表。本條目由 tools/opdocs.py md 自動產生(請勿手動編輯)。*
© 2026 Kazufumi Furuse — Fullseye operator documentation. Licensed under Apache-2.0.