de.unihalle.informatik.MiToBo.core.datatypes
Class MTBRegion2DSet

java.lang.Object
  extended by de.unihalle.informatik.Alida.operator.ALDData
      extended by de.unihalle.informatik.MiToBo.core.datatypes.MTBRegion2DSet
All Implemented Interfaces:
MTBRegionSetInterface, Cloneable, Iterable<MTBRegion2D>

@ALDParametrizedClass
public class MTBRegion2DSet
extends de.unihalle.informatik.Alida.operator.ALDData
implements Cloneable, MTBRegionSetInterface, Iterable<MTBRegion2D>

A set of 2D regions living in a common domain which is a rectangular subset of R x R. Each regions is of type Region2D

Author:
Stefan Posch

Field Summary
protected  Vector<MTBRegion2D> regionSet
          The set of regions represented as a Vector.
 
Constructor Summary
MTBRegion2DSet()
          Standard constructor.
MTBRegion2DSet(double _xMin, double _yMin, double _xMax, double _yMax)
          Construct an empty set of regions with given extent of domain
MTBRegion2DSet(MTBImage labelimage)
          Construct a set of regions from a label image.
MTBRegion2DSet(MTBImage labelimage, int backgroundLabel)
          Construct a set of regions from a label image.
MTBRegion2DSet(de.unihalle.informatik.MiToBo_xml.MTBXMLRegion2DSetType xmlregion2Dset)
          Construct a new MTBRegion2DSet from a region set object that was constructed from a xml-representation.
MTBRegion2DSet(String filename)
          Construct a set of regions from a xml-file that was written by the write method of this class.
MTBRegion2DSet(Vector<MTBRegion2D> regions, double _xMin, double _yMin, double _xMax, double _yMax)
          Construct an empty set of regions with given extent of domain
 
Method Summary
 boolean add(MTBRegion2D region)
          Append a region (at the end) to the set of regions.
 double calcAverageSize()
          Calculates the average size of the set.
 int calcMaxSize()
          Calculates the maximum size of the set.
 int calcMinSize()
          Calculates the minimum size of the set.
 void clear()
          Remove all regions from this set
 MTBRegion2DSet clone()
           
 MTBRegion2D elementAt(int i)
          Get a region by index
 MTBRegion2D get(int i)
          Get a region by index
 String getInfo()
           
 double getXmax()
           
 double getXmin()
           
 double getYmax()
           
 double getYmin()
           
 Iterator<MTBRegion2D> iterator()
           
 void remove(MTBRegion2D regionToRemove)
          Delete the given region object from the set, if contained.
 void removeElementAt(int i)
          Delete the i-th region from the set
 MTBRegion2DSet selectLargeRegions(int minSize)
           
 void setElementAt(MTBRegion2D region, int i)
          Set the i-th region from the set
 void setInfo(String info)
           
 int size()
          Get the number of regions of this region set
 de.unihalle.informatik.MiToBo_xml.MTBXMLRegion2DSetType toXMLType()
          Construct an object that represents this region by xml.
 void write(String filename)
          Write this region set to disk in XML format using MiToBo's xml-scheme MTBRegion2DSet.xsd
 
Methods inherited from class de.unihalle.informatik.Alida.operator.ALDData
cloneProperties, getLocation, getProperty, getPropertyKeys, print, setLocation, setProperty
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

regionSet

@ALDClassParameter(label="Set of regions")
protected Vector<MTBRegion2D> regionSet
The set of regions represented as a Vector.

Constructor Detail

MTBRegion2DSet

public MTBRegion2DSet()
Standard constructor.


MTBRegion2DSet

public MTBRegion2DSet(double _xMin,
                      double _yMin,
                      double _xMax,
                      double _yMax)
Construct an empty set of regions with given extent of domain


MTBRegion2DSet

public MTBRegion2DSet(Vector<MTBRegion2D> regions,
                      double _xMin,
                      double _yMin,
                      double _xMax,
                      double _yMax)
Construct an empty set of regions with given extent of domain


MTBRegion2DSet

public MTBRegion2DSet(String filename)
               throws org.apache.xmlbeans.XmlException,
                      IOException
Construct a set of regions from a xml-file that was written by the write method of this class. (These xml-files conform to xml-scheme MTBXMLRegion2DSet.xsd defined for MiToBo)

Parameters:
filename - path to the xml-file
Throws:
IOException - thrown if parsing of xml-file failed
org.apache.xmlbeans.XmlException - thrown if parsing of xml-file failed

MTBRegion2DSet

public MTBRegion2DSet(MTBImage labelimage)
Construct a set of regions from a label image. It is assumed that each set of pixels sharing the same label constitute one connected region. Admissible image types are BYTE, SHORT and INT.

Parameters:
filename - path to the xml-file
Throws:
IOException - thrown if parsing of xml-file failed
org.apache.xmlbeans.XmlException - thrown if parsing of xml-file failed

MTBRegion2DSet

public MTBRegion2DSet(MTBImage labelimage,
                      int backgroundLabel)
Construct a set of regions from a label image. It is assumed that each set of pixels sharing the same label constitute one connected region. The background of pixels with label equals backgroundLabel is excluded.

Admissible image types are BYTE, SHORT and INT.

Parameters:
filename - path to the xml-file
Throws:
IOException - thrown if parsing of xml-file failed
org.apache.xmlbeans.XmlException - thrown if parsing of xml-file failed

MTBRegion2DSet

public MTBRegion2DSet(de.unihalle.informatik.MiToBo_xml.MTBXMLRegion2DSetType xmlregion2Dset)
Construct a new MTBRegion2DSet from a region set object that was constructed from a xml-representation. Only used for reading region set bags (MTBRegion2DSetBag) from file.

Parameters:
xmlregion2Dset - object that represents the region set read from xml
Method Detail

clone

public MTBRegion2DSet clone()
Overrides:
clone in class Object

toXMLType

public de.unihalle.informatik.MiToBo_xml.MTBXMLRegion2DSetType toXMLType()
Construct an object that represents this region by xml. Only used for writing region set bags (MTBRegion2DSetBag) to file.


write

public void write(String filename)
           throws IOException,
                  de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException,
                  de.unihalle.informatik.Alida.exceptions.ALDOperatorException
Write this region set to disk in XML format using MiToBo's xml-scheme MTBRegion2DSet.xsd

Throws:
IOException
de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
de.unihalle.informatik.Alida.exceptions.ALDOperatorException

size

public int size()
Get the number of regions of this region set

Returns:
number of regions

getXmin

public double getXmin()

getXmax

public double getXmax()

getYmin

public double getYmin()

getYmax

public double getYmax()

getInfo

public String getInfo()

setInfo

public void setInfo(String info)

clear

public void clear()
Remove all regions from this set


get

public MTBRegion2D get(int i)
Get a region by index

Returns:
i-th region

elementAt

public MTBRegion2D elementAt(int i)
Get a region by index

Returns:
i-th region

add

public boolean add(MTBRegion2D region)
Append a region (at the end) to the set of regions.

Parameters:
region - region to add

setElementAt

public void setElementAt(MTBRegion2D region,
                         int i)
Set the i-th region from the set

Parameters:
i - index of region to remove

removeElementAt

public void removeElementAt(int i)
Delete the i-th region from the set

Parameters:
i - index of region to remove

remove

public void remove(MTBRegion2D regionToRemove)
Delete the given region object from the set, if contained. If the region object is contained multiple times, the first occurence is removed.

Parameters:
regionToRemove -

calcMinSize

public int calcMinSize()
Calculates the minimum size of the set.

Returns:
minimum size of all regions, -1 if vector is empty

calcMaxSize

public int calcMaxSize()
Calculates the maximum size of the set.

Returns:
maximum size of all regions, -1 if vector is empty

calcAverageSize

public double calcAverageSize()
Calculates the average size of the set.

Returns:
average size of all regions, -1 if vector is empty

selectLargeRegions

public MTBRegion2DSet selectLargeRegions(int minSize)
                                  throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException,
                                         de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
Throws:
de.unihalle.informatik.Alida.exceptions.ALDOperatorException
de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException

iterator

public Iterator<MTBRegion2D> iterator()
Specified by:
iterator in interface Iterable<MTBRegion2D>


Copyright © 2010–2015 Martin Luther University Halle-Wittenberg. All rights reserved.