@Override public ImgPlus<DoubleType> img() { final Img<DoubleType> img = new ResultsImg(this); final AxisType[] axes = { Axes.X, Axes.Y }; final String name = "Results"; final ImgPlus<DoubleType> imgPlus = new ImgPlus<DoubleType>(img, name, axes); // TODO: Once ImgPlus has a place for row & column labels, add those too. return imgPlus; }
private <T extends RealType<?>> ImgPlus<T> wrapAsImgPlus( final Img<T> newImg, final AxisType[] axes, final double[] calib) { return new ImgPlus<T>(newImg, getName(), axes, calib); }
@Override public <T extends RealType<T>> Dataset create( final ImgFactory<T> factory, final T type, final long[] dims, final String name, final AxisType[] axes) { final Img<T> img = factory.create(dims, type); final ImgPlus<T> imgPlus = new ImgPlus<T>(img, name, axes, null); return create(imgPlus); }
/** Makes an image that has same type, container, and dimensions as refImage. */ private static <T extends RealType<T>> ImgPlus<T> createBlankCopy( final ImgPlus<T> img) { final long[] dimensions = new long[img.numDimensions()]; img.dimensions(dimensions); final Img<T> blankImg = img.factory().create(dimensions, img.firstElement()); return new ImgPlus<T>(blankImg, img); }
public static < T extends NumericType< T > & NativeType< T > > ImgPlus< T > wrapImgPlus( final ImagePlus imp ) { Img< T > img = wrap( imp ); ImgPlus< T > image = new ImgPlus< T >( img ); // set calibration setCalibrationFromImagePlus1( image, imp ); // set title image.setName( imp.getTitle() ); // set axes setAxesFromImagePlus( image, imp ); return image; }
/** * {@inheritDoc} */ @Override public ImgPlus< T > createEmptyOutput( ImgPlus< T > op ) { AxisType[] axes = new AxisType[ op.numDimensions() ]; op.axes( axes ); m_isNewDim.clear(); for ( int d = 0; d < m_newDimensions.length; d++ ) { for ( int a = 0; a < axes.length; a++ ) { if ( !axes[ a ].getLabel().equals( m_newDimensions[ d ] ) ) { m_isNewDim.set( d ); } } } long[] newDims = new long[ op.numDimensions() + m_isNewDim.cardinality() ]; Arrays.fill( newDims, 1 ); for ( int i = 0; i < op.numDimensions(); i++ ) { newDims[ i ] = op.dimension( i ); } return new ImgPlus< T >( op.factory().create( newDims, op.firstElement().createVariable() ) ); }
/** * {@inheritDoc} */ @Override public ImgPlus< T > createEmptyOutput( ImgPlus< T > op ) { BitSet isLength1 = new BitSet( op.numDimensions() ); for ( int d = 0; d < op.numDimensions(); d++ ) { if ( op.dimension( d ) == 1 ) { isLength1.set( d ); } } long[] min = new long[ op.numDimensions() - isLength1.cardinality() ]; long[] max = new long[ min.length ]; int d = 0; for ( int i = 0; i < op.numDimensions(); i++ ) { if ( !isLength1.get( i ) ) { max[ d ] = op.dimension( i ) - 1; d++; } } Img< T > res = op.factory().create( new FinalInterval( min, max ), op.firstElement().createVariable() ); return new ImgPlus< T >( res ); }