color_thief

package module
v0.0.0-...-c1bf65e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 22, 2023 License: MIT Imports: 8 Imported by: 1

README

color-thief

A high performance Golang module for grabbing color palettes from images. Instead of implementing conventional Modified Median Color Quantization (MMCQ), it implements Xiaolin Wu's Color Quantizer[1] as well as Weighted Sort-Means + Wu algorithm[2]. They both yield much better color quantization result from the evaluation.[2].

performance:
Wu's Color Quantizer
goos: darwin
goarch: amd64
pkg: color-thief/wu
cpu: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
BenchmarkQuantWu
BenchmarkQuantWu-12    	    1315	    914729 ns/op
PASS
WSM-WU Color Quantizer
goos: darwin
goarch: amd64
pkg: color-thief/wsm
cpu: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
BenchmarkWSM
BenchmarkWSM-12    	     244	   4648723 ns/op
PASS

Reference

  • [1] X. Wu, Graphics Gems Volume II, Academic Press, 1991, Ch. Efficient Statistical Computations for Optimal Color Quantization, pp. 126–133.
  • [2] Celebi, M. Emre (2011). Improving the performance of k-means for color quantization. Image and Vision Computing 29, 260–271.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetColor

func GetColor(img image.Image, numColors, functionType int) (color.Color, error)

GetColor return the base color from the image

func GetColorFromFile

func GetColorFromFile(imgPath string) (color.Color, error)

GetColorFromFile return the base color from the image file

func GetPalette

func GetPalette(img image.Image, numColors, functionType int) ([]color.Color, error)

GetPalette return cluster similar colors by the median cut algorithm

func GetPaletteFromFile

func GetPaletteFromFile(imgPath string, numColors, functionType int) ([]color.Color, error)

GetPaletteFromFile return cluster similar colors from the image file

func PrintColor

func PrintColor(colors []color.Color, filename string) error

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL