JuliaImages / DitherPunk.jl

Dithering algorithms in Julia.
MIT License
60 stars 3 forks source link

Refactor internals to use lower-precision fixed point numbers #100

Open adrhill opened 8 months ago

adrhill commented 8 months ago

Addresses #70.

Currently, when passed an input image of eltype Colorant{T}, the dithered output image is computed using the floating point number type T provided by the user.

Since the goal of dithering is image quantization, it would be reasonable to exclusively use quantized N0f8 fixed-point numbers from FixedPointNumbers.jl internally.

This would also enable the optional use of a look-up table of closest colors. Currently, the performance bottleneck of most dithering algorithms is a large amount of calls to colordiff from Colors.jl. For color palettes of size $n$, this function is called at least $n$ times on each pixel. For an upfront cost of $256^3 \cdot n$ calls to colordiff, a N0f8 look-up table could be computed instead. This would open up DitherPunk for dithering of live-video.