docs: def graphcut_stawiaski(regions, gradient = False, foreground = False, background = False):
      """
      Executes a Stawiaski label graph cut.
      
      Parameters
      ----------
      regions : ndarray
          The regions image / label map.
      gradient : ndarray
          The gradient image.
      foreground : ndarray
          The foreground markers.
      background : ndarray
          The background markers.
          
      Returns
      -------
      segmentation : ndarray
          The graph-cut segmentation result as boolean array.
          
      Raises
      ------
      ArgumentError
          When the supplied data is erroneous.
      """
      # initialize logger
      logger = Logger.getInstance()
      
      # unpack images if required
      # !TODO: This is an ugly hack, especially since it can be seen inside the function definition
      # How to overcome this, since I can not use a wrapper function as the whole thing must be pickable
      if not gradient and not foreground and not background: 
          regions, gradient, foreground, background = regions
      
      # ensure that input images are scipy arrays
      img_region = scipy.asarray(regions)
      img_gradient = scipy.asarray(gradient)
      img_fg = scipy.asarray(foreground, dtype=scipy.bool_)
      img_bg = scipy.asarray(background, dtype=scipy.bool_)
      
      # ensure correctness of supplied images
      if not (img_region.shape == img_gradient.shape == img_fg.shape == img_bg.shape): raise ArgumentError('All supplied images must be of the same shape.')
  
      # recompute the label ids to start from id = 1
      img_region = relabel(img_region)
      
      # generate graph
      gcgraph = graph_from_labels(img_region, img_fg, img_bg, boundary_term = boundary_stawiaski, boundary_term_args = (img_gradient))
      
      # execute min-cut
      maxflow = gcgraph.maxflow() # executes the cut and returns the maxflow value
      
      logger.debug('Graph-cut terminated successfully with maxflow of {}.'.format(maxflow))
      
      # apply results to the region image
      mapping = [0] # no regions with id 1 exists in mapping, entry used as padding
      mapping.extend([0 if gcgraph.termtype.SINK == gcgraph.what_segment(int(x) - 1) else 1 for x in scipy.unique(img_region)])
      img_results = relabel_map(img_region, mapping)
      
      return img_results.astype(scipy.bool_)