private CellGrid createCellGrid(final long[] dimensions, final Fraction entitiesPerPixel) { CellImgFactory.verifyDimensions(dimensions); final int n = dimensions.length; final int[] defaultDims = new int[dimensions.length]; for (int d = 0; d < defaultDims.length; d++) { defaultDims[d] = dimensions[d] < defaultCellDimensions[d] ? // (int) dimensions[d] : defaultCellDimensions[d]; } final int[] cellDimensions = CellImgFactory.getCellDimensions( defaultDims, n, entitiesPerPixel); return new CellGrid(dimensions, cellDimensions); }
private CellGrid createCellGrid(final long[] dimensions, final Fraction entitiesPerPixel) { CellImgFactory.verifyDimensions(dimensions); final int n = dimensions.length; final int[] defaultDims = new int[dimensions.length]; for (int d = 0; d < defaultDims.length; d++) { defaultDims[d] = dimensions[d] < defaultCellDimensions[d] ? // (int) dimensions[d] : defaultCellDimensions[d]; } final int[] cellDimensions = CellImgFactory.getCellDimensions( defaultDims, n, entitiesPerPixel); return new CellGrid(dimensions, cellDimensions); }
private CellGrid createCellGrid( final long[] dimensions, final Fraction entitiesPerPixel, final DiskCachedCellImgOptions.Values options ) { CellImgFactory.verifyDimensions( dimensions ); final int n = dimensions.length; final int[] cellDimensions = CellImgFactory.getCellDimensions( options.cellDimensions(), n, entitiesPerPixel ); return new CellGrid( dimensions, cellDimensions ); }
private CellGrid createCellGrid( final long[] dimensions, final Fraction entitiesPerPixel, final ReadOnlyCachedCellImgOptions.Values options ) { CellImgFactory.verifyDimensions( dimensions ); final int n = dimensions.length; final int[] cellDimensions = CellImgFactory.getCellDimensions( options.cellDimensions(), n, entitiesPerPixel ); return new CellGrid( dimensions, cellDimensions ); } }
private < A extends ArrayDataAccess< A > > CellImg< T, A > create( final long[] dimensions, final T type, final NativeTypeFactory< T, A > typeFactory ) { verifyDimensions( dimensions ); final int n = dimensions.length; final Fraction entitiesPerPixel = type.getEntitiesPerPixel(); final int[] cellDimensions = getCellDimensions( defaultCellDimensions, n, entitiesPerPixel ); final CellGrid grid = new CellGrid( dimensions, cellDimensions ); final long[] gridDimensions = new long[ grid.numDimensions() ]; grid.gridDimensions( gridDimensions ); final Cell< A > cellType = new Cell<>( new int[] { 1 }, new long[] { 1 }, null ); final ListImg< Cell< A > > cells = new ListImg<>( gridDimensions, cellType ); final long[] cellGridPosition = new long[ n ]; final long[] cellMin = new long[ n ]; final int[] cellDims = new int[ n ]; final ListLocalizingCursor< Cell< A > > cellCursor = cells.localizingCursor(); while ( cellCursor.hasNext() ) { cellCursor.fwd(); cellCursor.localize( cellGridPosition ); grid.getCellDimensions( cellGridPosition, cellMin, cellDims ); final A data = ArrayDataAccessFactory.get( typeFactory ).createArray( ( int ) entitiesPerPixel.mulCeil( Intervals.numElements( cellDims ) ) ); cellCursor.set( new Cell<>( cellDims, cellMin, data ) ); } final CellImg< T, A > img = new CellImg<>( this, grid, cells, entitiesPerPixel ); img.setLinkedType( typeFactory.createLinkedType( img ) ); return img; }
private < A extends ArrayDataAccess< A > > CellImg< T, A > create( final long[] dimensions, final T type, final NativeTypeFactory< T, A > typeFactory ) { verifyDimensions( dimensions ); final int n = dimensions.length; final Fraction entitiesPerPixel = type.getEntitiesPerPixel(); final int[] cellDimensions = getCellDimensions( defaultCellDimensions, n, entitiesPerPixel ); final CellGrid grid = new CellGrid( dimensions, cellDimensions ); final long[] gridDimensions = new long[ grid.numDimensions() ]; grid.gridDimensions( gridDimensions ); final Cell< A > cellType = new Cell<>( new int[] { 1 }, new long[] { 1 }, null ); final ListImg< Cell< A > > cells = new ListImg<>( gridDimensions, cellType ); final long[] cellGridPosition = new long[ n ]; final long[] cellMin = new long[ n ]; final int[] cellDims = new int[ n ]; final ListLocalizingCursor< Cell< A > > cellCursor = cells.localizingCursor(); while ( cellCursor.hasNext() ) { cellCursor.fwd(); cellCursor.localize( cellGridPosition ); grid.getCellDimensions( cellGridPosition, cellMin, cellDims ); final A data = ArrayDataAccessFactory.get( typeFactory ).createArray( ( int ) entitiesPerPixel.mulCeil( Intervals.numElements( cellDims ) ) ); cellCursor.set( new Cell<>( cellDims, cellMin, data ) ); } final CellImg< T, A > img = new CellImg<>( this, grid, cells, entitiesPerPixel ); img.setLinkedType( typeFactory.createLinkedType( img ) ); return img; }