Skip to content

Commit

Permalink
Add convenience default method BlockSupplier.toCellImg(...)
Browse files Browse the repository at this point in the history
  • Loading branch information
tpietzsch committed Oct 23, 2024
1 parent 3971611 commit 6156cb8
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/main/java/net/imglib2/algorithm/blocks/BlockSupplier.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import net.imglib2.RandomAccessible;
import net.imglib2.Typed;
import net.imglib2.blocks.PrimitiveBlocks;
import net.imglib2.cache.img.CachedCellImg;
import net.imglib2.type.NativeType;
import net.imglib2.util.Cast;
import net.imglib2.util.Util;
Expand Down Expand Up @@ -156,6 +157,25 @@ default < U extends NativeType< U > > BlockSupplier< U > andThen( Function< Bloc
return andThen( function.apply( this ) );
}

/**
* Return a {@code CachedCellImg} which copies cells from this {@code BlockSupplier}.
*
* @param dimensions
* dimensions of the {@code CachedCellImg} to create
* @param cellDimensions
* block size of the {@code CachedCellImg} to create.
* This is extended or truncated as necessary.
* For example if {@code cellDimensions={64,32}} then for creating a 3D
* image it will be augmented to {@code {64,32,32}}. For creating a 1D image
* it will be truncated to {@code {64}}.
*
* @return a {@code CachedCellImg} which copies cells from this {@code BlockSupplier}.
*/
default CachedCellImg< T, ? > toCellImg( final long[] dimensions, final int... cellDimensions )
{
return BlockAlgoUtils.cellImg( this, dimensions, cellDimensions );
}

/**
* Create a {@code BlockSupplier} accessor for an arbitrary {@code
* RandomAccessible} source. Many View constructions (that ultimately end in
Expand Down

0 comments on commit 6156cb8

Please sign in to comment.