@Override public NLinearInterpolator< T > copy() { return new NLinearInterpolator< T >( this ); }
final private void graycodeBckRecursive( final int dimension ) { if ( dimension == 0 ) { target.bck( 0 ); code -= 1; accumulate(); } else { graycodeFwdRecursive( dimension - 1 ); target.bck( dimension ); code -= 1 << dimension; accumulate(); graycodeBckRecursive( dimension - 1 ); } }
@Override public NLinearInterpolator< T > copyRealRandomAccess() { return copy(); }
/** * Get the interpolated value at the current position. * * <p> * To visit the pixels that contribute to an interpolated value, we move in * a (binary-reflected) Gray code pattern, such that only one dimension of * the target position is modified per move. * </p> * <p> * See * <a href="http://en.wikipedia.org/wiki/Gray_code">http://en.wikipedia.org/ * wiki/Gray_code</a> * </p> */ @Override public T get() { fillWeights(); accumulator.set( target.get() ); accumulator.mul( weights[ 0 ] ); code = 0; graycodeFwdRecursive( n - 1 ); target.bck( n - 1 ); return accumulator; }
/** * Get the interpolated value at the current position. * * <p> * To visit the pixels that contribute to an interpolated value, we move in * a (binary-reflected) Gray code pattern, such that only one dimension of * the target position is modified per move. * </p> * <p> * See * <a href="http://en.wikipedia.org/wiki/Gray_code">http://en.wikipedia.org/ * wiki/Gray_code</a> * </p> */ @Override public T get() { fillWeights(); accumulator.set( target.get() ); accumulator.mul( weights[ 0 ] ); code = 0; graycodeFwdRecursive( n - 1 ); target.bck( n - 1 ); return accumulator; }
final private void graycodeBckRecursive( final int dimension ) { if ( dimension == 0 ) { target.bck( 0 ); code -= 1; accumulate(); } else { graycodeFwdRecursive( dimension - 1 ); target.bck( dimension ); code -= 1 << dimension; accumulate(); graycodeBckRecursive( dimension - 1 ); } }
@Override public NLinearInterpolator< T > copy() { return new NLinearInterpolator< T >( this ); }
@Override public NLinearInterpolator< T > copyRealRandomAccess() { return copy(); }
final private void graycodeFwdRecursive( final int dimension ) { if ( dimension == 0 ) { target.fwd( 0 ); code += 1; accumulate(); } else { graycodeFwdRecursive( dimension - 1 ); target.fwd( dimension ); code += 1 << dimension; accumulate(); graycodeBckRecursive( dimension - 1 ); } }
@Override public NLinearInterpolator< T > create( final RandomAccessible< T > randomAccessible ) { switch ( randomAccessible.numDimensions() ) { case 1: return new NLinearInterpolator1D< T >( randomAccessible ); case 2: return new NLinearInterpolator2D< T >( randomAccessible ); // case 3: // return new NLinearInterpolator3D< T >( randomAccessible ); default: return new NLinearInterpolator< T >( randomAccessible ); } }
final private void graycodeFwdRecursive( final int dimension ) { if ( dimension == 0 ) { target.fwd( 0 ); code += 1; accumulate(); } else { graycodeFwdRecursive( dimension - 1 ); target.fwd( dimension ); code += 1 << dimension; accumulate(); graycodeBckRecursive( dimension - 1 ); } }
@Override public NLinearInterpolator< T > create( final RandomAccessible< T > randomAccessible ) { switch ( randomAccessible.numDimensions() ) { case 1: return new NLinearInterpolator1D< T >( randomAccessible ); case 2: return new NLinearInterpolator2D< T >( randomAccessible ); // case 3: // return new NLinearInterpolator3D< T >( randomAccessible ); default: return new NLinearInterpolator< T >( randomAccessible ); } }
@SuppressWarnings( { "unchecked", "rawtypes" } ) @Override public RealRandomAccess< T > create( final RandomAccessible< T > randomAccessible ) { final T type = randomAccessible.randomAccess().get(); if ( type instanceof RealType ) { if ( type instanceof Volatile ) return new ClampingNLinearInterpolatorVolatileRealType( randomAccessible ); else return new ClampingNLinearInterpolatorRealType( randomAccessible ); } else if ( ARGBType.class.isInstance( type ) ) { return ( RealRandomAccess ) new NLinearInterpolatorARGB( ( RandomAccessible ) randomAccessible ); } else if ( VolatileARGBType.class.isInstance( type ) ) { return ( RealRandomAccess ) new ClampingNLinearInterpolatorVolatileARGB< VolatileARGBType >( ( RandomAccessible ) randomAccessible ); } else // fall back to (non-clamping) NLinearInterpolator return new NLinearInterpolator<>( randomAccessible ); }
@SuppressWarnings( { "unchecked", "rawtypes" } ) @Override public RealRandomAccess< T > create( final RandomAccessible< T > randomAccessible ) { final T type = randomAccessible.randomAccess().get(); if ( type instanceof RealType ) { if ( type instanceof Volatile ) return new ClampingNLinearInterpolatorVolatileRealType( randomAccessible ); else return new ClampingNLinearInterpolatorRealType( randomAccessible ); } else if ( ARGBType.class.isInstance( type ) ) { return ( RealRandomAccess ) new NLinearInterpolatorARGB( ( RandomAccessible ) randomAccessible ); } else if ( VolatileARGBType.class.isInstance( type ) ) { return ( RealRandomAccess ) new ClampingNLinearInterpolatorVolatileARGB< VolatileARGBType >( ( RandomAccessible ) randomAccessible ); } else // fall back to (non-clamping) NLinearInterpolator return new NLinearInterpolator<>( randomAccessible ); }