Convert a volume to a mesh using the Marching Cubes algorithm, with optional thresholding and padding.
**kwargs:any
)->hmesh.Manifold:
""" Convert a 3D numpy array to a mesh object using the [volumetric_isocontour](https://www2.compute.dtu.dk/projects/GEL/PyGEL/pygel3d/hmesh.html#volumetric_isocontour) function from Pygel3D.
Args:
volume (np.ndarray): The 3D numpy array representing the volume.
level (float, optional): The threshold value for Marching Cubes. If None, Otsu's method is used.
step_size (int, optional): The step size for the Marching Cubes algorithm.
allow_degenerate (bool, optional): Whether to allow degenerate (i.e. zero-area) triangles in the end-result. If False, degenerate triangles are removed, at the cost of making the algorithm slower. Default False.
padding (tuple of ints, optional): Padding to add around the volume.
**kwargs: Additional keyword arguments to pass to `skimage.measure.marching_cubes`.
volume (np.ndarray): A 3D numpy array representing a volume.
**kwargs: Additional arguments to pass to the Pygel3D volumetric_isocontour function.
Raises:
ValueError: If the input volume is not a 3D numpy array or if the input volume is empty.
Returns:
mesh (trimesh.Trimesh): The generated mesh.
hmesh.Manifold: A Pygel3D mesh object representing the input volume.
Example:
Convert a 3D numpy array to a Pygel3D mesh object: