Permalink
Browse files

Test rasterize method with combined regions

  • Loading branch information...
awalter17 committed Dec 19, 2016
1 parent 3340fa5 commit a8712f0c4fba14d6f2d2b3480d5b147ec32f4d3f
Showing with 37 additions and 0 deletions.
  1. +37 −0 src/test/java/net/imglib2/roi/geometric/GeometricShapeTest.java
@@ -6,6 +6,7 @@
import java.io.IOException;
import net.imglib2.Cursor;
import net.imglib2.RandomAccess;
import net.imglib2.RealPoint;
import net.imglib2.RealRandomAccess;
@@ -14,6 +15,7 @@
import net.imglib2.realtransform.AffineRealRandomAccessible;
import net.imglib2.realtransform.AffineTransform3D;
import net.imglib2.realtransform.RealViews;
import net.imglib2.roi.IterableRegion;
import net.imglib2.roi.Regions;
import net.imglib2.roi.operators.RealBinaryExclusiveOr;
import net.imglib2.roi.operators.RealBinaryIntersection;
@@ -551,6 +553,41 @@ public void testRasterizedHyperEllipsoid()
assertEquals( rhe.max( 1 ), 4 );
}
@Test
public void testCombineRaster()
{
final HyperRectangle hc0 = GeomRegions.hyperRectangle( new RealPoint( new double[] { 10, 10 } ), new double[] { 5, 8 } );
final HyperRectangle hc1 = GeomRegions.hyperRectangle( new RealPoint( new double[] { 5, 5 } ), new double[] { 10, 2 } );
final HyperRectangle hc2 = GeomRegions.hyperRectangle( new RealPoint( new double[] { 20, 10 } ), new double[] { 9, 4 } );
final RealRandomAccessibleRealInterval< BoolType > combine = Regions.intersect( hc0, Regions.intersect( hc1, hc2 ) );
final RasterizedRegion< RealRandomAccessibleRealInterval< BoolType > > rcombine = Regions.rasterize( combine );
final RandomAccess< BoolType > rra = rcombine.randomAccess();
rra.setPosition( new int[] { 13, 6 } );
assertTrue( rra.get().get() );
rra.setPosition( new int[] { -1, 4 } );
assertFalse( rra.get().get() );
rra.setPosition( new int[] { 14, 10 } );
assertFalse( rra.get().get() );
rra.setPosition( new int[] { 20, 8 } );
assertFalse( rra.get().get() );
final IterableRegion< BoolType > itrCombine = Regions.iterable( rcombine );
final Cursor< Void > c = itrCombine.cursor();
int s = 0;
while( c.hasNext() )
{
c.next();
s++;
}
assertTrue( s == 10 ); // This is true because a hyperRectangle contains all boundary points
}
public static void main(final String... args) throws IOException {
//new GeometricShapeTest().testHyperEllipsoid();
//new GeometricShapeTest().testHyperCubeWithoutVolume();

0 comments on commit a8712f0

Please sign in to comment.