imageutils

package
v0.0.0-...-61db93c Latest Latest
Warning

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

Go to latest
Published: May 14, 2022 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Load

func Load(filePath string, opts LoadOpts) (image.Image, error)

Load loads an image from the given path

func ToArray

func ToArray(img image.Image, opts ToTensorOpts) []float32

ToArray converts the image in a []float32

func ToTensor

func ToTensor(img image.Image, opts ToTensorOpts) tensor.Tensor

ToTensor converts the given image to a tensor

func ToTensorFromDirectory

func ToTensorFromDirectory(dirPath string, loadOpts LoadOpts, tensorOpts ToTensorOpts) (tensor.Tensor, error)

ToTensorFromDirectory loads all images in a directory

Types

type Augmenter

type Augmenter struct {
	// contains filtered or unexported fields
}

Augmenter is in charge of augmenting the given images

func NewAugmenter

func NewAugmenter(filters ...Filter) *Augmenter

NewAugmenter builds a new augmenter

func (*Augmenter) Apply

func (aug *Augmenter) Apply(img image.Image) (image.Image, error)

Apply applies the filters to the given image

func (*Augmenter) ApplyN

func (aug *Augmenter) ApplyN(img image.Image, n int) ([]image.Image, error)

ApplyN applies the filters to the given image N times

func (*Augmenter) ApplyToDir

func (aug *Augmenter) ApplyToDir(inputDir string, nAugmentations int, outputObserver func(n int, origPath string, img image.Image)) error

ApplyToDir applies all the augmentations to the images found in the given directory

type Filter

type Filter func(img image.Image) (image.Image, error)

Filter represents a filter applied to an image

func Either

func Either(filters ...Filter) Filter

Either applies either of the given filters

func WithCrop

func WithCrop(x, y, width, height int) Filter

WithCrop crops a region of the image, normally it should be applied as first filter

func WithRandomBoxBlur

func WithRandomBoxBlur(probability, minBoxBlur float64, maxBoxBlur float64) Filter

WithRandomBoxBlur configures the random gaussian blur applied to an image

func WithRandomBrightness

func WithRandomBrightness(probability, minBrightness float64, maxBrightness float64) Filter

WithRandomBrightness configures the random brightness applied to an image probability is a number between 0 and 1 indicating the probability to apply this filter

func WithRandomContrast

func WithRandomContrast(probability, minContrast float64, maxContrast float64) Filter

WithRandomContrast configures the random contrast applied to an image probability is a number between 0 and 1 indicating the probability to apply this filter

func WithRandomDilation

func WithRandomDilation(probability, minDilation float64, maxDilation float64) Filter

WithRandomDilation configures the random dilation applied to an image probability is a number between 0 and 1 indicating the probability to apply this filter

func WithRandomErosion

func WithRandomErosion(probability, minErosion float64, maxErosion float64) Filter

WithRandomErosion configures the random erosion applied to an image probability is a number between 0 and 1 indicating the probability to apply this filter

func WithRandomGamma

func WithRandomGamma(probability, minGamma float64, maxGamma float64) Filter

WithRandomGamma configures the random gamma applied to an image probability is a number between 0 and 1 indicating the probability to apply this filter

func WithRandomGaussianBlur

func WithRandomGaussianBlur(probability, minGaussianBlur float64, maxGaussianBlur float64) Filter

WithRandomGaussianBlur configures the random gaussian blur applied to an image probability is a number between 0 and 1 indicating the probability to apply this filter

func WithRandomHue

func WithRandomHue(probability float64, minHue int, maxHue int) Filter

WithRandomHue configures the random hue applied to an image probability is a number between 0 and 1 indicating the probability to apply this filter

func WithRandomRotation

func WithRandomRotation(probability, fromRadians, toRadians float64) Filter

WithRandomRotation configures the random rotation applied to an image probability is a number between 0 and 1 indicating the probability to apply this filter

func WithRandomSaturation

func WithRandomSaturation(probability, minSaturation float64, maxSaturation float64) Filter

WithRandomSaturation configures the random saturation applied to an image

func WithRandomShear

func WithRandomShear(probability, fromRadians, toRadians float64) Filter

WithRandomShear configures the random shear applied to an image probability is a number between 0 and 1 indicating the probability to apply this filter

func WithResize

func WithResize(width, height int) Filter

WithResize applies the resize operation to the image

type LoadOpts

type LoadOpts struct {
	TargetSize []uint
}

LoadOpts contains options to load an image

type TensorMode

type TensorMode string
const (
	TensorModeCaffe      TensorMode = "caffe"
	TensorModeTensorFlow TensorMode = "tensorflow"
	TensorModeTorch      TensorMode = "torch"
)

type ToTensorOpts

type ToTensorOpts struct {
	// TensorMode is the mode to weight the pixels. The default one is Caffe
	TensorMode TensorMode
}

ToTensorOpts are the options to convert the image to a tensor

Jump to

Keyboard shortcuts

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