quantise

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

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

Go to latest
Published: May 5, 2015 License: MIT Imports: 2 Imported by: 0

README

quantise

Provides a function to reduce the number of colours in an image.

func doQuantising(in image.Image) image.Image {
  return quantise.Quantise(in, quantise.OctreeQuantiser{
    Depth: 6,
    Size: 50,
    Strategy: quantise.LEAST,
  })
}
  • Depth gives the maximum depth the tree can reach, the deeper the tree the greater the detail can be captured, kinda anyway.

  • Size is the number of colours to use in the final image.

  • Strategy is either LEAST in which case the colours representing the fewest pixels are merged, or MOST which merges the colours representing the most.

The results aren't very accurate.

command line

There is a simple command line wrapper available:

$ go get hawx.me/code/quantise/cmd/quantise
$ quantise --depth 6 --size 128 < input.png > output.png

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Quantise

func Quantise(in image.Image, q Quantiser) image.Image

Types

type OctreeQuantiser

type OctreeQuantiser struct {
	Size     int
	Depth    uint8
	Strategy Strategy
}

func (OctreeQuantiser) Quantise

func (q OctreeQuantiser) Quantise(in image.Image) color.Palette

type Quantiser

type Quantiser interface {
	Quantise(in image.Image) color.Palette
}

type Strategy

type Strategy int
const (
	// Merge the colours representing the fewest pixels
	LEAST Strategy = iota

	// Merge the colours representing the greatest pixels
	MOST
)

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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