10.14. region#
- class itom.region#
- class itom.region(otherRegion) region
- class itom.region(x, y, w, h, type=region.RECTANGLE) region
Creates a rectangular or elliptical region.
This class is a wrapper for the class
QRegion
of Qt. It provides possibilities for creating pixel-based regions. Furtherone you can calculate new regions based on the intersection, union or subtraction of other regions. Based on the region it is possible to get a uint8 masked dataObject, where every point within the entire region has the value 255 and all other values 0If the constructor is called without argument, an empty region is created.
- Parameters:
- otherRegion
region
Pass this object of
region
to create a copied object of it.- x
int
x-coordinate of the reference corner of the region
- y
int
y-coordinate of the reference corner of the region
- w
int
width of the region
- h
int
height of the region
- type
int
,optional
region.RECTANGLE
creates a rectangular region (default).region.ELLIPSE
creates an elliptical region, which is placed inside of the given boundaries.
- otherRegion
- contains(x, y, w=-1, h=-1) bool #
This method returns True, if the given point (x,y) or rectangle (x,y,w,h) is fully contained in this region. Otherwise returns False.
- Parameters:
- Returns:
- bool
True if point or rectangle is contained in region, otherwise False.
- createMask(boundingRegion=None) dataObject #
Returns a
dataObject
with dtypeuint8
whose shape corresponds to the width and height of the bounding rectangle. All pixels contained in the region have a value of255
while the rest is set to0
. The offset value of the dataObject is set such that it fits to the real position of the region, since the first element in the dataObject corresponds to the left upper corner of the bounding rectangle.Indicate a
boundingRegion
in order to increase the size of the returned data object. Its size will have the size of the union between the boundingRegion and the region.- Parameters:
- boundingRegion
region
,optional
If a
region
object is given, the shape of the returneddataObject
is the maximum (union) between thisboundingRegion
and this region.
- boundingRegion
- Returns:
- mask
dataObject
- mask
- intersected(x, y, w, h) region #
- intersected(region) region
Returns a new region which is the intersection of the given region and this region.
The intersection only contains points that are part of both regions. The given region can either by a
region
object or a rectangular region, defined by its corner points (x
,y
) and its widthw
and heighth
.
- intersects(x, y, w, h) bool #
- intersects(region) bool
Returns True if this region intersects with the given region, otherwise False.
The given region can either by a
region
object or a rectangular region, defined by its corner points (x
,y
) and its widthw
and heighth
.- Parameters:
- Returns:
- bool
True if both regions intersect, otherwise False.
- subtracted(x, y, w, h) region #
- subtracted(region) region
This method returns a new region, which is the given, new region subtracted from this region.
The given region can either by a
region
object or a rectangular region, defined by its corner points (x
,y
) and its widthw
and heighth
.
- translate(x, y)#
This method translates this region by the given translation values.
See also
- translated(x, y) region #
This method returns a new region, which is translated by the given distances in x and y direction.
- Parameters:
- Returns:
region
new translated region.
See also
- united(x, y, w, h) region #
- united(region) region
returns a region which is the union of the given region with this region.
This method returns a new region, which is the union of this region with the given region. The union contains all areas, that are contained in any of both regions.
The given region can either by a
region
object or a rectangular region, defined by its corner points (x
,y
) and its widthw
and heighth
.
- xored(x, y, w, h) region #
- xored(region) region
returns a region which is an xor combination of the given region with this region.
This method returns a new region, which is defined by an xor-combination of this region with the given region.
The given region can either by a
region
object or a rectangular region, defined by its corner points (x
,y
) and its widthw
and heighth
.
- ELLIPSE = 1#
- RECTANGLE = 0#