https://github.com/alexander-lee/k-means-image-compression
Using K-means Clustering for Image Compression
https://github.com/alexander-lee/k-means-image-compression
clustering k-means-clustering k-means-implementation-in-python machine-learning unsupervised-learning
Last synced: 3 months ago
JSON representation
Using K-means Clustering for Image Compression
- Host: GitHub
- URL: https://github.com/alexander-lee/k-means-image-compression
- Owner: alexander-lee
- License: apache-2.0
- Created: 2018-11-08T07:42:59.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-11-08T16:42:05.000Z (over 6 years ago)
- Last Synced: 2025-03-18T11:05:20.875Z (3 months ago)
- Topics: clustering, k-means-clustering, k-means-implementation-in-python, machine-learning, unsupervised-learning
- Language: Python
- Size: 346 KB
- Stars: 9
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Image Compression via K-means Clustering (Color Quantization)
## Overview
This uses the Lloyd's K-means Clustering algorithm with RGB tuples in order to find the `k` colors that best represent the input image. The K-means Clustering algorithm was implemented by me for a better understanding of how the algorithm worked. In addition, this program also produces scatter plots of the colors to better visualize the clusters.## Running the Program
**NOTE:** Assuming you are using Python 3.x```sh
python image_k_means.py [-k ] [--iterations ] [--save-scatter]
```* `-k` is the number of clusters you want to find
* `--iterations` is the number of iterations you want to run Lloyd's Algorithm
* `--save-scatter` is a flag to choose to save a Scatter Plot of the data **(WARNING: Very slow)**## Results
| **Input Image** | **5-means Clustering (with 20 iterations)** |
| :---: | :---: |
|||
| **10-means Clustering (with 20 iterations** | **20-means Clustering (with 20 iterations)** |
|||| **Input Scatter Plot by Color** | **20-means Clustering Scatter Plot by Color** |
| :---: | :---: |
|  |  |