Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/joelgrus/posterization-k-means
Posterization using k means clustering
https://github.com/joelgrus/posterization-k-means
Last synced: 13 days ago
JSON representation
Posterization using k means clustering
- Host: GitHub
- URL: https://github.com/joelgrus/posterization-k-means
- Owner: joelgrus
- License: unlicense
- Created: 2015-06-23T00:27:55.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-06-23T00:41:58.000Z (over 9 years ago)
- Last Synced: 2024-11-13T07:34:40.129Z (2 months ago)
- Language: Python
- Size: 520 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# posterization-k-means
This is the code for a workshop I ran in June 2015. In it we implement [k-means clustering](http://en.wikipedia.org/wiki/K-means_clustering) and use it to "posterize" images.
It requires [matplotlib](http://matplotlib.org/). Apparently, for some people it also requires [Pillow](https://python-pillow.github.io/) if you want it to work with jpg files, I haven't quite figured out under which circumstances that is. :O
The file [posterization.py](posterization.py) contains stubs for all the methods. The "hints" folder contains hints for writing each one, while the "solution" folder contains my solution (which, it goes without saying, is not the only one).
For instance, if you start with the bee image (from http://commons.wikimedia.org/wiki/File:Polistes_May_2013-2.jpg)
![bee](bee.jpg)
and posterize it to four colors, you get:
![bee4](bee4.png)
If instead you use eight colors, you get:
![bee8](bee8.png)
Similarly, if you start with the crayon image (from http://commons.wikimedia.org/wiki/File:Crayons-scent.png)
![crayons](crayons.png)
and posterize it to four colors, you get:
![crayons4](crayons4.png)
If instead you use eight colors, you get
![crayons8](crayons8.png)