How to use the dijkstra3d.euclidean_distance_field function in dijkstra3d

To help you get started, we’ve selected a few dijkstra3d examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github seung-lab / kimimaro / kimimaro / trace.py View on Github external
if root is None:
    if soma_mode:
      root = find_soma_root(DBF, dbf_max)    
      soma_radius = dbf_max * soma_invalidation_scale + soma_invalidation_const
    else:
      root = find_root(labels, anisotropy)
      
  if root is None:
    return PrecomputedSkeleton()
 
  # DBF: Distance to Boundary Field
  # DAF: Distance from any voxel Field (distance from root field)
  # PDRF: Penalized Distance from Root Field
  DBF = kimimaro.skeletontricks.zero2inf(DBF) # DBF[ DBF == 0 ] = np.inf
  DAF = dijkstra3d.euclidean_distance_field(labels, root, anisotropy=anisotropy)
  DAF = kimimaro.skeletontricks.inf2zero(DAF) # DAF[ DAF == np.inf ] = 0
  PDRF = compute_pdrf(dbf_max, pdrf_scale, pdrf_exponent, DBF, DAF)

  # Use dijkstra propogation w/o a target to generate a field of
  # pointers from each voxel to its parent. Then we can rapidly
  # compute multiple paths by simply hopping pointers using path_from_parents
  if not fix_branching:
    parents = dijkstra3d.parental_field(PDRF, root)
    del PDRF
  else:
    parents = PDRF

  if soma_mode:
    invalidated, labels = kimimaro.skeletontricks.roll_invalidation_ball(
      labels, DBF, np.array([root], dtype=np.uint32),
      scale=soma_invalidation_scale,
github seung-lab / kimimaro / kimimaro / trace.py View on Github external
def find_root(labels, anisotropy):
  """
  "4.4 DAF:  Compute distance from any voxel field"
  Compute DAF, but we immediately convert to the PDRF
  The extremal point of the PDRF is a valid root node
  even if the DAF is computed from an arbitrary pixel.
  """
  any_voxel = kimimaro.skeletontricks.first_label(labels)   
  if any_voxel is None: 
    return None

  DAF = dijkstra3d.euclidean_distance_field(
    np.asfortranarray(labels), any_voxel, anisotropy=anisotropy)
  return kimimaro.skeletontricks.find_target(labels, DAF)

dijkstra3d

Implementation of Dijkstra's Shortest Path algorithm on 3D images.

GPL-3.0
Latest version published 6 months ago

Package Health Score

63 / 100
Full package analysis

Similar packages