@Override public CellImg< T, ? > create( final Dimensions dimensions ) { return create( Intervals.dimensionsAsLongArray( dimensions ) ); }
@Override public CellImg< T, ? > create( final Dimensions dimensions ) { return create( Intervals.dimensionsAsLongArray( dimensions ) ); }
@Deprecated @Override public CellImg< T, ? > create( final long[] dimensions, final T type ) { cache( type ); @SuppressWarnings( { "unchecked", "rawtypes" } ) final CellImg< T, ? > img = create( dimensions, type, ( NativeTypeFactory ) type.getNativeTypeFactory() ); return img; } }
@Deprecated @Override public CellImg< T, ? > create( final long[] dimensions, final T type ) { cache( type ); @SuppressWarnings( { "unchecked", "rawtypes" } ) final CellImg< T, ? > img = create( dimensions, type, ( NativeTypeFactory ) type.getNativeTypeFactory() ); return img; } }
@Override public CellImg< T, ? > create( final long... dimensions ) { @SuppressWarnings( { "unchecked", "rawtypes" } ) final CellImg< T, ? > img = create( dimensions, type(), ( NativeTypeFactory ) type().getNativeTypeFactory() ); return img; }
@Override public CellImg< T, ? > create( final long... dimensions ) { @SuppressWarnings( { "unchecked", "rawtypes" } ) final CellImg< T, ? > img = create( dimensions, type(), ( NativeTypeFactory ) type().getNativeTypeFactory() ); return img; }
/** * Convenience method for creating an appropriate storage img: * {@link ArrayImg} if size is less than {@link Integer#MAX_VALUE}, * {@link CellImg} otherwise. */ private static < T extends NativeType< T > & RealType< T > > Img< T > createAppropriateOneDimensionalImage( final long size, final T t ) { final long[] dim = new long[] { 1, size }; return size > Integer.MAX_VALUE ? new CellImgFactory<>( t, Integer.MAX_VALUE ).create( dim ) : new ArrayImgFactory<>( t ).create( dim ); }
@Override protected Img<T> getProcessingLine( final long sizeProcessLine ) { final Img<T> processLine; // try to use array if each individual line is not too long if ( sizeProcessLine <= Integer.MAX_VALUE ) { isArray = true; processLine = new ArrayImgFactory< T >().create( new long[]{ sizeProcessLine }, getProcessingType() ); } else { isArray = false; processLine = new CellImgFactory< T >( Integer.MAX_VALUE / 16 ).create( new long[]{ sizeProcessLine }, getProcessingType() ); } return processLine; }
@Override protected Img<FloatType> getProcessingLine( final long sizeProcessLine ) { final Img<FloatType> processLine; // try to use array if each individual line is not too long if ( sizeProcessLine <= Integer.MAX_VALUE ) { isArray = true; processLine = new ArrayImgFactory< FloatType >().create( new long[]{ sizeProcessLine }, new FloatType() ); } else { isArray = false; processLine = new CellImgFactory< FloatType >( Integer.MAX_VALUE / 16 ).create( new long[]{ sizeProcessLine }, new FloatType() ); } return processLine; }
public void createSourceData() { dimensions = new long[] { 480, 480, 102 }; numValues = 1; for ( int d = 0; d < dimensions.length; ++d ) numValues *= dimensions[ d ]; intData = new int[ numValues ]; intDataSum = 0; final Random random = new Random( 0 ); for ( int i = 0; i < numValues; ++i ) { intData[ i ] = random.nextInt(); intDataSum += intData[ i ]; } intImg = new CellImgFactory<>( new IntType(), 40 ).create( dimensions ); }
@Override protected Img< DoubleType > getProcessingLine( final long sizeProcessLine ) { final Img< DoubleType > processLine; // try to use array if each individual line is not too long if ( sizeProcessLine <= Integer.MAX_VALUE ) { isArray = true; processLine = new ArrayImgFactory< DoubleType >().create( new long[] { sizeProcessLine }, new DoubleType() ); } else { isArray = false; processLine = new CellImgFactory< DoubleType >( Integer.MAX_VALUE / 16 ).create( new long[] { sizeProcessLine }, new DoubleType() ); } return processLine; }
@Override protected Img< T > getProcessingLine( final long sizeProcessLine ) { final Img< T > processLine; // try to use array if each individual line is not too long if ( sizeProcessLine <= Integer.MAX_VALUE ) { isArray = true; processLine = new ArrayImgFactory< T >().create( new long[] { sizeProcessLine }, getProcessingType() ); } else { isArray = false; processLine = new CellImgFactory< T >( Integer.MAX_VALUE / 16 ).create( new long[] { sizeProcessLine }, getProcessingType() ); } return processLine; }
private < T extends NativeType< T > > void testDefaultCellSize( final T type ) { final int defaultCellSize = 43; final int[] expectedCellDims = { 43, 43, 43, 43 }; final CellImgFactory< T > factory = new CellImgFactory<>( type, defaultCellSize ); final long[] dimension = { 100, 80, 4, 3 }; final CellImg< T, ? > img = factory.create( dimension ); final int[] cellDims = new int[ dimension.length ]; img.getCellGrid().cellDimensions( cellDims ); assertArrayEquals( expectedCellDims, cellDims ); }
@Before public void setUp() { cellDimensions = new int[] { 8, 16, 5, 2 }; dimensions = new long[] { 20, 37, 12, 33 }; img = new CellImgFactory<>( new FloatType(), cellDimensions ).create( dimensions ); }
private < T extends NativeType< T > > void testDefaultCellDimensions( final T type ) { final int[] defaultCellDims = { 6, 8, 5, 3 }; final int[] expectedCellDims = defaultCellDims.clone(); final CellImgFactory< T > factory = new CellImgFactory<>( type, defaultCellDims ); final long[] dimension = { 100, 80, 4, 3 }; final CellImg< T, ? > img = factory.create( dimension ); final int[] cellDims = new int[ dimension.length ]; img.getCellGrid().cellDimensions( cellDims ); assertArrayEquals( expectedCellDims, cellDims ); }
@Test public void testCopyToCellContainerWithDestIteration() { final CellImg< IntType, ? > cellImg = new CellImgFactory<>( new IntType(), new int[] { 2, 7, 4 } ).create( dimensions ); copyWithDestIteration( intImg, cellImg ); assertArrayEquals( intData, getImgAsInts( cellImg ) ); }
public CellImg<ByteType, ?> generateByteTestCellImg(final boolean fill, final int[] cellDims, final long... dims) { final CellImg<ByteType, ?> img = new CellImgFactory<ByteType>(cellDims) .create(dims, new ByteType()); if (fill) { final Cursor<ByteType> c = img.cursor(); while (c.hasNext()) c.next().set((byte) pseudoRandom()); } return img; }
@Test public void testCopyToCellContainerWithSourceIteration() { final CellImg< IntType, ? > cellImg = new CellImgFactory<>( new IntType(), new int[] { 2, 7, 4 } ).create( dimensions ); copyWithSourceIteration( intImg, cellImg ); assertArrayEquals( intData, getImgAsInts( cellImg ) ); }
@Test public void equalIterationOrder() { final Img< FloatType > img2 = new CellImgFactory<>( new FloatType(), cellDimensions ).create( dimensions ); assertTrue( img2.iterationOrder().equals( img.iterationOrder() ) ); assertTrue( img.iterationOrder().equals( img2.iterationOrder() ) ); final Img< FloatType > img3 = new CellImgFactory<>( new FloatType(), 9 ).create( dimensions ); assertFalse( img3.iterationOrder().equals( img.iterationOrder() ) ); assertFalse( img.iterationOrder().equals( img3.iterationOrder() ) ); final Img< FloatType > img4 = new ArrayImgFactory<>( new FloatType() ).create( dimensions ); assertFalse( img4.iterationOrder().equals( img.iterationOrder() ) ); assertFalse( img.iterationOrder().equals( img4.iterationOrder() ) ); } }
public CellImg<ByteType, ?> generateByteTestCellImg(final boolean fill, final long... dims) { final CellImg<ByteType, ?> img = new CellImgFactory<ByteType>().create(dims, new ByteType()); if (fill) { final Cursor<ByteType> c = img.cursor(); while (c.hasNext()) c.next().set((byte) pseudoRandom()); } return img; }