Skip to content

poco-loco-athul/Color-quantization

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Introduction

Color quantization is a process of reducing the number of distinct colors used in an image. The most common techniques reduce the problem of color quantization into a clustering problem of points where each point represents the color of a pixel. This clustering can be performed through the k-means algorithm.

Background

This project is break downed to 4 main parts as follows:

  • Extract pixel values for a given image.
  • Get color palette using k-means in pixel values.
  • Create a small image of the palette.
  • Create a compressed image using the palette.

Read more about the project in the blog.

Usage

Requires python3.x

usage: color_palette.py [-h] [-i [imagepath]] [-n [N_COLORS]]

Quantizes colors in image. Produces a modified image using these colors.

positional arguments:
  imagepath             file-path of image

optional arguments:
  -h, --help            show this help message and exit
  -n [N_COLORS], --n_colors [N_COLORS]
                        Number of colors to be quantized (default: 5)
                        (warning: choose number carefully. It may take while
                        to run the program.)

Requirements

Check `requirements.txt` for dependencies

  • install them with `pip install -r requirements.txt`
  • to add more dependencies, use pip and: `pip freeze > requirements.txt`

About

Color quantization using K-means

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages