Skip to content

chao11111/kmeans

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

K-means

Python Implementation Of Color Reduction Using K-Means Clustering

Example - Paris Street

Original

Paris Street

K = 3

Paris Street Reduced to 3

Original to K = 3

Paris Street original to 3

Abstract

This gets a list of RGB color tuples from a given image and treats them as 3-dim vectors. Group those vectors regarding to how far they are from one another by Euclidean measure. And assign the avarage color to each group, and apply it to the original image.

Usage

$ git clone git@github.com:honake/kmeans.git
$ # If you haven't installed pillow
$ pip3 install pillow
$ cd kmeans
$ # Put an image file in this directory
$ python3 main.py demo.jpg 5
$ # => Converting...
$ # => Almost There...
$ # => Finished !

First argument is the image's path, and second is parameter K, which denotes how many colors the image will be reduced to.

References

About

colour reduction with k-means clustering

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages