Refine search
super( source.numDimensions() ); this.isSigned = source.firstElement().getMinValue() < 0; this.targetArray = target.update( null ).getCurrentStorageArray(); this.normalizationFactor = normalizationFactor; this.min = min; this.dims = new long[ n ]; source.dimensions( dims ); sourceArray = source.update( null ).getCurrentStorageArray();
@Override public ArrayRandomAccess< T > randomAccess( final Interval interval ) { return randomAccess(); }
@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; }
/** * Creates an {@link ArrayImg}<{@link ShortType}, {@link ShortAccess}> * using a {@link ShortAccess} passed as argument. */ final public static < A extends ShortAccess > ArrayImg< ShortType, A > shorts( final A access, final long... dim ) { final ArrayImg< ShortType, A > img = new ArrayImg<>( access, dim, new Fraction() ); final ShortType t = new ShortType( img ); img.setLinkedType( t ); return img; }
/** * 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 void mutate(final ArrayImg<ByteType, ByteArray> arg) { final byte[] data = arg.update(null).getCurrentStorageArray(); for (int i = 0; i < data.length; i++) { data[i] -= value; } }
@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 ); } }
final ArrayRandomAccess< UnsignedShortType > ra = img.randomAccess(); final Random ran = new Random(); for ( int i = 0; i < nspots; i++ ) for ( int d = 0; d < img.numDimensions(); d++ ) ra.setPosition( ran.nextInt( ( int ) img.dimension( d ) ), d ); Gauss3.gauss( rad / Math.sqrt( img.numDimensions() ), source, img ); final ImgPlus< UnsignedShortType > imgplus = new ImgPlus< >( img );
@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); }
final ArrayRandomAccess< UnsignedShortType > ra = img.randomAccess(); final Random ran = new Random(); for ( int i = 0; i < nspots; i++ ) ra.setPosition( ran.nextInt( ( int ) img.dimension( 0 ) ), 0 ); ra.setPosition( ran.nextInt( ( int ) img.dimension( 1 ) ), 1 ); ra.get().set( 5000 );
final int w = (int)target.dimension( 0 ); final int h = (int)target.dimension( 1 ); final int wb = (int)block.dimension( 0 ); final int hb = (int)block.dimension( 1 ); final float[] blockArray = ((FloatArray)block.update( null ) ).getCurrentStorageArray(); final float[] targetArray = ((FloatArray)target.update( null ) ).getCurrentStorageArray();
@Override public void run() { copy( b.array1.cursor(), new RandomAccessibleIntervalCursor< IntType >( b.array2 ) ); } } );
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; }
final ArrayRandomAccess< UnsignedShortType > ra = img.randomAccess(); final Random ran = new Random(); for ( int i = 0; i < nspots; i++ ) ra.setPosition( ran.nextInt( ( int ) img.dimension( 0 ) ), 0 ); ra.setPosition( ran.nextInt( ( int ) img.dimension( 1 ) ), 1 ); ra.get().set( 5000 ); System.out.println( img.size() + "\t" + ( ( double ) ( end - start ) / ntests ) );
img.setLinkedType(new BitType(img)); final RandomAccess<BitType> ra = img.randomAccess(); final byte[] buffer = new byte[in.readInt()]; in.read(buffer);
/** * 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 RandomAccessible<BitType> constantImg(final int numDims) { final long[] dims = new long[numDims]; Arrays.fill(dims, 1); final ArrayImg<BitType, LongArray> bitImg = ArrayImgs.bits(dims); bitImg.setLinkedType(new BitType(bitImg)); bitImg.cursor().next().set(true); return Views.extendBorder(bitImg); }
/** * @param dim a long array with the desired dimensions of the image * @return an {@link Img} of {@link UnsignedByteType} filled with random * values. */ public Img<UnsignedByteType> getRandomUnsignedByteImg(final long[] dim) { final ArrayImg<UnsignedByteType, ByteArray> img = ArrayImgs.unsignedBytes( dim); final UnsignedByteType type = img.firstElement(); final ArrayCursor<UnsignedByteType> cursor = img.cursor(); while (cursor.hasNext()) { cursor.next().set(rand.nextInt((int) type.getMaxValue())); } return img; }
final public static < T extends RealType< T > & NativeType< T > > void populateImage( final ArrayImg< T, ? > img, final BasicViewDescription< ? > vd, final MultipageTiffReader r ) final ArrayCursor< T > cursor = img.cursor(); for ( int j = 0; j < img.dimension( 0 ) * img.dimension( 1 ); ++j ) cursor.next();