This project implements an image compression technique using the K-means clustering algorithm. It reduces the number of distinct colors in an image, thereby compressing the image size while maintaining visual fidelity.
Image compression is a common technique used to reduce the file size of images while preserving quality. In this project, we utilize the K-means clustering algorithm to group pixels in the image based on their colors, allowing us to reduce the total number of colors in the image and thereby compressing it.
- Reduces image size by clustering similar colors.
- Maintains quality with adjustable number of clusters.
- Supports multiple image formats (JPEG, PNG, etc.).
- Easy-to-use command line interface or GUI (if applicable).
- Python 3.x
- NumPy
- Matplotlib (for visualization, if applicable)
- scikit-learn (for K-means algorithm)
-
Clone the repository:
git clone https://github.com/yourusername/image-compression-kmeans.git cd image-compression-kmeans -
Install the required packages:
pip install -r requirements.txt
To use the image compression tool, run the script from the command line with the following syntax:
pip install -r requirements.txt
input image:
output (using 32 clusters):
output (using 16 clusters):
output (using 8 clusters):
output (using 4 clusters):
- K-Means Clustering for the algorithm documentation.
- Libraries like NumPy, OpenCV, and scikit-learn for their essential functionalities.
If you would like to contribute to this project, please follow these steps:
- Fork the repository.
- Create a new branch (git checkout -b feature-branch).
- Make your changes.
- Commit your changes (git commit -m 'Add new feature').
- Push to the branch (git push origin feature-branch).
- Create a new Pull Request.
This project is licensed under the MIT License




