image posterization using k-means clustering
Python
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
hints
solution
README.md
UNLICENSE
bee.jpg
bee4.png
bee8.png
crayons.png
crayons4.png
crayons8.png
posterization.py
pst.png
pst4.png
pst8.png

README.md

posterization-pyladies

This is the code for a workshop (slides) I ran for the Seattle Pyladies group in May 2015. In it we implement k-means clustering and use it to "posterize" images.

It requires matplotlib. Apparently, for some people it also requires Pillow 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 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

and posterize it to four colors, you get:

bee4

If instead you use eight colors, you get:

bee8

Similarly, if you start with the crayon image (from http://commons.wikimedia.org/wiki/File:Crayons-scent.png)

crayons

and posterize it to four colors, you get:

crayons4

If instead you use eight colors, you get

crayons8