max[ dimX ] = target.max( X );
max[ dimY ] = target.max( Y );
// TODO: this is ugly, but the only way to make sure, that iteration
// order fits in the case of one sized dims. Tobi?
final IterableInterval< A > ii = Views.iterable( Views.interval( source, new FinalInterval( min, max ) ) );
final Cursor< A > sourceCursor = ii.cursor();
if ( target.iterationOrder().equals( ii.iterationOrder() ) && !( sourceCursor instanceof RandomAccessibleIntervalCursor ) )
{
final Cursor< B > targetCursor = target.cursor();
while ( targetCursor.hasNext() )
{
converter.convert( sourceCursor.next(), targetCursor.next() );
}
}
else if ( target.iterationOrder() instanceof FlatIterationOrder )
{
final Cursor< B > targetCursor = target.cursor();
targetCursor.fwd();
final FinalInterval sourceInterval = new FinalInterval( min, max );
// use localizing cursor
final RandomAccess< A > sourceRandomAccess = source.randomAccess( sourceInterval );
sourceRandomAccess.setPosition( position );