@Override public DoubleArray createArray( final int numEntities ) { return new DoubleArray( numEntities ); } }
@Override protected DataBufferDouble createDataBuffer( final DoubleArray data ) { final double[] sourceArray = data.getCurrentStorageArray(); return new DataBufferDouble( sourceArray, sourceArray.length ); }
return dirty ? ( volatil ? ( RandomAccessibleCacheLoader< T, A, CA > ) new RandomAccessibleCacheLoader<>( grid, source, type, new DoubleArray( 0 ), a -> new DirtyVolatileDoubleArray( a.getCurrentStorageArray(), true ) ) : ( RandomAccessibleCacheLoader< T, A, CA > ) new RandomAccessibleCacheLoader<>( grid, source, type, new DoubleArray( 0 ), a -> new DirtyDoubleArray( a.getCurrentStorageArray() ) ) ) : ( volatil ? ( RandomAccessibleCacheLoader< T, A, CA > ) new RandomAccessibleCacheLoader<>( grid, source, type, new DoubleArray( 0 ), a -> new VolatileDoubleArray( a.getCurrentStorageArray(), true ) ) : ( RandomAccessibleCacheLoader< T, A, CA > ) new RandomAccessibleCacheLoader<>( grid, source, type, new DoubleArray( 0 ), a -> a ) ); case FLOAT: return dirty
@Override public void convertBytes(final DoubleArray data, final byte[] bytes, final int planesRead) { final ImageMetadata iMeta = reader().getMetadata().get(0); if (isCompatible()) { final int bpp = getBitsPerElement() / 8; final int offset = planesRead * (bytes.length / bpp); final ByteBuffer bb = ByteBuffer.wrap(bytes); bb.order(iMeta.isLittleEndian() ? ByteOrder.LITTLE_ENDIAN : ByteOrder.BIG_ENDIAN); bb.asDoubleBuffer().get(data.getCurrentStorageArray(), offset, bytes.length / bpp); } else { final int pixelType = iMeta.getPixelType(); final int bpp = FormatTools.getBytesPerPixel(pixelType); final int offset = planesRead * (bytes.length / bpp); for (int index = 0; index < bytes.length / bpp; index++) { final double value = utils().decodeWord(bytes, index * bpp, pixelType, iMeta.isLittleEndian()); data.setValue(offset + index, value); } } }
@Override public void convertBytes(final DoubleArray data, final byte[] bytes, final int planesRead) { final ImageMetadata iMeta = reader().getMetadata().get(0); if (isCompatible()) { final int bpp = getBitsPerElement() / 8; final int offset = planesRead * (bytes.length / bpp); final ByteBuffer bb = ByteBuffer.wrap(bytes); bb.order(iMeta.isLittleEndian() ? ByteOrder.LITTLE_ENDIAN : ByteOrder.BIG_ENDIAN); bb.asDoubleBuffer().get(data.getCurrentStorageArray(), offset, bytes.length / bpp); } else { final int pixelType = iMeta.getPixelType(); final int bpp = FormatTools.getBytesPerPixel(pixelType); final int offset = planesRead * (bytes.length / bpp); for (int index = 0; index < bytes.length / bpp; index++) { final double value = utils().decodeWord(bytes, index * bpp, pixelType, iMeta.isLittleEndian()); data.setValue(offset + index, value); } } }
@Override public DoubleArray createArray( final int numEntities ) { return new DoubleArray( numEntities ); } }
@Override protected DataBufferDouble createDataBuffer( final DoubleArray data ) { final double[] sourceArray = data.getCurrentStorageArray(); return new DataBufferDouble( sourceArray, sourceArray.length ); }
@Override public DoubleArray emptyArray(final int entities) { return new DoubleArray(entities); }
@Override public void mutate(final ArrayImg<DoubleType, DoubleArray> arg) { final double[] data = arg.update(null).getCurrentStorageArray(); for (int i = 0; i < data.length; i++) { data[i] *= value; } }
@Override public DoubleArray emptyArray(final int entities) { return new DoubleArray(entities); }
@Override public void mutate(final ArrayImg<DoubleType, DoubleArray> arg) { final double[] data = arg.update(null).getCurrentStorageArray(); for (int i = 0; i < data.length; i++) { data[i] += value; } }
@Override public NativeImg< T, DoubleArray > createDoubleInstance( long[] dimensions, final int entitiesPerPixel ) { if ( dimensions.length > 5 ) throw new RuntimeException( "Unsupported dimensionality: " + dimensions.length ); return new ImagePlusImg< T, DoubleArray >( new DoubleArray( 1 ), dimensions, entitiesPerPixel ); }
@Override public void mutate(final ArrayImg<DoubleType, DoubleArray> arg) { final double[] data = arg.update(null).getCurrentStorageArray(); for (int i = 0; i < data.length; i++) { data[i] -= value; } }
/** * Creates an {@link ArrayImg}<{@link DoubleType}, {@link DoubleArray}> * reusing a passed double[] array. */ final public static ArrayImg< ComplexDoubleType, DoubleArray > complexDoubles( final double[] array, final long... dim ) { return complexDoubles( new DoubleArray( array ), dim ); }
@Override public void mutate(final ArrayImg<DoubleType, DoubleArray> arg) { final double[] data = arg.update(null).getCurrentStorageArray(); for (int i = 0; i < data.length; i++) { data[i] /= value; } }
/** * Creates an {@link ArrayImg}<{@link DoubleType}, {@link DoubleArray}> * reusing a passed double[] array. */ final public static ArrayImg< DoubleType, DoubleArray > doubles( final double[] array, final long... dim ) { return doubles( new DoubleArray( array ), dim ); }
@Override public void mutate(final PlanarImg<DoubleType, DoubleArray> arg) { long planeCount = 1; for (int d = 2; d < arg.numDimensions(); d++) { planeCount *= arg.dimension(d); } for (int p = 0; p < planeCount; p++) { final double[] plane = arg.getPlane(p).getCurrentStorageArray(); for (int i = 0; i < plane.length; i++) { plane[i] *= value; } } }
public NativeARGBDoubleType( final double a, final double r, final double g, final double b ) { img = null; dataAccess = new DoubleArray( 4 ); set( a, r, g, b ); }
@Override public void mutate(final PlanarImg<DoubleType, DoubleArray> arg) { long planeCount = 1; for (int d = 2; d < arg.numDimensions(); d++) { planeCount *= arg.dimension(d); } for (int p = 0; p < planeCount; p++) { final double[] plane = arg.getPlane(p).getCurrentStorageArray(); for (int i = 0; i < plane.length; i++) { plane[i] -= value; } } }
/** * Creates an {@link ArrayImg}<{@link DoubleType}, {@link DoubleArray}> * reusing a passed double[] array. */ final public static ArrayImg< DoubleType, DoubleArray > doubles( final double[] array, final long... dim ) { return doubles( new DoubleArray( array ), dim ); }