@Override public PlanarImgFactory< T > factory() { return new PlanarImgFactory<>( linkedType ); }
@SuppressWarnings( { "unchecked", "rawtypes" } ) @Override public < S > ImgFactory< S > imgFactory( final S type ) throws IncompatibleTypeException { if ( NativeType.class.isInstance( type ) ) return new PlanarImgFactory( ( NativeType ) type ); throw new IncompatibleTypeException( this, type.getClass().getCanonicalName() + " does not implement NativeType." ); }
@Override public <T extends RealType<T> & NativeType<T>> Dataset create( final T type, final long[] dims, final String name, final AxisType[] axes) { final PlanarImgFactory<T> imgFactory = new PlanarImgFactory<T>(); return create(imgFactory, type, dims, name, axes); }
@SuppressWarnings( { "unchecked", "rawtypes" } ) @Override public < S > ImgFactory< S > imgFactory( final S type ) throws IncompatibleTypeException { if ( NativeType.class.isInstance( type ) ) return new PlanarImgFactory( ( NativeType ) type ); throw new IncompatibleTypeException( this, type.getClass().getCanonicalName() + " does not implement NativeType." ); }
/** * Create an {@link PlanarImg}<{@link LongType}, {@link LongArray}>. */ @SuppressWarnings( "unchecked" ) final static public PlanarImg< LongType, LongArray > longs( final long... dim ) { return ( PlanarImg< LongType, LongArray > ) new PlanarImgFactory<>( new LongType() ).create( dim ); }
/** * Create an {@link PlanarImg}<{@link UnsignedByteType}, {@link ByteArray}>. */ @SuppressWarnings( "unchecked" ) final static public PlanarImg< UnsignedByteType, ByteArray > unsignedBytes( final long... dim ) { return ( PlanarImg< UnsignedByteType, ByteArray > ) new PlanarImgFactory<>( new UnsignedByteType() ).create( dim ); }
/** * Create an {@link PlanarImg}<{@link UnsignedShortType}, {@link ShortArray} * >. */ @SuppressWarnings( "unchecked" ) final static public PlanarImg< UnsignedShortType, ShortArray > unsignedShorts( final long... dim ) { return ( PlanarImg< UnsignedShortType, ShortArray > ) new PlanarImgFactory<>( new UnsignedShortType() ).create( dim ); }
/** * Create an {@link PlanarImg}<{@link NativeBoolType}, {@link BooleanArray}>. */ @SuppressWarnings( "unchecked" ) final static public PlanarImg< NativeBoolType, BooleanArray > booleans( final long... dim ) { return ( PlanarImg< NativeBoolType, BooleanArray > ) new PlanarImgFactory<>( new NativeBoolType() ).create( dim ); }
/** * Create an {@link PlanarImg}<{@link BitType}, {@link LongArray}>. */ @SuppressWarnings( "unchecked" ) final static public PlanarImg< BitType, LongArray > bits( final long... dim ) { return ( PlanarImg< BitType, LongArray > ) new PlanarImgFactory<>( new BitType() ).create( dim ); }
/** * Create an {@link PlanarImg}<{@link IntType}, {@link IntArray}>. */ @SuppressWarnings( "unchecked" ) final static public PlanarImg< IntType, IntArray > ints( final long... dim ) { return ( PlanarImg< IntType, IntArray > ) new PlanarImgFactory<>( new IntType() ).create( dim ); }
/** * Create an {@link PlanarImg}<{@link FloatType}, {@link FloatArray}>. */ @SuppressWarnings( "unchecked" ) final static public PlanarImg< FloatType, FloatArray > floats( final long... dim ) { return ( PlanarImg< FloatType, FloatArray > ) new PlanarImgFactory<>( new FloatType() ).create( dim ); }
/** * Create an {@link PlanarImg}<{@link UnsignedByteType}, {@link ByteArray}>. */ @SuppressWarnings( "unchecked" ) final static public PlanarImg< UnsignedByteType, ByteArray > unsignedBytes( final long... dim ) { return ( PlanarImg< UnsignedByteType, ByteArray > ) new PlanarImgFactory<>( new UnsignedByteType() ).create( dim ); }
/** * Create an {@link PlanarImg}<{@link UnsignedShortType}, {@link ShortArray} * >. */ @SuppressWarnings( "unchecked" ) final static public PlanarImg< UnsignedShortType, ShortArray > unsignedShorts( final long... dim ) { return ( PlanarImg< UnsignedShortType, ShortArray > ) new PlanarImgFactory<>( new UnsignedShortType() ).create( dim ); }
/** * Create an {@link PlanarImg}<{@link NativeBoolType}, {@link BooleanArray}>. */ @SuppressWarnings( "unchecked" ) final static public PlanarImg< NativeBoolType, BooleanArray > booleans( final long... dim ) { return ( PlanarImg< NativeBoolType, BooleanArray > ) new PlanarImgFactory<>( new NativeBoolType() ).create( dim ); }
/** * Create an {@link PlanarImg}<{@link ComplexFloatType}, {@link FloatArray} * >. */ @SuppressWarnings( "unchecked" ) final static public PlanarImg< ComplexFloatType, FloatArray > complexFloats( final long... dim ) { return ( PlanarImg< ComplexFloatType, FloatArray > ) new PlanarImgFactory<>( new ComplexFloatType() ).create( dim ); }
/** * Create an {@link PlanarImg}<{@link ByteType}, {@link ByteArray}>. */ @SuppressWarnings( "unchecked" ) final static public PlanarImg< ByteType, ByteArray > bytes( final long... dim ) { return ( PlanarImg< ByteType, ByteArray > ) new PlanarImgFactory<>( new ByteType() ).create( dim ); }
/** * Create an {@link PlanarImg}<{@link UnsignedIntType}, {@link IntArray}>. */ @SuppressWarnings( "unchecked" ) final static public PlanarImg< UnsignedIntType, IntArray > unsignedInts( final long... dim ) { return ( PlanarImg< UnsignedIntType, IntArray > ) new PlanarImgFactory<>( new UnsignedIntType() ).create( dim ); }
private ImgPlus<UnsignedByteType> splitColorChannels(ImgPlus<ARGBType> input) { Img<ARGBType> colored = input.getImg(); RandomAccessibleInterval<UnsignedByteType> colorStack = Views.stack( Converters.argbChannel( colored, 1 ), Converters.argbChannel( colored, 2 ), Converters.argbChannel( colored, 3 ) ); ImgPlus<UnsignedByteType> result = new ImgPlus<>(ImgView.wrap(colorStack, new PlanarImgFactory<>()), input.getName()); int lastAxis = colored.numDimensions(); for (int i = 0; i < lastAxis; i++) result.setAxis(input.axis(i).copy(), i); result.setAxis(new DefaultLinearAxis(Axes.CHANNEL), lastAxis); return ImgPlusViews.moveAxis(result, lastAxis, 2); }
@Test public void testCopyToPlanarContainerWithSourceIteration() { final PlanarImg< IntType, ? > planarImg = new PlanarImgFactory<>( new IntType() ).create( dimensions ); copyWithSourceIteration( intImg, planarImg ); assertArrayEquals( intData, getImgAsInts( planarImg ) ); }
@Test public void testCopyToPlanarContainerWithDestIteration() { final PlanarImg< IntType, ? > planarImg = new PlanarImgFactory<>( new IntType() ).create( dimensions ); copyWithDestIteration( intImg, planarImg ); assertArrayEquals( intData, getImgAsInts( planarImg ) ); } }