riemersma

package module
v0.1.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 = riemersma{}

Riemersma is a singleton [Drawer] that does Riemersma dithering to src image and draw result on dst image

Functions

This section is empty.

Types

type AnyImage

type AnyImage struct {
	Dst draw.Image
	Dp  image.Point
	Src image.Image
	Sp  image.Point
	// contains filtered or unexported fields
}

func (AnyImage) ColorNumChannels

func (img AnyImage) ColorNumChannels() int

func (AnyImage) DitherPixel

func (img AnyImage) DitherPixel(x int, y int, accErr ColorError) ColorError

func (AnyImage) Size

func (img AnyImage) Size() image.Point

type ColorError

type ColorError []float64

color quantization errors for each channel

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 RiemersmaDither

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

func NewRiemersmaDither

func NewRiemersmaDither(queueSize int, ratio float64) *RiemersmaDither

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 (*RiemersmaDither) AccumulatedError

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

func (*RiemersmaDither) Dither

func (rs *RiemersmaDither) Dither(image Image)

func (*RiemersmaDither) Draw

func (rs *RiemersmaDither) 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