Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BlockSupplier API and block algorithm improvements #104

Merged
merged 24 commits into from
Sep 16, 2024
Merged

Conversation

tpietzsch
Copy link
Member

@tpietzsch tpietzsch commented Sep 16, 2024

(1)
Add new BlockSupplier default method

BlockSupplier<U> andThen(Function<BlockSupplier<T>, UnaryBlockOperator<T, U>> function)

that takes a Function that produces a UnaryBlockOperator which is then append to the current BlockSupplier. (The function can pick an operator based on the type and dimensions of the current BlockSupplier.)
This allows to write, e.g.,

import static net.imglib2.algorithm.blocks.convert.Convert.convert;
import static net.imglib2.algorithm.blocks.downsample.Downsample.downsample;
import static net.imglib2.view.fluent.RandomAccessibleIntervalView.Extension.mirrorDouble;

Img<UnsignedByteType> img;

BlockSupplier<FloatType> downsampled = BlockSupplier
		.of(img.view().extend(mirrorDouble()))
		.andThen(convert(new FloatType()))
		.andThen(downsample(Offset.HALF_PIXEL));

(2)
Refactoring and augment existing block algorithm (Convert, Downsample, Transform):

  • Provide the above "operator factories".
  • Add javadoc.
  • Add downsampling method that averages over arbitrarily sized input blocks (for downsampling factor other than 2).
  • Add no-op block operator that is used when converting to the same type (e.g., in generic code, you want any type T to be converted to FloatType. When at runtime T already is FloatType, that is a no-op now.)

(3)
Add TilingBlockSupplier and BlockSupplier.tile(int...) default method.
TilingBlockSupplier wraps a source BlockSupplier, and splits large copy requests into several smaller copy calls on the source BlockSupplier.

Example use cases:

  • Computing large outputs (e. g. to write to N5 or wrap as ArrayImg) with operators that have better performance with smaller block sizes.
  • Avoiding excessively large blocks when chaining multiple downsampling operators.
BlockSupplier<FloatType> downsampled = BlockSupplier
		.of(img.view().extend(mirrorDouble()))
		.andThen(convert(new FloatType()))
		.andThen(downsample(Offset.HALF_PIXEL))
		.tile(32);

	imglib2.version    -> 7.1.1
	imglib2-roi        -> 0.15.1
	bigdataviewer-core -> 10.6.1

Remove obsolete bigdataviewer-vistools dependency.
…ementation.

Add BlockProcessorTargetInterval wrapper.
TilingBlockSupplier wraps a source BlockSupplier, and splits large
BlockSupplier. copy requests into several smaller copy calls on the source
BlockSupplier.

Example use cases:

- Computing large outputs (e. g. to write to N5 or wrap as ArrayImg) with
  operators that have better performance with smaller block sizes.

- Avoiding excessively large blocks when chaining downsampling operators.
downsample by averaging over arbitrarily sized blocks (like in BDV export)
@tpietzsch tpietzsch merged commit 3cfe360 into master Sep 16, 2024
1 check passed
@tpietzsch tpietzsch deleted the blk-algo branch September 16, 2024 20:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant