Puregrain.Kernel
- Package
- purescript-puregrain
- Repository
- roman-mkh/puregrain
Error-diffusion kernels: where each pixel's quantization error goes, and in what shares.
Use a ready-made kernel, or build your own from a list of offsets
with fromOffsets, which checks it. The ready-made ones:
floydSteinberg, atkinson, jarvisJudiceNinke, stucki, burkes,
the Sierras sierra3, sierra2 and sierraLite, fan, shiauFan
and shiauFan2; noDiffusion for none. Each one's table, its source
and what it suits:
docs/error-diffusion.md.
#fromOffsets Source
fromOffsets :: Array Offset -> Either String KernelChecks a list of offsets and makes it a kernel.
Array Offset: the neighbours and their shares.
Left says which offset breaks which rule (offsets counted from 0):
- every offset must point to a pixel not yet processed, in row-by-row
scan order: a later row (
dy > 0), or the same row further right (dy == 0,dx > 0); - every weight must be a finite number (not NaN or infinite);
- no two offsets may point to the same neighbour.
The weights usually add up to 1, but needn't: Atkinson's add up to
3/4 on purpose. An empty list is valid: it's noDiffusion.
-- half of the error to the right, half down
fromOffsets [ { dx: 1, dy: 0, weight: 0.5 }, { dx: 0, dy: 1, weight: 0.5 } ]
#floydSteinberg Source
floydSteinberg :: KernelFloyd–Steinberg (1976): 4 neighbours, the classic.
#jarvisJudiceNinke Source
jarvisJudiceNinke :: KernelJarvis–Judice–Ninke (1976): 12 neighbours over the next 2 rows, for the smoothest texture, at about 2.5 times Floyd–Steinberg's cost.
#sierraLite Source
sierraLite :: KernelSierra Lite (Frankie Sierra, 1989–1990; also "Filter Lite" or "Sierra-2-4A"): 3 neighbours, one fewer than Floyd–Steinberg, for similar results.
#noDiffusion Source
noDiffusion :: KernelNo neighbours: no error is passed on, so each pixel is quantized on
its own. With Puregrain.Ordered, that's pure ordered dithering;
with threshold or nearestLevel, plain rounding to a level.
- Modules
- Puregrain
- Puregrain.
Cells - Puregrain.
Dither - Puregrain.
Internal. Fifo - Puregrain.
Internal. Image - Puregrain.
Internal. Kernel - Puregrain.
Internal. Row - Puregrain.
Internal. State - Puregrain.
Internal. Step - Puregrain.
Internal. Util - Puregrain.
Kernel - Puregrain.
Machine. C64 - Puregrain.
Machine. ZxSpectrum - Puregrain.
Ordered - Puregrain.
Palette - Puregrain.
Palette. Presets - Puregrain.
Pixel - Puregrain.
Quantize