Skip to content

Image color-compression using manual implementation of the K-means clustering algorithm

License

Notifications You must be signed in to change notification settings

Sameer-13/Images-color-compression-using-clustering

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Images-color-compression-using-clustering

This project will be about manually implementing the K-means algorithm and using it for image compression.

  • Starting with a sample dataset that will help us gain an intuition of how the K-means algorithm works.
  • After that, we will use the K-means algorithm for image compression by reducing the number of colors that occur in an image to only those that are most common in that image.

Results Visualization:

Screenshot (289)

Getting Started:

  1. use the following command to clone the repository:

    $ git clone https://github.com/Sameer-13/Images-color-compression-using-clustering.git

  2. Download your image in the images folder then go to section 4 and type your photo name here instead of bird_small.png: original_img = plt.imread('images/bird_small.png')

Note: In Preprocessing step in 4.1, If you'll try this project later on a JPG file, you first need to divide the pixel values by 255 so it will be in the range 0 to 1. This is not necessary for PNG files (e.g. bird_small.png) because it is already loaded in the required range (as mentioned in the plt.imread() documentation). I commented a line below for this so you can just uncomment it later in case you want to try a different file.*

  1. Run the code and it will generate an color-compressed version of your image

Author:

Sameer Alsabei(Sameer-13) Github Twitter

About

Image color-compression using manual implementation of the K-means clustering algorithm

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published