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[tuple[Any, ...], dtype[uint8]], periodic: tuple[bool, bool] = (False, False), resolution: tuple[float, float] = (1.0, 1.0)) ndarray[tuple[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[tuple[Any, ...], dtype[uint8]], periodic: tuple[bool, ...] = (False, False, False), resolution: tuple[float, ...] = (1.0, 1.0, 1.0), squared: bool = False) ndarray[tuple[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.euclidean_distance_transform 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.euclidean_distance_transform.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.euclidean_distance_transform.edt2d(img: ndarray[tuple[Any, ...], dtype[uint8]], periodic: tuple[bool, bool] = (False, False), resolution: tuple[float, float] = (1.0, 1.0)) ndarray[tuple[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.euclidean_distance_transform.edt3d(img: ndarray[tuple[Any, ...], dtype[uint8]], periodic: tuple[bool, ...] = (False, False, False), resolution: tuple[float, ...] = (1.0, 1.0, 1.0), squared: bool = False) ndarray[tuple[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

pmmoto.filters.distance.euclidean_distance_transform.get_boundary_hull(subdomain: PaddedSubdomain | VerletSubdomain, img: NDArray[np.float32], og_img: NDArray[np.uint8], dimension: int, num_hull: int = 4) tuple[None | list[list[Hull]], None | list[list[Hull]]]

Get the boundary hull for a subdomain and image.

Always pad the domain by 1 to allow for exact update of img and account for subdomain padding.

Parameters:
  • subdomain – Subdomain object.

  • img (np.ndarray) – Image to update.

  • og_img (np.ndarray) – Original image.

  • dimension (int) – Dimension to compute hull for.

  • num_hull (int, optional) – Number of hull points.

Returns:

(lower_hull, upper_hull)

Return type:

tuple