SampleToMasks#

class deeptrack.features.SampleToMasks(transformation_function: Callable[[Image], Image], number_of_masks: int | Callable[[...], int] = 1, output_region: Tuple[int, int, int, int] | Callable[[...], Tuple[int, int, int, int]] | None = None, merge_method: str | Callable | List[str | Callable] | Callable[[...], str | Callable | List[str | Callable]] = 'add', **kwargs: Any)#

Bases: Feature

Creates a mask from a list of images.

Calls transformation_function for each input image, and merges the outputs to a single image with number_of_masks layers. Each input image needs to have a defined property position to place it within the image. If used with scatterers, note that the scatterers need to be passed the property voxel_size to correctly size the objects.

Parameters#

transformation_functionCallable[[Image], Image]

Function that takes an image as input, and outputs another image with number_of_masks layers.

number_of_masksPropertyLike[int], optional

The number of masks to create.

output_regionPropertyLike[Tuple[int, int, int, int]], optional

Size and relative position of the mask. Should generally be the same as optics.output_region.

merge_methodPropertyLike[str or Callable or List[str or Callable]]

How to merge the individual masks to a single image. If a list, the merge_metod is per mask. Can be: - “add”: Adds the masks together. - “overwrite”: later masks overwrite earlier masks. - “or”: 1 if either any mask is non-zero at that pixel. - function: a function that accepts two images. The first is the

current value of the output image where a new mask will be places, and the second is the mask to merge with the output image.

**kwargsDict[str, Any]

Additional keyword arguments passed to the parent Feature class.

Methods Summary

get(image, transformation_function, **kwargs)

Apply the transformation function to the input image.

Methods Documentation

get(image: Image, transformation_function: Callable[[Image], Image], **kwargs: Dict[str, Any]) Image#

Apply the transformation function to the input image.

Parameters#

imageImage

The input image to transform.

transformation_functionCallable[[Image], Image]

The function used to transform the input image.

**kwargsAny

Additional parameters.

Returns#

Image

The transformed image.