Class MergeSmallRegions<T extends ImageBase<T>>

All Implemented Interfaces:

public class MergeSmallRegions<T extends ImageBase<T>>
extends RegionMergeTree
Finds regions which are too small and merges them with a neighbor that is the most similar to it and connected. The process is repeated until there are no more regions below the size threshold. How similar two neighbors are is determined using each region's average color. Connectivity is determined using a 4-connect rule.
  • Field Details

  • Constructor Details

    • MergeSmallRegions

      public MergeSmallRegions​(int minimumSize, ConnectRule rule, ComputeRegionMeanColor<T> computeColor)
      minimumSize - Minimum number of pixels a region must have for it to not be pruned.
      computeColor - Computes the color of each region
  • Method Details

    • setMinimumSize

      public void setMinimumSize​(int minimumSize)
    • process

      public void process​(T image, GrayS32 pixelToRegion, DogArray_I32 regionMemberCount, DogArray<float[]> regionColor)
      Merges together smaller regions. Segmented image, region member count, and region color are all updated.
      image - Input image. Used to compute color of each region
      pixelToRegion - (input/output) Segmented image with the ID of each region. Modified.
      regionMemberCount - (input/output) Number of members in each region Modified.
      regionColor - (Output) Storage for colors of each region. Will contains the color of each region on output.
    • setupPruneList

      protected boolean setupPruneList​(DogArray_I32 regionMemberCount)
      Identifies which regions are to be pruned based on their member counts. Then sets up data structures for graph and converting segment ID to prune ID.
      true If elements need to be pruned and false if not.
    • findAdjacentRegions

      protected void findAdjacentRegions​(GrayS32 pixelToRegion)
      Go through each pixel in the image and examine its neighbors according to a 4-connect rule. If one of the pixels is in a region that is to be pruned mark them as neighbors. The image is traversed such that the number of comparisons is minimized.
    • adjacentInner4

      protected void adjacentInner4​(GrayS32 pixelToRegion)
    • adjacentInner8

      protected void adjacentInner8​(GrayS32 pixelToRegion)
    • adjacentBorder

      protected void adjacentBorder​(GrayS32 pixelToRegion)
    • selectMerge

      protected void selectMerge​(int pruneId, FastAccess<float[]> regionColor)
      Examine edges for the specified node and select node which it is the best match for it to merge with
      pruneId - The prune Id of the segment which is to be merged into another segment
      regionColor - List of region colors