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

java.lang.Object
  extended by de.unihalle.informatik.Alida.operator.ALDData
      extended by de.unihalle.informatik.MiToBo.core.datatypes.MTBBorder2D
All Implemented Interfaces:
Cloneable
Direct Known Subclasses:
MTBContour2D

@ALDParametrizedClass
public class MTBBorder2D
extends de.unihalle.informatik.Alida.operator.ALDData
implements Cloneable

Datatype to represent borders of components.

The border of a component is basically equal to its contours, however, the pixels are not arranged in a special ordering. In particular they are not ordered clockwise or counter-clockwise. Due to this the extraction is faster than using classical contour extraction algorithms.

Author:
moeller

Nested Class Summary
static class MTBBorder2D.BorderConnectivity
          Kind of neighborhood to be applied to border pixels.
 
Field Summary
protected  MTBBorder2D.BorderConnectivity connectivity
          Connectivity of border pixels.
protected  Vector<MTBBorder2D> inner
          Set of inner borders if available.
protected  int pointNum
          The number of border points.
protected  Vector<Point2D.Double> points
          Set of border pixels.
 
Constructor Summary
MTBBorder2D()
          Standard constructor.
MTBBorder2D(Vector<Point2D.Double> _points, MTBBorder2D.BorderConnectivity bc)
          Constructor to create an 2D border object from a 2D point vector.
 
Method Summary
 void addInner(MTBBorder2D ic)
          Add an inner border to the existing border object.
 void addPixel(int x, int y)
          Add a 2D point to the existing border.
 MTBBorder2D clone()
           
 int countInner()
          Get the number of inner borders included.
 Vector<MTBBorder2D> getAllInnerBorders()
          Get all inner borders from the border object.
 double[] getBoundingBox()
          Calculates the axes-parallel bounding box of the contour.
 MTBBorder2D.BorderConnectivity getConnectivity()
          Query the connectivity of pixels within border.
 MTBBorder2D getInner(int index)
          Get a specific inner border.
 Point2D.Double getPointAt(int index)
          Get a specific 2D point belonging to the border object.
 int getPointNum()
          Get the number of points of the border object.
 Vector<Point2D.Double> getPoints()
          Get all points belonging to the border object.
protected  void hookPointsUpdated()
          Function to update object state after setting new point list.
 void setConnectivity(MTBBorder2D.BorderConnectivity bc)
          Set the connectivity.
 void setInner(Vector<MTBBorder2D> ic)
          Set the inner borders of the border object.
 MTBImage toMTBImage(String file, MTBImage image)
          Draws border with all inner borders to a given image.
 MTBImageByte toMTBImageByte(String file, int width, int height)
          Draws a border with all inner borders to a binary image with given size.
 
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

points

@ALDClassParameter(label="Point list",
                   changeValueHook="hookPointsUpdated")
protected Vector<Point2D.Double> points
Set of border pixels.


inner

@ALDClassParameter(label="Set of inner borders")
protected Vector<MTBBorder2D> inner
Set of inner borders if available.


pointNum

protected int pointNum
The number of border points.


connectivity

@ALDClassParameter(label="Connectivity")
protected MTBBorder2D.BorderConnectivity connectivity
Connectivity of border pixels.

If nothing is specified, 8-connectivity is assumed.

Constructor Detail

MTBBorder2D

public MTBBorder2D()
Standard constructor. Creates an empty 2D border object.


MTBBorder2D

public MTBBorder2D(Vector<Point2D.Double> _points,
                   MTBBorder2D.BorderConnectivity bc)
Constructor to create an 2D border object from a 2D point vector.

Parameters:
_points - Vector with 2D points.
bc - Type of connectivity within point list.
Method Detail

clone

public MTBBorder2D clone()
Overrides:
clone in class Object

getPoints

public Vector<Point2D.Double> getPoints()
Get all points belonging to the border object.

Returns:
Vector with all 2D points of the border.

getPointAt

public Point2D.Double getPointAt(int index)
Get a specific 2D point belonging to the border object.

Parameters:
Index - of requested point.
Returns:
2D point at specific index.

getPointNum

public int getPointNum()
Get the number of points of the border object.

Returns:
Number of border points.

getConnectivity

public MTBBorder2D.BorderConnectivity getConnectivity()
Query the connectivity of pixels within border.

Returns:
Connectivity, either 4- or 8-neighborhood.

setConnectivity

public void setConnectivity(MTBBorder2D.BorderConnectivity bc)
Set the connectivity.

Parameters:
bc - Connectivity of border.

addPixel

public void addPixel(int x,
                     int y)
Add a 2D point to the existing border.

Parameters:
x - x-coordinate of the new point.
y - y-coordinate of the new point.

setInner

public void setInner(Vector<MTBBorder2D> ic)
              throws MTBDatatypeException
Set the inner borders of the border object.

Parameters:
ic - Vector with inner borders.
Throws:
MTBDatatypeException

addInner

public void addInner(MTBBorder2D ic)
              throws MTBDatatypeException
Add an inner border to the existing border object.

Parameters:
ic - New inner 2D border.
Throws:
MTBDatatypeException

getInner

public MTBBorder2D getInner(int index)
Get a specific inner border.

Parameters:
index - Index of desired inner border.
Returns:
Inner border with given index.

getAllInnerBorders

public Vector<MTBBorder2D> getAllInnerBorders()
Get all inner borders from the border object.

Returns:
All inner borders.

countInner

public int countInner()
Get the number of inner borders included.

Returns:
The number of inner borders.

toMTBImageByte

public MTBImageByte toMTBImageByte(String file,
                                   int width,
                                   int height)
                            throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException,
                                   de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
Draws a border with all inner borders to a binary image with given size.

Parameters:
file - Path where the file should be saved, can be null.
width - Width of the binary image.
height - Height of the binary image.
Returns:
Image with borders.
Throws:
de.unihalle.informatik.Alida.exceptions.ALDOperatorException
de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException

toMTBImage

public MTBImage toMTBImage(String file,
                           MTBImage image)
                    throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException,
                           de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
Draws border with all inner borders to a given image.

Parameters:
file - Path where the file should be saved, can be null.
image - Image to where the borders should be drawn.
Returns:
Image with borders.
Throws:
de.unihalle.informatik.Alida.exceptions.ALDOperatorException
de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException

getBoundingBox

public double[] getBoundingBox()
Calculates the axes-parallel bounding box of the contour.

The function extracts the coordinates of the upper left and lower right corner of the bounding box of the border. Note that the there is at least one point of the border lying on each side of the bounding box, i.e. the border not just touches the box, but lies on it.

The result array contains the corner coordinates in the following order: [xmin, ymin, xmax, ymax]

Returns:
Coordinates of upper left and lower right corners.

hookPointsUpdated

protected void hookPointsUpdated()
Function to update object state after setting new point list.

It is assumed that point list is up-to-date before calling the hook.



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