mediancut

package
v0.0.0-...-225f51f Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// HistogramSize is the maximum number of 16 bit colors
	HistogramSize = 32768
)

Variables

View Source
var ErrEmpty = errors.New("Empty")

Functions

func BlueColor

func BlueColor(color uint16) uint8

BlueColor return blue value from uint16 color

func GetPalette

func GetPalette(img image.Image, maxCubes int) ([]color.Color, []int, error)

GetPalette return cluster similar colors by the median cut algorithm

func GetRGB

func GetRGB(color uint16) (uint8, uint8, uint8)

func GreenColor

func GreenColor(color uint16) uint8

GreenColor return green value from uint16 color

func NewPriorityQueue

func NewPriorityQueue(maxSize int) *priorityQueue

NewPriorityQueue return a maximum heap

func RGB

func RGB(r uint8, g uint8, b uint8) uint16

RGB convert RGB color to 16 bit value

func RedColor

func RedColor(color uint16) uint8

RedColor return red value from uint16 color

Types

type ColorCube

type ColorCube struct {
	Count   int          // number of pixels
	Level   int          // cutting depth
	Longest LongestColor // RGB cube's longest edge

	RMin, RMax, GMin, GMax, BMin, BMax uint8 // range of RGB value

	Hist []uint16
}

func (ColorCube) Clone

func (cube ColorCube) Clone() ColorCube

func (ColorCube) GetColor

func (cube ColorCube) GetColor(hist []int) color.RGBA

GetColor return the cube's average color value

func (*ColorCube) Len

func (cube *ColorCube) Len() int

func (*ColorCube) Less

func (cube *ColorCube) Less(i, j int) bool

func (ColorCube) Rank

func (cube ColorCube) Rank() int

func (*ColorCube) Shrink

func (cube *ColorCube) Shrink()

Shrink will shrink the range of RGB value

func (*ColorCube) Swap

func (cube *ColorCube) Swap(i, j int)

func (ColorCube) Volume

func (cube ColorCube) Volume() int

type LongestColor

type LongestColor int
const (
	LongRed LongestColor = iota + 1
	LongGreen
	LongBlue
)

Jump to

Keyboard shortcuts

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