org.openimaj.image.processing.watershed
Class Component

java.lang.Object
  extended by org.openimaj.image.processing.watershed.Component
All Implemented Interfaces:
Cloneable

public class Component
extends Object
implements Cloneable

Represents a region or set of pixels (the name is based on the Microsoft paper)

Version:
$Author$, $Revision$, $Date$
Author:
David Dupplaw , Jonathon Hare

Field Summary
 ComponentFeature[] features
          List of features representing this component
 boolean isMSER
          Whether this component represents an MSER
 IntValuePixel pivot
          The pivot pixel
 
Constructor Summary
Component(IntValuePixel p, Class<? extends ComponentFeature>... featureClasses)
          Default constructor.
 
Method Summary
 void accumulate(IntValuePixel p)
          Add a pixel to the component
 Component clone()
           
<T extends ComponentFeature>
T
getFeature(Class<T> featureClass)
          Get the feature matching the given class if it exists.
 ComponentFeature getFeature(int index)
          Get the feature at the given index
 Set<Pixel> getPixels()
          Get the pixels in the component.
 void merge(Component p)
          Merge another component with this one
 int size()
          The size of the component (i.e.
 String toString()
          
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

isMSER

public boolean isMSER
Whether this component represents an MSER


features

public ComponentFeature[] features
List of features representing this component


pivot

public IntValuePixel pivot
The pivot pixel

Constructor Detail

Component

public Component(IntValuePixel p,
                 Class<? extends ComponentFeature>... featureClasses)
Default constructor.

Parameters:
p - The grey level of the component
featureClasses - the list of features to create for the component
Method Detail

toString

public String toString()

Overrides:
toString in class Object
See Also:
AbstractCollection.toString()

accumulate

public void accumulate(IntValuePixel p)
Add a pixel to the component

Parameters:
p - the pixel to add

merge

public void merge(Component p)
Merge another component with this one

Parameters:
p - the component to merge into this

size

public int size()
The size of the component (i.e. the number of pixels)

Returns:
the size of the component

getPixels

public Set<Pixel> getPixels()
Get the pixels in the component. If the component contains a PixelsFeature then the pixels will be returned from that; otherwise a set containing just the pivot pixel will be returned.

Returns:
the pixels in the component if possible, or just the pivot pixel

clone

public Component clone()
Overrides:
clone in class Object

getFeature

public ComponentFeature getFeature(int index)
Get the feature at the given index

Parameters:
index - the index
Returns:
the feature at the given index or null if it doesn't exist

getFeature

public <T extends ComponentFeature> T getFeature(Class<T> featureClass)
Get the feature matching the given class if it exists. If more than one feature of the given class exists, then the first will be returned.

Type Parameters:
T - the class of the feature
Parameters:
featureClass - the class of the feature
Returns:
the feature with the given class; or null if no feature is found


Copyright © 2011 The University of Southampton. All Rights Reserved.