@Override public Runnable create( final double[] halfkernel, final RandomAccess< S > in, final RandomAccess< T > out, final int d, final long lineLength ) { return new FloatConvolverRealTypeBuffered< S, T >( halfkernel, in, out, d, lineLength ); } };
private static < S extends RealType< S >, T extends RealType< T > > void convolveRealTypeFloat( final double[][] halfkernels, final RandomAccessible< S > source, final RandomAccessibleInterval< T > target, final ExecutorService service ) { final FloatType type = new FloatType(); final ImgFactory< FloatType > imgfac = getImgFactory( target, halfkernels, type ); if ( canUseBufferedConvolver( target, halfkernels ) ) convolve( halfkernels, source, target, FloatConvolverRealTypeBuffered.< S, FloatType >factory(), FloatConvolverRealTypeBuffered.< FloatType, FloatType >factory(), FloatConvolverRealTypeBuffered.< FloatType, T >factory(), FloatConvolverRealTypeBuffered.< S, T >factory(), imgfac, service ); else convolve( halfkernels, source, target, FloatConvolverRealType.< S, FloatType >factory(), FloatConvolverRealType.< FloatType, FloatType >factory(), FloatConvolverRealType.< FloatType, T >factory(), FloatConvolverRealType.< S, T >factory(), imgfac, service ); }
@Override public void run() { final int max = buflen - k1; for ( int i = k1; i < max; ++i ) { final float w = in.get().getRealFloat(); // center buf[ i ] += w * kernel[ 0 ]; // loop for ( int j = 1; j < k1; ++j ) { final float wk = w * kernel[ j ]; buf[ i + j ] += wk; buf[ i - j ] += wk; } // outer-most final float wk = w * kernel[ k1 ]; buf[ i - k1 ] += wk; buf[ i + k1 ] = wk; in.fwd( d ); } writeLine(); }
private static < S extends RealType< S >, T extends RealType< T > > void convolveRealTypeFloat( final double[][] halfkernels, final RandomAccessible< S > source, final RandomAccessibleInterval< T > target, final int numThreads ) { final FloatType type = new FloatType(); final ImgFactory< FloatType > imgfac = getImgFactory( target, halfkernels, type ); if ( canUseBufferedConvolver( target, halfkernels ) ) convolve( halfkernels, source, target, FloatConvolverRealTypeBuffered.< S, FloatType >factory(), FloatConvolverRealTypeBuffered.< FloatType, FloatType >factory(), FloatConvolverRealTypeBuffered.< FloatType, T >factory(), FloatConvolverRealTypeBuffered.< S, T >factory(), imgfac, type, numThreads ); else convolve( halfkernels, source, target, FloatConvolverRealType.< S, FloatType >factory(), FloatConvolverRealType.< FloatType, FloatType >factory(), FloatConvolverRealType.< FloatType, T >factory(), FloatConvolverRealType.< S, T >factory(), imgfac, type, numThreads ); }
@Override public void run() { final int max = buflen - k1; for ( int i = k1; i < max; ++i ) { final float w = in.get().getRealFloat(); // center buf[ i ] += w * kernel[ 0 ]; // loop for ( int j = 1; j < k1; ++j ) { final float wk = w * kernel[ j ]; buf[ i + j ] += wk; buf[ i - j ] += wk; } // outer-most final float wk = w * kernel[ k1 ]; buf[ i - k1 ] += wk; buf[ i + k1 ] = wk; in.fwd( d ); } writeLine(); }
@Override public Runnable create( final double[] halfkernel, final RandomAccess< S > in, final RandomAccess< T > out, final int d, final long lineLength ) { return new FloatConvolverRealTypeBuffered< S, T >( halfkernel, in, out, d, lineLength ); } };
/** * @return a {@link ConvolverFactory} producing {@link FloatConvolverRealTypeBuffered}. */ public static < S extends RealType< S >, T extends RealType< T > > ConvolverFactory< S, T > factory() { return new ConvolverFactory< S, T >() { @Override public Runnable create( final double[] halfkernel, final RandomAccess< S > in, final RandomAccess< T > out, final int d, final long lineLength ) { return new FloatConvolverRealTypeBuffered< S, T >( halfkernel, in, out, d, lineLength ); } }; }
/** * @return a {@link ConvolverFactory} producing * {@link FloatConvolverRealTypeBuffered}. */ public static < S extends RealType< S >, T extends RealType< T > > ConvolverFactory< S, T > factory() { return new ConvolverFactory< S, T >() { @Override public Runnable create( final double[] halfkernel, final RandomAccess< S > in, final RandomAccess< T > out, final int d, final long lineLength ) { return new FloatConvolverRealTypeBuffered< S, T >( halfkernel, in, out, d, lineLength ); } }; }