papaya2: 2D Irreducible Minkowski Tensor computation

A common challenge in scientific and technical domains is the quantitative description of geometries and shapes, e.g. in the analysis of microscope imagery or astronomical observation data. Frequently, it is desirable to go beyond scalar shape metrics such as porosity and surface to volume ratios because the samples are anisotropic or because direction-dependent quantities such as conductances or elasticity are of interest. Minkowski Tensors are a systematic family of versatile and robust higher-order shape descriptors that allow for shape characterization of arbitrary order and promise a path to systematic structure-function relationships for direction-dependent properties. Papaya2 is a software to calculate 2D higher-order shape metrics with a library interface, support for Irreducible Minkowski Tensors and interpolated marching squares. Extensions to Matlab, JavaScript and Python are provided as well. While the tensor of inertia is computed by many tools, we are not aware of other open-source software which provides higher-rank shape characterization in 2D.


Summary
A common challenge in scientific and technical domains is the quantitative description of geometries and shapes, e.g. in the analysis of microscope imagery or astronomical observation data. Frequently, it is desirable to go beyond scalar shape metrics such as porosity and surface to volume ratios because the samples are anisotropic or because direction-dependent quantities such as conductances or elasticity are of interest. Popular analysis software such as ImageJ and SExtractor provide only limited tooling for higher-order anisotropy characterization; usually only the tensor of inertia (rank 2) is available.
Here, we present papaya2, a C++ library which facilitates computation of Irreducible Minkowski Tensors for two-dimensional geometries and shapes, including planar objects bounded by polygonal contours, collections of points (point patterns) and greyscale pixel data. This library is accompanied by example programs and bindings for Python, Matlab, and the JavaScript language.
Papaya2 is a rewrite of papaya with a library interface, support for Irreducible Minkowski Tensors and interpolated marching squares, and extensions to Matlab, JavaScript and Python provided. While the tensor of inertia is computed by many tools, we are not aware of other open-source software which provides higher-rank shape characterization in 2D.
For the analysis of the examples in this paper, we employ our interactive online resource Morphometer which uses papaya2 for its computations.

C++ library papaya2
The C++ 11 library papaya2 contains the core algorithms to compute Irreducible Minkowski Tensors of two-dimensional geometries. It processes both polygonal and 2D image input data.
papaya2 is a header-only template library designed to operate on user data structures. We bundle several example programs which can be adapted to user requirements, or employed directly for simple analyses (see section Demos).
The main components of the library are defined in the header file <papaya2.hpp>. Analysis results are returned in a MinkowskiAccumulator object, which offers accessors to retrieve common morphometric data, including the following: • area() The 2D volume (area) enclosed by the geometry The supplementary header <papaya2/voronoi.hpp> implements the Minkowski Tensor analysis of point patterns via the Voronoi tessellation approach . The demo ppanalysis exemplifies how to use this header file.

Application Examples
Here we show some examples analyzed in the Morphometer web application, which uses papaya2.js, the JavaScript version of the papaya2. Morphometer provides rapid analysis of small amounts of data (up to 1000 points, or 500x500 pixels). For routine analysis we recommend using the ppanalysis and imganalysis demos or Python/Matlab bindings. Minkowski Tensors can be applied to different types of data: • Single polygons: s-fold symmetric polygons are characterized by high values of q s . Figure 1 shows a polygon with approximates an equilateral triangle. Therefore, we find high values of q 3 , q 6 , q 9 , etc. The distinguished directions of each Ψ s are depicted on the right of the q s bar diagram. • Point patterns can be, for instance, realizations of abstract point processes or data of physical particle systems. For the Minkowski Tensor analysis, a Voronoi tessellation of the points is constructed and Minkowski Tensors of the individual Voronoi cells are computed. Figure 2 (left) shows a hexagonal crystal cluster surrounded by an amorphous background. The Minkowski structure metric q 6 (indicated by the color of the Voronoi cells) is very well suited to detect hexagonal crystalline structures. The presence of ideal hexagonal cells is demonstrated by the peak at q 6 = 1 in the histogram on the right-hand side. • Greyscale images can also be analyzed in terms of Minkowski Tensors. Figure 3 (left) shows a detail of an anisotropic Gaussian random field, which is converted into a binary image by thresholding (center) and analyzed using Minkowski Tensors (right). The significant q 2 value in the Minkowski analysis (right) shows that the random field has a preferred direction, which is also reflected by the distinguished direction marker (red color).

Demos and language bindings
In the directory demos, we provide a number of example programs which use the library for data analysis. These are meant to be modified and adapted to user needs as required. For simple analyses, they can be used directly, see the README file in the demos folder.
We also provide bindings of the library for Python, Matlab and JavaScript.