IlluminationGradient#

class deeptrack.optics.IlluminationGradient(gradient: Tuple[float, ...] | List[float] | ndarray | Callable[[...], Tuple[float, ...] | List[float] | ndarray] = (0, 0), constant: float | Callable[[...], float] = 0, vmin: float | Callable[[...], float] = 0, vmax: float | Callable[[...], float] = inf, **kwargs: Dict[str, 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, vmin, vmax, **kwargs)

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: Tuple[complex, ...] | List[complex] | ndarray, gradient: Tuple[float, ...] | List[float] | ndarray, constant: float, vmin: float, vmax: float, **kwargs: Dict[str, Any]) Tuple[complex, ...] | List[complex] | ndarray#

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

Parameters#

image: numpy.ndarray

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

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 value for clipping the amplitude.

vmax: float

Maximum value for clipping the amplitude.

**kwargs: Dict[str, Any]

Additional parameters for customization.

Returns#

numpy.ndarray

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)