|
||||||||
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
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.
Field Summary | |
---|---|
(package private) int |
area
Size of region in pixels. |
(package private) float |
com_x
Center of mass in x (just sum, not normalized by area!). |
(package private) float |
com_y
Center of mass in y (just sum, not normalized by area!). |
(package private) int |
id
Id of the region (uniqueness is not guaranteed nor checked!). |
(package private) java.util.Vector<java.awt.geom.Point2D.Double> |
points
Pixels belonging to region. |
Constructor Summary | |
---|---|
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(java.util.Vector<java.awt.geom.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(java.awt.geom.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(java.awt.geom.Point2D.Double p)
Test if a point is inside the region or not. |
int |
getArea()
Return the area of the region in pixels. |
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. |
java.util.Vector<java.awt.geom.Point2D.Double> |
getPoints()
Return all points of the region. |
MTBRegion2D |
getRegion()
Get a Region2D copy of this object. |
MTBRegion2D |
join(MTBRegion2D reg)
Join a region with this region. |
void |
setID(int id)
Set the ID of the region. |
MTBImage |
toMTBImage(java.lang.String file,
MTBImage image)
Method to save a region with in a given MTBImage image. |
MTBImageByte |
toMTBImageByte(java.lang.String file,
int width,
int height)
Method to save the region on a binary image with specific width and height. |
MTBImageByte |
toMTBImageByte(java.lang.String file,
int width,
int height,
int color)
Method to save the region on a binary image with specific width, height and color. |
(package private) de.unihalle.informatik.MiToBo_xml.MTBXMLRegion2DType |
toXMLType()
Construct an object that represents this region by xml. |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
int area
float com_x
float com_y
int id
java.util.Vector<java.awt.geom.Point2D.Double> points
Constructor Detail |
---|
public MTBRegion2D()
MTBRegion2D(de.unihalle.informatik.MiToBo_xml.MTBXMLRegion2DType xmlregion2D)
MTBRegion2DSet
) from file.
xmlregion2D
- object that represents the region read from xmlpublic MTBRegion2D(java.util.Vector<java.awt.geom.Point2D.Double> inPoints)
inPoints
- vector of region pointsMethod Detail |
---|
public void addPixel(int x, int y)
x
- coordinate in x-dimensiony
- coordinate in y-dimensionpublic void addPixel(java.awt.geom.Point2D.Double p)
p
- point to addpublic MTBRegion2D clone()
clone
in class java.lang.Object
public boolean contains(java.awt.geom.Point2D.Double p)
p
- point that maybe lies in the region
public int getArea()
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 float getCenterOfMass_X()
public float getCenterOfMass_Y()
public double getCentralMoment(int p, int q)
p
- order of x-componentq
- oder of y-component
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 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 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 getEccentricity()
public int getID()
public double getMajorAxisLength()
public double[] getMinMaxCoordinates()
public double getMoment(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 java.util.Vector<java.awt.geom.Point2D.Double> getPoints()
public MTBRegion2D getRegion()
public MTBRegion2D join(MTBRegion2D reg)
reg
- region to join
public void setID(int id)
id
- Region IDpublic MTBImage toMTBImage(java.lang.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 MTBImageByte toMTBImageByte(java.lang.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(java.lang.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
de.unihalle.informatik.MiToBo_xml.MTBXMLRegion2DType toXMLType()
MTBRegion2DSet
) to file.
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |