riemersma

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2024 License: MIT Imports: 4 Imported by: 0

README

riemersma

riemersma is a Go implementation of Riemersma Dithering based on this example in C

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Riemersma = Drawer{}

Riemersma is a draw.Drawer (similar to draw.FloydSteinberg) which does Riemersma dithering to src image and draws result on dst image

Functions

This section is empty.

Types

type ColorError

type ColorError []float64

color quantization errors for each channel

type Drawer added in v0.2.0

type Drawer struct{}

func (Drawer) Draw added in v0.2.0

func (dr Drawer) Draw(dst draw.Image, r image.Rectangle, src image.Image, sp image.Point)

type Image

type Image interface {
	Size() image.Point                                      // image size
	ColorNumChannels() int                                  // number of color channels
	DitherPixel(x int, y int, accErr ColorError) ColorError // Dither pixel with accumulated error
}

func NewImage

func NewImage(dst draw.Image, r image.Rectangle, src image.Image, sp image.Point) Image

type Op added in v0.2.0

type Op struct {
	Ratio   float64   // weight ratio between youngest pixel and oldest pixel
	Weights []float64 // pre-calculated weights
	// contains filtered or unexported fields
}

Riemersma Dither Operation. It is not resuable.

func NewOperation added in v0.2.0

func NewOperation(queueSize int, ratio float64) *Op

Create new Riemersma dither operation with specific queueSize and ratio queueSize is the number of most recent pixel quantization errors to remember ratio is weight ratio between youngest pixel and oldest pixel

func (*Op) AccumulatedError added in v0.2.0

func (rs *Op) AccumulatedError(numChannel int) ColorError

func (*Op) Dither added in v0.2.0

func (rs *Op) Dither(image Image)

func (*Op) Draw added in v0.2.0

func (rs *Op) Draw(dst draw.Image, r image.Rectangle, src image.Image, sp image.Point)

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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