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
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
FieldsModifier and TypeFieldDescriptionfinal int
The ID number of this component (only used for debugging). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns 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
getLevel()
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
getSize()
Returns the size (number of pixels) of this component.boolean
Returnstrue
if this component represents an extremal region.boolean
isRoot()
Returnstrue
if this component is the root of the associatedComponentTree
.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.toString()
-
Field Details
-
ID
The ID number of this component (only used for debugging).
-
-
Constructor Details
-
Component
Constructor.- Parameters:
level
- the maximum pixel value in this componentid
- a unique component id (assigned by the factory)
-
-
Method Details
-
getParent
Returns the parent component of this component (null
if this node is the tree's root).- Returns:
- the parent component
-
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
Returns the level (max. gray value) of this component.- Returns:
- the component's level
-
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
Sets the properties of this component.- Parameters:
properties
- a property object (of type T)
-
getProperties
Returns the properties attached to this component.- Returns:
- the properties attached to this component
-
isRoot
Returnstrue
if this component is the root of the associatedComponentTree
.- Returns:
true
if this component is the root
-
isExtremal
Returnstrue
if this component represents an extremal region.- Returns:
true
if the component is extremal
-
sortBySize
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 ofComponent
instances
-
sortByLevel
Sorts a list of Components by (increasing) component level, i.e., the component with the lowest level becomes the first.- Parameters:
components
- a list ofComponent
instances
-
toString
-