@ALDParametrizedClass public class MTBRegion2D extends Object implements MTBRegionInterface
Modifier and Type | Field and Description |
---|---|
private int |
area
Size of region in pixels.
|
private float |
com_x
Center of mass in x (just sum, not normalized by area!).
|
private float |
com_y
Center of mass in y (just sum, not normalized by area!).
|
private int |
id
Id of the region (uniqueness is not guaranteed nor checked!).
|
(package private) Vector<Point2D.Double> |
points
Pixels belonging to region.
|
Constructor and Description |
---|
MTBRegion2D()
Construct a new empty MTBRegion2D object.
|
MTBRegion2D(de.unihalle.informatik.MiToBo_xml.MTBXMLRegion2DType xmlregion2D)
Construct a new MTBRegion2D from a region object that was constructed from
a xml-representation.
|
MTBRegion2D(Vector<Point2D.Double> inPoints)
Construct a new MTBRegion2D from the given points.
|
Modifier and Type | Method and Description |
---|---|
void |
addPixel(int x,
int y)
Append a point to the region from the given coordinates.
|
void |
addPixel(Point2D.Double p)
Append a point to the region from the given point object.
|
MTBRegion2D |
clone()
Override java.lang.Object.clone() to create and return a copy of this
object.
|
boolean |
contains(Point2D.Double p)
Test if a point is inside the region or not.
|
static MTBRegion2D |
createRandomRegion2D(int xSize,
int ySize,
int maxArea,
Random rndGen)
Create a random connected 2D region of size
maxArea in a hypothetical image of
a random size between 1 and maxArea . |
boolean |
equals(Object obj) |
int |
getArea()
Return the area of the region in pixels.
|
MTBBorder2D |
getBorder()
Method to get the border object from the current 2D region, for example to
visualize the regions.
|
double[] |
getBoundingBox()
Calculates the axes-parallel bounding box of the region.
|
float |
getCenterOfMass_X()
Return x-coordinate of the center of mass.
|
float |
getCenterOfMass_Y()
Return y-coordinate of the center of mass.
|
double |
getCentralMoment(int p,
int q)
Calculate central moment of the region of order p,q.
|
double |
getCircularity()
Calculates circularity of given region.
|
MTBContour2D |
getContour()
Method to get the contour object from the current 2D region.
|
double |
getCorrCircularity()
Calculates corrected circularity of given region.
|
double |
getEccentricity()
Calculates eccentricity of the region in the range of [0,1].
|
int |
getID()
Return the ID of the region.
|
double |
getMajorAxisLength()
Calculates length of the major axis of the ellipse best fitting.
|
double[] |
getMinMaxCoordinates()
Extracts the extreme coordinates of the region in each dimension.
|
double |
getMinorAxisLength()
Calculates length of the minor axis of the ellipse best fitting.
|
double |
getMoment(int p,
int q)
Calculate moment of the region of order p,q.
|
double |
getNormalCentralMoment(int p,
int q)
Calculate normalized central moment of the region of order p,q.
|
double |
getOrientation()
Calculates the orientation of the principal axis of the
MTBRegion2D. |
Vector<Point2D.Double> |
getPoints()
Return all points of the region.
|
MTBRegion2D |
getRegion()
Get a Region2D copy of this object.
|
private static void |
growRandomRegion2D(int x,
int y,
int xSize,
int ySize,
int area,
MTBRegion2D region2D,
Random rndGen)
Grow a 2D region adding the pixel specified and potentially grow further
|
protected void |
hookPointsUpdated()
Function to update object state after setting new point list.
|
MTBRegion2D |
join(MTBRegion2D reg)
Join a region with this region.
|
void |
setID(int _id)
Set the ID of the region.
|
MTBImage |
toMTBImage(String file,
MTBImage image)
Method to save a region with in a given MTBImage image.
|
MTBImageByte |
toMTBImageByte(String file,
int width,
int height)
Method to save the region on a binary image with specific width and height.
|
MTBImageByte |
toMTBImageByte(String file,
int width,
int height,
int color)
Method to save the region on a binary image with specific width, height and
color.
|
String |
toString() |
de.unihalle.informatik.MiToBo_xml.MTBXMLRegion2DType |
toXMLType()
Construct an object that represents this region by xml.
|
@ALDClassParameter(label="ID") private int id
@ALDClassParameter(label="List of points", changeValueHook="hookPointsUpdated") Vector<Point2D.Double> points
private float com_x
private float com_y
private int area
public MTBRegion2D()
public MTBRegion2D(Vector<Point2D.Double> inPoints)
inPoints
- Vector of region points.MTBRegion2D(de.unihalle.informatik.MiToBo_xml.MTBXMLRegion2DType xmlregion2D)
MTBRegion2DSet
) from file.xmlregion2D
- object that represents the region read from xmlpublic de.unihalle.informatik.MiToBo_xml.MTBXMLRegion2DType toXMLType()
MTBRegion2DSet
) to file.public MTBRegion2D clone()
public MTBRegion2D getRegion()
public Vector<Point2D.Double> getPoints()
public int getArea()
public float getCenterOfMass_X()
public float getCenterOfMass_Y()
public double[] getMinMaxCoordinates()
public int getID()
public void addPixel(int x, int y)
x
- coordinate in x-dimensiony
- coordinate in y-dimensionpublic void addPixel(Point2D.Double p)
p
- point to addpublic void setID(int _id)
_id
- Region IDpublic MTBRegion2D join(MTBRegion2D reg)
reg
- region to joinpublic boolean contains(Point2D.Double p)
p
- point that maybe lies in the regionpublic 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 if image should
not be stored at diskwidth
- width of the binary imageheight
- height of the binary imagede.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
de.unihalle.informatik.Alida.exceptions.ALDOperatorException
de.unihalle.informatik.Alida.exceptions.ALDOperatorException
de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
public MTBImageByte toMTBImageByte(String file, int width, int height, int color) throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException, de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
file
- path where the file should be saved, can be null if image should
not be stored at diskwidth
- width of the binary imageheight
- height of the binary imagecolor
- region colorde.unihalle.informatik.Alida.exceptions.ALDOperatorException
de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
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 if image should
not be stored at diskimage
- image where the region should be drawn inde.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
de.unihalle.informatik.Alida.exceptions.ALDOperatorException
public MTBContour2D getContour() throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException, de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
de.unihalle.informatik.Alida.exceptions.ALDOperatorException
de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
public MTBBorder2D getBorder() throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException, de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
de.unihalle.informatik.Alida.exceptions.ALDOperatorException
de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
BordersOnLabeledComponents
public double getMoment(int p, int q)
p
- order of x-componentq
- oder of y-componentpublic double getCentralMoment(int p, int q)
p
- order of x-componentq
- oder of y-componentpublic double getNormalCentralMoment(int p, int q)
p
- order of x-componentq
- oder of y-componentpublic double getOrientation()
MTBRegion2D.
The orientation is measured with regard to the horizontal x-axis.
We apply the atan2 function here:
For details on the calculations and some background infos take a look in Burger/Burge, Digitale Bildverarbeitung, 2nd edition, Springer, 2006, section "Orientierung" on pages 224 to 226.
public double getEccentricity()
The eccentricity is calculated according to the following equation:
1 refers to a sustained region.
Reference: Burger/Burge, Digitale Bildverarbeitung, Springer, 2006, pp. 227.
public double getCircularity() throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException, de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
The circularity is calculated according to the following equation:
A perfect circle yields 1, otherwise smaller values result.
Reference: Burger/Burge, Digitale Bildverarbeitung, Springer, 2006, pp. 220.
de.unihalle.informatik.Alida.exceptions.ALDOperatorException
de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
public double getCorrCircularity() throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException, de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
The circularity is calculated according to the following equation:
A perfect circle yields 1, otherwise smaller values result.
Compared to the getCircularity()
method here a corrected version
of the region's perimeter is used as suggested for small regions in
Burger/Burge, Digitale Bildverarbeitung, Springer, 2006, pp. 219.
de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
de.unihalle.informatik.Alida.exceptions.ALDOperatorException
public double[] getBoundingBox()
The function extracts the coordinates of the upper left and lower right corner of the bounding box of the region. Note that the there is at least one point of the region lying on each side of the bounding box, i.e. the region 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 double getMajorAxisLength()
The method is based on using moments of the region:
Reference: R. Prokop/A. Reeves, A Survey of Moment-Based Techniques for Unoccluded Object Representation and Recognition, Graphical Models and Image Processing (CVGIP), pp. 438-460, 1992.
public double getMinorAxisLength()
The method is based on using moments of the region:
Reference: R. Prokop/A. Reeves, A Survey of Moment-Based Techniques for Unoccluded Object Representation and Recognition, Graphical Models and Image Processing (CVGIP), pp. 438-460, 1992.
public static MTBRegion2D createRandomRegion2D(int xSize, int ySize, int maxArea, Random rndGen)
maxArea
in a hypothetical image of
a random size between 1
and maxArea
.xSize
- ySize
- maxArea
- private static void growRandomRegion2D(int x, int y, int xSize, int ySize, int area, MTBRegion2D region2D, Random rndGen)
x
- x coordinates of pixel to addy
- y coordinate of pixel to addarea
- design area of region, however: resulting region may be smallerregion2D
- current partial region to growrndGen
- random number generatorprotected 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.