Imgal (Image Algorithm Library), is fast and mostly* safe image processing and algorithm library written in Rust. This library is directly inspired by imagej-ops,
SciJava Ops, ImgLib2, the ImageJ2 ecosystem. imgal
is organized as a monorepo with imgal_core
as the core library that contains the algorithm logic while imgal_java
and imgal_python
serve imgal
's
Java and Python language bindings.
You can build the entire project from the root with:
$ cargo build --release
Note
--release
is necessary to compile speed optimized libraries. Without this flag rustc
will retain debug symbols (among other things) that reduce the performance of the libraries.
This will create one Rust static library (.rlib
) file for imgal
and two shared library files for the Java and Python bindings respectively. The file extension of the shared library is operating system dependent:
Platform | Extension |
---|---|
Linux | .so |
macOS | .dylib |
Windows | .dll |
Additionally, shared libraries will be prefixed with lib
, making the compiled imgal
library filename libimgal.rlib
. After building imgal
the three library files can be found in target/release
.
File name | Description |
---|---|
libimgal | The main Rust static library. |
libimgal_java | Java bindings using the Foreign Function and Memory (FFM) API (targeting Java 22+). |
libimgal_python | Python bindings (using PyO3). |
To build the imgal
Python bindings, use the maturin
build tool. If you're using uv
you can do the following in the imgal_python
:
$ cd imgal_python
$ uv run maturin develop --release
This will create a .venv
in the local directory, compile imgal_core
and imgal_python
and install the bindings in the venv.
Alternatively if you're using conda
or mamba
you can do the following:
$ cd imgal_python
$ mamba activate myenv
(myenv) $ mamba install maturin
...
(myenv) $ maturin develop --release
import imgal_python.phasor.time_domain as td
import numpy as np
from tifffile import imread
# read some FLIM data
data = imread("/path/to/flim_data.tif")
# transpose lifetime axis to last position for fastest
# compute time (contigous memory with C-order)
data = data.transpose(1, 2, 0).copy()
# compute phasor
result = td.image(data, 0.0012)