@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 ); } }
@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 ); }
this.min = min; this.dims = new long[ n ]; source.dimensions( dims );
this.min = min; this.dims = new long[ n ]; source.dimensions( dims );
this.min = min; this.dims = new long[ n ]; source.dimensions( dims );
this.min = min; this.dims = new long[ n ]; source.dimensions( dims );
kernel.dimensions( kernelSize );
@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 ); }