/** * {@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 > compute( ImgPlus< T > op, ImgPlus< T > r ) { r.setName( op.getName() ); r.setSource( op.getSource() ); for ( int d = 0; d < op.numDimensions(); d++ ) { r.setAxis( op.axis( d ), d ); r.setCalibration( op.calibration( d ), d ); } new ImgCopyOperation< T >().compute( op, r ); return r; }
/** 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); }
@Override public void setCalibration(final double cal, final int d) { if (imgPlus.calibration(d) == cal) return; imgPlus.setCalibration(cal, d); update(true); }
public ImgPlus< T > compute( ImgPlus< T > op, ImgPlus< T > r ) Cursor< T > srcCur = op.localizingCursor(); RandomAccess< T > resRA = r.randomAccess(); r.setName( op.getName() ); for ( int d = 0; d < op.numDimensions(); d++ ) r.setAxis( Axes.get( op.axis( d ).getLabel() ), d ); int d = op.numDimensions(); for ( int i = 0; i < m_newDimensions.length; i++ ) r.setAxis( Axes.get( m_newDimensions[ i ] ), d ); d++; for ( int i = 0; i < op.numDimensions(); i++ )
public ImgPlus< T > compute( ImgPlus< T > op, ImgPlus< T > r ) Cursor< T > srcCur = op.localizingCursor(); RandomAccess< T > resRA = r.randomAccess(); BitSet isLength1 = new BitSet( op.numDimensions() ); for ( int d = 0; d < op.numDimensions(); d++ ) if ( op.dimension( d ) == 1 ) for ( int i = 0; i < op.numDimensions(); i++ )
Calibration impcal = target.getCalibration(); int xaxis = imgplus.getAxisIndex(Axes.X); if (xaxis >= 0) { impcal.pixelWidth = imgplus.calibration(xaxis); int yaxis = imgplus.getAxisIndex(Axes.Y); if (yaxis >= 0) { impcal.pixelHeight = imgplus.calibration(yaxis); int zaxis = imgplus.getAxisIndex(Axes.Z); if (zaxis >= 0) { impcal.pixelDepth = imgplus.calibration(zaxis); int taxis = imgplus.getAxisIndex(Axes.TIME); if (taxis >= 0) { impcal.frameInterval = imgplus.calibration(taxis); target.setTitle( imgplus.getName() );
/** * Creates a DrawingTool to modify a specified Dataset. Will draw pixel values * using current channel values (default all zero). After construction the * default U axis will be the first non-channel axis. The default V axis will * be the second non-channel axis. */ public DrawingTool(final Dataset ds, RenderingService service) { this.dataset = ds; this.accessor = ds.getImgPlus().randomAccess(); this.channels = new ChannelCollection(); this.lineWidth = 1; this.intensity = 1; // FIXME - initialize renderer externally later. For now this works. this.textRenderer = service.getTextRenderer(); this.u0 = 0; this.v0 = 0; this.preferredChannel = -1; initAxisVariables(); }
private Object copyOfPlane(final int planeNum) { final long[] dimensions = new long[imgPlus.numDimensions()]; imgPlus.dimensions(dimensions); final long w = dimensions[0]; final long h = dimensions[1]; (ArrayImg<?, ?>) nativeType.createSuitableNativeImg(storageFactory, new long[] { w, h }); final RandomAccess<? extends RealType<?>> input = imgPlus.randomAccess(); @SuppressWarnings("unchecked") final RandomAccess<? extends RealType<?>> output =
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; }
protected static < T extends NumericType< T > & NativeType< T > > void setCalibrationFromImagePlus1( final ImgPlus<T> image, final ImagePlus imp ) final int d = image.numDimensions(); final float [] spacing = new float[d]; image.setCalibration( spacing );
@Override public String getSource() { return imgPlus.getSource(); }
@Override public ImgPlus< T > compute( ImgPlus< T > op, ImgPlus< T > r ) { Cursor< T > rc = r.localizingCursor(); RandomAccess< T > opc = op.randomAccess(); while ( rc.hasNext() ) { rc.next(); for ( int d = 0; d < m_interval.numDimensions(); d++ ) { opc.setPosition( rc.getLongPosition( d ) + m_interval.min( d ), d ); } rc.get().set( opc.get() ); } return r; }
@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; }
@Override public double calibration(final int d) { return imgPlus.calibration(d); }
@Override public void setCalibration(float[] cal) { imgPlus.setCalibration(cal); }
@Override public String getName() { return imgPlus.getName(); }
@Override public int numDimensions() { return imgPlus.numDimensions(); }