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:
Click to show internal directories.
Click to hide internal directories.