Skip to content

Reduce the number of colors in an image using the K-Means clustering algorithm.

Notifications You must be signed in to change notification settings

Neeraj-Ghodla/K-Color-Images

Repository files navigation

K-Color-Images

University of Auckland

ENGGEN 131 Project 1, Semester 2 2018

This Project uses the k-means clustering algorithm to find the clusters of similar pixels in the picture and then turns those clusters into a single pixel color by taking the average of the whole cluster. Hence, taking a picture with millions of colors and converting it to just a few while still retaining the original image.

This is the Original Image

1

This is the image Containing 10 Colors

2

For more information about the algorithm see: https://en.wikipedia.org/wiki/K-means_clustering

How to use

  1. Place the picture that you want to modify in the project directory.
  2. Run the ConvertImage file.
  3. Enter the name of the file (e.g. clocktower.jpg).
  4. Enter the number of colors you need in the picture (e.g. 10).
  5. Enter the upper bound for the number of iterations (e.g. 200).
  6. Voila! If convergence is met within the number of iterations then you will see the picture with k colors otherwise you will see an approximation of the image with k colors.

About

Reduce the number of colors in an image using the K-Means clustering algorithm.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages