img

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2023 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ArtotBin = func(w bool) func(<-chan [][]bool) <-chan []string {
	return u.GenChanFunc(func(in <-chan [][]bool, out chan<- []string) {
		for e := range in {
			out <- bin2art(e, w)
		}
	})
}

turning 2d binary matrix to string array. whether reverse color.

View Source
var BinotImg = func(threshold int) func(<-chan Img) <-chan [][]bool {
	return u.GenChanFunc(func(in <-chan Img, out chan<- [][]bool) {
		for im := range in {
			out <- img2bin(im, threshold)
		}
	})
}

turning image to 2d binary matrix. your threshold to adjust the binarization.

View Source
var Resize = func(scale float64) func(<-chan Img) <-chan Img {
	return u.GenChanFunc(func(in <-chan Img, out chan<- Img) {
		for i := range in {
			dx := int(math.Floor(scale * float64(i.Bounds().Dx())))
			dy := int(math.Floor(scale * float64(i.Bounds().Dy())))
			dst := image.NewRGBA(image.Rect(0, 0, dx, dy))
			xdraw.NearestNeighbor.Scale(dst, dst.Rect, i, i.Bounds(), xdraw.Over, nil)
			out <- dst
		}
	})
}

resizing the image with scale value, it won't change the ratio. return a stream chan function.

View Source
var TurnGray = u.GenChanFunc(func(in <-chan Img, out chan<- Img) {
	for i := range in {
		dx, dy := i.Bounds().Dx(), i.Bounds().Dy()
		dst := image.NewGray(image.Rect(0, 0, dx, dy))
		draw.Draw(dst, dst.Bounds(), i, i.Bounds().Min, draw.Src)
		out <- dst
	}
})

turning gray.

Functions

This section is empty.

Types

type Img

type Img = image.Image

func LoadAImage

func LoadAImage(f io.Reader) (Img, error)

loading an image, only support png and jpeg. if pass a gif, return the first embedded image. if there is any thing wrong, panic.

type Pale added in v1.0.1

type Pale = *image.Paletted

func LoadAGif

func LoadAGif(f io.Reader) ([]Pale, error)

loading a gif, return arrays of image.

Jump to

Keyboard shortcuts

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