Skip to content

Latest commit

 

History

History
36 lines (29 loc) · 1.48 KB

README.md

File metadata and controls

36 lines (29 loc) · 1.48 KB

ImgLib2 Appose helpers

Appose is a library for interprocess cooperation with shared memory. The guiding principles are simplicity and efficiency.

This repository relies on the following PRs:

Usage

net.imglib2.appose.NDArrayUtils contains static methods for working with Appose NDArray, most importantly:

NDArray ndArray = NDArrayUtils.asNDArray(img);

creates a NDArray with shape and data type corresponding to the shape and ImgLib2 type (must be NativeType) of the image. This can be put into Appose Task inputs. See these examples.

net.imglib2.appose.SharedMemoryImg<T> is a Img<T> implementation that wraps an ArrayImg that wraps a NDArray. If a SharedMemoryImg is passed to NDArrayUtils.asNDArray(img) then the wrapped NDArray is returned directly. So, no copying.

Create a SharedMemoryImg<T> with

Img<FloatType> img = new SharedMemoryImg<>(new FloatType(), 4, 3, 2);

Wrap it around an existing NDArray using

NDArray ndArray;
Img<FloatType> img = new SharedMemoryImg<>(ndArray);

(The SharedMemoryImg will have pixel type corresponding to the ndArray.dType(). Here we assume that the dType is FLOAT32, so we assign it to Img<FloatType>.)