Puregrain.Internal.WeightsByTone
- Package
- purescript-puregrain
- Repository
- roman-mkh/puregrain
Weights by tone: a fixed set of neighbours whose weights depend on the
pixel's tone, one table of 256 weights per neighbour. The general form
of Ostromoukhov's method (Puregrain.Internal.Ostromoukhov), so that
nothing in the diffusion core knows a method's name, and its engine
can be checked on random tables. Internal: may change without notice.
#WeightsByTone Source
newtype WeightsByToneThe neighbours, each with its column: the weight it gets for each tone, 0 to 255. One column per neighbour, not a row of weights per tone, so that the shape is fixed by construction: a tone changes how much error a neighbour gets, never which neighbours get it.
And the threshold's modulation strength by tone, 0 to 1, for a method that modulates its threshold (Zhou–Fang's): 0 everywhere for the others.
#fromRows Source
fromRows :: Array { dx :: Int, dy :: Int } -> Array (Array Number) -> Either String WeightsByToneA table by tone from its rows, as tables are printed: row i holds the weights for tone i, one per neighbour, in the neighbours' order.
Array { dx :: Int, dy :: Int }: the neighbours, under the rules ofPuregrain.Kernel.fromOffsets: each points forward, none twice.Array (Array Number): exactly 256 rows, each with one finite weight per neighbour.
Left names the first rule broken.
#withStrength Source
withStrength :: Array Number -> WeightsByTone -> Either String WeightsByToneThe table with a threshold's modulation strength by tone: Zhou and
Fang's m(i), which raises the threshold by noise × m(tone) / 255 of
the interval between the two levels around the value (the noise from 0
to 127), so below one half.
Array Number: exactly 256 strengths, one per tone, each from 0 to 1.WeightsByTone: the table.
Left names the first rule broken.
#strength Source
strength :: WeightsByTone -> Array NumberThe threshold's modulation strength by tone, as built.
#compileWeightsByTone Source
compileWeightsByTone :: forall a. MapChannels a => WeightsByTone -> CompiledKernel aThe table compiled for a pixel type: each neighbour looks its weight up in its column by the tone, channel by channel; and, where the strength isn't 0 everywhere, the threshold's raise for each pixel: the position's noise times each channel's strength, by its own tone, / 255.
- Modules
- Puregrain
- Puregrain.
Cells - Puregrain.
Dither - Puregrain.
Gamma - Puregrain.
Internal. Cells - Puregrain.
Internal. Exact - Puregrain.
Internal. Fifo - Puregrain.
Internal. Gamma - Puregrain.
Internal. Image - Puregrain.
Internal. Kernel - Puregrain.
Internal. Noise - Puregrain.
Internal. Ostromoukhov - Puregrain.
Internal. Params - Puregrain.
Internal. Quantize - Puregrain.
Internal. Row - Puregrain.
Internal. SelfCheck - Puregrain.
Internal. State - Puregrain.
Internal. Step - Puregrain.
Internal. Util - Puregrain.
Internal. WeightsByTone - Puregrain.
Internal. ZhouFang - Puregrain.
Kernel - Puregrain.
Machine. C64 - Puregrain.
Machine. ZxSpectrum - Puregrain.
Ordered - Puregrain.
Palette - Puregrain.
Palette. Presets - Puregrain.
Pixel - Puregrain.
Quantize - Puregrain.
SelfCheck