Skip to content

bchao1/quantization

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

color-quantization

Color quantization zoo.

This is a repository for exploring various color quantization methods. Algorithm implementations are in src/, with great help from numpy.

Table of Contents

  • Otsu's Method
  • Median Cut
  • Kmeans++
  • Octree
  • Floyd-Steinberg Dithering

Otsu's method - binarization

Otsu's method is an algorithm for color binarization. See src/otsu/.

Colored Otsu's method Median threshold
img img img

Median cut - quantization

Median cut is an algorithm for color quantization of images into 2n colors. See src/median_cut/.

Original 2 color
img img
4 color 8 color
img img
16 color 32 color
img img
64 color 128 color
img img

K-means++ - quantization

K-means++ is an improved K-means algorithm with better initialization. Initializing with sparser centroids (though more computationally expensive) can lead to faster convergence. Note that this algorithm can quantize an image to arbitrary number of colors. See src/kmeans/.

Original 2 color
img img
3 color 5 color
img img
10 color 20 color
img img
50 color 100 color
img img

Octree - quantization

Octrees are trees which each node has (at most) eight children. It is an effective data structure for partitioning 3-dimensional spaces. A great post on octree implementations (in JavaScript) for color quantization can be found here.

Floyd-Steinberg Dithering

Dither is an intentionally applied form of noise used to randomize quantization error, preventing large-scale patterns such as color banding in images. See src/dithering/.

Original 64-colored Dithered
img img img

About

Color quantization zoo.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages