/** * Creates an Interval with the boundaries [0, dimensions-1] * * @param dimensions * - the size of the interval */ public AbstractInterval( final Dimensions dimensions ) { this( dimensions.numDimensions() ); for ( int d = 0; d < n; ++d ) this.max[ d ] = dimensions.dimension( d ) - 1; }
private static long[] dimensions( final Dimensions img ) { final long[] dimensions = new long[ img.numDimensions() ]; img.dimensions( dimensions ); return dimensions; } }
public static RealInterval getBoundingBoxReal( final Dimensions dims, final AffineTransform3D transform ) { final double[] min = new double[]{ 0, 0, 0 }; final double[] max = new double[]{ dims.dimension( 0 ) - 1, dims.dimension( 1 ) - 1, dims.dimension( 2 ) - 1 }; return transform.estimateBounds( new FinalRealInterval( min, max ) ); } }
final long[] dim = new long[dimAccu.numDimensions()]; dimAccu.dimensions( dim ); dim[2] += dimNew.dimension( 2 ); dimensionGroupedMap.put( key, new ValuePair<>(new FinalDimensions( dim ), dimensionGroupedMap.get( key ).getB() ) );
/** * Calculates padding size size for real to complex FFT * * @param fast if true calculate size for fast FFT * @param inputDimensions original real dimensions * @return padded real dimensions */ public static Dimensions getPaddedInputDimensionsRealToComplex( final boolean fast, final Dimensions inputDimensions) { final long[] paddedSize = new long[inputDimensions.numDimensions()]; final long[] fftSize = new long[inputDimensions.numDimensions()]; dimensionsRealToComplex(fast, inputDimensions, paddedSize, fftSize); return new FinalDimensions(paddedSize); }
subdivisions.add( subdiv_16_16_16 ); setup.getSize().dimensions( size ); long maxSize = 0; for ( int d = 0; d < 3; ++d )
final long dim0 = op.dimension( m_dimIndex0 ); for ( Queue< T > q : m_kernel ) op.dimensions( dim ); dim[ m_dimIndex0 ] = 1;
public static List< AffineTransform3D > generateRegularGrid(RegularTranslationParameters params, Dimensions dims) { final ArrayList< AffineTransform3D > transforms = new ArrayList<>(); int nTiles = prod(params.nSteps); for (int i = 0; i < nTiles; ++i) transforms.add(new AffineTransform3D()); int modulo = 1; for (int i = 0; i < params.nDimensions; ++i) { int d = params.dimensionOrder[i]; double moveSize = (1.0 - params.overlaps[d]) * dims.dimension( d ); moveD(transforms, d, moveSize, modulo, params.nSteps[d], params.alternating[d], params.increasing[d]); modulo *= params.nSteps[d]; } //transforms.forEach( ( t ) -> System.out.println( Util.printCoordinates( t.getTranslation() ))) ; return transforms; }
/** * Calculates complex FFT size for real to complex FFT * * @param fast if true calculate size for fast FFT * @param inputDimensions original real dimensions * @return complex FFT dimensions */ public static Dimensions getFFTDimensionsRealToComplex(final boolean fast, final Dimensions inputDimensions) { final long[] paddedSize = new long[inputDimensions.numDimensions()]; final long[] fftSize = new long[inputDimensions.numDimensions()]; dimensionsRealToComplex(fast, inputDimensions, paddedSize, fftSize); return new FinalDimensions(fftSize); }
private K binaryop( ConnectedType type, final K r, final K op, final boolean erode, final int count ) r.dimensions( dim ); switch ( r.numDimensions() )
static boolean canUseBufferedConvolver( final Dimensions targetsize, final double[][] halfkernels ) { final int n = targetsize.numDimensions(); for ( int d = 0; d < n; ++d ) if ( targetsize.dimension( d ) + 4 * halfkernels[ d ].length - 4 > Integer.MAX_VALUE ) return false; return true; }
/** * Gets the dimensions of a {@link Dimensions}. */ public static long[] getDims(final Dimensions dimensions) { final long[] dims = new long[dimensions.numDimensions()]; dimensions.dimensions(dims); return dims; }
private static Translation3D getCenterTranslation(Collection<Translation3D> translations, Dimensions size) { final int n = translations.iterator().next().numDimensions(); double[] centerTranslation = new double[n]; int count = 0; for (final Translation3D t : translations) { for (int d = 0; d<n; d++) centerTranslation[d] += t.getTranslation( d ); count++; } for (int d = 0; d<n; d++) { centerTranslation[d] /= count; centerTranslation[d] += size.dimension( d ) / 2; centerTranslation[d] *= -1; } return new Translation3D( centerTranslation ); }
public static BoundingBox getBoundingBox( final Dimensions dims, final AffineTransform3D transform ) { final RealInterval interval = getBoundingBoxReal( dims, transform ); final int[] minInt = new int[ 3 ]; final int[] maxInt = new int[ 3 ]; for ( int d = 0; d < dims.numDimensions(); ++d ) { minInt[ d ] = (int)Math.round( interval.realMin( d ) ) - 1; maxInt[ d ] = (int)Math.round( interval.realMax( d ) ) + 1; } return new BoundingBox( minInt, maxInt ); }
FloodFill< BitType, K > ff = new FloodFill< BitType, K >( m_connectedType ); long[] dim = new long[ r.numDimensions() ]; r.dimensions( dim ); Cursor< BitType > rc = r.cursor(); Cursor< BitType > opc = op.localizingCursor();
static boolean canUseArrayImgFactory( final Dimensions targetsize, final double[][] halfkernels ) { final int n = targetsize.numDimensions(); long size = targetsize.dimension( 0 ); for ( int d = 1; d < n; ++d ) size *= targetsize.dimension( d ) + 2 * halfkernels[ d ].length; return size <= Integer.MAX_VALUE; }
private static long[] dims(Dimensions d) { final long[] dims = new long[d.numDimensions()]; d.dimensions(dims); return dims; }
@Override protected void loadMetaData( ViewId view ) { final BasicViewDescription< ? > vd = sd.getViewDescriptions().get( view ); final Dimensions d = vd.getViewSetup().getSize(); final VoxelDimensions dv = vd.getViewSetup().getVoxelSize(); updateMetaDataCache( view, (int)d.dimension( 0 ), (int)d.dimension( 1 ), (int)d.dimension( 2 ), dv.dimension( 0 ), dv.dimension( 1 ), dv.dimension( 2 ) ); }
@Override public long[][] calculate(Dimensions inputDimensions) { long[][] size = new long[2][]; size[0] = new long[inputDimensions.numDimensions()]; size[1] = new long[inputDimensions.numDimensions()]; if (fast && forward) { FFTMethods.dimensionsRealToComplexFast(inputDimensions, size[0], size[1]); } else if (!fast && forward) { FFTMethods.dimensionsRealToComplexSmall(inputDimensions, size[0], size[1]); } if (fast && !forward) { FFTMethods.dimensionsComplexToRealFast(inputDimensions, size[0], size[1]); } else if (!fast && !forward) { FFTMethods.dimensionsComplexToRealSmall(inputDimensions, size[0], size[1]); } return size; }
@SuppressWarnings("unchecked") public <T extends RealType< T > & NativeType< T >> RandomAccessibleInterval< T > createVirtual( final IFormatReader reader, final File file, final int series, final int channel, final int timepoint, T type, Dimensions dim) throws IncompatibleTypeException { setReaderFileAndSeriesIfNecessary( reader, file, series ); final boolean isLittleEndian = reader.isLittleEndian(); final long[] dims = new long[]{reader.getSizeX(), reader.getSizeY(), reader.getSizeZ()}; if (dim != null) dim.dimensions( dims ); final int pixelType = reader.getPixelType(); if (pixelType == FormatTools.UINT8) return new VirtualRandomAccessibleIntervalLOCI< T >( reader, file, dims, series, channel, timepoint, type == null ? (T) new UnsignedByteType() : type, (t, buf, i) -> {t.setReal( (int) buf[i] & 0xff);} ); else if (pixelType == FormatTools.UINT16) return new VirtualRandomAccessibleIntervalLOCI< T >( reader, file, dims, series, channel, timepoint, type == null ? (T) new UnsignedShortType() : type, (t, buf, i) -> {t.setReal( LegacyStackImgLoaderLOCI.getShortValueInt( buf, i*2, isLittleEndian ) );} ); else if (pixelType == FormatTools.INT16) return new VirtualRandomAccessibleIntervalLOCI< T >( reader, file, dims, series, channel, timepoint, type == null ? (T) new ShortType() : type, (t, buf, i) -> {t.setReal( LegacyStackImgLoaderLOCI.getShortValue( buf, i*2, isLittleEndian ) );} ); else if (pixelType == FormatTools.UINT32) return new VirtualRandomAccessibleIntervalLOCI< T >( reader, file, dims, series, channel, timepoint, type == null ? (T) new UnsignedIntType() : type, (t, buf, i) -> {t.setReal( LegacyStackImgLoaderLOCI.getIntValue( buf, i*4, isLittleEndian ) );} ); else if (pixelType == FormatTools.FLOAT) return new VirtualRandomAccessibleIntervalLOCI< T >( reader, file, dims, series, channel, timepoint, type == null ? (T) new FloatType() : type, (t, buf, i) -> {t.setReal( LegacyStackImgLoaderLOCI.getFloatValue( buf, i*4, isLittleEndian ) );} ); else throw new IncompatibleTypeException( this, "cannot create virtual image for this pixel type" ); }