protected < S extends NativeType< S > > VolatileCachedCellImg< S, A > prepareCachedImage( final int timepointId, final int level, final LoadingStrategy loadingStrategy, final S t ) { final int priority = resolutions.length - 1 - level; final CacheHints cacheHints = new CacheHints( loadingStrategy, priority, false ); final CellGrid grid = new CellGrid( dimensions[ level ], cellDimensions[level ] ); return cache.createImg( grid, timepointId, setupId, level, cacheHints, loader, t ); }
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); }
/** * Create a {@link VolatileCachedCellImg} backed by the cache. The type * should be either {@link ARGBType} and {@link VolatileARGBType}. */ protected < T extends NativeType< T > > VolatileCachedCellImg< T, VolatileByteArray > prepareCachedImage( final int timepointId, final int setupId, final int level, final LoadingStrategy loadingStrategy, final T type ) { final long[] dimensions = imageDimensions[ level ]; final int[] cellDimensions = blockDimensions[ level ]; final CellGrid grid = new CellGrid( dimensions, cellDimensions ); final int priority = numScales - 1 - level; final CacheHints cacheHints = new CacheHints( loadingStrategy, priority, false ); return cache.createImg( grid, timepointId, setupId, level, cacheHints, loader, type ); }
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); }
/** * Create a {@link VolatileCachedCellImg} backed by the cache. The type * should be either {@link ARGBType} and {@link VolatileARGBType}. */ protected < T extends NativeType< T > > VolatileCachedCellImg< T, VolatileIntArray > prepareCachedImage( final int timepointId, final int setupId, final int level, final LoadingStrategy loadingStrategy, final T type ) { final long[] dimensions = imageDimensions[ level ]; final CellGrid grid = new CellGrid( dimensions, blockDimensions[ level ] ); final int priority = numScales - 1 - level; final CacheHints cacheHints = new CacheHints( loadingStrategy, priority, false ); return cache.createImg( grid, timepointId, setupId, level, cacheHints, loader, type ); }
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 ); } }
final CellGrid grid = new CellGrid( dimensions, cellDimensions );
/** * (Almost) create a {@link CellImg} backed by the cache. * The created image needs a {@link NativeImg#setLinkedType(net.imglib2.type.Type) linked type} before it can be used. * The type should be either {@link UnsignedShortType} and {@link VolatileUnsignedShortType}. */ protected < T extends NativeType< T > > RandomAccessibleInterval< T > prepareCachedImage( final int timepointId, final int level, final LoadingStrategy loadingStrategy, final T type ) { open(); final ViewLevelId id = new ViewLevelId( timepointId, setupId, level ); if ( ! existsImageData( id ) ) { System.err.println( String.format( "image data for timepoint %d setup %d level %d could not be found. Partition file missing?", id.getTimePointId(), id.getViewSetupId(), id.getLevel() ) ); return getMissingDataImage( id, type ); } final long[] dimensions = getDimsAndExistence( id ).getDimensions(); final int[] cellDimensions = mipmapInfo.getSubdivisions()[ level ]; final CellGrid grid = new CellGrid( dimensions, cellDimensions ); final int priority = mipmapInfo.getMaxLevel() - level; final CacheHints cacheHints = new CacheHints( loadingStrategy, priority, false ); return cache.createImg( grid, timepointId, setupId, level, cacheHints, shortLoader, type ); }
/** * (Almost) create a {@link CellImg} backed by the cache. The created image * needs a {@link NativeImg#setLinkedType(net.imglib2.type.Type) linked * type} before it can be used. The type should be either * {@link UnsignedShortType} and {@link VolatileUnsignedShortType}. */ protected < T extends NativeType< T > > AbstractCellImg< T, A, ?, ? > prepareCachedImage( final ViewLevelId id, final LoadingStrategy loadingStrategy, final T type ) { open(); final int timepointId = id.getTimePointId(); final int setupId = id.getViewSetupId(); final int level = id.getLevel(); final long[] dimensions = mipmapDimensions[ level ]; final int[] cellDimensions = mipmapInfo.getSubdivisions()[ level ]; final CellGrid grid = new CellGrid( dimensions, cellDimensions ); final int priority = mipmapInfo.getMaxLevel() - level; final CacheHints cacheHints = new CacheHints( loadingStrategy, priority, false ); return cache.createImg( grid, timepointId, setupId, level, cacheHints, loader, type ); }
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; }