Package org.eclipse.imagen
Class ROIShape
- All Implemented Interfaces:
Serializable
A class representing a region of interest within an image as a
Shape. Such regions are binary by
definition. Using a Shape representation allows boolean operations to be performed quickly and with
compact storage. If a PropertyGenerator responsible for generating the ROI property of a
particular OperationDescriptor (e.g., a warp) cannot reasonably produce an ROIShape
representing the region, it should call getAsImage() on its sources and produce its output ROI
in image form.- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdds another mask to this one.booleancontains(double x, double y) Returnstrueif the mask contains the point (x, y).booleancontains(double x, double y, double w, double h) Returnstrueif a given rectangle (x, y, w, h) is entirely included within the mask.booleancontains(int x, int y) Returnstrueif the mask contains the point (x, y).booleancontains(int x, int y, int w, int h) Returnstrueif a given rectangle (x, y, w, h) is entirely included within the mask.booleanReturnstrueif the mask contains a given Point2D.booleancontains(Rectangle2D rect) Returnstrueif a givenRectangle2Dis entirely included within the mask.booleanReturnstrueif the mask contains a given Point.booleanReturnstrueif a givenRectangleis entirely included within the mask.exclusiveOr(ROI roi) Sets the mask to its exclusive-or with another mask.int[][]getAsBitmask(int x, int y, int width, int height, int[][] mask) Returns a bitmask for a given rectangular region of the ROI indicating whether the pixel is included in the region of interest.Returns the shape as aPlanarImage.getAsRectangleList(int x, int y, int width, int height) Returns aLinkedListofRectangles for a given rectangular region of the ROI.Returns the internal Shape representation or null if a shape representation is not possible.Returns the bounds of the mask as aRectangle.Returns the bounds of the mask as aRectangle2D.Sets the mask to its intersection with another mask.booleanintersects(double x, double y, double w, double h) Returnstrueif a given rectangle (x, y, w, h) intersects the mask.booleanintersects(int x, int y, int w, int h) Returnstrueif a given rectangle (x, y, w, h) intersects the mask.booleanReturnstrueif a givenRectangle2Dintersects the mask.booleanReturnstrueif a givenRectangleintersects the mask.Subtracts another mask from this one.Transforms the current contents of theROIby a givenAffineTransform.Methods inherited from class ROI
getThreshold, performImageOp, performImageOp, setThreshold, transform
-
Constructor Details
-
ROIShape
Constructs an ROIShape from a Shape.- Parameters:
s- A Shape.- Throws:
IllegalArgumentException- if s is null.
-
ROIShape
Constructs an ROIShape from an Area.- Parameters:
a- An Area.
-
-
Method Details
-
getBounds
Returns the bounds of the mask as aRectangle. -
getBounds2D
Returns the bounds of the mask as aRectangle2D.- Overrides:
getBounds2Din classROI
-
contains
Returnstrueif the mask contains a given Point.- Overrides:
containsin classROI- Parameters:
p- a Point specifying the coordinates of the pixel to be queried.- Returns:
trueif the pixel lies within the mask.- Throws:
IllegalArgumentException- is p is null.
-
contains
Returnstrueif the mask contains a given Point2D.- Overrides:
containsin classROI- Parameters:
p- A Point2D specifying the coordinates of the pixel to be queried.- Returns:
trueif the pixel lies within the mask.- Throws:
IllegalArgumentException- is p is null.
-
contains
public boolean contains(int x, int y) Returnstrueif the mask contains the point (x, y). -
contains
public boolean contains(double x, double y) Returnstrueif the mask contains the point (x, y). -
contains
Returnstrueif a givenRectangleis entirely included within the mask.- Overrides:
containsin classROI- Parameters:
rect- ARectanglespecifying the region to be tested for inclusion.- Returns:
trueif the rectangle is entirely contained within the mask.- Throws:
IllegalArgumentException- is rect is null.
-
contains
Returnstrueif a givenRectangle2Dis entirely included within the mask.- Overrides:
containsin classROI- Parameters:
rect- ARectangle2Dspecifying the region to be tested for inclusion.- Returns:
trueif the rectangle is entirely contained within the mask.- Throws:
IllegalArgumentException- is rect is null.
-
contains
public boolean contains(int x, int y, int w, int h) Returnstrueif a given rectangle (x, y, w, h) is entirely included within the mask.- Overrides:
containsin classROI- Parameters:
x- The int X coordinate of the upper left corner of the region.y- The int Y coordinate of the upper left corner of the region.w- The int width of the region.h- The int height of the region.- Returns:
trueif the rectangle is entirely contained within the mask.
-
contains
public boolean contains(double x, double y, double w, double h) Returnstrueif a given rectangle (x, y, w, h) is entirely included within the mask.- Overrides:
containsin classROI- Parameters:
x- The double X coordinate of the upper left corner of the region.y- The double Y coordinate of the upper left corner of the region.w- The double width of the region.h- The double height of the region.- Returns:
trueif the rectangle is entirely contained within the mask.
-
intersects
Returnstrueif a givenRectangleintersects the mask.- Overrides:
intersectsin classROI- Parameters:
r- ARectanglespecifying the region to be tested for inclusion.- Returns:
trueif the rectangle intersects the mask.- Throws:
IllegalArgumentException- is r is null.
-
intersects
Returnstrueif a givenRectangle2Dintersects the mask.- Overrides:
intersectsin classROI- Parameters:
r- ARectangle2Dspecifying the region to be tested for inclusion.- Returns:
trueif the rectangle intersects the mask.- Throws:
IllegalArgumentException- is r is null.
-
intersects
public boolean intersects(int x, int y, int w, int h) Returnstrueif a given rectangle (x, y, w, h) intersects the mask.- Overrides:
intersectsin classROI- Parameters:
x- The int X coordinate of the upper left corner of the region.y- The int Y coordinate of the upper left corner of the region.w- The int width of the region.h- The int height of the region.- Returns:
trueif the rectangle intersects the mask.
-
intersects
public boolean intersects(double x, double y, double w, double h) Returnstrueif a given rectangle (x, y, w, h) intersects the mask.- Overrides:
intersectsin classROI- Parameters:
x- The double X coordinate of the upper left corner of the region.y- The double Y coordinate of the upper left corner of the region.w- The double width of the region.h- The double height of the region.- Returns:
trueif the rectangle intersects the mask.
-
add
Adds another mask to this one. This operation may force this mask to be rendered.- Overrides:
addin classROI- Parameters:
roi- A ROI.- Returns:
- A new ROI containing the new ROI data.
- Throws:
IllegalArgumentException- is roi is null.
-
subtract
Subtracts another mask from this one. This operation may force this mask to be rendered.- Overrides:
subtractin classROI- Parameters:
roi- A ROI.- Returns:
- A new ROI containing the new ROI data.
- Throws:
IllegalArgumentException- is roi is null.
-
intersect
Sets the mask to its intersection with another mask. This operation may force this mask to be rendered.- Overrides:
intersectin classROI- Parameters:
roi- A ROI.- Returns:
- A new ROI containing the new ROI data.
- Throws:
IllegalArgumentException- is roi is null.
-
exclusiveOr
Sets the mask to its exclusive-or with another mask. This operation may force this mask to be rendered.- Overrides:
exclusiveOrin classROI- Parameters:
roi- A ROI.- Returns:
- A new ROI containing the new ROI data.
- Throws:
IllegalArgumentException- is roi is null.
-
getAsShape
Returns the internal Shape representation or null if a shape representation is not possible.- Overrides:
getAsShapein classROI- Returns:
- The
ROIas aShape.
-
getAsImage
Returns the shape as aPlanarImage. This requires performing an antialiased rendering of the internal Shape.- Overrides:
getAsImagein classROI- Returns:
- If the upper-left corner of the bounds of this
ROIShapeis (0, 0), the returned image is aBufferedImageof type TYPE_BYTE_BINARY wrapped as aPlanarImage. Otherwise, the returned image is a (bilevel)TiledImagewhoseSampleModelis an instance ofMultiPixelPackedSampleModel.
-
transform
Transforms the current contents of theROIby a givenAffineTransform.- Overrides:
transformin classROI- Parameters:
at- AnAffineTransformobject.- Returns:
- a new ROI containing the transformed ROI data.
- Throws:
IllegalArgumentException- if at is null.
-
getAsBitmask
public int[][] getAsBitmask(int x, int y, int width, int height, int[][] mask) Returns a bitmask for a given rectangular region of the ROI indicating whether the pixel is included in the region of interest. The results are packed into 32-bit integers, with the MSB considered to lie on the left. The last entry in each row of the result may have bits that lie outside of the requested rectangle. These bits are guaranteed to be zeroed.The
maskarray, if supplied, must be of length equal to or greater thanheightand each of its subarrays must have length equal to or greater than (width + 31)/32. Ifnullis passed in, a suitable array will be constructed. If the mask is non-null but has insufficient size, an exception will be thrown.- Overrides:
getAsBitmaskin classROI- Parameters:
x- The X coordinate of the upper left corner of the rectangle.y- The Y coordinate of the upper left corner of the rectangle.width- The width of the rectangle.height- The height of the rectangle.mask- A two-dimensional array of ints at least (width + 31)/32 entries wide and (height) entries tall, or null.- Returns:
- A reference to the
maskparameter, or to a newly constructed array ifmaskisnull.
-
getAsRectangleList
Returns aLinkedListofRectangles for a given rectangular region of the ROI. TheRectangles in the list are merged into a minimal set.- Overrides:
getAsRectangleListin classROI- Parameters:
x- The X coordinate of the upper left corner of the rectangle.y- The Y coordinate of the upper left corner of the rectangle.width- The width of the rectangle.height- The height of the rectangle.- Returns:
- A
LinkedListofRectangles.
-