ImgLib2

ImgLib2 is a general-purpose, multidimensional image and data processing library.

It provides a unified API to work with discrete and continuous n-dimensional data. This API is interface driven and therefore extensible at will.

ImgLib2 includes implementations of standard numeric and non-numeric data types (8-bit unsigned integer, 32-bit floating point, …) as well as a number of less typical data types (complex 64-bit floating point, 64-bit ARGB, base pairs, …). Data values can be accessed directly or through on-the-fly converters or multi-variate functions.

For discrete data (images, n-dimensional arrays), ImgLib2 implements a variety of memory layouts, data generation, loading, and caching strategies, including data linearized into single primitive arrays, series of arrays, n-dimensional arrays of arrays (“cells”), stored in memory, generated or loaded from disk on demand, and cached in memory or on disk. Coordinates and values can be accessed directly or through on-the-fly views that invert or permute axes, generate hyperslices or stack slices top higher dimensional datasets, collapse dimensions into vectors

For continuous data (functions, n-dimensional interpolants), ImgLib2 implements a variety of interpolators, geometric transformations, and generator functions. Coordinates and values can be accessed directly or transformed on-the-fly.

Need a quick start? Install OpenJDK and maven:

sudo apt install openjdk-16-jdk maven

Then check out BigDataViewer vistools:

git clone https://github.com/bigdataviewer/bigdataviewer-vistools.git

Then start JShell in the BigDataViewer vistools project directory:

cd bigdataviewer-vistools
mvn compile com.github.johnpoth:jshell-maven-plugin:1.3:run

Then try out this code snippet:

import bdv.util.*;
import net.imglib2.position.FunctionRealRandomAccessible;
import net.imglib2.type.numeric.integer.IntType;
import net.imglib2.util.Intervals;

BdvFunctions.show(
  new FunctionRealRandomAccessible<IntType>(
    2,
    (x, y) -> {
      int i = 0;
      double v = 0,
        c = x.getDoublePosition(0),
        d = x.getDoublePosition(1);
      for (; i < 64 && v < 4096; ++i) {
        final double e = c * c - d * d;
        d = 2 * c * d;
        c = e + 0.2;
        d += 0.6;
        v = Math.sqrt(c * c + d * d);
        ++i;
      }
      y.set(i);
    },
    IntType::new),
  Intervals.createMinMax(-1, -1, 1, 1),
  "",
  BdvOptions.options().is2D()).setDisplayRange(0, 64);

Resources

Source code

You can find the source {% include github org=‘imglib’ repo=‘imglib2’ %}.

There is also a continuous integration system that builds ImgLib2 every time the code changes.

ImgLib2 vs. ImgLib1

ImgLib1 is the previous incarnation of the library. We encourage developers to use ImgLib2 instead, and migrate existing ImgLib1 programs to ImgLib2 whenever possible.

For an explanation of how ImgLib2 has changed from ImgLib1, see the Changes from ImgLib1 to ImgLib2 page.

See the How To Migrate Code From ImgLib To ImgLib2 page for details on how to update your ImgLib1-based code to use ImgLib2.

API Version History

A history of API changes is available at: https://abi-laboratory.pro/java/tracker/timeline/imglib2/

Publication

Pietzsch, T., Preibisch, S., Tomančák, P., & Saalfeld, S. (2012). ImgLib2—generic image processing in Java. Bioinformatics, 28(22), 3009-3011.