ArithmeticOperationFeature#
- class deeptrack.features.ArithmeticOperationFeature(op: Callable[[Any, Any], Any], value: float | int | List[float | int] = 0, **kwargs: Dict[str, Any])#
Bases:
Feature
Applies an arithmetic operation element-wise to inputs.
This feature performs an arithmetic operation (e.g., addition, subtraction, multiplication, etc.) on the input data. The inputs can be single values or lists of values. If a list is passed, the operation is applied to each element in the list. When both inputs are lists of different lengths, the shorter list is cycled.
Parameters#
- opCallable
The arithmetic operation to apply. This can be a built-in operator or a custom callable.
- valuefloat or int or List[float or int], optional
The other value(s) to apply the operation with. Defaults to 0.
- **kwargsDict[str, Any]
Additional keyword arguments passed to the parent Feature.
Attributes#
- __distributed__bool
Set to False, indicating that this feature’s get(…) method processes the entire list of images or values at once, rather than distributing calls for each item.
- __gpu_compatible__bool
Set to True, indicating compatibility with GPU processing.
Example#
>>> import operator >>> import numpy as np >>> from deeptrack.features import ArithmeticOperationFeature
Define a simple addition operation:
>>> addition = ArithmeticOperationFeature(operator.add, value=10)
Create a list of input values:
>>> input_values = [1, 2, 3, 4]
Apply the operation:
>>> output_values = addition(input_values) >>> print(output_values) [11, 12, 13, 14]
In this example, each value in the input list is incremented by 10.
Methods Summary
get
(image, value, **kwargs)Apply the operation element-wise to the input data.
Methods Documentation
- get(image: Any | List[Any], value: float | int | List[float | int], **kwargs: Any) List[Any] #
Apply the operation element-wise to the input data.
Parameters#
- imageAny or List[Any]
The input data (list or single value) to transform.
- valuefloat or int or List[float or int]
The value(s) to apply the operation with. If a single value is provided, it is broadcast to match the input size. If a list is provided, it will be cycled to match the length of the input list.
- **kwargsDict[str, Any]
Additional parameters or overrides (unused here).
Returns#
- List[Any]
A list with the result of applying the operation to the input.