@Override public ByteArray createArray( final int numEntities ) { return new ByteArray( numEntities ); } }
@Override public ByteArray createArray( final int numEntities ) { return new ByteArray( numEntities ); } }
@Override public ByteArray emptyArray(final int entities) { return new ByteArray(entities); }
@Override public ByteArray emptyArray(final int entities) { return new ByteArray(entities); }
public GenericByteType( final byte value ) { img = null; dataAccess = new ByteArray( 1 ); setByte( value ); }
/** * Creates an {@link ArrayImg}<{@link ByteType}, {@link ByteArray}> reusing * a passed byte[] array. */ final public static ArrayImg< ByteType, ByteArray > bytes( final byte[] array, final long... dim ) { return bytes( new ByteArray( array ), dim ); }
@Override public ByteArray load( final ByteBuffer bytes, final int numElements ) { return new ByteArray( loadData( bytes, numElements ) ); } }
/** * Creates an {@link ArrayImg}<{@link UnsignedByteType}, {@link ByteArray}> * reusing a passed byte[] array. */ final public static ArrayImg< UnsignedByteType, ByteArray > unsignedBytes( final byte[] array, final long... dim ) { return unsignedBytes( new ByteArray( array ), dim ); }
/** * Creates an {@link ArrayImg}<{@link UnsignedByteType}, {@link ByteArray}> * reusing a passed byte[] array. */ final public static ArrayImg< UnsignedByteType, ByteArray > unsignedBytes( final byte[] array, final long... dim ) { return unsignedBytes( new ByteArray( array ), dim ); }
public GenericByteType( final byte value ) { img = null; dataAccess = new ByteArray( 1 ); setByte( value ); }
@Override public ByteArray wrap( final A access ) { return new ByteArray( ( byte[] ) access.getCurrentStorageArray() ); }
/** * Creates an {@link ArrayImg}<{@link ByteType}, {@link ByteArray}> reusing * a passed byte[] array. */ final public static ArrayImg< ByteType, ByteArray > bytes( final byte[] array, final long... dim ) { return bytes( new ByteArray( array ), dim ); }
public static ImageStackImageLoader< UnsignedByteType, ByteArray > createUnsignedByteInstance( final ImagePlus imp ) { return new ImageStackImageLoader<>( new UnsignedByteType(), imp, array -> new ByteArray( ( byte[] ) array ) ); }
public UnsignedByteImage(final long[] dim, final byte[] pixels) { super(new ByteArray(pixels), dim, new Fraction()); setLinkedType(new UnsignedByteType(this)); } }
public ByteImagePlus( final long[] dim, final int entitiesPerPixel ) { super( dim, entitiesPerPixel ); if ( entitiesPerPixel == 1 ) { final ImageStack stack = new ImageStack( width, height ); for ( int i = 0; i < numSlices; ++i ) stack.addSlice( "", new ByteProcessor( width, height ) ); imp = new ImagePlus( "image", stack ); imp.setDimensions( channels, depth, frames ); if ( numSlices > 1 ) imp.setOpenAsHyperStack( true ); mirror.clear(); for ( int t = 0; t < frames; ++t ) for ( int z = 0; z < depth; ++z ) for ( int c = 0; c < channels; ++c ) mirror.add( new ByteArray( ( byte[] )imp.getStack().getProcessor( imp.getStackIndex( c + 1, z + 1 , t + 1 ) ).getPixels() ) ); } else { imp = null; mirror.clear(); for ( int i = 0; i < numSlices; ++i ) mirror.add( new ByteArray( width * height * entitiesPerPixel ) ); } }
private static final Img<?> createImg(final BufferedImage bi) { final long[] dims = new long[]{bi.getWidth(), bi.getHeight()}; switch (bi.getType()) { case BufferedImage.TYPE_BYTE_GRAY: case BufferedImage.TYPE_BYTE_INDEXED: ByteArray ba = new ByteArray(((DataBufferByte)bi.getRaster().getDataBuffer()).getData()); ArrayImg<UnsignedByteType, ByteArray> b = new ArrayImg<UnsignedByteType, ByteArray>(ba, dims, new Fraction()); b.setLinkedType(new UnsignedByteType(b)); return b; case BufferedImage.TYPE_USHORT_GRAY: ShortArray sa = new ShortArray(((DataBufferShort)bi.getRaster().getDataBuffer()).getData()); ArrayImg<UnsignedShortType, ShortArray> s = new ArrayImg<UnsignedShortType, ShortArray>(sa, dims, new Fraction()); s.setLinkedType(new UnsignedShortType(s)); return s; case BufferedImage.TYPE_INT_RGB: case BufferedImage.TYPE_INT_ARGB: IntArray ia = new IntArray(((DataBufferInt)bi.getRaster().getDataBuffer()).getData()); ArrayImg<ARGBType, IntArray> i = new ArrayImg<ARGBType, IntArray>(ia, dims, new Fraction()); i.setLinkedType(new ARGBType(i)); return i; } throw new UnsupportedOperationException("Cannot wrap images of type " + bi.getType()); } }
public ByteImagePlus( final ImagePlus imp ) { super( imp.getWidth(), imp.getHeight(), imp.getNSlices(), imp.getNFrames(), imp.getNChannels(), 1 ); this.imp = imp; mirror.clear(); for ( int t = 0; t < frames; ++t ) for ( int z = 0; z < depth; ++z ) for ( int c = 0; c < channels; ++c ) mirror.add( new ByteArray( ( byte[] )imp.getStack().getProcessor( imp.getStackIndex( c + 1, z + 1 , t + 1 ) ).getPixels() ) ); }
/** * Wraps the given primitive array in an {@link ArrayDataAccess} object of the * proper type. */ private ArrayDataAccess<?> createArrayDataAccess(final Object newPlane) { if (newPlane instanceof byte[]) { return new ByteArray((byte[]) newPlane); } else if (newPlane instanceof short[]) { return new ShortArray((short[]) newPlane); } else if (newPlane instanceof int[]) { return new IntArray((int[]) newPlane); } else if (newPlane instanceof float[]) { return new FloatArray((float[]) newPlane); } else if (newPlane instanceof long[]) { return new LongArray((long[]) newPlane); } else if (newPlane instanceof double[]) { return new DoubleArray((double[]) newPlane); } return null; }
/** * Wraps the given primitive array in an {@link ArrayDataAccess} object of the * proper type. */ private ArrayDataAccess<?> createArrayDataAccess(final Object newPlane) { if (newPlane instanceof byte[]) { return new ByteArray((byte[]) newPlane); } else if (newPlane instanceof short[]) { return new ShortArray((short[]) newPlane); } else if (newPlane instanceof int[]) { return new IntArray((int[]) newPlane); } else if (newPlane instanceof float[]) { return new FloatArray((float[]) newPlane); } else if (newPlane instanceof long[]) { return new LongArray((long[]) newPlane); } else if (newPlane instanceof double[]) { return new DoubleArray((double[]) newPlane); } return null; }
/** Wraps raw primitive array in ImgLib2 Array object. */ @Override public ArrayDataAccess<?> makeArray(final Object array) { final ArrayDataAccess<?> access; if (array instanceof byte[]) { access = new ByteArray((byte[]) array); } else if (array instanceof char[]) { access = new CharArray((char[]) array); } else if (array instanceof double[]) { access = new DoubleArray((double[]) array); } else if (array instanceof int[]) { access = new IntArray((int[]) array); } else if (array instanceof float[]) { access = new FloatArray((float[]) array); } else if (array instanceof short[]) { access = new ShortArray((short[]) array); } else if (array instanceof long[]) { access = new LongArray((long[]) array); } else access = null; return access; }