3D triangle mesh data structures and algorithms for ImgLib2.
ImgLib2 Mesh provides a lightweight Mesh interface, several implementations,
and a collection of algorithms for building meshes from images, measuring them,
transforming them, and turning them back into images.
Data structures
Mesh— a collection ofVertices(position, normal, texture coordinates) andTriangles(vertex indices plus a normal), with coordinates accessible asfloatordouble.BufferMesh— backed byjava.niobuffers, suitable for handing off to OpenGL-style renderers.NaiveFloatMesh/NaiveDoubleMesh— simple growable array-backed meshes.TranslateMeshandReadOnlyMesh— lightweight views over an existing mesh.
Algorithms (mostly exposed via Meshes and MeshStats)
| Task | Classes |
|---|---|
| Image → mesh | Marching cubes for BooleanType and RealType images |
| Mesh → image | EuclideanDistanceVoxelization (and the deprecated Voxelization) |
| Cleanup | RemoveDuplicateVertices, SimplifyMesh, TaubinSmoothing, normal calculation |
| Topology | MeshConnectedComponents, Meshes.merge |
| Geometry | Convex hull (quickhull), ellipsoid fitting, inertia tensor, bounding box, centroid |
| Shape descriptors | Volume, surface area, solidity, convexity, sphericity, compactness, elongation, … |
| Queries | Point-in-mesh tests (Interior), ray–triangle intersection (MollerTrumbore) |
| Slicing | ZSlicer — cut a two-manifold mesh with Z planes into closed contours |
| Transforms | Translate, scale |
I/O (net.imglib2.mesh.io)
PLYMeshIO— read and write PLY (ASCII and binary).STLMeshIO— read and write binary STL.XYZPointsIO— read XYZ point clouds.
Many algorithms are also annotated for discovery by
SciJava Ops (e.g. geom.size,
geom.boundingBox), so they can also be called as ops.
ImgLib2 Mesh is released to the SciJava Maven repository.
Add the repository and dependency to your pom.xml:
<repositories>
<repository>
<id>scijava.public</id>
<url>https://maven.scijava.org/content/groups/public</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>net.imglib2</groupId>
<artifactId>imglib2-mesh</artifactId>
<version>1.2.0</version>
</dependency>
</dependencies>If your project extends pom-scijava, the version is managed for you and can be omitted.
See ExamplesTest.java for
worked examples: building a mesh from an image and measuring it, building one
by hand, reading and writing files, and a tour of other operations. They run as
part of the test suite, so they stay in sync with the API. The other
unit tests show more usage.
Building requires JDK 11.0.17 or newer and Maven; the resulting library targets Java 8.
git clone https://github.com/imglib/imglib2-mesh
cd imglib2-mesh
mvn clean installBug reports and pull requests are welcome on GitHub. For questions and discussion, visit the Image.sc Forum.
ImgLib2 Mesh is distributed under the Simplified BSD License.