Documentation
¶
Index ¶
- Variables
- func AlphaEval(c color.Color) uint8
- func BoxBlurKernel(radius uint) utils.Kernel
- func ChannelDifference(c1, c2 color.Color) color.Color
- func CornerPixelsSampling(img image.Image, x, y int, factor ScaleFactor) color.Color
- func DividedColorCorrection(c color.Color, val int16) color.Color
- func Extend(bounds image.Rectangle, x, y int) (int, int)
- func GaussianBlurKernel(sigma float64) utils.Kernel
- func Grayscale(in color.Color) color.Color
- func Identity(in color.Color) color.Color
- func Lightness(in color.Color) color.Color
- func LightnessCorrection(c color.Color, val int16) color.Color
- func LightnessEval(c color.Color) uint8
- func Mirror(bounds image.Rectangle, x, y int) (int, int)
- func Negative(in color.Color) color.Color
- func None(_ image.Rectangle, x, y int) (int, int)
- func Sepia(in color.Color) color.Color
- func SinglePixelSampling(img image.Image, destX, destY int, factor ScaleFactor) color.Color
- func SobelKernels() []utils.Kernel
- func SobelMerge(results []color.Color) color.Color
- func UniformColorCorrection(c color.Color, val int16) color.Color
- func ValueEval(c color.Color) uint8
- func Wrap(bounds image.Rectangle, x, y int) (int, int)
- type ColorCorrection
- type ColorDifference
- type ColorEvaluation
- type ColorMerger
- type ColorSampling
- type Condition
- type EdgeHandling
- type FishEyeLens
- type HorizontalWavesLens
- type Lens
- type LensAssembly
- type LensOperation
- type MappingRule
- func AddCondition(rule MappingRule, condition Condition) MappingRule
- func BlackAndWhite(evaluation ColorEvaluation, threshold uint8) MappingRule
- func BrightnessMapping(brightnessFactor float64) MappingRule
- func ComposeRule(condition Condition, ruleTrue, ruleFalse MappingRule) MappingRule
- func CorrectionMapping(correction ColorCorrection, factor int16) MappingRule
- func GrayscaleRatioFactory(redRatio, greenRatio, blueRatio float64) MappingRule
- type PlanoLens
- type RotationLens
- type ScaleFactor
- type ScalingTarget
- type Vector
Constants ¶
This section is empty.
Variables ¶
var VecZero = Vec(0, 0)
VecZero is a constant vector that represents a point vector (magnitude 0)
Functions ¶
func BoxBlurKernel ¶
func ChannelDifference ¶
ChannelDifference returns a ColorDifference that returns the absolute value of the effective difference of 2 colors, channel by channel; for example, the difference for red and blue will be magenta, as both channels will be returned at maximum value
func CornerPixelsSampling ¶
CornerPixelsSampling is an implementation of ColorSampling that uses a bilinear interpolation between the corners of the rectangle obtained by scaling back a pixel from the destination image to the source image; the scaled rectangle can actually be smaller than a single pixel would for factors greater than 1
func DividedColorCorrection ¶
DividedColorCorrection modifies all 3 color channels by equal part of shifting value, clamping the result
func GaussianBlurKernel ¶
func Grayscale ¶
Grayscale maps the given color to a gray shade using the standard library default color converter logic
func Lightness ¶
Lightness returns a grayscale color for the given color calculated based on lightness equation
func LightnessCorrection ¶
LightnessCorrection modifies all 3 color channels with respect the lightness ratios
func LightnessEval ¶
LightnessEval returns a value based on lightness equation
func Mirror ¶
Mirror returns the color of the pixel as if the image is conceptually mirrored at the edges
func SinglePixelSampling ¶
SinglePixelSampling is an implementation of ColorSampling that uses the color of a single pixel (the closest to the target) from the source image
func SobelKernels ¶
func SobelMerge ¶
SobelMerge defines the rule used to merge results for sobel operator; despite sobel using only 2 kernels, the function handles more values
func UniformColorCorrection ¶
UniformColorCorrection modifies all 3 color channels with the entire value
Types ¶
type ColorCorrection ¶
ColorCorrection is a function that shifts the value of a color by a certain degree, be it negative or positive
type ColorDifference ¶
ColorDifference takes 2 colors and return a difference between them based on the logic it contains
func BinaryDifference ¶
func BinaryDifference(delta float64, same, difference color.Color) ColorDifference
BinaryDifference returns a ColorDifference that for 2 colors that are more different (in matter of color channels) than a threshold, returns a predefined color, otherwise returns other predefined color, reducing the image to only 2 colors
type ColorEvaluation ¶
ColorEvaluation is a function that transform a given color with multiple color channels into a single numerical value, easier to index
type ColorMerger ¶
ColorMerger defines an interface for all functions used to determine the merged result of multiple applied filters for MultiKernel
type ColorSampling ¶
ColorSampling encapsulates a strategy used to decide what color the pixel at the given position from the destination image will have
type EdgeHandling ¶
EdgeHandling defines an interface for all functions used to determine the behaviour of filtering around the edge of the image
type FishEyeLens ¶
type FishEyeLens struct {
// contains filtered or unexported fields
}
FishEyeLens encapsulates logic for a fish eye distortion
func NewFishEyeLens ¶
func NewFishEyeLens(center geometry.Point2D, radius, strength float64) *FishEyeLens
NewFishEyeLens returns a FishEyeLens with the given center, radius and strength
func (FishEyeLens) VecAt ¶
func (lens FishEyeLens) VecAt(x, y int) Vector
VecAt returns the Vector for the given cooridinates obtained from the fish-eye effect
type HorizontalWavesLens ¶
type HorizontalWavesLens struct {
// contains filtered or unexported fields
}
HorizontalWavesLens encapsulates logic for a wave distortion on the horizontal direction
func NewHorizontalWavesLens ¶
func NewHorizontalWavesLens(frequency, magnitude, translation float64) *HorizontalWavesLens
NewHorizontalWavesLens returns a HorizontalWavesLens with the given frequency, magnitude and translation
func (HorizontalWavesLens) VecAt ¶
func (lens HorizontalWavesLens) VecAt(x, y int) Vector
VecAt returns the Vector for the given cooridinates obtained from the horizontal wave distortion
type Lens ¶
type Lens interface { // VecAt returns the given distortion vector for a given position VecAt(x, y int) Vector }
Lens encapsulates the logic needed obtain distortion vectors for an image
type LensAssembly ¶
type LensAssembly struct {
// contains filtered or unexported fields
}
LensAssembly encapsulates 2 Lenses and a LensOperation used to compose the two Lens
func (LensAssembly) VecAt ¶
func (asm LensAssembly) VecAt(x, y int) Vector
VecAt returns the Vector for the given cooridinates obtained by navigation the Lens and LensOperation in the LensAssembly
type LensOperation ¶
LensOperation defines a general method of composing lens
type MappingRule ¶
MappingRule modifies a color using contained logic
func AddCondition ¶
func AddCondition(rule MappingRule, condition Condition) MappingRule
AddCondition returns MappingRule that execute the given MappingRule only if the given Condition evaluates to true
func BlackAndWhite ¶
func BlackAndWhite(evaluation ColorEvaluation, threshold uint8) MappingRule
BlackAndWhite maps the given color to black or white depending on a color evaluation function and its output to the color input relative to the given threshold
func BrightnessMapping ¶
func BrightnessMapping(brightnessFactor float64) MappingRule
BrightnessMapping maps the given color to a brighter or darker color depending on the given brightness factor
func ComposeRule ¶
func ComposeRule(condition Condition, ruleTrue, ruleFalse MappingRule) MappingRule
ComposeRule returns a MappingRule that executes the first MappingRule if the given Condition returns true, or second MappingRule for false
func CorrectionMapping ¶
func CorrectionMapping(correction ColorCorrection, factor int16) MappingRule
CorrectionMapping maps the given color to a color obtained by applying the correction strategy with a given factor on each color pixel
func GrayscaleRatioFactory ¶
func GrayscaleRatioFactory(redRatio, greenRatio, blueRatio float64) MappingRule
GrayscaleRatioFactory returns a grayscale mapper that uses the given ration to calculate the resulting shade of gray
type PlanoLens ¶
type PlanoLens struct{}
PlanoLens encapsulates logic for a Plano lens (0.0 magnitude) that does not alter the image at all
func NewPlanoLens ¶
func NewPlanoLens() *PlanoLens
type RotationLens ¶
type RotationLens struct {
// contains filtered or unexported fields
}
RotationLens encapsulates logic for a fish eye distortion
func NewRotationLens ¶
func NewRotationLens(anchor geometry.Point2D, radians float64) *RotationLens
NewRotationLens returns a RotationLens with the given anchor and rotation
func (RotationLens) VecAt ¶
func (lens RotationLens) VecAt(x, y int) Vector
VecAt returns the Vector for the given cooridinates obtained from the rotation distortion
type ScaleFactor ¶
type ScaleFactor struct {
X, Y float64
}
ScaleFactor represents the value a point must be multiplied by in order to obtain its color coordinates on the source image
func (ScaleFactor) GetSourcePx ¶
func (factor ScaleFactor) GetSourcePx(x, y float64) (float64, float64)
GetSourcePx returns the color coordinates of the source image for the given color coordinates of the destination image
type ScalingTarget ¶
type ScalingTarget func(image.Rectangle) (ScaleFactor, image.Rectangle)
ScalingTarget encapsulates a strategy used to obtain the scale factor of an image and the target size of the said image