private static < T > RandomAccessible< T > createRandomAccessible( final RealRandomAccessible< T > rra, final RealTransform t ) { if ( t instanceof AffineGet ) { return new AffineRandomAccessible<>( rra, ( AffineGet ) t ); } return new RealTransformRandomAccessible<>( rra, t ); }
/** * See a {@link RealRandomAccessible} as a {@link RandomAccessible} * transformed by an {@link AffineGet}. The {@link AffineGet} is interpreted * according to the natural understanding that the source is transformed by * it. E.g. a positive translation of dimension <em>x</em> would shift the * source to the right. Therefore, the samples need to be generated by the * inverse of the {@link AffineGet}. Here, the {@link AffineGet} is inverted * using it's {@link AffineGet#inverse()} method that is expected to * generate and inverse that changes with the original transformation * accordingly. That way, changing the state of the {@link AffineGet} will * immediately change the state of any new {@link RandomAccess} generated * by the view. * * @param source * the {@link RealRandomAccessible} to be transformed * @param transformFromSource * the {@link InvertibleRealTransform} transforming source * coordinates to coordinates of the returned * {@link RealRandomAccessible} * @param <T> the type * * @return {@link AffineRandomAccessible} representing the transformed * source */ public static < T > AffineRandomAccessible< T, AffineGet > affine( final RealRandomAccessible< T > source, final AffineGet transformFromSource ) { return new AffineRandomAccessible< >( source, transformFromSource.inverse() ); }
private static < T > RealRandomAccessible< T > createRealRandomAccessible( final RealRandomAccessible< T > rra, final RealTransform t ) { if ( !t.isIdentity() ) { if ( t instanceof AffineGet ) { return new AffineRandomAccessible<>( rra, ( AffineGet ) t ); } return new RealTransformRandomAccessible<>( rra, t ); } return rra; }