dither — GFX2D post op

• Data kinds: image2d → image2d

• Call: import fullseye as fs; fs.ledger.dither(img, levels=2, method='ordered', matrix_size=4) (implementation को सीधे call करना हो तो import gfx2d; gfx2d.dither(img, levels=2, method='ordered', matrix_size=4), registry से लेना हो तो opsgfx2d.get("dither"))

उपयोग

local mean बनाए रखते हुए हर channel को levels मानों में quantise करता है।

> नीचे का विस्तृत विवरण मूल text में है — सारांश और headings का अनुवाद हो चुका है।

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).

संदर्भ (sample data, साहित्य)

• Sample data catalog (DL URL / license) — 2-D के लिए skimage.data (BSD/public) + synthetic, 3-D के लिए real data sources (Stanford/PDS आदि) के DL URL।

• Operators का स्रोत और संदर्भ — इस op family के मूल research/methods के स्रोत।

• Algorithm का मानक स्रोत (लेखक, वर्ष) और उपयोग ऊपर की family usage guide में दिए गए हैं।

चलाए जा सकने वाले उदाहरण (verified samples जो सच में यह op call करते हैं)

• gfx2d_scene — py -3.11 examples/gfx2d_scene.py

वे अगले ops जिनसे type जुड़ता है (image2d को input के रूप में लेते हैं)

shadow_cast_2d · raw_black_level · raw_dead_pixel_mask · raw_dead_pixel_correct · lens_shading_gain · lens_shading_correct · raw_apply_gains · raw_demosaic_bilinear

इसी category के (post)

bloom · vignette · chromatic_aberration · film_grain · color_lut · color_grade · palette_quantize


*Provenance: gfx2d.py — GFX2D operator registry. यह per-op note tools/opdocs.py md से अपने-आप generate होता है (हाथ से edit न करें)।*

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