imageutil

package
v0.0.0-...-e938fac Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var KernelGaussian3x3 = [][]float32{
	{0.0625, 0.1250, 0.0625},
	{0.1250, 0.2500, 0.1250},
	{0.0625, 0.1250, 0.0625},
}
View Source
var KernelLaplacian = [][]float32{
	{0.0, 1.0, 0.0},
	{1.0, -4.0, 1.0},
	{0.0, 1.0, 0.0},
}
View Source
var KernelXAngle = [][]float32{
	{0, 0, 0},
	{-1, 0, 1},
	{0, 0, 0},
}
View Source
var KernelYAngle = [][]float32{
	{0, -1, 0},
	{0, 0, 0},
	{0, 1, 0},
}

Functions

func ApplyFn

func ApplyFn(img *image.RGBA, fn func(float32) float32, chanel Chanel) *image.RGBA

Apply provided function to every pixel of img

func Ceil

func Ceil(img *image.RGBA, threshold float32, chanels Chanel) *image.RGBA

Ceil the image by setting all pixels greater than threshold to 100%

func DrawLine

func DrawLine(img *image.RGBA, p1, p2 math.Vector2[int], c color.RGBA, thickness int)

Draw the line

func DrawPoint

func DrawPoint(img *image.RGBA, point math.Vector2[int], c color.RGBA, size int)

func DrawRectOutline

func DrawRectOutline(img *image.RGBA, rect math.Box2D[int], c color.RGBA, thickness int)

Draw a rectangular outline

func Filter

func Filter(img *image.RGBA, kernel [][]float32, chanels Chanel) *image.RGBA

Apply kernel to image. Kernel dimensions should be odd numbers

func Floor

func Floor(img *image.RGBA, threshold float32, chanels Chanel) *image.RGBA

Floor the image by setting all pixels less that threshold to zero

func RgbaFromFile

func RgbaFromFile(file string) (*image.RGBA, error)

Load an image file (only pngs for now)

func SaveRgba

func SaveRgba(image *image.RGBA, filename string) error

Save rgba image to disk. Saved as png.

func Scale

func Scale(img *image.RGBA, f float32, chanels Chanel) *image.RGBA

Multiply image pixels by factor f

Types

type Chanel

type Chanel uint8 // red, green, blue and alpha
const (
	RED_CHANEL   Chanel = 1
	GREEN_CHANEL Chanel = 2
	BLUE_CHANEL  Chanel = 4
	ALPHA_CHANEL Chanel = 8
	RGB_CHANEL   Chanel = RED_CHANEL | GREEN_CHANEL | BLUE_CHANEL
	RGBA_CHANEL  Chanel = RED_CHANEL | GREEN_CHANEL | BLUE_CHANEL | ALPHA_CHANEL
)

func (Chanel) Is

func (a Chanel) Is(b Chanel) bool

Jump to

Keyboard shortcuts

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