utils

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2023 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BinaryThreshold

func BinaryThreshold(c color.Color, t float64) color.Color

Perform a binary threshold on a given color with specfied cutoff threshold and returna black or white color.

func BlurImage

func BlurImage(src image.Image, dst *image.RGBA, radius int) error

Perform a "stackblur" blurring on the source image with a specified radius parameter and store the result to the destination image pointer.

func ColorToGrayscale

func ColorToGrayscale(c color.Color) float64

Convert a color to grayscale represented as a value from zero to one.

func ColorToRgba

func ColorToRgba(c color.Color) color.RGBA

Convert the provided color represented by the color.Color interface to the color.RGBA struct instance.

func CreateFileWithTree

func CreateFileWithTree(path string) (*os.File, error)

Create the whole path directory tree and the final file.

func ExportImageAsPng

func ExportImageAsPng(path string, img image.Image) error

Create a new png file at the given path and encode the specified image into it.

func GetColorBrightness

func GetColorBrightness(c color.Color) float64

Calculate the brightness of the color represented as a value from zero to one.

func GetColorDifference

func GetColorDifference(a, b color.Color) float64

Calculate the difference between two colors represented as a value from zero to one using the mean of RGB components difference.

func Max

func Max(x []float64) float64

Calcualte the max value of the provided set. Panic if the value set is empty.

func Mean

func Mean(x []float64) float64

Calculate the mean value of the provided set. Panic if the value set is empty.

func MinInt

func MinInt(x, y int) int

Return the smaller value of x or y. This functions does not support the edge cases like math.Min

func MovingMean

func MovingMean(x []float64, position, bias int) float64

Calculate the moving mean value of the provided set. The position paramter is the index of the central subset element and the bias is the amount of "left" and "right" neighbours. Elements out of index are not taken under account.

func ScaleImage

func ScaleImage(src, dst *image.RGBA, factor float64) error

Perform a scaling process by a given factor on the RGBA image provided by the src pointer and store the result to the RGBA image specified by the dst pointer.

func StandardDeviation

func StandardDeviation(x []float64) float64

Calculate the population standard deviation value of the provided set. Panic if the value set is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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