Class ConnectedTwoRowSpeckleFiller<T extends ImageGray<T>>

java.lang.Object
boofcv.alg.segmentation.cc.ConnectedTwoRowSpeckleFiller<T>
All Implemented Interfaces:
ConnectedSpeckleFiller<T>
Direct Known Subclasses:
ConnectedTwoRowSpeckleFiller_F32, ConnectedTwoRowSpeckleFiller_U8

public abstract class ConnectedTwoRowSpeckleFiller<T extends ImageGray<T>> extends Object implements ConnectedSpeckleFiller<T>
Searches for small clusters (or blobs) of connected pixels and then fills them in with the specified fill color. Two pixels are considered to be connected if their intensity value is within the specified tolerance of each other. No pixel can be connected to a pixel with the value of a fill color. A connect-4 rule is used to determine the local neighborhood of a pixel. This algorithm has been optimized for speed and low memory. Memory usage is approximately O(W) where W is the width of the image and has an approximate runtime of O(W*H). As long as the fill in regions are small this approximation will be accurate. The algorithm works by considering two rows at a time. Each row is initially processed independently and sets of connected pixels are found. Then the connectivity is found between the first row to the second row. A merge directed graph is built to handle potential many to one mappings from regions in the first row to the second row. Once this is complete the second row is updated by merging and by adding the region size counts. Any region in the first row with no match in the second row is declared complete as it's impossible to grow any more. When a region is complete the number of pixels in it is then considered. if it's less than the threshold it will be filled in by doing a depth first search starting from a pixel in the first row. See BoofCV Tech Report BLAH.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected int
    Number of clusters that were filed in
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected abstract void
    fillCluster(int seedX, int seedY, int clusterSize)
    Fill cluster by performing a search of connected pixels.
    protected abstract void
    findConnectionsBetweenRows(int startRowA, int startRowB)
    Compres pxiel values between the two rows to find the mapping between the regions.
    int
    Returns the number of filled in regions
    protected abstract void
    initTypeSpecific(double similarTol, double fillValue)
     
    protected abstract int
    labelRow(int idx0, int[] labels, int[] labelCount, int[] locationX)
    Applies connectivity rule along a single row in 1D
    void
    process(T image, int maximumArea, double _similarTol, double _fillValue)
    Finds non-smooth regions and fills them in with the fill value.
    protected final int
    traverseToEnd(int labelB)
    Traverses the graph until it hits an end point then and returns the end point/root.

    Methods inherited from class java.lang.Object

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

    Methods inherited from interface boofcv.alg.segmentation.cc.ConnectedSpeckleFiller

    getImageType
  • Field Details

    • totalFilled

      protected int totalFilled
      Number of clusters that were filed in
  • Constructor Details

    • ConnectedTwoRowSpeckleFiller

      public ConnectedTwoRowSpeckleFiller()
  • Method Details

    • process

      public void process(T image, int maximumArea, double _similarTol, double _fillValue)
      Finds non-smooth regions and fills them in with the fill value. Uses 4-connect rule.
      Specified by:
      process in interface ConnectedSpeckleFiller<T extends ImageGray<T>>
      Parameters:
      image - (Input, Output) Image which is searched for speckle noise which is then filled in
      maximumArea - (Input) All regions with this number of pixels or fewer will be filled in.
      _similarTol - (Input) Two pixels are connected if their different in value is ≤ than this.
      _fillValue - (Input) The value that small regions are filled in with.
    • initTypeSpecific

      protected abstract void initTypeSpecific(double similarTol, double fillValue)
    • labelRow

      protected abstract int labelRow(int idx0, int[] labels, int[] labelCount, int[] locationX)
      Applies connectivity rule along a single row in 1D
      Parameters:
      labels - Array that stores labels
      labelCount - Array that stores label counts
      Returns:
      number of clusters
    • findConnectionsBetweenRows

      protected abstract void findConnectionsBetweenRows(int startRowA, int startRowB)
      Compres pxiel values between the two rows to find the mapping between the regions. This is also where "finished" regions in A are identified.
      Parameters:
      startRowA - Index of row in image array
      startRowB - Index of row in image array
    • traverseToEnd

      protected final int traverseToEnd(int labelB)
      Traverses the graph until it hits an end point then and returns the end point/root.
    • fillCluster

      protected abstract void fillCluster(int seedX, int seedY, int clusterSize)
      Fill cluster by performing a search of connected pixels. This step can be slow and a memory hog if the regions are large. It's also effectively the naive algorithm
    • getTotalFilled

      public int getTotalFilled()
      Description copied from interface: ConnectedSpeckleFiller
      Returns the number of filled in regions
      Specified by:
      getTotalFilled in interface ConnectedSpeckleFiller<T extends ImageGray<T>>