quant

package
v0.0.0-...-92869c5 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2015 License: MIT, Apache-2.0 Imports: 4 Imported by: 0

README

Quant

Experiments with color quantizers

Implemented here are two rather simple quantizers and an (also simple) ditherer. The quantizers satisfy the draw.Quantizer interface of the standard library. The ditherer satisfies the draw.Drawer interface of the standard library.

Documentation

Overview

Quant provides an interface for image color quantizers.

Quant provides an interface for image color quantizers.

Quant provides an interface for image color quantizers.

Index

Constants

View Source
const (
	TLeaf = iota
	TSplitR
	TSplitG
	TSplitB
)

Variables

This section is empty.

Functions

This section is empty.

Types

type LinearPalette

type LinearPalette struct {
	// Convert method of Palette satisfied by method of color.Palette.
	color.Palette
}

LinearPalette implements the Palette interface with color.Palette and has no optimizations.

func (LinearPalette) ColorNear

func (p LinearPalette) ColorNear(c color.Color) color.Color

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

type Palette

type Palette interface {
	IndexNear(color.Color) int
	ColorNear(color.Color) color.Color
	ColorPalette() color.Palette
}

Palette is a palette of color.Colors, much like color.Pallete 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 {
	// Image quantizes an image and returns a paletted image.
	Image(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 Sierra24A

type Sierra24A struct{}

Sierra24A satisfies draw.Drawer

func (Sierra24A) Draw

func (d Sierra24A) Draw(dst draw.Image, r image.Rectangle, src image.Image, sp image.Point)

Draw performs error diffusion dithering.

This method satisfies the draw.Drawer interface, implementing a dithering filter attributed to Frankie Sierra. It uses the kernel

  X 2
1 1

type TreePalette

type TreePalette struct {
	Type int
	// for TLeaf
	Index int
	Color color.RGBA64
	// for TSplit
	Split     uint32
	Low, High *TreePalette
}

func (*TreePalette) ColorNear

func (t *TreePalette) ColorNear(c color.Color) (p color.Color)

func (*TreePalette) ColorPalette

func (t *TreePalette) ColorPalette() (p color.Palette)

func (*TreePalette) IndexNear

func (t *TreePalette) IndexNear(c color.Color) (i int)

Directories

Path Synopsis
Mean is a simple color quantizer.
Mean is a simple color quantizer.
Median implements basic median cut color quantization.
Median implements basic median cut color quantization.

Jump to

Keyboard shortcuts

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