filter

package
v0.0.0-...-d974ece Latest Latest
Warning

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

Go to latest
Published: May 6, 2024 License: GPL-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// FloydSteinberg is the Floyd Steinberg matrix
	FloydSteinberg = [][]float32{
		{0, 0, 7.0 / 16.0},
		{3.0 / 16.0, 5.0 / 16.0, 1.0 / 16.0},
	}
	// JarvisJudiceNinke is the JarvisJudiceNinke matrix
	JarvisJudiceNinke = [][]float32{
		{0, 0, 0, 7.0 / 48.0, 5.0 / 48.0},
		{3.0 / 48.0, 5.0 / 48.0, 7.0 / 48.0, 5.0 / 48.0, 3.0 / 48.0},
		{1.0 / 48.0, 3.0 / 48.0, 5.0 / 48.0, 3.0 / 48.0, 1.0 / 48.0},
	}
	// Stucki is the Stucki matrix
	Stucki = [][]float32{
		{0, 0, 0, 8.0 / 42.0, 4.0 / 42.0},
		{2.0 / 42.0, 4.0 / 42.0, 8.0 / 42.0, 4.0 / 42.0, 2.0 / 42.0},
		{1.0 / 42.0, 2.0 / 42.0, 4.0 / 42.0, 2.0 / 42.0, 1.0 / 42.0},
	}
	// Atkinson is the Atkinson matrix
	Atkinson = [][]float32{
		{0, 0, 1.0 / 8.0, 1.0 / 8.0},
		{1.0 / 8.0, 1.0 / 8.0, 1.0 / 8.0, 0},
		{0, 1.0 / 8.0, 0, 0},
	}
	// Burkes is the Burkes matrix
	Burkes = [][]float32{
		{0, 0, 0, 8.0 / 32.0, 4.0 / 32.0},
		{2.0 / 32.0, 4.0 / 32.0, 8.0 / 32.0, 4.0 / 32.0, 2.0 / 32.0},
	}
	// Sierra is the Sierra matrix
	Sierra = [][]float32{
		{0, 0, 0, 5.0 / 32.0, 3.0 / 32.0},
		{2.0 / 32.0, 4.0 / 32.0, 5.0 / 32.0, 4.0 / 32.0, 2.0 / 32.0},
		{0, 2.0 / 32.0, 3.0 / 32.0, 2.0 / 32.0, 0},
	}
	// TwoRowSierra is a variant of the Sierrra matrix
	TwoRowSierra = [][]float32{
		{0, 0, 0, 4.0 / 16.0, 3.0 / 16.0},
		{1.0 / 32.0, 2.0 / 32.0, 3.0 / 32.0, 2.0 / 32.0, 1.0 / 32.0},
	}
	// SierraLite is a variant of the Sierra matrix
	SierraLite = [][]float32{
		{0, 0, 2.0 / 4.0},
		{1.0 / 4.0, 1.0 / 4.0, 0},
	}
	// Sierra3
	Sierra3 = [][]float32{
		{0.0, 0.0, 0.0, 5.0 / 32.0, 3.0 / 32.0},
		{2.0 / 32.0, 4.0 / 32.0, 5.0 / 32.0, 4.0 / 32.0, 2.0 / 32.0},
		{0.0, 2.0 / 32.0, 3.0 / 32.0, 2.0 / 32.0, 0.0},
	}
	// bayer 4
	Bayer2 = [][]float32{
		{0, 3},
		{2, 1},
	}
	Bayer3 = [][]float32{
		{0, 6, 4},
		{7, 5, 1},
		{3, 2, 8},
	}
	Bayer4 = [][]float32{
		{0, 12, 3, 15},
		{8, 4, 11, 7},
		{2, 14, 1, 13},
		{10, 6, 9, 5},
	}
	Bayer8 = [][]float32{
		{0, 32, 8, 40, 2, 34, 10, 42},
		{48, 16, 56, 24, 50, 18, 58, 26},
		{12, 44, 4, 36, 14, 46, 6, 38},
		{60, 28, 52, 20, 62, 30, 54, 22},
		{3, 35, 11, 43, 1, 33, 9, 41},
		{51, 19, 59, 27, 49, 17, 57, 25},
		{15, 47, 7, 39, 13, 45, 5, 37},
		{63, 31, 55, 23, 61, 29, 53, 21},
	}
)

Functions

func ColorCompare

func ColorCompare(r1, g1, b1, r2, g2, b2 uint) float64

func Dithering

func Dithering(input *image.NRGBA, filter [][]float32, errorMultiplier float32) *image.NRGBA

func EvaluateMixingError

func EvaluateMixingError(r, g, b, r0, g0, b0, r1, g1, b1, r2, g2, b2 uint, ratio float64) float64

func InitPal

func InitPal() [216]uint

func InitPalWithPalette

func InitPalWithPalette(p color.Palette) []uint

func QuantizeNoDither

func QuantizeNoDither(in *image.NRGBA, numColors int, pal color.Palette) *image.NRGBA

func QuantizeWithDither

func QuantizeWithDither(input *image.NRGBA, filter [][]float32, numColors int, pal color.Palette) *image.NRGBA

Types

type MixingPlan

type MixingPlan struct {
	Colors [4]uint
	Ratio  float32
}

func DeviseBestMixingPlan

func DeviseBestMixingPlan(color uint, pal []uint, matrixLenght uint) MixingPlan

nolint: funlen, gocognit

Jump to

Keyboard shortcuts

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