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 virtualInterval
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 anIntervalIterator
to aPositionable
.
Note that... IntervalIterator i = new IntervalIterator(image); RandomAccess<T> s = image.randomAccess(); while (i.hasNext()) { i.fwd(); s.setPosition(i); s.get().performOperation(...); ... } ...
IntervalIterator
is 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), useLocalizingIntervalIterator
instead.- Author:
- Stephan Preibisch, Stephan Saalfeld
-
-
Field Summary
Fields Modifier and Type Field Description protected long[]
dimensions
protected long
index
protected long
lastIndex
protected 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 anInterval
of the given dimensions with min= 0nIntervalIterator(int[] min, int[] max)
Iterates anInterval
with given min and max.IntervalIterator(long[] dimensions)
Iterates anInterval
of the given dimensions with min= 0nIntervalIterator(long[] min, long[] max)
Iterates anInterval
with 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 IntervalIterator
create(Interval interval)
long
dimension(int d)
Get the number of pixels in a given dimension d.void
dimensions(long[] dim)
Write the number of pixels in each dimension into long[].void
fwd()
Move forward.double
getDoublePosition(int dim)
Return the current position in a given dimension.float
getFloatPosition(int dim)
Return the current position in a given dimension.long
getIndex()
int
getIntPosition(int dim)
Return the current position in a given dimension.long
getLongPosition(int dim)
Return the current position in a given dimension.boolean
hasNext()
Returns true if another step forward is possible.void
jumpFwd(long i)
Move steps × forward.void
localize(double[] position)
Write the current position into the passed array.void
localize(float[] position)
Write the current position into the passed array.void
localize(int[] position)
Write the current position into the passed array.void
localize(long[] position)
Write the current position into the passed array.void
reset()
Reset theIterator
, that is put it to where it would be if newly created.java.lang.String
toString()
-
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.EuclideanSpace
numDimensions
-
-
-
-
Constructor Detail
-
IntervalIterator
public IntervalIterator(long[] dimensions)
Iterates anInterval
of the given dimensions with min= 0n- Parameters:
dimensions
-
-
IntervalIterator
public IntervalIterator(int[] dimensions)
Iterates anInterval
of the given dimensions with min= 0n- Parameters:
dimensions
-
-
IntervalIterator
public IntervalIterator(long[] min, long[] max)
Iterates anInterval
with given min and max.- Parameters:
min
-max
-
-
IntervalIterator
public IntervalIterator(int[] min, int[] max)
Iterates anInterval
with 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:Iterator
Move steps × forward.
-
fwd
public void fwd()
Description copied from interface:Iterator
Move forward.
-
reset
public void reset()
Description copied from interface:Iterator
Reset theIterator
, that is put it to where it would be if newly created.
-
hasNext
public boolean hasNext()
Description copied from interface:Iterator
Returns 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:Localizable
Return the current position in a given dimension.- Specified by:
getLongPosition
in interfaceLocalizable
- Parameters:
dim
- dimension- Returns:
- dimension of current position
-
localize
public void localize(long[] position)
Description copied from interface:Localizable
Write the current position into the passed array.- Specified by:
localize
in interfaceLocalizable
- Parameters:
position
- receives current position
-
getIntPosition
public int getIntPosition(int dim)
Description copied from interface:Localizable
Return the current position in a given dimension.- Specified by:
getIntPosition
in interfaceLocalizable
- Parameters:
dim
- dimension- Returns:
- dimension of current position
-
localize
public void localize(int[] position)
Description copied from interface:Localizable
Write the current position into the passed array.- Specified by:
localize
in interfaceLocalizable
- Parameters:
position
- receives current position
-
getDoublePosition
public double getDoublePosition(int dim)
Description copied from interface:RealLocalizable
Return the current position in a given dimension.- Specified by:
getDoublePosition
in interfaceRealLocalizable
- Parameters:
dim
- dimension- Returns:
- dimension of current position
-
getFloatPosition
public float getFloatPosition(int dim)
Description copied from interface:RealLocalizable
Return the current position in a given dimension.- Specified by:
getFloatPosition
in interfaceRealLocalizable
- Parameters:
dim
- dimension- Returns:
- dimension of current position
-
localize
public void localize(float[] position)
Description copied from interface:RealLocalizable
Write the current position into the passed array.- Specified by:
localize
in interfaceRealLocalizable
- Parameters:
position
- receives current position
-
localize
public void localize(double[] position)
Description copied from interface:RealLocalizable
Write the current position into the passed array.- Specified by:
localize
in interfaceRealLocalizable
- Parameters:
position
- receives current position
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
dimension
public long dimension(int d)
Description copied from interface:Dimensions
Get the number of pixels in a given dimension d.- Specified by:
dimension
in interfaceDimensions
- Overrides:
dimension
in classAbstractInterval
-
dimensions
public void dimensions(long[] dim)
Description copied from interface:Dimensions
Write the number of pixels in each dimension into long[].- Specified by:
dimensions
in interfaceDimensions
- Overrides:
dimensions
in classAbstractInterval
-
-