code: def skeletonize_3d(image):
      """Compute the skeleton of a binary image.
  
      Thinning is used to reduce each connected component in a binary image
      to a single-pixel wide skeleton.
  
      Parameters
      ----------
      image : ndarray, 2D or 3D
          A binary image containing the objects to be skeletonized. Zeros
          represent background, nonzero values are foreground.
  
      Returns
      -------
      skeleton : ndarray of bool
          The thinned image.
  
      See Also
      --------
      skeletonize, medial_axis
  
      Notes
      -----
      The method of [Lee94]_ uses an octree data structure to examine a 3x3x3
      neighborhood of a pixel. The algorithm proceeds by iteratively sweeping
      over the image, and removing pixels at each iteration until the image
      stops changing. Each iteration consists of two steps: first, a list of
      candidates for removal is assembled; then pixels from this list are
      rechecked sequentially, to better preserve connectivity of the image.
  
      The algorithm this function implements is different from the algorithms
      used by either `skeletonize` or `medial_axis`, thus for 2D images the
      results produced by this function are generally different.
  
      References
      ----------
      .. [Lee94] T.-C. Lee, R.L. Kashyap and C.-N. Chu, Building skeleton models
             via 3-D medial surface/axis thinning algorithms.
             Computer Vision, Graphics, and Image Processing, 56(6):462-478, 1994.
  
      """
      # make sure the image is 3D or 2D
      if image.ndim < 2 or image.ndim > 3:
          raise ValueError(
              "skeletonize_3d can only handle 2D or 3D images; "
              f"got image.ndim = {image.ndim} instead."
          )
  
      image_io = image.astype(bool, copy=False)
  
      # make a 2D input image 3D and pad it w/ zeros to simplify dealing w/ boundaries
      # NB: careful here to not clobber the original *and* minimize copying
      if image.ndim == 2:
          image_io = image_io[np.newaxis, ...]
      image_o = np.pad(image_io, pad_width=1, mode="constant")
  
      # do the computation
      image_o = _compute_thin_image(image_o)
  
      # crop it back and restore the original intensity range
      image_o = crop(image_o, crop_width=1)
      if image.ndim == 2:
          image_o = image_o[0]
  
      return image_o
  
file_path: scikit-image/skimage/morphology/_skeletonize.py
imports: import numpy
  from scipy import ndimage
  from .._shared.utils import check_nD
  from ..util import crop
  from ._skeletonize_3d_cy import _compute_thin_image
  from ._skeletonize_cy import _fast_skeletonize, _skeletonize_loop, _table_lookup_index
label_desc: Use image node_id 8 for calling a global function with example usage: skeletonize_3d(image) and returns: image_o