pixelate

package
v0.0.0-...-43e8dff Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalcMeanColor

func CalcMeanColor(img image.Image, rect image.Rectangle) color.Color

CalcMeanColor computes the geometric average of the pixels in a given image.Rectangle.

func DecodeImage

func DecodeImage(path string) (image.Image, string, error)

DecodeImage reads an image from a path on the filesystem and returns an image.Image or error

func EncodeImage

func EncodeImage(filename string, img image.Image, format string) error

EncodeImage writes an image to the filesystem in the given format and returns an error if unsuccessful

func Min

func Min[T cmp.Ordered](x, y T) T

just put generics in the stdlib already

Types

type Block

type Block struct {
	Rect image.Rectangle
	Idx  int
}

Block represents a group of pixels from the original image that have all been converted to a single color. A Block is a big pixel.

type BlockImage

type BlockImage struct {
	W, H      int
	BlockSize int
	Grid      Grid
	Palette   []color.RGBA
}

func Pixelate

func Pixelate(img image.Image, numColors, blockSize int) *BlockImage

Pixelate converts and Image into a BlockImage of the specified block size and number of colors

func (*BlockImage) ToImage

func (p *BlockImage) ToImage() image.Image

ToImage creates an image.Image from the BlockImage

type Grid

type Grid [][]Block

Grid is a 2D arrangement of Blocks, like pixels in an image

Jump to

Keyboard shortcuts

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