nanomesh.image2mesh.mesher3d

Classes:

BoundingBox(xmin, xmax, ymin, ymax, zmin, zmax)

Container for bounding box coordinates.

Functions:

get_region_markers(vol)

Get region markers describing the featuers in the volume.

pad(mesh, *, side, width[, label, name])

Pad a contour triangle mesh (3D).

volume2mesh(image, *[, level])

Generate a tetrahedral mesh from a 3D segmented image.

class nanomesh.image2mesh._mesher3d.BoundingBox(xmin: float, xmax: float, ymin: float, ymax: float, zmin: float, zmax: float)[source]

Bases: object

Container for bounding box coordinates.

Attributes:

center

Return center of the bounding box.

dimensions

Return dimensions of bounding box.

xmax

xmin

ymax

ymin

zmax

zmin

Methods:

from_points(points)

Generate bounding box from set of points or coordinates.

from_shape(shape)

Generate bounding box from data shape.

to_points()

Return (m,3) array with corner points.

property center: ndarray

Return center of the bounding box.

property dimensions: Tuple[float, float, float]

Return dimensions of bounding box.

classmethod from_points(points: ndarray)[source]

Generate bounding box from set of points or coordinates.

classmethod from_shape(shape: tuple)[source]

Generate bounding box from data shape.

to_points() ndarray[source]

Return (m,3) array with corner points.

xmax: float
xmin: float
ymax: float
ymin: float
zmax: float
zmin: float
nanomesh.image2mesh._mesher3d.get_region_markers(vol: Union[Volume, ndarray]) RegionMarkerList[source]

Get region markers describing the featuers in the volume.

The array will be labeled, and points inside the labeled region will be obtained using the skeletonize function. The region markers can be used to flood the connected regions in the tetrahedralization step.

Parameters

vol (Union[Volume, np.ndarray]) – Segmented integer volume.

Returns

region_markers – List of tuples. The first element is the label in the source image, and the second the pixel coordinates somewhere in the center of the corresponding region.

Return type

List[RegionMArker]

nanomesh.image2mesh._mesher3d.pad(mesh: TriangleMesh, *, side: str, width: int, label: int = None, name: str = None) TriangleMesh[source]

Pad a contour triangle mesh (3D).

Note that tetgen will assign a different label for physically separate regions, even when they are given the same label/name.

Parameters
  • mesh (TriangleMesh) – The mesh to pad.

  • side (str) – Side to pad, must be one of left, right, top, bottom, back, front.

  • width (int) – Width of the padded area.

  • label (int, optional) – The label to assign to the padded area. If not defined, generates the next unique label based on the existing ones.

  • name (str, optional) – Name of the added region. Note that in case of conflicts, the label takes presedence over the name.

Returns

new_mesh – Padded contour triangle mesh.

Return type

TriangleMesh

Raises

ValueError – When the value of side is invalid.

nanomesh.image2mesh._mesher3d.volume2mesh(image: np.ndarray | Volume, *, level: float = None, **kwargs) MeshContainer[source]

Generate a tetrahedral mesh from a 3D segmented image.

Parameters
  • image ((i,j,k) numpy.ndarray or Volume) – Input image to mesh.

  • level (float, optional) – Contour value to search for isosurfaces (i.e. the threshold value). By default takes the average of the min and max value. Can be ignored if a binary image is passed as image.

  • **kwargs – Optional keyword arguments passed to tetrahedralize()

Returns

volume_mesh – Instance of MeshContainer

Return type

MeshContainer