|
ImageScience 3.0.0 | ||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectimagescience.shape.Region
public class Region
An arbitrarily but discretely shaped region in the x-y plane. This class can be used to represent and manipulate shapes with boundaries consisting of straight-line segments constrained to the Cartesian 2D integer grid. The class uses java.awt.geom.Area
as a back-end.
Constructor Summary | |
---|---|
Region()
Default constructor. |
|
Region(Image image)
Image constructor. |
|
Region(Region region)
Copy constructor. |
Method Summary | |
---|---|
void |
add(Region region)
Adds the shape of the given region to the shape of this region. |
double |
area()
Returns the area covered by the region. |
Image |
bitmap(boolean binary)
Computes a bitmapped version of the shape. |
Bounds |
bounds()
Computes the bounding box of the shape. |
boolean |
contains(double x,
double y)
Indicates the position of a point relative to the region. |
boolean |
contains(Point point)
Indicates the position of a point relative to the region. |
java.awt.geom.GeneralPath |
contour()
Returns the contour of the region. |
Shape |
duplicate()
Duplicates the shape. |
boolean |
empty()
Indicates whether the shape is empty. |
boolean |
equals(Shape shape)
Indicates whether this object has the same shape as the given object. |
void |
exclusive(Region region)
Sets the shape of this region to the union of its current shape and the shape of the given region, minus their intersection. |
void |
intersect(Region region)
Sets the shape of this region to the intersection of its current shape and the shape of the given region. |
void |
reset()
Restores this region to an empty region. |
void |
subtract(Region region)
Subtracts the shape of the given region from the shape of this region. |
void |
translate(int dx,
int dy)
Translates the region over the given distance. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Region()
public Region(Image image)
image
- An image defining the region. The resulting region is the union of all unit squares corresponding to elements in the image with value larger than 0
. If the image is not a 2D but a higher-dimensional image, only the elements in the x-y plane are considered for which the higher coordinates are 0
.
java.lang.NullPointerException
- If image
is null
.public Region(Region region)
region
- The region to be copied. All information is copied and no memory is shared with this region.
java.lang.NullPointerException
- If region
is null
.Method Detail |
---|
public void add(Region region)
region
- The region to be added to this region.
java.lang.NullPointerException
- If region
is null
.public void exclusive(Region region)
region
- The region to be joined with this region as described.
java.lang.NullPointerException
- If region
is null
.public void intersect(Region region)
region
- The region to be intersected with this region.
java.lang.NullPointerException
- If region
is null
.public void subtract(Region region)
region
- The region to be subtracted from this region.
java.lang.NullPointerException
- If region
is null
.public void reset()
public double area()
public Image bitmap(boolean binary)
Shape
bitmap
in interface Shape
binary
- Determines whether the returned bitmap image is two-valued. If true
, image elements whose center positions fall inside the shape are set to 255
, and elements whose center positions fall outside the shape are set to 0
. If false
, additional processing is performed, by which each image element falling partly inside and partly outside the shape is set to 255
times its (approximate) inside-fraction.
ByteImage
object containing a bitmapped version of the shape. The origin of the integer coordinate system of the image corresponds to the position in the shape coordinate system obtained by taking the floor value of the lower bound of the shape in each dimension.public void translate(int dx, int dy)
dx
- The distance in the x-dimension over which to translate.dy
- The distance in the y-dimension over which to translate.public Shape duplicate()
Shape
duplicate
in interface Shape
Shape
object that is an exact copy of this object. All information is copied and no memory is shared between this and the returned object.public boolean contains(Point point)
contains
in interface Shape
point
- The point whose position relative to the region is to be tested. The point is treated as a 2D point. That is, only its x- and y-coordinate values are considered.
contains(point.x,point.y)
.
java.lang.NullPointerException
- If point
is null
.public boolean contains(double x, double y)
x
- The x-coordinate of the point.y
- The y-coordinate of the point.
true
if the point is on or inside the region, or false
if it is outside the region.public java.awt.geom.GeneralPath contour()
GeneralPath
object containing the contour of the region.public Bounds bounds()
Shape
bounds
in interface Shape
Bounds
object containing the bounding box of the shape.public boolean equals(Shape shape)
Shape
equals
in interface Shape
shape
- The shape to compare this shape with.
true
if shape
is not null
, and an instance of the same class as this object, with the exact same shape, or false
if this is not the case.public boolean empty()
Shape
empty
in interface Shape
true
if the shape does not enclose any space, or false
if it does.
|
ImageScience 3.0.0 | ||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright (C) Erik Meijering. Permission to use this software and corresponding documentation for educational, research, and not-for-profit purposes, without a fee and without a signed licensing agreement, is granted, subject to the following terms and conditions.
IT IS NOT ALLOWED TO REDISTRIBUTE, SELL, OR LEASE THIS SOFTWARE, OR DERIVATIVE WORKS THEREOF, WITHOUT PERMISSION IN WRITING FROM THE COPYRIGHT HOLDER. THE COPYRIGHT HOLDER IS FREE TO MAKE VERSIONS OF THE SOFTWARE AVAILABLE FOR A FEE OR COMMERCIALLY ONLY.
IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OF ANY KIND WHATSOEVER, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE EXPRESS OR IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE AND CORRESPONDING DOCUMENTATION IS PROVIDED "AS IS". THE COPYRIGHT HOLDER HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.