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
Use this class to iterate a virtual
Interval in 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 an
IntervalIterator to a Positionable.
...
IntervalIterator i = new IntervalIterator(image);
RandomAccess<T> s = image.randomAccess();
while (i.hasNext()) {
i.fwd();
s.setPosition(i);
s.get().performOperation(...);
...
}
...
Note that IntervalIterator is the right choice in situations where
not for each pixel you want to localize and/or set the
Positionable [Sampler], that is in a sparse sampling
situation. For localizing at each iteration step (as in the simplified
example above), use LocalizingIntervalIterator instead.- Author:
- Stephan Preibisch, Stephan Saalfeld
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final long[]protected longprotected final longprotected final long[]Fields inherited from class net.imglib2.AbstractInterval
max, minFields inherited from class net.imglib2.AbstractEuclideanSpace
n -
Constructor Summary
ConstructorsConstructorDescriptionIntervalIterator(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
Modifier and TypeMethodDescriptionstatic IntervalIteratorlongdimension(int d) Get the number of pixels in a given dimension d.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.toString()Methods inherited from class net.imglib2.AbstractInterval
max, max, max, min, min, min, realMax, realMax, realMax, realMin, realMin, realMinMethods inherited from class net.imglib2.AbstractEuclideanSpace
numDimensionsMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface net.imglib2.EuclideanSpace
numDimensions
-
Field Details
-
dimensions
protected final long[] dimensions -
steps
protected final long[] steps -
lastIndex
protected final long lastIndex -
index
protected long index
-
-
Constructor Details
-
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-
-
IntervalIterator
Iterates a givenInterval.- Parameters:
interval-
-
-
Method Details
-
create
-
jumpFwd
public void jumpFwd(long i) Description copied from interface:IteratorMove steps × forward. -
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
-
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
-
getDoublePosition
public double getDoublePosition(int dim) Description copied from interface:RealLocalizableReturn the current position in a given dimension.- 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 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
-
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
-
toString
-
dimension
public long dimension(int d) Description copied from interface:DimensionsGet the number of pixels in a given dimension d.- Specified by:
dimensionin interfaceDimensions- Overrides:
dimensionin classAbstractInterval- Parameters:
d-
-
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- Parameters:
dim-
-