Documentation ¶
Overview ¶
Quant provides an interface for image color quantizers.
Index ¶
- Constants
- func Paletted(p Palette, img image.Image) *image.Paletted
- type LinearPalette
- type Node
- type Palette
- type Quantizer
- type Sierra24A
- type TreePalette
- func (t TreePalette) ColorNear(c color.Color) (p color.Color)
- func (t TreePalette) ColorPalette() color.Palette
- func (t TreePalette) IndexNear(c color.Color) (i int)
- func (p TreePalette) Len() int
- func (t TreePalette) Search(c color.Color, f func(leaf *Node))
- func (t TreePalette) Walk(f func(leaf *Node, i int))
Constants ¶
const ( TLeaf = iota TSplitR TSplitG TSplitB )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type LinearPalette ¶
LinearPalette implements the Palette interface with color.Palette and has no optimizations.
func (LinearPalette) ColorNear ¶
func (p LinearPalette) ColorNear(c color.Color) color.Color
Color near returns the nearest palette color.
It simply wraps color.Palette.Convert.
func (LinearPalette) ColorPalette ¶
func (p LinearPalette) ColorPalette() color.Palette
ColorPalette satisfies interface Palette.
It simply returns the internal color.Palette.
func (LinearPalette) IndexNear ¶
func (p LinearPalette) IndexNear(c color.Color) int
IndexNear returns the palette index of the nearest palette color.
It simply wraps color.Palette.Index.
func (LinearPalette) Len ¶
func (p LinearPalette) Len() int
type Node ¶
type Node struct { Type int // for TLeaf Index int Color color.RGBA64 // for TSplit Split uint32 Low, High *Node }
Node is a TreePalette node. It is exported for access by quantizer packages and otherwise can be ignored for typical use of this package.
type Palette ¶
type Palette interface { Len() int IndexNear(color.Color) int ColorNear(color.Color) color.Color ColorPalette() color.Palette }
Palette is a palette of color.Colors, much like color.Palette of the standard library.
It is defined as an interface here to allow more general implementations, presumably ones that maintain some data structure to achieve performance advantages over linear search.
type Quantizer ¶
type Quantizer interface { // Paletted quantizes an image and returns a paletted image. Paletted(image.Image) *image.Paletted // Palette quantizes an image and returns a Palette. Note the return // type is the Palette interface of this package and not image.Palette. Palette(image.Image) Palette }
Quantizer defines a color quantizer for images.
type TreePalette ¶
TreePalette implements the Palette interface with a binary tree.
XNear methods run in O(log n) time for palette size.
Fields are exported for access by quantizer packages. Typical use of TreePalette should be through methods.
func (TreePalette) ColorNear ¶
func (t TreePalette) ColorNear(c color.Color) (p color.Color)
ColorNear returns the nearest palette color.
func (TreePalette) ColorPalette ¶
func (t TreePalette) ColorPalette() color.Palette
ColorPalette returns a color.Palette corresponding to the TreePalette.
func (TreePalette) IndexNear ¶
func (t TreePalette) IndexNear(c color.Color) (i int)
IndexNear returns the index of the nearest palette color.
func (TreePalette) Len ¶
func (p TreePalette) Len() int
func (TreePalette) Search ¶
func (t TreePalette) Search(c color.Color, f func(leaf *Node))
Search searches for the given color and calls f for the node representing the nearest color.
func (TreePalette) Walk ¶
func (t TreePalette) Walk(f func(leaf *Node, i int))
Walk walks the TreePalette calling f for each color.