papaya2

Description

papaya2 is a small header-only C++ library for computing irreducible 2D Minkowski tensors of image and polygonal data. The library needs a C++ 11 compliant compiler, and no external dependencies. Papaya2 is meant for routine data analysis. For exploring small 2D datasets, have a look at the morphometer!

The distribution contains a few small sample programs which perform different kinds of data analysis:

  • ppanalysis – pointpattern analysis
  • imganalysis – image analysis
  • banana – analysis of FITS files
  • pypaya2 – a Python module for doing pointpattern analysis
  • Two Matlab extensions for doing image and pointpattern analysis

These programs are meant to be simple, and to be adaptable to your purposes by modification.

Download:

The source code can be found on Github: papaya2, or as a ZIP archive

Papaya2 was written by Sebastian Kapfer, Jenny Wagner and Fabian Schaller.

Papaya2 is licensed under the Boost License, except for the file picopng.hpp, which is a copy of PicoPNG. It also includes a copy of Catch2 for unit testing.

ppanalysis

ppanalysis performs a morphometric analysis of the Voronoi cells generated by a 2D point pattern.

Usage

Type make ppanalysis to build the program. ppanalysis needs the CGAL library to build Voronoi diagrams.
ppanalysis in input_filename out output_filename
(nonperiodic mode)
ppanalysis in input_filename out output_filename boxL box sidelength
(continues the point pattern with periodic boundary conditions)

Input file format

ppanalysis reads a simple ASCII file containing the seed point coordinates:

# comments
x1 y1
x2 y2
x3 y3
....

Output file format

ppanalysis writes an ASCII table containing the seed point coordinates,
and the IMTs for each Voronoi cell.

# IMTs of Voronoi cells of a point pattern
# seedx seedy area perimeter q2 q3 q4 q5 q6
x1 y1 area1 perimeter1 q2,1 q3,1 q4,1 q5,1 q6,1
x2 y2 area2 perimeter2 q2,2 q3,2 q4,2 q5,2 q6,2
x3 y3 area3 perimeter3 q2,3 q3,3 q4,3 q5,3 q6,3
....

imganalysis

Usage

Type make imganalysis to build the program.
imganalysis in input_filename.png out output_filename.dat
imganalysis in input_filename.png out output_filename.dat contours contours_filename.dat

Input file format

imganalysis reads a plain PNG file, and analyzes the red color channel only.
More advanced analysis requires adjustments to the code (which is pretty brief, so that should be easy).

Output file format

imganalysis writes an ASCII table containing IMTs of several thresholds of the image. Each line begins with the threshold value, followed by the enclosed area, the perimeter, and the IMTs.

# comments
threshold area perim q2 arg2 q3 arg3 q4 arg4 q5 arg5 q6 arg6 q7 arg7 q8 arg8
....

Optionally, it can also write out the isocontours that are constructed by the program for analysis. You can plot them in Gnuplot, for example, using the “with vectors” plotting style:

banana

banana can be used for analyzing astrophysics data in FITS format.

Usage

Type make banana to build the program. banana needs the CCfits library to read FITS files.
banana in input_filename.fits out output_filename [more options]
Options can be:
mask mask_filename.fits supply a mask for analyzing part of the image
mint lowest threshold
maxt largest threshold
numt number of thresholds to choose the thresholds for binarizing the image

Banana writes an ASCII table containing IMTs of several thresholds of the observation. Each line begins with the threshold value, followed by the enclosed area, the perimeter, and the IMTs.

# comments
threshold area perim q2 arg2 q3 arg3 q4 arg4 q5 arg5 q6 arg6 q7 arg7 q8 arg8
....

pypaya2

Papaya comes with a Python2 module which can be used for analyzing pointpatterns quickly:

In [1]: import pypaya2
In [2]: imt = pypaya2.imt_for_pointpattern(a)
# output the psi2 for the first three Voronoi cells
In [3]: imt['psi2'][:3]

Out[3]: array([ 0.05116231+0.00505045j, -0.01378112-0.00431184j,
0.02915654-0.0727168j , -0.07049936+0.04529508j,
-0.04246323-0.02388724j, -2.00074429-0.08287061j])

Support for image analysis is in preparation.

To build the Python module, type make pypaya2.so.

Matlab exensions

Papaya2 comes with two Matlab extensions for doing image and pointpattern analysis,
see the folder “matlab” in the Papaya2 download, and the example Matlab scripts there.