deeptrack.elementwise Module#

Classes that apply functions to features elementwise.

This module provides the elementwise DeepTrack2 classes which work as a handle to apply various NumPy functions to Feature objects elementwise.

Key Features#

  • Extends NumPy Functions

    The convenience of NumPy functions are extended with this module such that they can be applied elementwise to a DeepTrack Feature object.

  • Trigonometric Functions

    The elementary trigonometric functions: Sin, Cos, Tan.

  • Hyperbolic Functions

    The trigonometric hyperbolic functions: Sinh, Cosh, Tanh.

  • Rounding Functions

    Common rounding functions: nearest integer rounding Round, nearest lowest integer Floor, nearest highest integer Ceil.

  • Exponents And Logarithm Functions

    Includes Exponential (exp) function, Natural Logarithm function, Logarithm function with base 10, and Logarithm function with base 2.

  • Complex Number Functions

    Functions to get various values from a complex number: Angle, Absolute value, Real value, Imaginary value, Conjugate

  • Miscellaneous Functions

    Contains Square root, Square, Sign function.

Module Structure#

Classes:

  • ElementwiseFeature

    Forms the base from which other classes inherit from.

  • Sin

  • Cos

  • Tan

  • ArcSin

  • Arccos

  • ArcTan

  • Sinh

  • Cosh

  • Tanh

  • ArcSinh

  • Arccosh

  • ArcTanh

  • Round

  • Floor

  • Ceil

  • Exp

  • Log

  • Log10

  • Log2

  • Angle

  • Real

  • Imag

  • Abs

  • Conjugate

  • Sqrt

  • Square

  • Sign

Examples#

Apply cosine elementwise to a Feature:

>>> import numpy as np
>>> from deeptrack import Feature, elementwise
>>> class TestFeature(Feature):
>>>     __distributed__ = False
>>>        def get(self, image, **kwargs):
>>>            output = np.array([[np.pi, 0],
...                               [np.pi / 4, 0]])
>>>            return output
>>> test_feature = TestFeature()
>>> elementwise_cosine = test_feature >> elementwise.Cos()
[[-1.          1.        ]
 [ 0.70710678  1.        ]]

Classes#

Abs([feature])

Applies the absolute value function elementwise.

Angle([feature])

Applies the angle function elementwise.

Arccos([feature])

Applies the arccosine function elementwise.

Arccosh([feature])

Applies the hyperbolic arccosine function elementwise.

Arcsin([feature])

Applies the arcsine function elementwise.

Arcsinh([feature])

Applies the hyperbolic arcsine function elementwise.

Arctan([feature])

Applies the arctangent function elementwise.

Arctanh([feature])

Applies the hyperbolic arctangent function elementwise.

Ceil([feature])

Applies the ceil function elementwise.

Conjugate([feature])

Applies the conjugate function elementwise.

Cos([feature])

Applies the cosine function elementwise.

Cosh([feature])

Applies the hyperbolic cosine function elementwise.

ElementwiseFeature(function[, feature])

Base class for applying NumPy functions elementwise.

Exp([feature])

Applies the exponential function elementwise.

Feature([_input])

Base feature class.

Floor([feature])

Applies the floor function elementwise.

Imag([feature])

Applies the imaginary function elementwise.

Log([feature])

Applies the natural logarithm function elementwise.

Log10([feature])

Applies the logarithm function with base 10 elementwise.

Log2([feature])

Applies the logarithm function with base 2 elementwise.

Real([feature])

Applies the real function elementwise.

Round([feature])

Applies the round function elementwise.

Sign([feature])

Applies the sign function elementwise.

Sin([feature])

Applies the sine function elementwise.

Sinh([feature])

Applies the hyperbolic sine function elementwise.

Sqrt([feature])

Applies the square root function elementwise.

Square([feature])

Applies the square function elementwise.

Tan([feature])

Applies the tangent function elementwise.

Tanh([feature])

Applies the hyperbolic tangent function elementwise.