Module

Puregrain.Internal.ZhouFang

Package
purescript-puregrain
Repository
roman-mkh/puregrain

Zhou and Fang's error diffusion with threshold modulation (SIGGRAPH 2003): its tables, and the table by tone built from them. Internal: may change without notice; Puregrain.Dither.zhouFang is the public value.

The tables are the authors' code's, tmed.cpp, dated 2003-04-25 (https://github.com/cczbf/TMED), which libdither uses too; they differ from the paper's Table 1 and Table 2 in three places, which measure alike (docs/weights-by-tone/zhou-fang.md).

#coefficients Source

coefficients :: Array (Array Int)

The weights as the code prints them, levels 0 to 127: right, down-left and down (Ostromoukhov's three neighbours), divided by their sum. Levels 128 to 255 are these mirrored (level i uses the row of 255 − i), as the code folds them.

#strengthPercent Source

strengthPercent :: Array Int

The threshold's modulation strength m(i), in percent, levels 0 to 127, as the code's m_lpRandomScale; mirrored like the weights.

#zhouFangWeights Source

zhouFangWeights :: Unit -> WeightsByTone

The table by tone: each row divided by its sum, the strengths by 100, both mirrored to 256. Built when called, once per run by the drivers.