Skip to content

joelgrus/posterization-k-means

Repository files navigation

posterization-k-means

This is the code for a workshop I ran in June 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

About

Posterization using k means clustering

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages