Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/minimaxir/tritonize
Convert images to a styled, minimal representation, quickly with NumPy
https://github.com/minimaxir/tritonize
image-processing python
Last synced: 3 months ago
JSON representation
Convert images to a styled, minimal representation, quickly with NumPy
- Host: GitHub
- URL: https://github.com/minimaxir/tritonize
- Owner: minimaxir
- License: mit
- Created: 2017-02-14T06:27:18.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-08-28T06:23:04.000Z (over 7 years ago)
- Last Synced: 2024-10-04T12:51:00.109Z (3 months ago)
- Topics: image-processing, python
- Language: Python
- Size: 5.28 MB
- Stars: 27
- Watchers: 4
- Forks: 7
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# tritonize
![](tritonize_collage.png)**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](https://en.wikipedia.org/wiki/Sigmoid_function) 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](https://en.wikipedia.org/wiki/Barack_Obama_%22Hope%22_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:
![](tritonize_collage_gradient.png)
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:
```shell
python tritonize.py -i Lenna.png -c "#1a1a1a" "#FFFFFF" "#2c3e50" -b 10
``````shell
python tritonize.py -i Lenna.png -c "(0, 0, 0, 0)" "(26, 26, 26, 255)" "(255, 255, 255, 255)" -b 4 -p "spring"
```* the `-i/--image` required parameter specifies the image file.
* the `-c/--color` required parameter specified the color, followed by quote-wrapped hexidecimal, 3-element RGB, or 4-element RGBA color representations. [NB: the last RGBA parameter is scaled from 0 to 255]
* the `-b/--blur` optional parameter controls the blur strength per megapixel (default: 4)
* the `-bg/--background` optional parameter sets the background color (only relevant if any colors are transparent)
* the `-p/--palette` optional parameter sets a horizontal gradient using a palette from the matplotlib palettes (only relevant if any colors are transparent)See the `examples` folder for more examples.
## Requirements
numpy, scipy, PIL/Pillow, matplotlib## Todo
* Add direction changing of gradient
## Maintainer
Max Woolf ([@minimaxir](http://minimaxir.com))## Credits
User martineau on Stack Overflow for [an easy method](http://stackoverflow.com/a/4296727) of converting color hex strings to triplets.## License
MIT