code: def boundary_maximum_linear(graph, xxx_todo_changeme1):
      r"""
      Boundary term processing adjacent voxels maximum value using a linear relationship.
  
      An implementation of a boundary term, suitable to be used with the
      `~medpy.graphcut.generate.graph_from_voxels` function.
  
      The same as `boundary_difference_linear`, but working on the gradient image instead
      of the original. See there for details.
  
      Parameters
      ----------
      graph : GCGraph
          The graph to add the weights to.
      gradient_image : ndarray
          The gradient image.
      spacing : sequence of float or False
          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.
  
      Notes
      -----
      This function requires the gradient image to be passed along. That means that
      `~medpy.graphcut.generate.graph_from_voxels` has to be called with ``boundary_term_args`` set to the
      gradient image.
      """
      (gradient_image, spacing) = xxx_todo_changeme1
      gradient_image = scipy.asarray(gradient_image)
  
      # compute maximum intensity to encounter
      max_intensity = float(numpy.abs(gradient_image).max())
  
      def boundary_term_linear(intensities):
          """
          Implementation of a linear boundary term computation over an array.
          """
          # normalize the intensity distances to the interval (0, 1]
          intensities /= max_intensity
          # difference_to_neighbour[difference_to_neighbour > 1] = 1 # this line should not be required, but might be due to rounding errors
          intensities = (
              1.0 - intensities
          )  # reverse weights such that high intensity difference lead to small weights and hence more likely to a cut at this edge
          intensities[
              intensities == 0.0
          ] = sys.float_info.min  # required to avoid zero values
          return intensities
  
      __skeleton_maximum(
          graph, gradient_image, boundary_term_linear, spacing
      )
  
file_path: medpy/medpy/graphcut/energy_voxel.py
imports: import sys
  import numpy
  import scipy
  import math
label_desc: Use image node_id 2 for calling a global function with example usage: boundary_maximum_linear(graph, xxx_todo_changeme1) and returns: intensities