Skip to content

A small program written in C showing implementations of common image dithering algorithms.

License

Notifications You must be signed in to change notification settings

jonmortiboy/dither

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

dither.exe

A small program written in C demonstrating implementations of common image dithering algorithms such as Floyd-Steinberg, error-diffuse dithering and ordered dithering. The program takes an image file and optionally a text file containing a list of hex codes to use as a colour palette.

The code is in dither.c. Methods prefixed with render (render_monochrome_1D_errordiffuse, render_monochrome_floydstein, render_monochrome_ordered4x4 etc.) contain the implementations of the different algorithms for reference. The final quantised colour for each pixel is determined by the shortest euclidean distance between colours: sqrt(Δr + Δg + Δb)

usage

Dither.exe runs in the Windows command prompt (or under any terminal emulator on Windows):

dither.exe imagefile.png palette.txt
./dither imagefile.png palette.txt (unix/bash terminal emulators)

imagefile.png - A png image (also supports jpeg)
palette.txt - A text file with hex colour codes arranged on separate lines (see included files for examples)

Move back and forth between the different dithering algorithms using the < arrow keys >.

compilation

A windows build of the program is included with the required DLLs. The program requires SDL2 and SDL2_Image which must be downloaded if you wish to compile the code for a different OS.

About

A small program written in C showing implementations of common image dithering algorithms.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages