Class NeighborGraph

Object
NeighborGraph

public class NeighborGraph extends Object
Creates a graph where each vertex represents an ObjectMask and edges between indicate that two objects neighbor each other.

The weight associated with the edge, indicates the number of neighbvoring voxels, which is always a positive integer.

Author:
Owen Feehan
  • Method Details

    • create

      public static GraphWithPayload<ObjectMask,Integer> create(ObjectCollection objects, Extent sceneExtent, boolean preventObjectIntersection, boolean do3D) throws CreateException
      Create the graph with object-masks as vertices, where edges represent the number of neighboring voxels between objects.
      Parameters:
      objects - objects to create a graph of neighbors for, and who become the vertices in the graph.
      sceneExtent - the size of the image, the object-masks exist in.
      preventObjectIntersection - iff true, objects can only be neighbors, if they have no intersecting voxels.
      do3D - if true, the Z-dimension is also considered for neighbors. Otherwise, only the X and Y dimensions.
      Returns:
      the newly created graph.
      Throws:
      CreateException - if any objects are not fully contained in the scene.
    • create

      public static <V> GraphWithPayload<V,Integer> create(List<V> vertices, Function<V,ObjectMask> vertexToObject, Extent sceneExtent, boolean preventObjectIntersection, boolean do3D) throws CreateException
      Like create(ObjectCollection, Extent, boolean, boolean) but extracts objects from a list of elements which form the vertices.
      Type Parameters:
      V - vertex-type from which an object-mask must be derivable.
      Parameters:
      vertices - the elements to construct graph from, each which maps uniquely to an ObjectMask.
      vertexToObject - converts the vertex to a unique object-mask. This function is called repeatedly so should have low computational-cost to call.
      sceneExtent - the size of the image, the object-masks exist in.
      preventObjectIntersection - iff true, objects can only be neighbors, if they have no intersecting voxels.
      do3D - if true, the Z-dimension is also considered for neighbors. Otherwise, only the X and Y dimensions.
      Returns:
      the newly created graph.
      Throws:
      CreateException - if any objects are not fully contained in the scene.