pmmoto.filters.distance package

Distance transform filters for PMMoTo.

pmmoto.filters.distance.edt(img: NDArray[np.uint8], subdomain: None | PaddedSubdomain | VerletSubdomain = None) NDArray[np.float32]

Calculate the exact Euclidean transform of an image.

Parameters:
  • img (np.ndarray) – Input binary image.

  • subdomain (optional) – Subdomain object for distributed/periodic support.

Returns:

Euclidean distance transform of the image.

Return type:

np.ndarray

pmmoto.filters.distance.edt2d(img: ndarray[Any, dtype[uint8]], periodic: tuple[bool, bool] = (False, False), resolution: tuple[float, float] = (1.0, 1.0)) ndarray[Any, dtype[float32]]

Perform an exact Euclidean transform on a 2D image.

Parameters:
  • img (np.ndarray) – Input binary image.

  • periodic (list[bool], optional) – Periodicity for each dimension.

  • resolution (tuple[float], optional) – Voxel spacing for each dimension.

Returns:

Euclidean distance transform of the image.

Return type:

np.ndarray

pmmoto.filters.distance.edt3d(img: ndarray[Any, dtype[uint8]], periodic: tuple[bool, ...] = (False, False, False), resolution: tuple[float, ...] = (1.0, 1.0, 1.0), squared: bool = False) ndarray[Any, dtype[float32]]

Perform an exact Euclidean transform on a 3D image.

Parameters:
  • img (np.ndarray) – Input binary image.

  • periodic (list[bool], optional) – Periodicity for each dimension.

  • resolution (tuple[float], optional) – Voxel spacing for each dimension.

  • squared (bool, optional) – If True, return squared distances.

Returns:

Euclidean distance transform of the image.

Return type:

np.ndarray

Submodules

pmmoto.filters.distance.edt module

edt.py

Exact Euclidean Distance Transform (EDT) functions for 2D and 3D images, with support for periodic boundaries and distributed subdomains.

pmmoto.filters.distance.edt.edt(img: NDArray[np.uint8], subdomain: None | PaddedSubdomain | VerletSubdomain = None) NDArray[np.float32]

Calculate the exact Euclidean transform of an image.

Parameters:
  • img (np.ndarray) – Input binary image.

  • subdomain (optional) – Subdomain object for distributed/periodic support.

Returns:

Euclidean distance transform of the image.

Return type:

np.ndarray

pmmoto.filters.distance.edt.edt2d(img: ndarray[Any, dtype[uint8]], periodic: tuple[bool, bool] = (False, False), resolution: tuple[float, float] = (1.0, 1.0)) ndarray[Any, dtype[float32]]

Perform an exact Euclidean transform on a 2D image.

Parameters:
  • img (np.ndarray) – Input binary image.

  • periodic (list[bool], optional) – Periodicity for each dimension.

  • resolution (tuple[float], optional) – Voxel spacing for each dimension.

Returns:

Euclidean distance transform of the image.

Return type:

np.ndarray

pmmoto.filters.distance.edt.edt3d(img: ndarray[Any, dtype[uint8]], periodic: tuple[bool, ...] = (False, False, False), resolution: tuple[float, ...] = (1.0, 1.0, 1.0), squared: bool = False) ndarray[Any, dtype[float32]]

Perform an exact Euclidean transform on a 3D image.

Parameters:
  • img (np.ndarray) – Input binary image.

  • periodic (list[bool], optional) – Periodicity for each dimension.

  • resolution (tuple[float], optional) – Voxel spacing for each dimension.

  • squared (bool, optional) – If True, return squared distances.

Returns:

Euclidean distance transform of the image.

Return type:

np.ndarray