tritonize

tritonize is a Python 2.7/3.6 script which allows users to convert images to a styled, minimal representation, quickly with NumPy, even on large 12MP+ images. The script uses sigmoid thresholding to split a given image into 3 (or more) regions of distinct colors, and applies user-defined colors to the image instead; this transformation results in a style similar to that of the famous Barack Obama "Hope" poster.

You can also use transparent RGBA colors to make semitransparent images, which can be placed on top of a solid background or gradient like spring, Spectral, and inferno for even cooler effects:

The script will generate images and store them in a tritonize folder for each possible permutation of the given colors such that the user can choose the best result: for 3 colors, that is 6 images; for 4 colors, 24 images; for 5 colors, 120 images.

Usage

The tritonize script is used from the command line:

python tritonize.py -i Lenna.png -c "#1a1a1a" "#FFFFFF" "#2c3e50" -b 10
python tritonize.py -i Lenna.png -c "(0, 0, 0, 0)" "(26, 26, 26, 255)" "(255, 255, 255, 255)" -b 4 -p "spring"

See the examples folder for more examples.

Requirements

numpy, scipy, PIL/Pillow, matplotlib

Todo

Maintainer

Max Woolf (@minimaxir)

Credits

User martineau on Stack Overflow for an easy method of converting color hex strings to triplets.

License

MIT