This is a Python implementation of K-means algorithm for image compression. Given an input image and initial clusters, the algorithm compresses the image.
The code depends on the following Python packages:
- NumPy
- Matplotlib
Here is an example command to run the algorithm on an input image with 3 clusters:
python3 ex1.py dog.jpeg cents3.txt output.txtThe compressed image will be saved in the compressed_dog.jpeg file, the centroids for each iteration until
convergence in output.txt.
This code was written by DeanZi as part of a university programming project. Feel free to use and modify it as you like.