ROIGeometry extends ROI { @Override public int[][] getAsBitmask(int x, int y, int width, int height, int[][] mask) { ROI roiImage = new ROI(getAsImage()); return roiImage.getAsBitmask(x, y, width, height, mask); } ROIGeometry(Geometry geom);  ROIGeometry(Rectangle rect);  ROIGeometry(Geometry geom, final boolean useFixedPrecision);  ROIGeometry(Geometry geom, final boolean antiAliasing, final boolean useFixedPrecision);  ROIGeometry(Geometry geom, final RenderingHints hints);  ROIGeometry(Geometry geom, final boolean antiAliasing, 
            final boolean useFixedPrecision, final RenderingHints hints); @Override ROI add(ROI roi); @Override boolean contains(Point p); @Override boolean contains(Point2D p); @Override boolean contains(int x, int y); @Override boolean contains(double x, double y); @Override boolean contains(Rectangle rect); @Override boolean contains(Rectangle2D rect); @Override boolean contains(int x, int y, int w, int h); @Override boolean contains(double x, double y, double w, double h); @Override ROI exclusiveOr(ROI roi); @Override int[][] getAsBitmask(int x, int y, int width, int height, int[][] mask); @Override PlanarImage getAsImage(); @Override LinkedList getAsRectangleList(int x, int y, int width, int height); @Override Shape getAsShape(); Geometry getAsGeometry(); @Override Rectangle getBounds(); @Override Rectangle2D getBounds2D(); @Override int getThreshold(); @Override ROI intersect(ROI roi); @Override boolean intersects(Rectangle rect); @Override boolean intersects(Rectangle2D rect); @Override boolean intersects(int x, int y, int w, int h); @Override boolean intersects(double x, double y, double w, double h); @Override ROI performImageOp(RenderedImageFactory RIF, ParameterBlock paramBlock, int sourceIndex, RenderingHints renderHints); @Override ROI performImageOp(String name, ParameterBlock paramBlock, int sourceIndex, RenderingHints renderHints); @Override void setThreshold(int threshold); @Override ROI subtract(ROI roi); @Override ROI transform(AffineTransform at, Interpolation interp); @Override ROI transform(AffineTransform at); @Override String toString(); static final boolean DEFAULT_ROIGEOMETRY_ANTIALISING; static final boolean DEFAULT_ROIGEOMETRY_USEFIXEDPRECISION; }
@Test public void testBitmaskSimple() throws ParseException { ROI leftRight = createLeftRightROIGeometry(); int[][] mask = leftRight.getAsBitmask(130, 0, 64, 64, null); assertNull(mask); mask = leftRight.getAsBitmask(0, 0, 256, 256, null); assertEquals(256, mask.length); for (int i = 0; i < mask.length; i++) { assertEquals(8, mask[i].length); for (int j = 0; j < mask[i].length; j++) { if(j < 4) { assertEquals(-1, mask[i][j]); } else { assertEquals(0, mask[i][j]); } } } mask = leftRight.getAsBitmask(64, 64, 128, 128, null); assertEquals(128, mask.length); for (int i = 0; i < mask.length; i++) { assertEquals(4, mask[i].length); for (int j = 0; j < mask[i].length; j++) { if(j < 2) { assertEquals(-1, mask[i][j]); } else { assertEquals(0, mask[i][j]); } } } }