kevinganster / eikonalfm

The Fast Marching method to solve the eikonal equation
MIT License
36 stars 9 forks source link

Eikonal Fast Marching

eikonalfm is a Python (C++) extension which implements the Fast Marching method for the eikonal equation
$$\lvert\nabla\tau(x)\rvert^2=\frac{1}{c^2(x)},$$
and the factored eikonal equation
$$\lvert(\tau_0\nabla\tau_1 + \tau_1\nabla\tau_0)(x)\rvert^2=\frac{1}{c^2(x)},$$
where $\tau_0(x)=\lvert x-x_s\rvert$.

References

Requirements

Installation

Installation from PyPi:

pip install eikonalfm

Manual install from the repository:

git clone https://github.com/kevinganster/eikonalfm.git
cd eikonalfm
pip install .

or

pip install git+https://github.com/kevinganster/eikonalfm.git

Examples

import numpy as np
import eikonalfm

c = np.ones((100, 100))
x_s = (0, 0)
dx = (1.0, 1.0)
order = 2

tau_fm = eikonalfm.fast_marching(c, x_s, dx, order)
tau1_ffm = eikonalfm.factored_fast_marching(c, x_s, dx, order)

Note that the source position x_s describes an index-vector.

To visualize the results, matplotlib (https://pypi.org/project/matplotlib/) can be used, for example:

import matplotlib.pyplot as plt

# for the distance-function 'x_s' also describes an index-vector
tau0 = eikonalfm.distance(tau1_ffm.shape, dx, x_s, indexing="ij")
plt.contourf(tau0 * tau1_ffm)
plt.show()