diff --git a/src/main/java/net/imglib2/roi/labeling/LabelRegion.java b/src/main/java/net/imglib2/roi/labeling/LabelRegion.java index 9f18492b..a6adf3b8 100644 --- a/src/main/java/net/imglib2/roi/labeling/LabelRegion.java +++ b/src/main/java/net/imglib2/roi/labeling/LabelRegion.java @@ -78,7 +78,7 @@ public class LabelRegion< T > extends PositionableInterval implements Positionab private final ArrayList< TIntArrayList > itcodes; - private long size; + private long insideSize; private final RealPoint centerOfMass; @@ -93,7 +93,7 @@ public LabelRegion( final LabelRegions< T > regions, final LabelRegionProperties this.regionProperties = regionProperties; this.label = label; expectedGeneration = regionProperties.update(); - size = regionProperties.getSize(); + insideSize = regionProperties.getSize(); itcodes = regionProperties.getItcodes(); centerOfMass = RealPoint.wrap( regionProperties.getCenterOfMass() ); inside = new LabelRegionIterable(); @@ -109,7 +109,7 @@ protected LabelRegion( final LabelRegion< T > other ) this.regionProperties = other.regionProperties; this.label = other.label; this.expectedGeneration = other.expectedGeneration; - this.size = other.size; + this.insideSize = other.insideSize; this.itcodes = other.itcodes; this.centerOfMass = other.centerOfMass; this.inside = new LabelRegionIterable(); @@ -153,7 +153,7 @@ private void update() initialMin[ d ] = bbmin[ d ]; initialMax[ d ] = bbmax[ d ]; } - size = regionProperties.getSize(); + insideSize = regionProperties.getSize(); } } @@ -215,7 +215,7 @@ public LabelRegionCursor localizingCursor() @Override public long size() { - return LabelRegion.this.size(); + return LabelRegion.this.insideSize(); } @Override @@ -267,10 +267,10 @@ public long max( final int d ) } } - public long size() + private long insideSize() { update(); - return size; + return insideSize; } @Override diff --git a/src/main/java/net/imglib2/roi/util/IterableRegionOnBooleanRAI.java b/src/main/java/net/imglib2/roi/util/IterableRegionOnBooleanRAI.java index 81b39361..5d48499c 100644 --- a/src/main/java/net/imglib2/roi/util/IterableRegionOnBooleanRAI.java +++ b/src/main/java/net/imglib2/roi/util/IterableRegionOnBooleanRAI.java @@ -89,6 +89,30 @@ public RandomAccess< T > randomAccess( final Interval interval ) return sourceInterval.randomAccess( interval ); } + @Override + public Cursor< T > cursor() + { + return sourceInterval.cursor(); + } + + @Override + public Cursor< T > localizingCursor() + { + return sourceInterval.localizingCursor(); + } + + @Override + public Object iterationOrder() + { + return sourceInterval.iterationOrder(); + } + + @Override + public long size() + { + return sourceInterval.size(); + } + @Override public T getType() { diff --git a/src/main/java/net/imglib2/roi/util/PositionableWrappedIterableRegion.java b/src/main/java/net/imglib2/roi/util/PositionableWrappedIterableRegion.java index 08093c81..7c040c7f 100644 --- a/src/main/java/net/imglib2/roi/util/PositionableWrappedIterableRegion.java +++ b/src/main/java/net/imglib2/roi/util/PositionableWrappedIterableRegion.java @@ -84,6 +84,30 @@ public RandomAccess< T > randomAccess( final Interval interval ) return new RA( source.randomAccess( Intervals.translate( interval, currentOffset ) ), currentOffset ); } + @Override + public Cursor< T > cursor() + { + return new C( source.cursor(), currentOffset ); + } + + @Override + public Cursor< T > localizingCursor() + { + return new C( source.localizingCursor(), currentOffset ); + } + + @Override + public Object iterationOrder() + { + return this; + } + + @Override + public long size() + { + return source.size(); + } + @Override public T getType() { @@ -116,6 +140,56 @@ public RA copy() } } + private final class C extends OffsetLocalizable< Cursor< T > > implements Cursor< T > + { + public C( final Cursor< T > cursor, final long[] offset ) + { + super( cursor, offset ); + } + + @Override + public T get() + { + return source.get(); + } + + @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 T next() + { + return source.next(); + } + + @Override + public C copy() + { + return new C( source.copy(), offset ); + } + } + @Override public PositionableWrappedIterableRegion< T > copy() {