class_docstr: Executes the complete pipeline of the graph cut algorithm, checking the results.
class_docstr_tok: ["Executes","the","complete","pipeline","of","the","graph","cut","algorithm",",","checking","the","results","."]
docstr: Executes the complete pipeline of the graph cut algorithm.
docstr_tok: ["Executes","the","complete","pipeline","of","the","graph","cut","algorithm","."]
code: def test_voxel_based(self):
      """Executes the complete pipeline of the graph cut algorithm."""
      # create the graph from the image
      original_image = scipy.asarray(self.__voriginal_image)
      graph = graph_from_voxels(
          scipy.asarray(self.__vfg_markers),
          scipy.asarray(self.__vbg_markers),
          boundary_term=boundary_difference_linear,
          boundary_term_args=(original_image, False),
      )
  
      # execute min-cut / executing BK_MFMC
      try:
          maxflow = graph.maxflow()
      except Exception as e:
          self.fail(
              "An error was thrown during the external executions: {}".format(
                  e.message
              )
          )
  
      # reshape results to form a valid mask
      result = scipy.zeros(original_image.size, dtype=scipy.bool_)
      for idx in range(len(result)):
          result[idx] = (
              0 if graph.termtype.SINK == graph.what_segment(idx) else 1
          )
      result = result.reshape(original_image.shape)
  
      # check results for validity
      self.assertTrue(
          (result == scipy.asarray(self.__vexpected)).all(),
          "Resulting voxel-based cut is different than expected.",
      )
      self.assertEqual(
          maxflow,
          self.__vmaxflow,
          "The resulting maxflow {} differs from the expected one {}.".format(
              maxflow, self.__vmaxflow
          ),
      )
  
file_path: medpy/tests/graphcut_/cut.py
imports: import unittest
  from medpy.graphcut import graph_from_labels, GraphDouble, Graph, graph_from_voxels
  from medpy.graphcut.energy_voxel import boundary_difference_linear
  from medpy import filter
  import scipy
label_desc: Use image node_id 1 for calling the TestCut obj's underlying member method code with example usage: obj.test_voxel_based() without return types