Class Component<T>

java.lang.Object
imagingbook.common.mser.components.Component<T>
Type Parameters:
T - the type of properties that can be attached to instances of this class

public class Component<T> extends Object
This class represents a connected component (i.e., a binary image region). Instances of this class form the nodes of a ComponentTree.
Version:
2022/11/19
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    final int
    The ID number of this component (only used for debugging).
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Component(int level, int id)
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns a collection of all pixels of this component, including the component's local pixels and the pixels of all child components.
    Returns a collection of all pixels contained in the children of this component.
    Returns the list of this component's child components.
    int
    Returns the height of the sub-tree which this component is the root of.
    int
    Returns the level (max.
    Returns a list of "local" pixels that directly belong to this component All these pixels have the same 'level' as the component itself.
    Returns the parent component of this component (null if this node is the tree's root).
    Returns the properties attached to this component.
    int
    Returns the size (number of pixels) of this component.
    boolean
    Returns true if this component represents an extremal region.
    boolean
    Returns true if this component is the root of the associated ComponentTree.
    void
    setProperties(T properties)
    Sets the properties of this component.
    static void
    sortByLevel(List<? extends Component<?>> components)
    Sorts a list of Components by (increasing) component level, i.e., the component with the lowest level becomes the first.
    static void
    sortBySize(List<? extends Component<?>> components)
    Sorts a list of Components by (decreasing) component size, i.e., the largest component (with the most pixels) becomes the first.
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • ID

      public final int ID
      The ID number of this component (only used for debugging).
  • Constructor Details

    • Component

      protected Component(int level, int id)
      Constructor.
      Parameters:
      level - the maximum pixel value in this component
      id - a unique component id (assigned by the factory)
  • Method Details

    • getParent

      public Component<T> getParent()
      Returns the parent component of this component (null if this node is the tree's root).
      Returns:
      the parent component
    • getSize

      public int getSize()
      Returns the size (number of pixels) of this component.
      Returns:
      the size of this component
    • getChildren

      Returns the list of this component's child components.
      Returns:
      a (possibly empty) list of components, never null
    • getLevel

      public int getLevel()
      Returns the level (max. gray value) of this component.
      Returns:
      the component's level
    • getHeight

      public int getHeight()
      Returns the height of the sub-tree which this component is the root of.
      Returns:
      the height of the sub-tree rooted by this component
    • getLocalPixels

      Returns a list of "local" pixels that directly belong to this component All these pixels have the same 'level' as the component itself.
      Returns:
      the component's local pixels
    • getAllPixels

      Returns a collection of all pixels of this component, including the component's local pixels and the pixels of all child components. Not needed in actual code, used only for debugging.
      Returns:
      all pixels contained in this component
    • getChildPixels

      Returns a collection of all pixels contained in the children of this component.
      Returns:
      all pixels from child components
    • setProperties

      public void setProperties(T properties)
      Sets the properties of this component.
      Parameters:
      properties - a property object (of type T)
    • getProperties

      public T getProperties()
      Returns the properties attached to this component.
      Returns:
      the properties attached to this component
    • isRoot

      public boolean isRoot()
      Returns true if this component is the root of the associated ComponentTree.
      Returns:
      true if this component is the root
    • isExtremal

      public boolean isExtremal()
      Returns true if this component represents an extremal region.
      Returns:
      true if the component is extremal
    • sortBySize

      public static void sortBySize(List<? extends Component<?>> components)
      Sorts a list of Components by (decreasing) component size, i.e., the largest component (with the most pixels) becomes the first.
      Parameters:
      components - a list of Component instances
    • sortByLevel

      public static void sortByLevel(List<? extends Component<?>> components)
      Sorts a list of Components by (increasing) component level, i.e., the component with the lowest level becomes the first.
      Parameters:
      components - a list of Component instances
    • toString

      public String toString()
      Overrides:
      toString in class Object