I have used K-Means Clustering algorithm, an unsupervised machine learning algorithm, to build a tool for image compression. The size of the compressed image depends on the number of clusters chosen. Decreasing the number of clusters will reduce the size of the image but will affect the quality of the image. Choose the number of clusters according to your personal requirements.
- Python
- NumPy
- scikit-learn
- scikit-image
- Download tool.py and move it to the directory containing the required images.
- Open terminal and type python tool.py image.png and run it.
- You will be asked to enter the number of clusters. Enter the desired number and run it.