code: def find_disconnected_voxels(im, conn=None):
      r
      if im.ndim != im.squeeze().ndim:
          warnings.warn('Input image conains a singleton axis:' + str(im.shape) +
                        ' Reduce dimensionality with np.squeeze(im) to avoid' +
                        ' unexpected behavior.')
      if im.ndim == 2:
          if conn == 4:
              strel = disk(1)
          elif conn in [None, 8]:
              strel = square(3)
      elif im.ndim == 3:
          if conn == 6:
              strel = ball(1)
          elif conn in [None, 26]:
              strel = cube(3)
      labels, N = spim.label(input=im, structure=strel)
      holes = clear_border(labels=labels) > 0
      return holes
docs: r"""
      This identifies all pore (or solid) voxels that are not connected to the
      edge of the image.  This can be used to find blind pores, or remove
      artifacts such as solid phase voxels that are floating in space.
  
      Parameters
      ----------
      im : ND-image
          A Boolean image, with True values indicating the phase for which
          disconnected voxels are sought.
  
      conn : int
          For 2D the options are 4 and 8 for square and diagonal neighbors, while
          for the 3D the options are 6 and 26, similarily for square and diagonal
          neighbors.  The default is max
  
      Returns
      -------
      image : ND-array
          An ND-image the same size as ``im``, with True values indicating
          voxels of the phase of interest (i.e. True values in the original
          image) that are not connected to the outer edges.
  
      Notes
      -----
      image : ND-array
          The returned array (e.g. ``holes``) be used to trim blind pores from
          ``im`` using: ``im[holes] = False``