Giter Site home page Giter Site logo

gurkandemir / color-quantizer Goto Github PK

View Code? Open in Web Editor NEW
5.0 2.0 4.0 9.64 MB

Color quantization is the process of reducing number of colors used in an image while trying to maintain the visual appearance of the original image. In general, it is a form of cluster analysis, if each RGB color value is considered as a coordinate triple in the 3D colorspace.

Python 100.00%
k-means-implementation-in-python k-means-clustering color-quantization computer-vision

color-quantizer's Introduction

Color-Quantizer

Color quantization is the process of reducing number of colors used in an image while trying to maintain the visual appearance of the original image. In gen- eral, it is a form of cluster analysis, if each RGB color value is considered as a coordinate triple in the 3D colorspace

K-Means Algorithm

  1. Convert input image to a matrix of pixels.
  2. Pick K initial colors to begin quantization by clicking on the image or randomly.
  3. Implement K-Means Algoritm. Repeat followings 10 times.
    • Assign each pixel to closest clusters by comparing their R, G, B values.
    • Find clusters' new R, G, B values by getting means of assigned pixels' values.

How to Run?

In order to run color quantizer, execute the following from the command line:

python3 colorQuantizer.py [IMG] [K] [TYPE]

WHERE

  1. IMG : Path of image want to be quantized.

  2. K : Number of colors in an image we want to quantize.

  3. TYPE : Type of selecting cluster centers.

    • 1 for choosing cluster centers by clicking on photo.
    • 2 for choosing cluster centers randomly.

    For example, if you want to quantize cat.png into 8 colors, by choosing random cluster centers. You have to execute following command: \textbf{python3 colorQuantizer.py cat.png 8 2 }

python3 colorQuantizer.py cat.png 8 2

color-quantizer's People

Contributors

gurkandemir avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.