Class RegionAdjacencyGraph

java.lang.Object
inra.ijpb.label.RegionAdjacencyGraph

public class RegionAdjacencyGraph
extends java.lang.Object

Contains several methods for extracting the set of adjacencies between regions in a label image.

The value zero is assumed to be background, and is not computed for adjacencies. Moreover, in order to take into account label images obtained after a watershed transform, adjacencies are computed by comparing label values with the values of neighbors shifted by two pixels in the X, Y or Z directions.

Usage:


 // create demo image with four regions, and four adjacencies 
 byte[] data = new byte[]{
 			1, 1, 1, 0, 2, 2, 
 			1, 1, 1, 0, 2, 2, 
 			0, 0, 0, 0, 2, 2, 
 			3, 3, 0, 0, 0, 0,  
 			3, 3, 0, 4, 4, 4,  
 			3, 3, 0, 4, 4, 4};
 ImageProcessor image = new ByteProcessor(6, 6, data);
 	
 // compute adjacencies, and return result as a set of label pairs
 Set<RegionAdjacencyGraph.LabelPair> adjacencies =
     RegionAdjacencyGraph.computeAdjacencies(image);
 
 // display which regions are adjacent 
 for (RegionAdjacencyGraph.LabelPair pair : adjacencies)
 {
     System.out.println("(" + pair.label1 + "," + pair.label2 + ")");
 }
 
Author:
dlegland
  • Nested Class Summary

    Nested Classes
    Modifier and Type Class Description
    static class  RegionAdjacencyGraph.LabelPair
    Used to stores the adjacency information between two regions.
  • Method Summary

    Modifier and Type Method Description
    static java.util.Set<RegionAdjacencyGraph.LabelPair> computeAdjacencies​(ij.ImagePlus image)
    Returns the set of region adjacencies in an ImagePlus, that can contains either an ImageProcessor or an ImageStack.
    static java.util.Set<RegionAdjacencyGraph.LabelPair> computeAdjacencies​(ij.ImageStack image)
    Returns the set of region adjacencies in an ImageProcessor of labels.
    static java.util.Set<RegionAdjacencyGraph.LabelPair> computeAdjacencies​(ij.process.ImageProcessor image)
    Returns the set of region adjacencies in an ImageProcessor of labels.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • computeAdjacencies

      public static final java.util.Set<RegionAdjacencyGraph.LabelPair> computeAdjacencies​(ij.ImagePlus image)
      Returns the set of region adjacencies in an ImagePlus, that can contains either an ImageProcessor or an ImageStack.
      Parameters:
      image - an ImagePlus containing a 2D or 3D label image
      Returns:
      the set of adjacencies within the image
    • computeAdjacencies

      public static final java.util.Set<RegionAdjacencyGraph.LabelPair> computeAdjacencies​(ij.process.ImageProcessor image)
      Returns the set of region adjacencies in an ImageProcessor of labels.
      Parameters:
      image - an ImageProcesor containing a label image
      Returns:
      the set of adjacencies within the image
    • computeAdjacencies

      public static final java.util.Set<RegionAdjacencyGraph.LabelPair> computeAdjacencies​(ij.ImageStack image)
      Returns the set of region adjacencies in an ImageProcessor of labels.
      Parameters:
      image - an ImageProcesor containing a label image
      Returns:
      the set of adjacencies within the image