diff --git a/pom.xml b/pom.xml
index ce8b83c7..13ea5197 100644
--- a/pom.xml
+++ b/pom.xml
@@ -11,7 +11,7 @@
net.imglib2
imglib2-roi
- 0.14.2-SNAPSHOT
+ 0.15.0-SNAPSHOT
ImgLib2 ROI
Regions of interest in ImgLib2.
diff --git a/src/main/java/net/imglib2/roi/IterableRegion.java b/src/main/java/net/imglib2/roi/IterableRegion.java
index 25d9785b..02d42c39 100644
--- a/src/main/java/net/imglib2/roi/IterableRegion.java
+++ b/src/main/java/net/imglib2/roi/IterableRegion.java
@@ -47,9 +47,10 @@
* i.e., it is assumed that all pixels outside the interval have value
* {@code false}.
*
- * Iterating only the pixels contained in the region is indicated by
- * {@code IterableInterval}, i.e., when iterating, only the coordinates
- * that are visited are interesting. There is no associated value.
+ * Iterating only the pixels contained in the region is done via the {@code
+ * IterableInterval} {@link #inside()}. (The pixel type is {@code Void}
+ * because, when iterating, only the coordinates that are visited are
+ * interesting. There is no associated value.)
*
* We put interfaces {@code RandomAccessibleInterval}, extended by
* {@code IterableRegion}, extended by
@@ -62,5 +63,13 @@
*
* @author Tobias Pietzsch
*/
-public interface IterableRegion< T extends BooleanType< T > > extends IterableInterval< Void >, RandomAccessibleInterval< T >
-{}
+public interface IterableRegion< T extends BooleanType< T > > extends RandomAccessibleInterval< T >
+{
+ /**
+ * Get an {@code IterableInterval} view of only the pixels contained in the
+ * region (having value {@code true}).
+ *
+ * @return iterable of the pixels in the region
+ */
+ IterableInterval< Void > inside();
+}
diff --git a/src/main/java/net/imglib2/roi/PositionableIterableInterval.java b/src/main/java/net/imglib2/roi/PositionableIterableInterval.java
index 7655c3fc..629d8c26 100644
--- a/src/main/java/net/imglib2/roi/PositionableIterableInterval.java
+++ b/src/main/java/net/imglib2/roi/PositionableIterableInterval.java
@@ -74,7 +74,7 @@ public interface PositionableIterableInterval< T > extends IterableInterval< T >
*
* @return the origin to which the interval is relative.
*/
- public PositionableLocalizable origin();
+ PositionableLocalizable origin();
/**
* Make a copy of this {@link PositionableIterableInterval} which can be
@@ -82,5 +82,5 @@ public interface PositionableIterableInterval< T > extends IterableInterval< T >
*
* @return a copy with an independent position
*/
- public PositionableIterableInterval< T > copy();
+ PositionableIterableInterval< T > copy();
}
diff --git a/src/main/java/net/imglib2/roi/PositionableIterableRegion.java b/src/main/java/net/imglib2/roi/PositionableIterableRegion.java
index 45d187fe..0dcfdcae 100644
--- a/src/main/java/net/imglib2/roi/PositionableIterableRegion.java
+++ b/src/main/java/net/imglib2/roi/PositionableIterableRegion.java
@@ -33,11 +33,19 @@
*/
package net.imglib2.roi;
+import net.imglib2.Localizable;
+import net.imglib2.Positionable;
+import net.imglib2.roi.util.PositionableLocalizable;
import net.imglib2.type.BooleanType;
+import net.imglib2.type.logic.BitType;
/**
* An {@link IterableRegion} that can be moved around.
*
+ * The iterable view of {@link #inside()} pixels can also be moved around. Its
+ * position is the same as the position of this {@code
+ * PositionableIterableRegion}. Moving one will also move the other.
+ *
* We put interfaces {@code RandomAccessibleInterval}, extended by
* {@code IterableRegion}, extended by
* {@code PositionableIterableRegion} into this sequence such that
@@ -49,9 +57,48 @@
*
* @author Tobias Pietzsch
*/
-public interface PositionableIterableRegion< T extends BooleanType< T > >
- extends IterableRegion< T >, PositionableIterableInterval< Void >
+public interface PositionableIterableRegion< T extends BooleanType< T > > extends IterableRegion< T >, Localizable, Positionable
{
+ /**
+ * Get an {@code PositionableIterableInterval} view of only the pixels contained in the
+ * region (having value {@code true}).
+ *
+ * The position of the {@link #inside()} view is the same as the position of
+ * this {@code PositionableIterableRegion}. Moving one will also move the
+ * other.
+ *
+ * @return iterable of the pixels in the region
+ */
@Override
- public PositionableIterableRegion< T > copy();
+ PositionableIterableInterval< Void > inside();
+
+ /**
+ * Get the {@link Positionable}, {@link Localizable} origin of this
+ * interval.
+ *
+ * The origin is the relative offset of the position to the minimum. For
+ * example if a positionable (bitmask) region is made from a {@link BitType}
+ * image with a circular pattern, then it is more natural if the region
+ * position refers to the center of the pattern instead of the upper left
+ * corner of the {@link BitType} image. This can be achieved by positioning
+ * the origin.
+ *
+ * Assume a region is created from a 9x9 bitmask. The region initially has
+ * min=(0,0), max=(8,8), position=(0,0). Because both position and min are
+ * (0,0), initially origin=(0,0). Now assume the origin is moved to the
+ * center of the bitmask using
+ * origin().setPosition(new int[]{4,4})
. After this,
+ * min=(-4,-4), max=(4,4), position=(0,0), and origin=(4,4).
+ *
+ * @return the origin to which the interval is relative.
+ */
+ PositionableLocalizable origin();
+
+ /**
+ * Make a copy of this {@link PositionableIterableInterval} which can be
+ * positioned independently.
+ *
+ * @return a copy with an independent position
+ */
+ PositionableIterableRegion< T > copy();
}
diff --git a/src/main/java/net/imglib2/roi/Regions.java b/src/main/java/net/imglib2/roi/Regions.java
index bb2fc450..7c6396c4 100644
--- a/src/main/java/net/imglib2/roi/Regions.java
+++ b/src/main/java/net/imglib2/roi/Regions.java
@@ -60,6 +60,11 @@ public static < T > IterableInterval< T > sample( final IterableInterval< Void >
return SamplingIterableInterval.create( region, img );
}
+ public static < T > IterableInterval< T > sample( final IterableRegion< ? > region, final RandomAccessible< T > img )
+ {
+ return sample( region.inside(), img );
+ }
+
/**
* Given a mask and an image, return an {@link IterableInterval} over the
* pixels of the image inside the mask.
@@ -106,8 +111,7 @@ public static < T > IterableInterval< T > sample( final RealMaskRealInterval mas
// NB: this method is not named "sample" to avoid ambiguation with sample(IterableInterval, RandomAccessible)
public static < T, B extends BooleanType< B > > IterableInterval< T > sampleWithRandomAccessible( final RandomAccessible< B > mask, final RandomAccessibleInterval< T > img )
{
- final IterableInterval< Void > region = iterable( Views.interval( mask, img ) );
- return sample( region, img );
+ return sample( iterable( Views.interval( mask, img ) ), img );
}
/**
diff --git a/src/main/java/net/imglib2/roi/boundary/Boundary.java b/src/main/java/net/imglib2/roi/boundary/Boundary.java
index fda6c718..489baf90 100644
--- a/src/main/java/net/imglib2/roi/boundary/Boundary.java
+++ b/src/main/java/net/imglib2/roi/boundary/Boundary.java
@@ -39,6 +39,7 @@
import net.imglib2.AbstractWrappedInterval;
import net.imglib2.Cursor;
import net.imglib2.Interval;
+import net.imglib2.IterableInterval;
import net.imglib2.Localizable;
import net.imglib2.Point;
import net.imglib2.RandomAccess;
@@ -70,7 +71,8 @@
public final class Boundary< T extends BooleanType< T > >
extends AbstractWrappedInterval< RandomAccessibleInterval< T > > implements IterableRegion< BoolType >
{
- public static enum StructuringElement
+
+ public enum StructuringElement
{
FOUR_CONNECTED,
EIGHT_CONNECTED
@@ -84,6 +86,8 @@ public static enum StructuringElement
private final int size;
+ private final BoundaryIterable inside;
+
public Boundary( final RandomAccessibleInterval< T > region )
{
this( region, FOUR_CONNECTED );
@@ -108,56 +112,71 @@ public Boundary( final RandomAccessibleInterval< T > region, final StructuringEl
break;
}
size = coords.size() / n;
+ inside = new BoundaryIterable();
}
@Override
- public long size()
+ public IterableInterval< Void > inside()
{
- return size;
+ return inside;
}
@Override
- public Object iterationOrder()
+ public RandomAccess< BoolType > randomAccess()
{
- return this;
+ return structuringElement == FOUR_CONNECTED
+ ? new BoundaryRandomAccess4< T >( sourceInterval )
+ : new BoundaryRandomAccess8< T >( sourceInterval );
}
@Override
- public BoundaryCursor cursor()
+ public RandomAccess< BoolType > randomAccess( final Interval interval )
{
- return new BoundaryCursor();
+ return randomAccess();
}
- @Override
- public BoundaryCursor localizingCursor()
+ final class BoundaryIterable extends AbstractWrappedInterval< Interval > implements IterableInterval< Void >
{
- return cursor();
- }
+ BoundaryIterable()
+ {
+ super( Boundary.this );
+ }
- @Override
- public BoundaryCursor iterator()
- {
- return cursor();
- }
+ @Override
+ public long size()
+ {
+ return size;
+ }
- @Override
- public Void firstElement()
- {
- return cursor().next();
- }
+ @Override
+ public Object iterationOrder()
+ {
+ return this;
+ }
- @Override
- public RandomAccess< BoolType > randomAccess()
- {
- return structuringElement == FOUR_CONNECTED
- ? new BoundaryRandomAccess4< T >( sourceInterval )
- : new BoundaryRandomAccess8< T >( sourceInterval );
- }
+ @Override
+ public BoundaryCursor cursor()
+ {
+ return new BoundaryCursor();
+ }
- @Override
- public RandomAccess< BoolType > randomAccess( final Interval interval )
- {
- return randomAccess();
+ @Override
+ public BoundaryCursor localizingCursor()
+ {
+ return cursor();
+ }
+
+ @Override
+ public BoundaryCursor iterator()
+ {
+ return cursor();
+ }
+
+ @Override
+ public Void firstElement()
+ {
+ return cursor().next();
+ }
}
final class BoundaryCursor extends Point implements Cursor< Void >
@@ -246,7 +265,7 @@ static final class BoundaryConstructor< T extends BooleanType< T > > implements
public BoundaryConstructor( final RandomAccessibleInterval< T > region, final StructuringElement structuringElement )
{
- c = Regions.iterable( region ).localizingCursor();
+ c = Regions.iterable( region ).inside().localizingCursor();
a = structuringElement == FOUR_CONNECTED
? new BoundaryRandomAccess4< T >( region )
: new BoundaryRandomAccess8< T >( region );
diff --git a/src/main/java/net/imglib2/roi/labeling/LabelRegion.java b/src/main/java/net/imglib2/roi/labeling/LabelRegion.java
index 90c3ae93..6813e29d 100644
--- a/src/main/java/net/imglib2/roi/labeling/LabelRegion.java
+++ b/src/main/java/net/imglib2/roi/labeling/LabelRegion.java
@@ -35,6 +35,7 @@
import java.util.ArrayList;
+import net.imglib2.AbstractWrappedPositionableLocalizable;
import net.imglib2.FinalInterval;
import net.imglib2.Interval;
import net.imglib2.Positionable;
@@ -44,6 +45,7 @@
import net.imglib2.RealPositionable;
import net.imglib2.outofbounds.OutOfBounds;
import net.imglib2.outofbounds.OutOfBoundsConstantValue;
+import net.imglib2.roi.PositionableIterableInterval;
import net.imglib2.roi.PositionableIterableRegion;
import net.imglib2.roi.labeling.LabelRegions.LabelRegionProperties;
import net.imglib2.roi.util.PositionableInterval;
@@ -82,17 +84,19 @@ public class LabelRegion< T > extends PositionableInterval implements Positionab
private int expectedGeneration;
+ private final LabelRegionIterable inside;
+
public LabelRegion( final LabelRegions< T > regions, final LabelRegionProperties regionProperties, final T label )
{
super( new FinalInterval( regionProperties.getBoundingBoxMin(), regionProperties.getBoundingBoxMax() ) );
this.regions = regions;
this.regionProperties = regionProperties;
this.label = label;
-
expectedGeneration = regionProperties.update();
size = regionProperties.getSize();
itcodes = regionProperties.getItcodes();
centerOfMass = RealPoint.wrap( regionProperties.getCenterOfMass() );
+ inside = new LabelRegionIterable();
}
/**
@@ -108,6 +112,7 @@ protected LabelRegion( final LabelRegion< T > other )
this.size = other.size;
this.itcodes = other.itcodes;
this.centerOfMass = other.centerOfMass;
+ this.inside = new LabelRegionIterable();
}
/**
@@ -117,6 +122,7 @@ protected LabelRegion( final LabelRegion< T > other )
*
* @return an independent copy of this {@link LabelRegion}.
*/
+ @Override
public LabelRegion< T > copy()
{
return new LabelRegion<>( this );
@@ -175,41 +181,84 @@ public RandomAccess< BoolType > randomAccess( final Interval interval )
}
@Override
- public LabelRegionCursor cursor()
+ public PositionableIterableInterval< Void > inside()
{
- update();
- return new LabelRegionCursor( itcodes, currentOffset );
+ return inside;
}
- @Override
- public LabelRegionCursor localizingCursor()
+ class LabelRegionIterable extends AbstractWrappedPositionableLocalizable< LabelRegion > implements PositionableIterableInterval< Void >
{
- return cursor();
- }
+ LabelRegionIterable()
+ {
+ super( LabelRegion.this );
+ }
- @Override
- public long size()
- {
- update();
- return size;
- }
+ @Override
+ public LabelRegionCursor cursor()
+ {
+ update();
+ return new LabelRegionCursor( itcodes, currentOffset );
+ }
- @Override
- public Void firstElement()
- {
- return null;
- }
+ @Override
+ public LabelRegionCursor localizingCursor()
+ {
+ return cursor();
+ }
- @Override
- public Object iterationOrder()
- {
- return this;
+ @Override
+ public long size()
+ {
+ return LabelRegion.this.size();
+ }
+
+ @Override
+ public Void firstElement()
+ {
+ return null;
+ }
+
+ @Override
+ public Object iterationOrder()
+ {
+ return this;
+ }
+
+ @Override
+ public LabelRegionCursor iterator()
+ {
+ return cursor();
+ }
+
+ @Override
+ public PositionableLocalizable origin()
+ {
+ return LabelRegion.this.origin();
+ }
+
+ @Override
+ public PositionableIterableInterval< Void > copy()
+ {
+ return LabelRegion.this.copy().inside();
+ }
+
+ @Override
+ public long min( final int d )
+ {
+ return LabelRegion.this.min( d );
+ }
+
+ @Override
+ public long max( final int d )
+ {
+ return LabelRegion.this.max( d );
+ }
}
- @Override
- public LabelRegionCursor iterator()
+ public long size()
{
- return cursor();
+ update();
+ return size;
}
@Override
diff --git a/src/main/java/net/imglib2/roi/util/IterableRandomAccessibleRegion.java b/src/main/java/net/imglib2/roi/util/IterableRandomAccessibleRegion.java
index 0a521e82..e805d49a 100644
--- a/src/main/java/net/imglib2/roi/util/IterableRandomAccessibleRegion.java
+++ b/src/main/java/net/imglib2/roi/util/IterableRandomAccessibleRegion.java
@@ -54,6 +54,8 @@
* {@link Cursor Cursors} are realized by wrapping source {@link RandomAccess
* RandomAccesses} (using {@link RandomAccessibleRegionCursor}).
*
+ * @deprecated Use {@code IterableRegionOnBooleanRAI} instead.
+ *
* @author Tobias Pietzsch
*/
@Deprecated
@@ -62,6 +64,8 @@ public class IterableRandomAccessibleRegion< T extends BooleanType< T > >
{
final long size;
+ private final InsideIterable inside;
+
public static < T extends BooleanType< T > > IterableRandomAccessibleRegion< T > create( final RandomAccessibleInterval< T > interval )
{
return new IterableRandomAccessibleRegion<>( interval, Regions.countTrue( interval ) );
@@ -71,55 +75,70 @@ public IterableRandomAccessibleRegion( final RandomAccessibleInterval< T > inter
{
super( interval );
this.size = size;
+ inside = new InsideIterable();
}
@Override
- public long size()
+ public RandomAccess< T > randomAccess()
{
- return size;
+ return sourceInterval.randomAccess();
}
@Override
- public Void firstElement()
+ public RandomAccess< T > randomAccess( final Interval interval )
{
- if ( size() == 0 )
- throw new NoSuchElementException();
- return cursor().next();
+ return sourceInterval.randomAccess( interval );
}
@Override
- public Object iterationOrder()
+ public IterableInterval< Void > inside()
{
- return this;
+ return inside;
}
- @Override
- public Iterator< Void > iterator()
+ class InsideIterable extends AbstractWrappedInterval< Interval > implements IterableInterval< Void >
{
- return cursor();
- }
+ InsideIterable()
+ {
+ super( IterableRandomAccessibleRegion.this.sourceInterval );
+ }
- @Override
- public Cursor< Void > cursor()
- {
- return new RandomAccessibleRegionCursor<>( sourceInterval, size );
- }
+ @Override
+ public long size()
+ {
+ return size;
+ }
- @Override
- public Cursor< Void > localizingCursor()
- {
- return cursor();
- }
+ @Override
+ public Void firstElement()
+ {
+ if ( size() == 0 )
+ throw new NoSuchElementException();
+ return cursor().next();
+ }
- @Override
- public RandomAccess< T > randomAccess()
- {
- return sourceInterval.randomAccess();
- }
+ @Override
+ public Object iterationOrder()
+ {
+ return this;
+ }
- @Override
- public RandomAccess< T > randomAccess( final Interval interval )
- {
- return sourceInterval.randomAccess( interval );
+ @Override
+ public Iterator< Void > iterator()
+ {
+ return cursor();
+ }
+
+ @Override
+ public Cursor< Void > cursor()
+ {
+ return new RandomAccessibleRegionCursor<>( IterableRandomAccessibleRegion.this.sourceInterval, size );
+ }
+
+ @Override
+ public Cursor< Void > localizingCursor()
+ {
+ return cursor();
+ }
}
}
diff --git a/src/main/java/net/imglib2/roi/util/IterableRegionOnBooleanRAI.java b/src/main/java/net/imglib2/roi/util/IterableRegionOnBooleanRAI.java
index 51d1a130..d5c449f0 100644
--- a/src/main/java/net/imglib2/roi/util/IterableRegionOnBooleanRAI.java
+++ b/src/main/java/net/imglib2/roi/util/IterableRegionOnBooleanRAI.java
@@ -62,6 +62,8 @@ public class IterableRegionOnBooleanRAI< T extends BooleanType< T > >
private final IterableInterval< T > sourceIterable;
+ private final InsideIterable inside;
+
public IterableRegionOnBooleanRAI( final RandomAccessibleInterval< T > interval )
{
this( interval, Regions.countTrue( interval ) );
@@ -72,55 +74,70 @@ public IterableRegionOnBooleanRAI( final RandomAccessibleInterval< T > interval,
super( interval );
this.size = size;
sourceIterable = Views.iterable( interval );
+ inside = new InsideIterable();
}
@Override
- public long size()
+ public RandomAccess< T > randomAccess()
{
- return size;
+ return sourceInterval.randomAccess();
}
@Override
- public Void firstElement()
+ public RandomAccess< T > randomAccess( final Interval interval )
{
- if ( size() == 0 )
- throw new NoSuchElementException();
- return cursor().next();
+ return sourceInterval.randomAccess( interval );
}
@Override
- public Object iterationOrder()
+ public IterableInterval< Void > inside()
{
- return this;
+ return inside;
}
- @Override
- public Iterator< Void > iterator()
+ class InsideIterable extends AbstractWrappedInterval< Interval > implements IterableInterval< Void >
{
- return cursor();
- }
+ InsideIterable()
+ {
+ super( IterableRegionOnBooleanRAI.this );
+ }
- @Override
- public Cursor< Void > cursor()
- {
- return new TrueCursor< T >( sourceIterable.cursor(), size );
- }
+ @Override
+ public long size()
+ {
+ return size;
+ }
- @Override
- public Cursor< Void > localizingCursor()
- {
- return new TrueCursor< T >( sourceIterable.localizingCursor(), size );
- }
+ @Override
+ public Void firstElement()
+ {
+ if ( size() == 0 )
+ throw new NoSuchElementException();
+ return cursor().next();
+ }
- @Override
- public RandomAccess< T > randomAccess()
- {
- return sourceInterval.randomAccess();
- }
+ @Override
+ public Object iterationOrder()
+ {
+ return this;
+ }
- @Override
- public RandomAccess< T > randomAccess( final Interval interval )
- {
- return sourceInterval.randomAccess( interval );
+ @Override
+ public Iterator< Void > iterator()
+ {
+ return cursor();
+ }
+
+ @Override
+ public Cursor< Void > cursor()
+ {
+ return new TrueCursor< T >( sourceIterable.cursor(), size );
+ }
+
+ @Override
+ public Cursor< Void > localizingCursor()
+ {
+ return new TrueCursor< T >( sourceIterable.localizingCursor(), size );
+ }
}
}
diff --git a/src/main/java/net/imglib2/roi/util/PositionableWrappedIterableInterval.java b/src/main/java/net/imglib2/roi/util/PositionableWrappedIterableInterval.java
index 90c5767a..b33d4a14 100644
--- a/src/main/java/net/imglib2/roi/util/PositionableWrappedIterableInterval.java
+++ b/src/main/java/net/imglib2/roi/util/PositionableWrappedIterableInterval.java
@@ -51,6 +51,7 @@
* @author Tobias Pietzsch
* @author Christian Dietz
*/
+@Deprecated
public class PositionableWrappedIterableInterval< T, S extends IterableInterval< T > >
extends PositionableInterval
implements PositionableIterableInterval< T >
@@ -151,13 +152,7 @@ public T next()
@Override
public PositionableIterableIntervalCursor copy()
{
- return new PositionableIterableIntervalCursor( source.copyCursor() );
- }
-
- @Override
- public PositionableIterableIntervalCursor copyCursor()
- {
- return copy();
+ return new PositionableIterableIntervalCursor( source.copy() );
}
}
diff --git a/src/main/java/net/imglib2/roi/util/PositionableWrappedIterableRegion.java b/src/main/java/net/imglib2/roi/util/PositionableWrappedIterableRegion.java
index 715c15be..2359d43a 100644
--- a/src/main/java/net/imglib2/roi/util/PositionableWrappedIterableRegion.java
+++ b/src/main/java/net/imglib2/roi/util/PositionableWrappedIterableRegion.java
@@ -33,9 +33,12 @@
*/
package net.imglib2.roi.util;
+import net.imglib2.AbstractWrappedPositionableLocalizable;
+import net.imglib2.Cursor;
import net.imglib2.Interval;
import net.imglib2.RandomAccess;
import net.imglib2.roi.IterableRegion;
+import net.imglib2.roi.PositionableIterableInterval;
import net.imglib2.roi.PositionableIterableRegion;
import net.imglib2.type.BooleanType;
import net.imglib2.util.Intervals;
@@ -48,12 +51,25 @@
* pixel type of source
*/
public class PositionableWrappedIterableRegion< T extends BooleanType< T > >
- extends PositionableWrappedIterableInterval< Void, IterableRegion< T > >
+ extends PositionableInterval
implements PositionableIterableRegion< T >
{
+ private final IterableRegion< T > source;
+
+ private final PositionableWrappedIterableRegion< T >.InsideIterable inside;
+
public PositionableWrappedIterableRegion( final IterableRegion< T > source )
{
super( source );
+ this.source = source;
+ inside = new InsideIterable();
+ }
+
+ private PositionableWrappedIterableRegion( final PositionableWrappedIterableRegion< T > other )
+ {
+ super( other.source );
+ this.source = other.source;
+ inside = new InsideIterable();
}
@Override
@@ -84,19 +100,125 @@ public T get()
@Override
public RA copy()
{
- return new RA( source.copyRandomAccess(), offset );
+ return new RA( source.copy(), offset );
+ }
+ }
+
+ @Override
+ public PositionableWrappedIterableRegion< T > copy()
+ {
+ return new PositionableWrappedIterableRegion<>( this );
+ }
+
+ @Override
+ public PositionableIterableInterval< Void > inside()
+ {
+ return inside;
+ }
+
+ class InsideIterable extends AbstractWrappedPositionableLocalizable< PositionableWrappedIterableRegion< T > > implements PositionableIterableInterval< Void >
+ {
+ InsideIterable()
+ {
+ super( PositionableWrappedIterableRegion.this );
}
@Override
- public RA copyRandomAccess()
+ public PositionableLocalizable origin()
{
- return copy();
+ return PositionableWrappedIterableRegion.this.origin();
+ }
+
+ @Override
+ public PositionableIterableInterval< Void > copy()
+ {
+ return PositionableWrappedIterableRegion.this.copy().inside();
+ }
+
+ @Override
+ public Cursor< Void > cursor()
+ {
+ return new PositionableInsideCursor( inside().cursor() );
+ }
+
+ @Override
+ public Cursor< Void > localizingCursor()
+ {
+ return new PositionableInsideCursor( inside().localizingCursor() );
+ }
+
+ @Override
+ public long size()
+ {
+ return inside().size();
+ }
+
+ @Override
+ public Object iterationOrder()
+ {
+ return this;
+ }
+
+ @Override
+ public long min( final int d )
+ {
+ return PositionableWrappedIterableRegion.this.min( d );
+ }
+
+ @Override
+ public long max( final int d )
+ {
+ return PositionableWrappedIterableRegion.this.max( d );
}
}
- @Override
- public PositionableWrappedIterableRegion< T > copy()
+ class PositionableInsideCursor extends OffsetLocalizable< Cursor< Void > > implements Cursor< Void >
{
- return new PositionableWrappedIterableRegion<>( this );
+ public PositionableInsideCursor( final Cursor< Void > cursor )
+ {
+ super( cursor, currentOffset );
+ }
+
+ @Override
+ public Void get()
+ {
+ return null;
+ }
+
+ @Override
+ public void jumpFwd( final long steps )
+ {
+ source.jumpFwd( steps );
+ }
+
+ @Override
+ public void fwd()
+ {
+ source.fwd();
+ }
+
+ @Override
+ public void reset()
+ {
+ source.reset();
+ }
+
+ @Override
+ public boolean hasNext()
+ {
+ return source.hasNext();
+ }
+
+ @Override
+ public Void next()
+ {
+ return source.next();
+ }
+
+ @Override
+ public PositionableInsideCursor copy()
+ {
+ return new PositionableInsideCursor( source.copy() );
+ }
}
}
diff --git a/src/test/java/net/imglib2/roi/util/IterableRandomAccessibleRegionBenchmarkTest.java b/src/test/java/net/imglib2/roi/util/IterableRandomAccessibleRegionBenchmarkTest.java
index 396f9a26..0cea94c1 100644
--- a/src/test/java/net/imglib2/roi/util/IterableRandomAccessibleRegionBenchmarkTest.java
+++ b/src/test/java/net/imglib2/roi/util/IterableRandomAccessibleRegionBenchmarkTest.java
@@ -101,7 +101,7 @@ public void testIterating()
{
for ( final IterableRegion< BitType > region : regions )
{
- final Cursor< Void > cursor = region.cursor();
+ final Cursor< Void > cursor = region.inside().cursor();
while ( cursor.hasNext() )
cursor.fwd();
}
diff --git a/src/test/java/net/imglib2/roi/util/IterableRegionOnBooleanRAIBenchmark.java b/src/test/java/net/imglib2/roi/util/IterableRegionOnBooleanRAIBenchmark.java
index 1b5f780b..bd037b0b 100644
--- a/src/test/java/net/imglib2/roi/util/IterableRegionOnBooleanRAIBenchmark.java
+++ b/src/test/java/net/imglib2/roi/util/IterableRegionOnBooleanRAIBenchmark.java
@@ -87,7 +87,7 @@ public void doSetup()
@Benchmark
public void testIterableRandomAccessibleRegion( MyState state )
{
- final Cursor< Void > c = state.irOld.cursor();
+ final Cursor< Void > c = state.irOld.inside().cursor();
while ( c.hasNext() )
{
c.next();
@@ -97,7 +97,7 @@ public void testIterableRandomAccessibleRegion( MyState state )
@Benchmark
public void testIterableRegionOnBooleanRAI( MyState state )
{
- final Cursor< Void > c = state.ir.cursor();
+ final Cursor< Void > c = state.ir.inside().cursor();
while ( c.hasNext() )
{
c.next();
@@ -107,7 +107,7 @@ public void testIterableRegionOnBooleanRAI( MyState state )
@Benchmark
public void testIterableRandomAccessibleRegionForNonIterableView( MyState state )
{
- final Cursor< Void > c = state.irViewOld.cursor();
+ final Cursor< Void > c = state.irViewOld.inside().cursor();
while ( c.hasNext() )
{
c.next();
@@ -117,7 +117,7 @@ public void testIterableRandomAccessibleRegionForNonIterableView( MyState state
@Benchmark
public void testIterableRegionOnBooleanRAIForNonIterableView( MyState state )
{
- final Cursor< Void > c = state.irView.cursor();
+ final Cursor< Void > c = state.irView.inside().cursor();
while ( c.hasNext() )
{
c.next();
diff --git a/src/test/java/net/imglib2/roi/util/IterableRegionOnBooleanRAITest.java b/src/test/java/net/imglib2/roi/util/IterableRegionOnBooleanRAITest.java
index 0437d2f5..544fa422 100644
--- a/src/test/java/net/imglib2/roi/util/IterableRegionOnBooleanRAITest.java
+++ b/src/test/java/net/imglib2/roi/util/IterableRegionOnBooleanRAITest.java
@@ -93,7 +93,7 @@ public void testCursorFwd()
{
final long count = Regions.countTrue( img );
long countIR = 0;
- final Cursor< Void > c = ir.cursor();
+ final Cursor< Void > c = ir.inside().cursor();
while ( c.hasNext() )
{
c.fwd();
@@ -107,7 +107,7 @@ public void testCursorFwd()
public void testCursorNext()
{
final Cursor< BitType > imgC = img.cursor();
- final Cursor< Void > irC = ir.cursor();
+ final Cursor< Void > irC = ir.inside().cursor();
while ( imgC.hasNext() )
{
@@ -125,14 +125,14 @@ public void testCursorNext()
public void testFirstElement()
{
// Ensure no error is thrown
- assertTrue( ir.firstElement() == null );
+ assertTrue( ir.inside().firstElement() == null );
}
@Test
public void testCursorFwdEmptyRegion()
{
int count = 0;
- final Cursor< Void > c = empty.cursor();
+ final Cursor< Void > c = empty.inside().cursor();
while ( c.hasNext() )
{
c.fwd();
@@ -148,7 +148,7 @@ public void testCursorNextEmptyRegion()
final long[] originalLocation = new long[ 2 ];
final long[] newLocation = new long[ 2 ];
- final Cursor< Void > c = empty.cursor();
+ final Cursor< Void > c = empty.inside().cursor();
c.fwd();
c.localize( originalLocation );
c.next();
@@ -162,6 +162,6 @@ public void testCursorNextEmptyRegion()
public void testCursorFirstElementEmptyRegion()
{
exception.expect( NoSuchElementException.class );
- empty.firstElement();
+ empty.inside().firstElement();
}
}