|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.unihalle.informatik.MiToBo.core.datatypes.MTBRegion2D
@ALDParametrizedClass public class MTBRegion2D
Class to implement a 2D region object. the region is stored in a vector of 2D double points with its x- and y-coordinate. The area, center of mass, moments, and other properties of the region can be calculated. For further details watch the implemented methods.
Constructor Summary | |
---|---|
MTBRegion2D()
Construct a new empty MTBRegion2D object. |
|
MTBRegion2D(Vector<Point2D.Double> inPoints)
Construct a new MTBRegion2D from the given points. |
Method Summary | |
---|---|
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 (1 for perfect circle, else smaller). |
MTBContour2D |
getContour()
Method to get the contour object from the current 2D region. |
double |
getCorrCircularity()
Calculates corrected circularity of given region (1 for perfect circle, else smaller). |
double |
getEccentricity()
Calculate eccentricity of the region in range [0,1]. 1 means a sustained region. |
int |
getID()
Return the ID of the region. |
double |
getMajorAxisLength()
calculation of the length of the major axis of the ellipse best fitting using moments of the region |
double[] |
getMinMaxCoordinates()
Extracts the extreme coordinates of the region in each dimension. |
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()
Calculate orientation of principal axis of the MTBRegion2D, using the atan2 function. |
Vector<Point2D.Double> |
getPoints()
Return all points of the region. |
MTBRegion2D |
getRegion()
Get a Region2D copy of this object. |
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()
|
Methods inherited from class java.lang.Object |
---|
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public MTBRegion2D()
public MTBRegion2D(Vector<Point2D.Double> inPoints)
inPoints
- Vector of region points.Method Detail |
---|
public MTBRegion2D clone()
clone
in class Object
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 join
public boolean contains(Point2D.Double p)
p
- point that maybe lies in the region
public boolean equals(Object obj)
equals
in class Object
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 if image should
not be stored at diskwidth
- width of the binary imageheight
- height of the binary image
de.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 color
de.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 in
de.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-component
public double getCentralMoment(int p, int q)
p
- order of x-componentq
- oder of y-component
public double getNormalCentralMoment(int p, int q)
p
- order of x-componentq
- oder of y-component
public double getOrientation()
public double getEccentricity()
public double getCircularity() throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException, de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
imageSizeX
- width of image that includes the regionimageSizeY
- height of image that includes the region
de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
de.unihalle.informatik.Alida.exceptions.ALDOperatorException
public double getCorrCircularity() throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException, de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
imageSizeX
- width of image that includes the regionimageSizeY
- height of image that includes the region
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()
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
-
public String toString()
toString
in class Object
protected void hookPointsUpdated()
It is assumed that point list is up-to-date before calling the hook.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |