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 ); }
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; }
/** * See a {@link RealRandomAccessible} as a {@link RandomAccessible} * transformed by an {@link InvertibleRealTransform}. The * {@link InvertibleRealTransform} 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 InvertibleRealTransform}. Here, the inverse is realized by * {@link InverseRealTransform}. That way, changing the state of the * {@link InvertibleRealTransform} 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 RealTransformRandomAccessible} representing the * transformed source */ public static < T > RealTransformRandomAccessible< T, InverseRealTransform > transform( final RealRandomAccessible< T > source, final InvertibleRealTransform transformFromSource ) { return new RealTransformRandomAccessible< >( source, new InverseRealTransform( transformFromSource ) ); }