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;
.show(
BdvFunctionsnew FunctionRealRandomAccessible<IntType>(
2,
(x, y) -> {
int i = 0;
double v = 0,
= x.getDoublePosition(0),
c = x.getDoublePosition(1);
d for (; i < 64 && v < 4096; ++i) {
final double e = c * c - d * d;
= 2 * c * d;
d = e + 0.2;
c += 0.6;
d = Math.sqrt(c * c + d * d);
v ++i;
}
.set(i);
y},
::new),
IntType.createMinMax(-1, -1, 1, 1),
Intervals"",
.options().is2D()).setDisplayRange(0, 64); BdvOptions
Resources
- ImgLib2 paper
- ImgLib2 Documentation
- ImgLib2 Examples
- ImgLib2 Blog
- Image.sc forum
- {% include javadoc project=‘ImgLib2’ %} javadoc
- How To Migrate Code From ImgLib To ImgLib2
- “Introduction to ImgLib2” workshop
- “Advanced Programming with ImgLib2” workshop
- “I2K 2020 Introductory ImgLib2” workshop
- “I2K 2020 Advanced ImgLib2” workshop
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/
Other links
- ImgLib2 development discussion
- ImgLib2 performance benchmarks
- ImageJ2 uses ImgLib2 as its core data model
Publication
Pietzsch, T., Preibisch, S., Tomančák, P., & Saalfeld, S. (2012). ImgLib2—generic image processing in Java. Bioinformatics, 28(22), 3009-3011.