br.usp.ime.klava.segmentit.structures
Class PrimitiveCatchmentBasinsGraph

java.lang.Object
  extended by br.usp.ime.klava.segmentit.structures.PrimitiveCatchmentBasinsGraph

public class PrimitiveCatchmentBasinsGraph
extends java.lang.Object

Represents a graph where the vertices are PrimitiveCatchmentBasins.

Author:
Bruno Klava

Constructor Summary
PrimitiveCatchmentBasinsGraph(java.awt.image.BufferedImage image, Connectivity connectivity)
          Constructs a region adjacency graph derived from image and connectivity, where there is a primitive catchment basin for each regional minima of image (classical watershed partition).
PrimitiveCatchmentBasinsGraph(java.awt.image.BufferedImage image, int thresholdLevel, Connectivity connectivity)
          Constructs a region adjacency graph derived from image and connectivity, where there is a primitive catchment basin for each connected component of the threshold at level thresholdLevel of image (the threshold of image is utilized as markers in the watershed from markers algorithm).
PrimitiveCatchmentBasinsGraph(PrimitiveCatchmentBasinsGraph graph, java.awt.image.BufferedImage originalImage)
          Derives a PrimitiveCatchmentBasinsGraph with the same structure of the given graph, but with the gray levels of the pixels in the originalImage.
 
Method Summary
 int[] distanceToTheBorders(int[] labels)
          Returns the distance of each vertex to the borders of the partition derived from labels.
 PrimitiveCatchmentBasin getBasin(int label)
          Returns the vertex labeled by label.
 java.awt.image.BufferedImage getBasinsImage(ColorSpace colorSpace)
          Returns an image with each PrimitiveCatchmentBasin painted with a unique color.
 Connectivity getConnectivity()
          Returns the adjacency relation between pixels used to build the primitive catchment basins of this graph.
 Pixel getGeneratorPixelBetween(PrimitiveCatchmentBasin basin1, PrimitiveCatchmentBasin basin2)
          Returns the pixel of basin1 that generated the edge linking basin1 to basin2.
 int getHeight()
          Returns the height of the image represented by this graph.
 java.util.List<Edge> getIncidentEdges(int label)
          Returns a List of Edges that links the vertex labeled by label to its neighbors.
 java.util.List<Edge> getIncidentEdges(PrimitiveCatchmentBasin basin)
          Returns a List of Edges that links basin to its neighbors.
 int getNumVertices()
          Returns the number of vertices of this graph.
 java.util.List<Edge> getOrderedEdges()
          Returns a List with the edges of this graph, ordered by their weights.
 PrimitiveCatchmentBasin[] getPathsFromBasin(PrimitiveCatchmentBasin basin, int[] labels)
          Returns the predecessors map that defined the paths from basin to all other basins of the same label as it (within the region of interest)
 Pixel[][] getPixels()
          Returns the pixels of the image represented by this graph.
 java.util.List<PrimitiveCatchmentBasin> getVertices()
          Returns a List with the vertices of this graph.
 int getWidth()
          Returns the width of the image represented by this graph.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PrimitiveCatchmentBasinsGraph

public PrimitiveCatchmentBasinsGraph(java.awt.image.BufferedImage image,
                                     Connectivity connectivity)
                              throws ColorImageException
Constructs a region adjacency graph derived from image and connectivity, where there is a primitive catchment basin for each regional minima of image (classical watershed partition).

Parameters:
image - the input image
connectivity - the adjacency relation between pixels to be used to build the primitive catchment basins of this graph
Throws:
ColorImageException

PrimitiveCatchmentBasinsGraph

public PrimitiveCatchmentBasinsGraph(PrimitiveCatchmentBasinsGraph graph,
                                     java.awt.image.BufferedImage originalImage)
                              throws ColorImageException
Derives a PrimitiveCatchmentBasinsGraph with the same structure of the given graph, but with the gray levels of the pixels in the originalImage.

Parameters:
graph - the PrimitiveCatchmentBasinsGraph from which the new PrimitiveCatchmentBasinsGraph will be derived
originalImage - the image to get the gray levels from
Throws:
ColorImageException - if originalImage is a color image

PrimitiveCatchmentBasinsGraph

public PrimitiveCatchmentBasinsGraph(java.awt.image.BufferedImage image,
                                     int thresholdLevel,
                                     Connectivity connectivity)
                              throws ColorImageException
Constructs a region adjacency graph derived from image and connectivity, where there is a primitive catchment basin for each connected component of the threshold at level thresholdLevel of image (the threshold of image is utilized as markers in the watershed from markers algorithm).

Parameters:
image - the input image
thresholdLevel - a threshold level to be used to select markers for the partition
connectivity - the adjacency relation between pixels to be used to build the primitive catchment basins of this graph
Throws:
ColorImageException
Method Detail

getNumVertices

public int getNumVertices()
Returns the number of vertices of this graph.

Returns:
the number of vertices of this graph

getVertices

public java.util.List<PrimitiveCatchmentBasin> getVertices()
Returns a List with the vertices of this graph.

Returns:
a List with the vertices of this graph

getOrderedEdges

public java.util.List<Edge> getOrderedEdges()
Returns a List with the edges of this graph, ordered by their weights.

Returns:
a List with the edges of this graph

getIncidentEdges

public java.util.List<Edge> getIncidentEdges(int label)
Returns a List of Edges that links the vertex labeled by label to its neighbors.

Parameters:
label - the label associated to a vertex
Returns:
a List of Edges that links the vertex labeled by label to its neighbors

getIncidentEdges

public java.util.List<Edge> getIncidentEdges(PrimitiveCatchmentBasin basin)
Returns a List of Edges that links basin to its neighbors.

Parameters:
basin - a vertex of this graph
Returns:
a List of Edges that links basin to its neighbors

distanceToTheBorders

public int[] distanceToTheBorders(int[] labels)
Returns the distance of each vertex to the borders of the partition derived from labels.

Parameters:
labels - a labeling of the vertices of this graph
Returns:
the distance of each vertex to the borders

getPathsFromBasin

public PrimitiveCatchmentBasin[] getPathsFromBasin(PrimitiveCatchmentBasin basin,
                                                   int[] labels)
Returns the predecessors map that defined the paths from basin to all other basins of the same label as it (within the region of interest)

Parameters:
basin - a PrimitiveCatchmentBasin from which the paths will be computed
labels - the labeling that defines the regions of interest in this graph
Returns:
the predecessors maps defining paths from basin to the others nodes in the same region of interest

getGeneratorPixelBetween

public Pixel getGeneratorPixelBetween(PrimitiveCatchmentBasin basin1,
                                      PrimitiveCatchmentBasin basin2)
Returns the pixel of basin1 that generated the edge linking basin1 to basin2.

Parameters:
basin1 - a vertex of this graph
basin2 - another vertex of this graph
Returns:
the pixel of basin1 that generated the edge linking basin1 to basin2

getPixels

public Pixel[][] getPixels()
Returns the pixels of the image represented by this graph.

Returns:
the pixels of the image represented by this graph

getBasin

public PrimitiveCatchmentBasin getBasin(int label)
Returns the vertex labeled by label.

Parameters:
label - the label of a primitive catchment basin that is a vertex of this graph
Returns:
the primitive catchment basin labeled by label, null if label is an invalid label

getHeight

public int getHeight()
Returns the height of the image represented by this graph.

Returns:
the height of the image represented by this graph

getWidth

public int getWidth()
Returns the width of the image represented by this graph.

Returns:
the width of the image represented by this graph

getConnectivity

public Connectivity getConnectivity()
Returns the adjacency relation between pixels used to build the primitive catchment basins of this graph.

Returns:
the adjacency relation between pixels used to build the primitive catchment basins of this graph

getBasinsImage

public java.awt.image.BufferedImage getBasinsImage(ColorSpace colorSpace)
Returns an image with each PrimitiveCatchmentBasin painted with a unique color.

Returns:
an image with each PrimitiveCatchmentBasin painted