Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kiran-kumar-k3/image-color-compression-using-k-means
A Python tool that compresses images using K-Means, shows both the original and compressed images, and lets you save the compressed version while displaying file sizes.
https://github.com/kiran-kumar-k3/image-color-compression-using-k-means
images matplotlib numpy pillow python scikit-learn
Last synced: about 3 hours ago
JSON representation
A Python tool that compresses images using K-Means, shows both the original and compressed images, and lets you save the compressed version while displaying file sizes.
- Host: GitHub
- URL: https://github.com/kiran-kumar-k3/image-color-compression-using-k-means
- Owner: KIRAN-KUMAR-K3
- License: mit
- Created: 2024-07-17T20:52:01.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2024-08-04T08:34:01.000Z (5 months ago)
- Last Synced: 2024-11-12T10:20:45.943Z (2 months ago)
- Topics: images, matplotlib, numpy, pillow, python, scikit-learn
- Language: Python
- Homepage:
- Size: 2.05 MB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Image Color Compression using K-Means
This project demonstrates color compression of images using the K-Means clustering algorithm. The main script `main.py` allows you to select an image file, specify the number of colors for compression, and saves the compressed image to an `outputs` directory.
## Features
- **Image Input:** Supports PNG, JPG, JPEG, BMP, and GIF images.
- **Color Compression:** Utilizes K-Means clustering to reduce the number of distinct colors.
- **File Size Information:** Displays original and compressed image file sizes.
- **Output:** Saves the compressed image to an `outputs` directory and displays both the original and compressed images side by side.## Requirements
- Python 3.x
- Pillow (PIL)
- NumPy
- Matplotlib
- scikit-learn## Installation
1. Clone the repository:
```bash
git clone https://github.com/KIRAN-KUMAR-K3/Image-Color-Compression-using-K-Means.git
cd Image-Color-Compression-using-K-Means
```2. Install dependencies:
```bash
pip install -r requirements.txt
```## Usage
1. Ensure you have images in the `images` directory.
2. Run `main.py`:
```bash
python main.py
```
3. Follow the prompts to:
- Enter the path to the image file.
- Specify the number of colors for compression.
- Save the compressed image to the `outputs` directory.
4. View the original and compressed images, as well as their file sizes.## Example
![Original and Compressed Image](images/comparision.png)
## License
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.