Evaluation of classical correlation functions from 2/3D images on CPU and GPU architectures: Introducing CorrelationFunctions.jl
Authors: Gerke Kirill M. 
Published: August 2024

Correlation functions are becoming one of the major tools for quantification of structural information that is usually represented as 2D or 3D images of porous material. In this paper we introduce open-source package developed in Julia and capable of computing all classical correlation functions based on imaging input data. Images include both binary and multi-phase representations. Our code is capable of evaluating two-point probability S2, phase cross-correlation ρij, cluster C2, lineal-path L2, surface-surface Fss, surface-void Fsv, pore-size P and chord-length p distribution functions on both CPU and GPU architectures. Where possible, we presented two types of computations: full correlation map (correlations of each point with other points on the image, that also allows obtaining ensemble averaged CF) and directional correlation functions (currently in major orthogonal and diagonal directions). Such an implementation allowed for the first time to assemble a completely free solution to evaluate correlation functions under any operating system with well documented application programming interface (API). Our package includes automatic tests against analytical solutions that are described in the paper. We measured execution times for all CPU and GPU implementations and as a rule of thumb full correlation maps on GPU are faster than other methods. However, full maps require more RAM and, thus, are limited to available RAM resources. On the other hand, directional CFs are memory efficient and can be evaluated for huge datasets – this way they are the first candidates for structural data compression of feature extraction. The package itself is available through Julia package ecosystem and on GitHub, the latter source also contains documentation and additional helpful resources such as tutorials. We believe that a single powerful computational tool such as presented in this paper will significantly facilitate the usage of correlation functions in numerous areas of structural description and research of porous materials, as well as in machine learning applications. We also present some example as applied to ceramic, soil composite and oil-bearing rock samples based on their 3D X-ray tomography and 2D scanning electron microscope images. Finally, we conclude our paper with discussion of possible ways to further improve presented computational framework.- Program Title: CorrelationFunctions.jl
- CPC Library link to program files: https://doi.org/10.17632/6gb9gfm3dw.1 Developer's repository link: https://github.com/fatimp/CorrelationFunctions.jl
- Licensing provisions: MIT
- Programming language: Julia
- Supplementary material: Numerous Jupiter notebooks with examples are available on the GitHub page**Nature of problem**Correlation functions are invaluable universal statistical descriptors of structures used in numerous scientific fields such as astronomy, material science, rock and soil physics, hydrology and biology, to name just a handful of examples. While computational approaches are available in the literature for some functions, they are fragmented and are usually implemented in proprietary interpreted languages for CPU architecture alone. Solution method: We contribute an open source and cross-platform solution with well documented API for computation of all classical correlation functions from both 2D and 3D images on CPU and GPU architectures. The package computes correlation functions using two approaches: : computation of correlation maps and computation along predefined directions. These two approaches can be thought of as an execution time - memory trade-off, but the choice may also depend on the application. The computations are based on fast Fourier transform with preprocessing steps as cluster labeling or edge detection, and linear scan approach to evaluate correlation functions along predefined directions. Where justified, the algorithms can be executed on both CPU and GPU which results in high execution speed on modern hardware.