/** * TODO Javadoc * * @param img * @param offset * @param size */ public AbstractArrayCursor( final ArrayImg< T, ? > img, final int offset, final int size ) { super( img.numDimensions() ); this.type = img.createLinkedType(); this.img = img; this.lastIndex = offset + size - 1; this.offset = offset; this.size = size; reset(); }
/** * TODO Javadoc * * @param img * @param offset * @param size */ public AbstractArrayCursor( final ArrayImg< T, ? > img, final int offset, final int size ) { super( img.numDimensions() ); this.type = img.createLinkedType(); this.img = img; this.lastIndex = offset + size - 1; this.offset = offset; this.size = size; reset(); }
private long offset( final Interval interval ) { final int maxDim = numDimensions() - 1; long i = interval.min( maxDim ); for ( int d = maxDim - 1; d >= 0; --d ) { i = i * dimension( d ) + interval.min( d ); } return i; }
private long offset( final Interval interval ) { final int maxDim = numDimensions() - 1; long i = interval.min( maxDim ); for ( int d = maxDim - 1; d >= 0; --d ) { i = i * dimension( d ) + interval.min( d ); } return i; }
public ArrayRandomAccess( final ArrayImg< T, ? > container ) { super( container.numDimensions() ); this.img = container; this.type = container.createLinkedType(); for ( int d = 0; d < n; d++ ) position[ d ] = 0; type.updateContainer( this ); type.updateIndex( 0 ); }
public ArrayRandomAccess( final ArrayImg< T, ? > container ) { super( container.numDimensions() ); this.img = container; this.type = container.createLinkedType(); for ( int d = 0; d < n; d++ ) position[ d ] = 0; type.updateContainer( this ); type.updateIndex( 0 ); }
public static ArrayImg< FloatType, ? > computeInvertedKernel( final ArrayImg< FloatType, ? > kernel ) { final ArrayImg< FloatType, ? > invKernel = kernel.copy(); for ( int d = 0; d < invKernel.numDimensions(); ++d ) Mirror.mirror( invKernel, d, Threads.numThreads() ); return invKernel; }
public Img< ComplexFloatType > getKernel1FFT() { if ( fftKernel1 == null ) { if ( service == null ) throw new RuntimeException( "getKernel1FFT can only be called after calling init()."); final long[] min = new long[ kernel1.numDimensions() ]; final long[] max = new long[ kernel1.numDimensions() ]; final Pair< Interval, Interval > fftIntervals = FFTConvolution.setupFFTs( new FinalInterval( Util.int2long( blockSize ) ), kernel1, min, max ); fftKernel1 = FFTConvolution.computeKernelFFT( fftIntervals.getB(), min, max, false, Views.extendValue( kernel1, new FloatType() ), new ArrayImgFactory< ComplexFloatType >(), service ); } return fftKernel1; }
public Img< ComplexFloatType > getKernel2FFT() { if ( fftKernel2 == null ) { if ( service == null ) throw new RuntimeException( "getKernel2FFT can only be called after calling init()."); final long[] min = new long[ kernel2.numDimensions() ]; final long[] max = new long[ kernel2.numDimensions() ]; final Pair< Interval, Interval > fftIntervals = FFTConvolution.setupFFTs( new FinalInterval( Util.int2long( blockSize ) ), kernel2, min, max ); fftKernel2 = FFTConvolution.computeKernelFFT( fftIntervals.getB(), min, max, false, Views.extendValue( kernel2, new FloatType() ), new ArrayImgFactory< ComplexFloatType >(), service ); } return fftKernel2; }
/** * TODO Javadoc * * @param img * @param offset * @param size */ public AbstractArrayLocalizingCursor( final ArrayImg< T, ? > img, final int offset, final int size ) { super( img.numDimensions() ); this.img = img; this.offset = offset; this.size = size; this.type = img.createLinkedType(); this.lastIndex = offset + size - 1; max = new int[ n ]; for ( int d = 0; d < n; ++d ) max[ d ] = ( int ) img.max( d ); reset(); }
/** * TODO Javadoc * * @param img * @param offset * @param size */ public AbstractArrayLocalizingCursor( final ArrayImg< T, ? > img, final int offset, final int size ) { super( img.numDimensions() ); this.img = img; this.offset = offset; this.size = size; this.type = img.createLinkedType(); this.lastIndex = offset + size - 1; max = new int[ n ]; for ( int d = 0; d < n; ++d ) max[ d ] = ( int ) img.max( d ); reset(); }
@Override public ArrayImg<T, A> createOutput(final ArrayImg<T, A> input) { // NB: Workaround for ArrayImgFactory not overriding create(Dimensions, T). final long[] dims = new long[ input.numDimensions() ]; input.dimensions( dims ); final ArrayImg<T, ?> copy = input.factory().create(dims, input.firstElement().createVariable()); // TODO: Find a way to guarantee the type. @SuppressWarnings("unchecked") final ArrayImg<T, A> typedCopy = (ArrayImg<T, A>) copy; return typedCopy; }
@Test public void testOverSizedBitImageArrayImgs() { final int numLongs = ( int ) Math.ceil( 100 * 100 / 64d ); final ArrayImg< BitType, LongArray > img = ArrayImgs.bits( 100, 100 ); final Random r = new Random( 42l ); img.forEach( p -> { p.set( r.nextBoolean() ); } ); final long[] storage = ( long[] ) ( ( ArrayDataAccess< ? > ) img.update( null ) ).getCurrentStorageArray(); final long[] sizes = new long[ img.numDimensions() ]; img.dimensions( sizes ); assertEquals( numLongs, storage.length ); } }
super( source.numDimensions() );
@Test public void testOverSizedBitImageExplicitStorageArray() { final int numLongs = ( int ) Math.ceil( 100 * 100 / 64d ); final ArrayImg< BitType, LongArray > img = ArrayImgs.bits( new LongArray( new long[ numLongs ] ), 100, 100 ); final Random r = new Random( 42l ); img.forEach( p -> { p.set( r.nextBoolean() ); } ); final long[] storage = ( long[] ) ( ( ArrayDataAccess< ? > ) img.update( null ) ).getCurrentStorageArray(); final long[] sizes = new long[ img.numDimensions() ]; img.dimensions( sizes ); assertEquals( storage.length, numLongs ); }
super( source.numDimensions() );
super( source.numDimensions() );
super( source.numDimensions() );
@Test public void testOverSizedBitImageImgFactory() { final ArrayImgFactory< BitType > factory = new ArrayImgFactory<>( new BitType() ); // evenly dividable by 64 final int numLongs = 1000 * 1000 / 64; final ArrayImg< BitType, ? > img = factory.create( 1000, 1000 ); final Random r = new Random( 42l ); img.forEach( p -> { p.set( r.nextBoolean() ); } ); final long[] storage = ( long[] ) ( ( ArrayDataAccess< ? > ) img.update( null ) ).getCurrentStorageArray(); final long[] sizes = new long[ img.numDimensions() ]; img.dimensions( sizes ); assertEquals( numLongs, storage.length ); }
@Override @Before public void setUp() { super.setUp(); // make a random float array image img = generateFloatArrayTestImg(true, 100, 100); // get direct access to the float array array = img.update(null).getCurrentStorageArray(); arraySize = 1; for (int d = 0; d < img.numDimensions(); d++) arraySize *= img.dimension(d); randomlyFilledImg = generateRandomlyFilledUnsignedByteTestImgWithSeed( new long[] { 100, 100 }, 1234567890L); }