jjil.algorithm
Class GrayConnComp

java.lang.Object
  extended by jjil.algorithm.GrayConnComp

public class GrayConnComp
extends java.lang.Object

Gray connected components. Input is a Gray8Image. Pixels with value Byte.MIN_VALUE are taken to be background. Other connected pixels are labeled with unique labels. The connected component image can be retrieved, as can the connected component bounding rectangles, sorted by area.

Author:
webb

Constructor Summary
GrayConnComp()
          Creates a new instance of GrayConnComp.
 
Method Summary
 Rect getComponent(int nComponent)
          Returns the nComponent'th bounding rectangle in order by size.
 int getComponents()
          Get the number of connected components in the labeled image.
 Gray16Image getLabeledImage()
          Get the labeled image
 void push(Image image)
          Compute connected components of input gray image using a union-find algorithm.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GrayConnComp

public GrayConnComp()
Creates a new instance of GrayConnComp.

Method Detail

getComponent

public Rect getComponent(int nComponent)
                  throws Error
Returns the nComponent'th bounding rectangle in order by size. Sorts only as many components as are necessary to reach the requested component. Does this by observing the state of rSortedLabels. If it is null, it has to be allocated. If the nComponent'th element is null, more need to be copied from pqLabels. This is done by copying and deleting the minimum element until we reach the requested component.

Parameters:
nComponent - the number of the component to return.
Returns:
the nComponent'th bounding rectangle, ordered by pixel count, largest first
Throws:
Error - if nComponent is greater than the number of components available.

getComponents

public int getComponents()
                  throws Error
Get the number of connected components in the labeled image. Computes the components from the labeled image if necessary.

Returns:
the number of connected components.
Throws:
Error - if BinaryHeap returns jjil.core.Error due to coding error.

getLabeledImage

public Gray16Image getLabeledImage()
Get the labeled image

Returns:
a Gray16Image with final labels assigned to every pixel

push

public void push(Image image)
          throws Error
Compute connected components of input gray image using a union-find algorithm.

Parameters:
image - the input image.
Throws:
Error - if the image is not a gray 8-bit image.