public class IntervalIterator extends AbstractInterval implements Iterator, Localizable
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.Modifier and Type | Field and Description |
---|---|
protected long[] |
dimensions |
protected long |
index |
protected long |
lastIndex |
protected long[] |
steps |
max, min
n
Constructor and Description |
---|
IntervalIterator(int[] dimensions)
Iterates an
Interval of the given dimensions with min=
0n |
IntervalIterator(int[] min,
int[] max)
Iterates an
Interval with given min and max. |
IntervalIterator(Interval interval)
Iterates a given
Interval . |
IntervalIterator(long[] dimensions)
Iterates an
Interval of the given dimensions with min=
0n |
IntervalIterator(long[] min,
long[] max)
Iterates an
Interval with given min and max. |
Modifier and Type | Method and Description |
---|---|
static IntervalIterator |
create(Interval interval) |
long |
dimension(int d)
Default implementation of
Dimensions.dimension(int) . |
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 the
Iterator , that is put it to where it would be if newly
created. |
String |
toString() |
max, max, max, min, min, min, realMax, realMax, realMax, realMin, realMin, realMin
numDimensions
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
localize, positionAsLongArray, positionAsPoint
localize, positionAsDoubleArray, positionAsRealPoint
numDimensions
maxAsLongArray, maxAsPoint, minAsLongArray, minAsPoint
maxAsDoubleArray, maxAsRealPoint, minAsDoubleArray, minAsRealPoint
allPositive, allPositive, dimensions, dimensionsAsLongArray, dimensionsAsPoint, verify, verify, verifyAllPositive, verifyAllPositive
protected final long[] dimensions
protected final long[] steps
protected final long lastIndex
protected long index
public IntervalIterator(long[] dimensions)
Interval
of the given dimensions with min=
0ndimensions
- public IntervalIterator(int[] dimensions)
Interval
of the given dimensions with min=
0ndimensions
- public IntervalIterator(long[] min, long[] max)
Interval
with given min and max.min
- max
- public IntervalIterator(int[] min, int[] max)
Interval
with given min and max.min
- max
- public static IntervalIterator create(Interval interval)
public void jumpFwd(long i)
Iterator
public void fwd()
Iterator
public void reset()
Iterator
Iterator
, that is put it to where it would be if newly
created.public boolean hasNext()
Iterator
public long getIndex()
public long getLongPosition(int dim)
Localizable
getLongPosition
in interface Localizable
dim
- dimensionpublic void localize(long[] position)
Localizable
localize
in interface Localizable
position
- receives current positionpublic int getIntPosition(int dim)
Localizable
getIntPosition
in interface Localizable
dim
- dimensionpublic void localize(int[] position)
Localizable
localize
in interface Localizable
position
- receives current positionpublic double getDoublePosition(int dim)
RealLocalizable
getDoublePosition
in interface Localizable
getDoublePosition
in interface RealLocalizable
dim
- dimensionpublic float getFloatPosition(int dim)
RealLocalizable
getFloatPosition
in interface Localizable
getFloatPosition
in interface RealLocalizable
dim
- dimensionpublic void localize(float[] position)
RealLocalizable
localize
in interface RealLocalizable
position
- receives current positionpublic void localize(double[] position)
RealLocalizable
localize
in interface RealLocalizable
position
- receives current positionpublic String toString()
toString
in class AbstractInterval
public long dimension(int d)
Interval
Dimensions.dimension(int)
.dimension
in interface Dimensions
dimension
in interface Interval
dimension
in class AbstractInterval
public void dimensions(long[] dim)
Dimensions
dimensions
in interface Dimensions
dimensions
in class AbstractInterval
Copyright © 2015–2022 ImgLib2. All rights reserved.