code: def __skeleton_difference(graph, image, boundary_term, spacing):
      """
      A skeleton for the calculation of intensity difference based boundary terms.
  
      Iterates over the images dimensions and generates for each an array of absolute
      neighbouring voxel :math:`(p, q)` intensity differences :math:`|I_p, I_q|`. These are
      then passed to the supplied function :math:`g(\cdot)` for for boundary term
      computation. Finally the returned edge weights are added to the graph.
  
      Formally for each edge :math:`(p, q)` of the image, their edge weight is computed as
  
      .. math::
  
          w(p,q) = g(|I_p - I_q|)
  
      ,where :math:`g(\cdot)` is the supplied boundary term function.
  
      The boundary term function has to take an array of intensity differences as only
      parameter and return an array of the same shape containing the edge weights. For the
      implemented function the condition :math:`g(\cdot)\in(0, 1]` must hold true, i.e., it
      has to be strictly positive with :math:`1` as the upper limit.
  
      @note the underlying neighbourhood connectivity is 4 for 2D, 6 for 3D, etc.
  
      @note This function is able to work with images of arbitrary dimensions, but was only
      tested for 2D and 3D cases.
  
      @param graph An initialized graph.GCGraph object
      @type graph.GCGraph
      @param image The image to compute on
      @type image numpy.ndarray
      @param boundary_term A function to compute the boundary term over an array of
                           absolute intensity differences
      @type boundary_term function
      @param spacing A sequence containing the slice spacing used for weighting the
                     computed neighbourhood weight value for different dimensions. If
                     False, no distance based weighting of the graph edges is performed.
      @param spacing sequence | False
      """
  
      def intensity_difference(neighbour_one, neighbour_two):
          """
          Takes two voxel arrays constituting neighbours and computes the absolute
          intensity differences.
          """
          return scipy.absolute(neighbour_one - neighbour_two)
  
      __skeleton_base(
          graph, image, boundary_term, intensity_difference, spacing
      )
  
file_path: medpy/medpy/graphcut/energy_voxel.py
imports: import sys
  import numpy
  import scipy
  import math
label_desc: Use image node_id 11 for calling a global function with example usage: __skeleton_difference(graph, image, boundary_term, spacing) and returns: scipy