mymesh.converter.im2voxel#

mymesh.converter.im2voxel(img, voxelsize, scalefactor=1, scaleorder=1, return_nodedata=False, return_gradient=False, gaussian_sigma=1, threshold=None, crop=None, threshold_direction=1)[source]#

Convert 3D image data to a cubic mesh. Each voxel will be represented by an element.

Parameters:
  • img (str or np.ndarray) – If a str, should be the directory to an image stack of tiff or dicom files. If an array, shoud be a 3D array of image data.

  • voxelsize (float, or tuple) – Size of voxel (based on image resolution). If a tuple, should be specified as (hx,hy,hz)

  • 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.

  • threshold (float, optional) – Voxel intensity threshold, by default None. If given, elements with all nodes less than threshold will be discarded.

Returns:

  • VoxelCoords (list) – Node coordinates for the voxel mesh

  • VoxelConn (list) – Node connectivity for the voxel mesh

  • VoxelData (numpy.ndarray) – Image intensity data for each voxel.

  • NodeData (numpy.ndarray) – Image intensity data for each node, averaged from connected voxels.