@Override public ClampingNLinearInterpolatorVolatileRealType< R, T > copy() { return new ClampingNLinearInterpolatorVolatileRealType<>( 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 ClampingNLinearInterpolatorVolatileRealType< R, 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> * @see <a href="http://en.wikipedia.org/wiki/Gray_code">Gray code</a>. */ @Override public T get() { fillWeights(); final T t = target.get(); acc = t.getRealDouble() * weights[ 0 ]; valid = t.isValid(); code = 0; graycodeFwdRecursive( n - 1 ); target.bck( n - 1 ); accumulator.setReal( Math.max( clampMin, Math.min( clampMax, acc ) ) ); accumulator.setValid( valid ); 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> * @see <a href="http://en.wikipedia.org/wiki/Gray_code">Gray code</a>. */ @Override public T get() { fillWeights(); final T t = target.get(); acc = t.getRealDouble() * weights[ 0 ]; valid = t.isValid(); code = 0; graycodeFwdRecursive( n - 1 ); target.bck( n - 1 ); accumulator.setReal( Math.max( clampMin, Math.min( clampMax, acc ) ) ); accumulator.setValid( valid ); return accumulator; }
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 ClampingNLinearInterpolatorVolatileRealType< R, T > copy() { return new ClampingNLinearInterpolatorVolatileRealType<>( this ); }
@Override public ClampingNLinearInterpolatorVolatileRealType< R, 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 ); } }
@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 ); }
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 ); } }
@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 ); }