1) A framework for implementing block-processing algorithms that build off the PrimitiveBlocks utility introduced in imglib2 6.2.0.
Package net.imglib2.algorithm.block contains helpers to define and chain block operators.
In particular, the BlockProcessor<I,O> interface specifies an algorithm that computes values in a flattened primitive output array (type O) from values in a flattened primitive input array (type I).
To avoid mistakes in unchecked casting of primitive array types, BlockProcessor should be typically wrapped in UnaryBlockOperator<S,T> where S and T are source and target ImgLib2 RealType corresponding to the respective I and O array types. UnaryBlockOperator can be chained using UnaryBlockOperator.andThen(...).
Block algorithms are intended to run single-threaded.
Multi-threading is achieved on a coarser level by using them in CellLoaders for CahcedCellImg and creating multiple cells in parallel.
2) An operator to convert between common RealTypes (signed and unsigned, with and without clamping).
This code is partially auto-generated using the bin/generate.groovy script lifted from scijava-ops.
3) An operator to downsample, by factor 2, blocks of common RealType.
It can be specified whether intermediate calculations should happen in FLOAT or DOUBLE precision (or AUTOmatically determined). There are versions for downsampling 2x2x2... blocks with half-pixel offset and 3x3x3... blocks on pixel centers.
Together with PrimitiveBlocks from imglib2 core, the downsampling algorithm achieves speedup of
factor ~4 over the downsampling used in bigdataviewer-core, and speedup of factor ~10 to ~30 over the downsampling used in BigStitcher (depending on Java version, block size, etc).
(This is on ArrayImg inputs. Speedups are probably even larger for CellImg or PlanarImg inputs, where PrimitveBlocks has a larger impact.)
I will make PRs to BigStitcher and bigdataviewer-core when this is merged and released.
This PR provides
1) A framework for implementing block-processing algorithms that build off the
PrimitiveBlocks
utility introduced in imglib2 6.2.0. Packagenet.imglib2.algorithm.block
contains helpers to define and chain block operators. In particular, theBlockProcessor<I,O>
interface specifies an algorithm that computes values in a flattened primitive output array (typeO
) from values in a flattened primitive input array (typeI
). To avoid mistakes in unchecked casting of primitive array types,BlockProcessor
should be typically wrapped inUnaryBlockOperator<S,T>
whereS
andT
are source and target ImgLib2 RealType corresponding to the respectiveI
andO
array types.UnaryBlockOperator
can be chained usingUnaryBlockOperator.andThen(...)
.Block algorithms are intended to run single-threaded. Multi-threading is achieved on a coarser level by using them in
CellLoaders
forCahcedCellImg
and creating multiple cells in parallel.2) An operator to convert between common
RealType
s (signed and unsigned, with and without clamping). This code is partially auto-generated using thebin/generate.groovy
script lifted from scijava-ops.3) An operator to downsample, by factor 2, blocks of common
RealType
. It can be specified whether intermediate calculations should happen in FLOAT or DOUBLE precision (or AUTOmatically determined). There are versions for downsampling 2x2x2... blocks with half-pixel offset and 3x3x3... blocks on pixel centers.Together with
PrimitiveBlocks
from imglib2 core, the downsampling algorithm achieves speedup of factor ~4 over the downsampling used in bigdataviewer-core, and speedup of factor ~10 to ~30 over the downsampling used in BigStitcher (depending on Java version, block size, etc). (This is onArrayImg
inputs. Speedups are probably even larger forCellImg
orPlanarImg
inputs, wherePrimitveBlocks
has a larger impact.)I will make PRs to BigStitcher and bigdataviewer-core when this is merged and released.