mymesh.image.VoxelMesh#
- mymesh.image.VoxelMesh(img, h, threshold=None, threshold_direction=1, scalefactor=1, scaleorder=1, return_nodedata=False)[source]#
Generate voxel mesh of an image function
- Parameters:
img (str or np.ndarray) – Image array or file path to an image
h (scalar, tuple) – Voxel size of the image. Can be specified as a single scalar value, or a three element tuple (or array_like). If a tuple, entries should correspond to (hx, hy, hz).
threshold (scalar) – Isovalue threshold to use for keeping/removing elements, by default 0.
threshold_direction (signed integer) – If threshold_direction is negative, values less than or equal to the threshold will be considered “inside” the mesh and the opposite if threshold_direction is positive, by default 1.
scalefactor (float, optional) – Scale factor for resampling the image. If greater than 1, there will be more than 1 elements per voxel. If less than 1, will coarsen the image, by default 1.
scaleorder (int, optional) – Interpolation order for scaling the image (see scipy.ndimage.zoom), by default 1. Must be 0-5.
return_nodedata (bool, optional) – Option to interpolate image data to the nodes rather than just the voxels, by default False. This can add significant computational costs for large images.
- Returns:
voxel – Mesh object containing the voxel mesh. The image data are stored in voxel.ElemData[‘Image Data’] and optional voxel.NodeData[‘Image Data’]
Note
Due to the ability to unpack the mesh object to NodeCoords and NodeConn, the NodeCoords and NodeConn array can be returned directly (instead of the mesh object) by running:
NodeCoords, NodeConn = implicit.VoxelMesh(...)
- Return type:
Examples