Class FloodFillComponentsLabeling

java.lang.Object
inra.ijpb.algo.AlgoStub
inra.ijpb.binary.conncomp.FloodFillComponentsLabeling
All Implemented Interfaces:
Algo, ConnectedComponentsLabeling

public class FloodFillComponentsLabeling
extends AlgoStub
implements ConnectedComponentsLabeling
Computes the labels of the connected components in a binary image. The type of result is controlled by the bitDepth option. Uses a Flood-fill type algorithm. The image pixels are iterated, and each time a foreground pixel not yet associated with a label is encountered, its connected component is associated with a new label. Example of use:

    int conn = 4;
    int bitDepth = 16;
    ConnectedComponentsLabeling algo = new FloodFillComponentsLabeling(conn, bitDepth);
    DefaultAlgoListener.monitor(algo);
    ImageProcessor labels = algo.computeLabels(image);
    // or:
    FloodFillComponentsLabeling.Result res = algo.computeResult(image);
    ImageProcessor labels = res.labelMap; 
 
Author:
dlegland
See Also:
FloodFillComponentsLabeling3D, FloodFill
  • Nested Class Summary

    Nested Classes
    Modifier and Type Class Description
    class  FloodFillComponentsLabeling.Result
    Data class that stores result of connected component labeling.
  • Constructor Summary

    Constructors
    Constructor Description
    FloodFillComponentsLabeling()
    Constructor with default connectivity 4 and default output bitdepth equal to 16.
    FloodFillComponentsLabeling​(int connectivity)
    Constructor specifying the connectivity and using default output bitdepth equal to 16.
    FloodFillComponentsLabeling​(int connectivity, int bitDepth)
    Constructor specifying the connectivity and the bitdepth of result label image
  • Method Summary

    Modifier and Type Method Description
    ij.process.ImageProcessor computeLabels​(ij.process.ImageProcessor image)
    Computes labels corresponding to connected components in input image.
    FloodFillComponentsLabeling.Result computeResult​(ij.process.ImageProcessor image)
    Computes connected components labeling on the input binary image, and returns the results encapsulated into a Result class together with the largest label index.
    static int largestPossibleLabel​(int bitDepth)
    Returns the largest possible label that can be obtained given the specified bit-depth.

    Methods inherited from class inra.ijpb.algo.AlgoStub

    addAlgoListener, removeAlgoListener

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface inra.ijpb.algo.Algo

    addAlgoListener, removeAlgoListener
  • Constructor Details

    • FloodFillComponentsLabeling

      public FloodFillComponentsLabeling()
      Constructor with default connectivity 4 and default output bitdepth equal to 16.
    • FloodFillComponentsLabeling

      public FloodFillComponentsLabeling​(int connectivity)
      Constructor specifying the connectivity and using default output bitdepth equal to 16.
      Parameters:
      connectivity - the connectivity of connected components (4 or 8)
    • FloodFillComponentsLabeling

      public FloodFillComponentsLabeling​(int connectivity, int bitDepth)
      Constructor specifying the connectivity and the bitdepth of result label image
      Parameters:
      connectivity - the connectivity of connected components (4 or 8)
      bitDepth - the bit depth of the result (8, 16, or 32)
  • Method Details

    • largestPossibleLabel

      public static final int largestPossibleLabel​(int bitDepth)
      Returns the largest possible label that can be obtained given the specified bit-depth. The value of the largest possible label is usually obtained by 2^bitdepth-1.
      Parameters:
      bitDepth - the bit-depth of the ImageProcessor used for storing labels. Must be either 8, 16 or 32.
      Returns:
      the largest possible label that can be obtained with the given bit-depth.
    • computeLabels

      public ij.process.ImageProcessor computeLabels​(ij.process.ImageProcessor image)
      Description copied from interface: ConnectedComponentsLabeling
      Computes labels corresponding to connected components in input image.
      Specified by:
      computeLabels in interface ConnectedComponentsLabeling
      Parameters:
      image - binary image containing components
      Returns:
      the label image of the components
    • computeResult

      public FloodFillComponentsLabeling.Result computeResult​(ij.process.ImageProcessor image)
      Computes connected components labeling on the input binary image, and returns the results encapsulated into a Result class together with the largest label index.
      Parameters:
      image - the input binary image
      Returns:
      an instance of the Result class that can be used to retrieve the label map.