quantize

package
v0.0.0-...-857cc7c Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2022 License: BSD-3-Clause Imports: 4 Imported by: 1

Documentation

Overview

Package quantize offers an implementation of the draw.Quantize interface using an optimized Median Cut method, including advanced functionality for fine-grained control of color priority

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AggregationType

type AggregationType uint8

AggregationType specifies the type of aggregation to be done

const (
	// Mode - pick the highest priority value
	Mode AggregationType = iota
	// Mean - weighted average all values
	Mean
)

type MedianCutQuantizer

type MedianCutQuantizer struct {
	// The type of aggregation to be used to find final colors
	Aggregation AggregationType
	// The weighting function to use on each pixel
	Weighting func(image.Image, int, int) uint32
	// Whether to create a transparent entry
	AddTransparent bool
}

MedianCutQuantizer implements the go draw.Quantizer interface using the Median Cut method

Example
file, err := os.Open("test_image.jpg")
if err != nil {
	fmt.Println("Couldn't open test file")
	return
}
i, _, err := image.Decode(file)
if err != nil {
	fmt.Println("Couldn't decode test file")
	return
}
q := MedianCutQuantizer{}
p := q.Quantize(make([]color.Color, 0, 256), i)
fmt.Println(p)
Output:

func (MedianCutQuantizer) Quantize

Quantize quantizes an image to a palette and returns the palette

func (MedianCutQuantizer) QuantizeMultiple

func (q MedianCutQuantizer) QuantizeMultiple(p color.Palette, m []image.Image) color.Palette

QuantizeMultiple quantizes several images at once to a palette and returns the palette

Jump to

Keyboard shortcuts

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