taufactor.metrics.surfaces

Functions

interfacial_areas(img[, spacing, method, ...])

specific_surface_area(img[, spacing, ...])

Compute specific surface area per phase.

taufactor.metrics.surfaces.interfacial_areas(img, spacing=(1, 1, 1), method='face_counting', periodic=[False, False, False], normalize=True, device='cuda', smoothing=True, verbose=False)[source]
taufactor.metrics.surfaces.specific_surface_area(img, spacing=(1, 1, 1), phases={}, method='gradient', periodic=[False, False, False], device='cuda', smoothing=True, sigma=0.8, verbose=False)[source]

Compute specific surface area per phase.

Supports three methods: - 'gradient' (default): Smooth binary masks and integrate gradient magnitude. - 'face_counting': Count voxel face changes between neighboring cells. - 'marching_cubes': Extract surfaces and compute mesh area (CPU-only; assumes

dx == dy == dz).

Parameters:
  • img (torch.Tensor | numpy.ndarray) – Labeled microstructure; integer values represent phases.

  • spacing (tuple[float, float, float], optional) – Voxel spacing (dx, dy, dz). Defaults to (1, 1, 1).

  • phases (dict[str, int], optional) – Mapping from phase name to the integer label in img. If empty, all labels are processed. Defaults to {}.

  • method (str, optional) – One of 'gradient', 'face_counting', or 'marching_cubes'. Defaults to 'gradient'.

  • device (str | torch.device, optional) – Device for GPU-accelerated methods. Only used for 'gradient'/'face_counting'. Defaults to 'cuda'.

  • smoothing (bool, optional) – Apply light Gaussian smoothing to the binary mask prior to measurement (used in 'gradient' and 'marching_cubes'). Defaults to True.

  • verbose (bool, optional) – Print simple memory usage diagnostics. Defaults to False.

Returns:

Mapping from phase name to specific surface area (surface per unit volume).

Return type:

dict[str, float]

Raises:
  • ImportError – If PyTorch is not available for 'gradient' or 'face_counting' methods.

  • ValueError – If method is invalid, or if 'marching_cubes' is used with anisotropic spacing (requires dx == dy == dz).