public interface Cursor<T extends Type<T>> extends Iterator<T>, Iterable<T>, Iterable, Dimensionality
Cursor is responsible for iterating over the image. Therefore it has to be implemented
for each type of Container like Array, CellContainer, ...
Cursor does not know which Type of Image it is working on as there this
is not important for its positioning. It is typed to the Type so that the Cursor is
able to return the correct instance of Type when calling the getType() method.
Cursor class itself is only capable of iterating over all pixels of the Image,
there is no guaranteed order in which the pixels are iterated, this depends on the implementation for
the specific Container.
However, it is guaranteed that for two images having the same Container, the
traverse path will be the same. For instance, if the following is true:
Container< T > c1 = img1.getContainer();
Container< S > c2 = img2.getContainer();
if ( c1.compareStorageContainerCompatibility( c2 ) )
then, it is ensured that
{
Cursor< T > cursor1 = img1.createCursor();
Cursor< S > cursor2 = img2.createCursor();
while ( cursor1.hasNext() )
{
cursor1.fwd();
cursor2.fwd();
}
}
will visit the same pixel positions.
If the two Container are not the same, then LocalizableCursor and LocalizableByDimCursor
have to be used:
else {
LocalizableCursor< T > cursor1 = img1.createLocalizableCursor();
LocalizableByDimCursor< S > cursor2 = img2.createLocalizableByDimCursor();
while ( cursor1.hasNext() )
{
cursor1.fwd();
cursor2.moveTo( cursor1 );
}
}
This snippet will also traverse images the same way, but this is less efficient than the previous solution
with identical containers.
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
int[] |
createPositionArray() |
int |
getArrayIndex() |
Image<T> |
getImage() |
Container<T> |
getStorageContainer() |
int |
getStorageIndex() |
T |
getType() |
boolean |
isActive() |
void |
reset() |
void |
setDebug(boolean debug) |
forEachRemaining, hasNext, next, removeforEach, iterator, spliteratorgetDimensions, getDimensions, getNumDimensionsvoid reset()
boolean isActive()
T getType()
int getArrayIndex()
int getStorageIndex()
void setDebug(boolean debug)
int[] createPositionArray()
void close()
Copyright © 2015–2021 Fiji. All rights reserved.