@ALDParametrizedClass public class MTBBorder2D extends de.unihalle.informatik.Alida.operator.ALDData implements Cloneable
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.
Modifier and Type | Class and Description |
---|---|
static class |
MTBBorder2D.BorderConnectivity
Kind of neighborhood to be applied to border pixels.
|
Modifier and Type | Field and Description |
---|---|
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 and Description |
---|
MTBBorder2D()
Standard constructor.
|
MTBBorder2D(Vector<Point2D.Double> _points,
MTBBorder2D.BorderConnectivity bc)
Constructor to create a 2D border object from a 2D point vector.
|
Modifier and Type | Method and Description |
---|---|
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.
|
static MTBBorder2D |
readBorderFromASCIIFile(String file,
String delim,
int skipLines)
Read a 2D border object from an ASCII file in xSV format.
|
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.
|
@ALDClassParameter(label="Point list", changeValueHook="hookPointsUpdated") protected Vector<Point2D.Double> points
@ALDClassParameter(label="Set of inner borders") protected Vector<MTBBorder2D> inner
protected int pointNum
@ALDClassParameter(label="Connectivity") protected MTBBorder2D.BorderConnectivity connectivity
If nothing is specified, 8-connectivity is assumed.
public MTBBorder2D()
public MTBBorder2D(Vector<Point2D.Double> _points, MTBBorder2D.BorderConnectivity bc)
_points
- Vector with 2D points.bc
- Type of connectivity within point list.public MTBBorder2D clone()
public Vector<Point2D.Double> getPoints()
public Point2D.Double getPointAt(int index)
index
- Index of requested point.public int getPointNum()
public MTBBorder2D.BorderConnectivity getConnectivity()
public void setConnectivity(MTBBorder2D.BorderConnectivity bc)
bc
- Connectivity of border.public void addPixel(int x, int y)
x
- x-coordinate of the new point.y
- y-coordinate of the new point.public void setInner(Vector<MTBBorder2D> ic) throws MTBDatatypeException
ic
- Vector with inner borders.MTBDatatypeException
- Thrown in case of failure.public void addInner(MTBBorder2D ic) throws MTBDatatypeException
ic
- New inner 2D border.MTBDatatypeException
- Thrown in case of failure.public MTBBorder2D getInner(int index)
index
- Index of desired inner border.public Vector<MTBBorder2D> getAllInnerBorders()
public int countInner()
public MTBImageByte toMTBImageByte(String file, int width, int height) throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException, de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
file
- Path where the file should be saved, can be null.width
- Width of the binary image.height
- Height of the binary image.de.unihalle.informatik.Alida.exceptions.ALDOperatorException
- Thrown in case of failure.de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
- Thrown in case of failure.public MTBImage toMTBImage(String file, MTBImage image) throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException, de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
file
- Path where the file should be saved, can be null.image
- Image to where the borders should be drawn.de.unihalle.informatik.Alida.exceptions.ALDOperatorException
- Thrown in case of failure.de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
- Thrown in case of failure.public double[] getBoundingBox()
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]
public static MTBBorder2D readBorderFromASCIIFile(String file, String delim, int skipLines)
The file is expected to contain a single point in each row, first the x-coordinate and then the y-coordinate. Both coordinates should be separated by the delimiter character, e.g. ',' or ' '.
file
- File name from where to read the points.delim
- Delimiter in the file.skipLines
- Number of header lines to skip.protected void hookPointsUpdated()
It is assumed that point list is up-to-date before calling the hook.
Copyright © 2010–2020 Martin Luther University Halle-Wittenberg, Institute of Computer Science, Pattern Recognition and Bioinformatics. All rights reserved.