IlluminationGradient#

class deeptrack.optical.optics.IlluminationGradient(gradient: tuple[float, float] | Callable[[...], tuple[float, float]] = (0.0, 0.0), constant: float | Callable[[...], float] = 0.0, vmin: float | Callable[[...], float] = 0.0, vmax: float | Callable[[...], float] = inf, **kwargs: Any)#

Bases: Feature

Adds a gradient to the illumination of the sample.

This class modifies the amplitude of the field by adding a planar gradient and a constant offset. The amplitude is clipped within the specified bounds.

Parameters#

gradient: array_like of float, optional

Gradient of the plane to add to the field amplitude, specified in pixels. Default is (0, 0).

constant: float, optional

Constant value to add to the field amplitude. Default is 0.

vmin: float, optional

Minimum allowed value for the amplitude. Values below this are clipped. Default is 0.

vmax: float, optional

Maximum allowed value for the amplitude. Values above this are clipped. Default is infinity.

Attributes#

gradient: array_like of float

Gradient of the plane to add to the field amplitude.

constant: float

Constant value to add to the field amplitude.

vmin: float

Minimum allowed value for the amplitude.

vmax: float

Maximum allowed value for the amplitude.

Methods#

get(image, gradient, constant, …) -> np.ndarray | torch.Tensor

Applies the gradient and constant offset to the amplitude of the field.

Examples#

Adding a gradient to the illumination:

>>> gradient_feature = dt.IlluminationGradient(gradient=(0.1, 0.2))
>>> print(gradient_feature.properties['gradient']())
(0.1, 0.2)

Methods Summary

get(image, gradient, constant, vmin, vmax, ...)

Applies the gradient and constant offset to the amplitude of the field.

Methods Documentation

get(image: ndarray | Tensor, gradient: tuple[float, float], constant: float, vmin: float, vmax: float, **kwargs: Any) ndarray | Tensor#

Applies the gradient and constant offset to the amplitude of the field.

Parameters#

image: np.ndarray | torch.Tensor

The input field to which the gradient and constant are applied.

gradient: tuple[float, float]

Gradient of the plane to add to the field amplitude.

constant: float

Constant value to add to the field amplitude.

vmin: float

Minimum value for clipping the amplitude.

vmax: float

Maximum value for clipping the amplitude.

**kwargs: Any

Additional parameters for customization.

Returns#

np.ndarray | torch.Tensor

The modified field with the gradient and constant applied.

Examples#

>>> import deeptrack as dt
>>> image=np.ones((100, 100))
>>> gradient_feature = dt.IlluminationGradient(gradient=(0.3, 0.1))
>>> properties_dict = gradient_feature.properties()
>>> modified_image = gradient_feature.get(image, **properties_dict)
>>> print(modified_image.shape)
(100, 100)