Package net.imglib2.iterator
Class IntervalIterator
- java.lang.Object
-
- net.imglib2.AbstractEuclideanSpace
-
- net.imglib2.AbstractInterval
-
- net.imglib2.iterator.IntervalIterator
-
- All Implemented Interfaces:
Dimensions,EuclideanSpace,Interval,Iterator,Localizable,RealInterval,RealLocalizable
- Direct Known Subclasses:
LocalizingIntervalIterator,OffsetableIntervalIterator,ZeroMinIntervalIterator
public class IntervalIterator extends AbstractInterval implements Iterator, Localizable
Use this class to iterate a virtualIntervalin flat order, that is: row by row, plane by plane, cube by cube, ... This is useful for iterating an arbitrary interval in a defined order. For that, connect anIntervalIteratorto aPositionable.
Note that... IntervalIterator i = new IntervalIterator(image); RandomAccess<T> s = image.randomAccess(); while (i.hasNext()) { i.fwd(); s.setPosition(i); s.get().performOperation(...); ... } ...IntervalIteratoris the right choice in situations where not for each pixel you want to localize and/or set thePositionable[Sampler], that is in a sparse sampling situation. For localizing at each iteration step (as in the simplified example above), useLocalizingIntervalIteratorinstead.
-
-
Field Summary
Fields Modifier and Type Field Description protected long[]dimensionsprotected longindexprotected longlastIndexprotected long[]steps-
Fields inherited from class net.imglib2.AbstractInterval
max, min
-
Fields inherited from class net.imglib2.AbstractEuclideanSpace
n
-
-
Constructor Summary
Constructors Constructor Description IntervalIterator(int[] dimensions)Iterates anIntervalof the given dimensions with min= 0nIntervalIterator(int[] min, int[] max)Iterates anIntervalwith given min and max.IntervalIterator(long[] dimensions)Iterates anIntervalof the given dimensions with min= 0nIntervalIterator(long[] min, long[] max)Iterates anIntervalwith given min and max.IntervalIterator(Interval interval)Iterates a givenInterval.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static IntervalIteratorcreate(Interval interval)longdimension(int d)Default implementation ofDimensions.dimension(int).voiddimensions(long[] dim)Write the number of pixels in each dimension into long[].voidfwd()Move forward.doublegetDoublePosition(int dim)Return the current position in a given dimension.floatgetFloatPosition(int dim)Return the current position in a given dimension.longgetIndex()intgetIntPosition(int dim)Return the current position in a given dimension.longgetLongPosition(int dim)Return the current position in a given dimension.booleanhasNext()Returns true if another step forward is possible.voidjumpFwd(long i)Move steps × forward.voidlocalize(double[] position)Write the current position into the passed array.voidlocalize(float[] position)Write the current position into the passed array.voidlocalize(int[] position)Write the current position into the passed array.voidlocalize(long[] position)Write the current position into the passed array.voidreset()Reset theIterator, that is put it to where it would be if newly created.java.lang.StringtoString()-
Methods inherited from class net.imglib2.AbstractInterval
max, max, max, min, min, min, realMax, realMax, realMax, realMin, realMin, realMin
-
Methods inherited from class net.imglib2.AbstractEuclideanSpace
numDimensions
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface net.imglib2.Dimensions
dimensions, dimensionsAsLongArray, dimensionsAsPoint
-
Methods inherited from interface net.imglib2.EuclideanSpace
numDimensions
-
Methods inherited from interface net.imglib2.Interval
maxAsLongArray, maxAsPoint, minAsLongArray, minAsPoint
-
Methods inherited from interface net.imglib2.Localizable
localize, localize, positionAsLongArray, positionAsPoint
-
Methods inherited from interface net.imglib2.RealInterval
maxAsDoubleArray, maxAsRealPoint, minAsDoubleArray, minAsRealPoint
-
Methods inherited from interface net.imglib2.RealLocalizable
positionAsDoubleArray, positionAsRealPoint
-
-
-
-
Constructor Detail
-
IntervalIterator
public IntervalIterator(long[] dimensions)
Iterates anIntervalof the given dimensions with min= 0n- Parameters:
dimensions-
-
IntervalIterator
public IntervalIterator(int[] dimensions)
Iterates anIntervalof the given dimensions with min= 0n- Parameters:
dimensions-
-
IntervalIterator
public IntervalIterator(long[] min, long[] max)Iterates anIntervalwith given min and max.- Parameters:
min-max-
-
IntervalIterator
public IntervalIterator(int[] min, int[] max)Iterates anIntervalwith given min and max.- Parameters:
min-max-
-
-
Method Detail
-
create
public static IntervalIterator create(Interval interval)
-
jumpFwd
public void jumpFwd(long i)
Description copied from interface:IteratorMove steps × forward.Highly recommended to override this with a more efficient version.
-
fwd
public void fwd()
Description copied from interface:IteratorMove forward.
-
reset
public void reset()
Description copied from interface:IteratorReset theIterator, that is put it to where it would be if newly created.
-
hasNext
public boolean hasNext()
Description copied from interface:IteratorReturns true if another step forward is possible.
-
getIndex
public long getIndex()
- Returns:
- - the current iteration index
-
getLongPosition
public long getLongPosition(int dim)
Description copied from interface:LocalizableReturn the current position in a given dimension.- Specified by:
getLongPositionin interfaceLocalizable- Parameters:
dim- dimension- Returns:
- dimension of current position
-
localize
public void localize(long[] position)
Description copied from interface:LocalizableWrite the current position into the passed array.- Specified by:
localizein interfaceLocalizable- Parameters:
position- receives current position, length must be ≥EuclideanSpace.numDimensions()
-
getIntPosition
public int getIntPosition(int dim)
Description copied from interface:LocalizableReturn the current position in a given dimension.- Specified by:
getIntPositionin interfaceLocalizable- Parameters:
dim- dimension- Returns:
- dimension of current position
-
localize
public void localize(int[] position)
Description copied from interface:LocalizableWrite the current position into the passed array.- Specified by:
localizein interfaceLocalizable- Parameters:
position- receives current position, length must be ≥EuclideanSpace.numDimensions()
-
getDoublePosition
public double getDoublePosition(int dim)
Description copied from interface:RealLocalizableReturn the current position in a given dimension.- Specified by:
getDoublePositionin interfaceLocalizable- Specified by:
getDoublePositionin interfaceRealLocalizable- Parameters:
dim- dimension- Returns:
- dimension of current position
-
getFloatPosition
public float getFloatPosition(int dim)
Description copied from interface:RealLocalizableReturn the current position in a given dimension.- Specified by:
getFloatPositionin interfaceLocalizable- Specified by:
getFloatPositionin interfaceRealLocalizable- Parameters:
dim- dimension- Returns:
- dimension of current position
-
localize
public void localize(float[] position)
Description copied from interface:RealLocalizableWrite the current position into the passed array.- Specified by:
localizein interfaceRealLocalizable- Parameters:
position- receives current position, length must be ≥EuclideanSpace.numDimensions()
-
localize
public void localize(double[] position)
Description copied from interface:RealLocalizableWrite the current position into the passed array.- Specified by:
localizein interfaceRealLocalizable- Parameters:
position- receives current position, length must be ≥EuclideanSpace.numDimensions()
-
toString
public java.lang.String toString()
- Overrides:
toStringin classAbstractInterval
-
dimension
public long dimension(int d)
Description copied from interface:IntervalDefault implementation ofDimensions.dimension(int).- Specified by:
dimensionin interfaceDimensions- Specified by:
dimensionin interfaceInterval- Overrides:
dimensionin classAbstractInterval
-
dimensions
public void dimensions(long[] dim)
Description copied from interface:DimensionsWrite the number of pixels in each dimension into long[].- Specified by:
dimensionsin interfaceDimensions- Overrides:
dimensionsin classAbstractInterval
-
-