1 Introduction

Tubular and membranous shape textures are widely present in biology. They display a large variety of morphologies in terms of geometry and topology, which are important to analyze since they reflect the state of a biological system. For instance, the bone marrow capillaries are highly branching and merging vessels [88, 101], whose organization is subject to drastic remodeling in acute myeloid leukaemia [30, 82]. In cells, the endoplasmic reticulum, where proteins are synthesized, consists of an interconnected network [96] that undergoes sheets-to-tubules topological transformations [87]. Furthermore, trabecular bone is a combination of rods and platelets [76, 93] that are optimally restructured under mechanical stress [1, 90, 92] or pathological conditions [40, 81, 103].

However, due to their disparity and complexity, tubular and membranous structures are difficult to describe within a unifying framework that captures both their rich morphological diversity as well as their continuous variations. We approach this question by building a generation model that creates shape textures from noise, similarly to texture synthesis in images [46, 62, 85]. We model tubules and membranes as optimizers under constant volume of a curvature functional

$$\begin{aligned} \mathbf {F}(\mathscr {S}) = \int _\mathscr {S}p(\kappa _1, \kappa _2) ~ {\mathrm {d}}A, \end{aligned}$$
(1)

where p is a second-degree polynomial of the principal curvatures \(\kappa _1\) and \(\kappa _2\) of the surface \(\mathscr {S}\). As our main contribution, we provide a novel phase-field formulation \(\mathscr {F}_\epsilon \) to approximate the original geometric problem \(\mathbf {F}\), and show that the \(\varGamma \)-limsup holds, a notion coming from the \(\varGamma \)-convergence framework [3, 12, 24]. The optimization problem then translates into the mass-preserving \(H^{-1}\) gradient flow [22, 35]

$$\begin{aligned} {\dot{u}} = \varDelta \frac{\partial \mathscr {F}_\epsilon }{\partial u}(u). \end{aligned}$$
(2)

Combining the stochastic optimizer Adam [55, 66] to the automatic differentiation provided by PyTorch [83] results in an efficient and flexible GPU implementation, curvatubes. It successfully leads to a wide continuum of shape textures (see Fig. 1), which constitutes a first step towards a unifying theory.

Fig. 1
figure 1

A continuum of shape textures generated by curvatubes, after optimizing a curvature-based polynomial energy of the surface \(\int _\mathscr {S}p(\kappa _1,\kappa _2) ~{\mathrm {d}}A\), with a volume constraint. The polynomial coefficients vary linearly in space, by interpolating four values that define different shape textures, at the vertical median of the four squares. In the formulas, \(\kappa _1\) and \(\kappa _2\) are the principal curvatures of the surface, while \(H = \kappa _1+ \kappa _2\) and \(K = \kappa _1\kappa _2\) are the mean and the Gaussian curvatures. More details are given at the end of Sect. 5.2

Related work. The variational formulation (1) generalizes two classical functionals, the Willmore energy studied in differential geometry [6, 14, 51, 67, 100, 104, 110], as well as the Helfrich energy used to model biomembranes [17, 18, 25, 28, 44, 97]. In contrast to these models, the polynomial p is here not required to be symmetric in the principal curvatures, which allows the generation of tubules. Other generalizations have been proposed in [43, 106] and [19, 26].

Curvature functionals are often used as image prior models in imaging, due to their ability to interpolate. Mumford [75] considered Euler’s elastica functional as a prior curve model in computer vision, and this was subsequently applied to digital inpainting [10, 68, 99]. Similar ideas were then used for 3D volume reconstruction from 2D slices [13, 53, 64]. Our work is also related to Poisson reconstruction methods [48, 49] that implicitly reconstruct a surface from noisy oriented points.

However, as in [27,28,29], we use the diffuse setting to model shapes. By construction, our phase-field formulation \(\mathscr {F}_\epsilon \) extends the standard approximation of the Willmore energy (see [14] and references therein) as well as the one proposed by Bellettini & Mugnai in [8] for the Helfrich energy. In terms of \(\varGamma \)-convergence, we also provide an extension of the \(\varGamma \)-limsup result in [8], while keeping the \(\varGamma \)-liminf as an open question (except in the cases previously covered) that we do not aim to solve here.

Finally, our attempt in building a unifying framework is connected to the Functionalized Cahn–Hilliard (FCH) model proposed in [20, 21, 23, 41, 56, 57]. The FCH energy describes how amphiphilic molecules self-assemble into complex network morphologies that feature spheres, tubules, sheets, and mixtures of them. Loosely speaking, such shape textures result from a compromise between minimizing a bending energy while rewarding an increase in interfacial area. Yet, we choose to treat the principal curvatures independently, which is not the case in their model.

Outline. In Sect. 2, we introduce the Willmore and the Helfrich energies, as well as their classical phase-field approximations in light of the \(\varGamma \)-convergence framework. In Sect. 3, we build the phase-field functional and justify its construction with heuristic arguments and in terms of \(\varGamma \)-limsup. Section 4 describes the computational framework and displays a large number of simulations. Finally, we discuss in Sect. 5 the implications of a unifying theory on applied fields and present future extensions to this work.

2 Background

We begin by introducing the Willmore and the Helfrich energies in more detail, then sketch the notion of \(\varGamma \)-convergence before moving on with their classical phase-field approximations.

But first, let us describe curvatures in simple terms. Curvature measures how much a line or a surface is locally deviating from a straight line or a flat plane. For a line contained in a plane, the curvature \(\kappa \) at a point is the inverse \(\frac{1}{r}\) of the radius of the osculating circle, i.e., the tangent circle that approaches the curves most tightly at this point. Surfaces are characterized at each point by two principal curvatures \(\kappa _1\) and \(\kappa _2\), that correspond to the maximal and minimal curvatures of the lines resulting from the perpendicular intersection of the surface with a plane. The maximally and minimally curved lines are directed by two perpendicular principal directions, tangent to the surface. For instance, the principal curvatures are zero on a plane; on a sphere of radius r, they are all equal to \((\frac{1}{r}, \frac{1}{r})\); on a cylinder of base radius R, they are all equal to \((\frac{1}{R}, 0)\).

2.1 The Willmore, Helfrich, and Generalized Curvature Functionals

In the 1970’s, Canham [18], and subsequently Helfrich [44], proposed to model the surface of a biomembrane as a minimizer of a curvature bending energy, or Helfrich energy

$$\begin{aligned} \mathbf {E}_\text {H}(\mathscr {S}) = \int _{\mathscr {S}} \left( \frac{\chi _b}{2}(H - H_0)^2 + \chi _G K \right) \,{\mathrm {d}}A. \end{aligned}$$
(3)

In this expression, \(\mathscr {S}\) is a smooth compact orientable surface in \(\mathbb {R}^3\) whose principal curvatures are denoted \(\kappa _1\) and \(\kappa _2\), with the convention \(\kappa _1\ge \kappa _2\). The mean curvatureFootnote 1\(H = \kappa _1 + \kappa _2\) and the Gaussian curvature \(K = \kappa _1 \kappa _2\) are respectively the sum and the product of the principal curvatures. The signs of H, \(\kappa _1\), and \(\kappa _2\) depend on the orientation of \(\mathscr {S}\), while that of K does not. Throughout this work, we use the convention that H should be positive on convex objects like spheres. Let us remark that there is a closed relationship between \((\kappa _1,\kappa _2)\) and (HK), provided by the bijection \(\phi (x,y) = (x+y, \, x \, y)\) from \(\{(x,y) \in \mathbb {R}^2 ~|~ y \le x \}\) onto \(\{(x,y) \in \mathbb {R}^2 ~|~ y \le \frac{1}{4} \, x^2 \}\),

$$\begin{aligned} {\left\{ \begin{array}{ll} H = \kappa _1+ \kappa _2\\ K = \kappa _1\kappa _2\\ \kappa _1\ge \kappa _2\end{array}\right. } \Leftrightarrow \quad {\left\{ \begin{array}{ll} \kappa _1= ( H + \sqrt{H^2 - 4 K} ) / 2 \\ \kappa _2= ( H - \sqrt{H^2 - 4 K} ) / 2 \\ \end{array}\right. } \end{aligned}$$
(4)

and that \(H^2 - 4 K = (\kappa _1- \kappa _2)^2\).

In (3), the coefficients \(\chi _b > 0\) and \(\chi _G\) are the bending and Gaussian rigidities. The parameter \(H_0\), or spontaneous curvature, models the asymmetry of the two layers composing the bilipidic membrane [32, 98]. The Willmore energy, defined as

$$\begin{aligned} \mathbf {E}_\text {W}(\mathscr {S}) = \int _{\mathscr {S}} H^2 ~{\mathrm {d}}A, \end{aligned}$$
(5)

is then a special case of the Helfrich energy, with \(\chi _G = 0\), \(\chi _b = 2\), and \(H_0 = 0\).

In both of the classical functionals (3) and (5), the integrand is a polynomial \(p(\kappa _1,\kappa _2)\) symmetric in the principal curvatures, i.e., \(p(\kappa _1,\kappa _2) = p(\kappa _2,\kappa _1)\), since it can be reformulated as a polynomial of their sum H and product K. However, one may want to construct a general curvature functional where p is a smooth function with no symmetry constraint. A similarFootnote 2 form is given in [43, 106], for a smooth function q(HK). A generalization to functions that depend on the position and the normal to the surface can be found in [19, 26].

We will restrict ourselves to p which are polynomials of degree 2, as the framework is then rich enough to generate complex shape textures. We are thus interested in the curvature functional

$$\begin{aligned} \begin{aligned} \mathbf {F}(\mathscr {S})&= \int _{\mathscr {S}} \big (a_{2,0} ~\kappa _1^2 + a_{1,1} ~\kappa _1 \kappa _2 + a_{0,2} ~\kappa _2^2 \\&\quad + a_{1,0} ~\kappa _1+ a_{0,1} ~\kappa _2+ a_{0,0} \big ) ~dA \\&= \int _\mathscr {S}\left( \sum \limits _{|\alpha | \le 2} a_\alpha (\kappa _1,\kappa _2)^\alpha \right) ~{\mathrm {d}}A, \end{aligned} \end{aligned}$$
(6)

where we use multi-index notation.

2.2 Phase-Fields and \(\varGamma \)-Convergence

Numerically, critical points of the curvature energies (3), (5), and (6) can be searched for by following a gradient flow. Before implementing an algorithm, it is however preferable to convert these sharp-interface functionals defined for 2D surfaces, to diffuse approximations defined for scalar fields in a 3D volume. This way, surfaces are implicitly represented as level sets of the volumetric scalar field, which allows us to address topological changes encountered in the flow seamlessly; whereas in explicit methods, surfaces are tracked as a mesh that needs dynamic remeshing to avoid entanglement through topological transitions [80]. The gain is considerable in view of the high topological complexity of the targeted shape textures.

This leads us to consider a phase-field energy approximating the original geometric problem, for instance as in [27,28,29] for the modeling of biomembranes. Phase-fields have been extensively used to model phase separation in binary mixtures, beginning with the Cahn–Hilliard (or Ginzburg–Landau) energy [16, 34], that was subsequently reused in several other contexts [54, 72]. These functions typically take values close to 1 and \(-1\) inside and outside a region, with a smooth transition between the two phases at the interface. A parameter \(\epsilon > 0\) represents the thickness of phase transition at the interface.

The quality of a diffuse approximation with phase-fields is typically studied in the \(\varGamma \)-convergence framework [3, 12, 24]. \(\varGamma \)-convergence expresses the convergence of minimization problems, so that, rather than solving a limit problem, we solve a sequence of approaching problems (or the reverse). The complete convergence consists in a \(\varGamma \)-limsup, which relies on a constructive proof, and a \(\varGamma \)-liminf, generally more difficult to prove.

Definition 1

(\(\varGamma \)-convergence) Given X a metric space, let F and \(F_\epsilon \) be functions from X to \([-\infty ,+\infty ]\), where the \(F_\epsilon \) are defined for \(\epsilon > 0\). We say that the sequence \((F_\epsilon )_{\epsilon > 0}\) \(\varGamma \)-converges to F as \(\epsilon \rightarrow 0\), and write

$$\begin{aligned} \left[ \varGamma (X) - \lim \limits _{\epsilon \rightarrow 0} F_\epsilon \right] = F, \end{aligned}$$

if the following two bounds hold for any \(u \in X\):

[\(\varGamma \)-liminf] For every sequence \((u_\epsilon )\) such that \(u_\epsilon \rightarrow u\) in X,

$$\begin{aligned} \liminf \limits _{\epsilon \rightarrow 0} F_\epsilon (u_\epsilon ) \ge F(u). \end{aligned}$$

[\(\varGamma \)-limsup] There exists a sequence \((u_\epsilon )\), called recovery sequence, such that \(u_\epsilon \rightarrow u\) in X and

$$\begin{aligned} \lim \limits _{\epsilon \rightarrow 0} F_\epsilon (u_\epsilon ) = F(u). \end{aligned}$$

\(\varGamma \)-convergence is especially interesting due to the following fundamental result.

Theorem 1

Let X be a metric space, and let \(F = \varGamma (X)-\lim \limits _{\epsilon \rightarrow 0} F_\epsilon \). Suppose that the sequence \(F_\epsilon : X \rightarrow [-\infty , +\infty ]\) is equi-coercive, i.e., for all \(t \in \mathbb {R}\) there exists a compact set \(K_t \subset X\) such that \(\{ F_\epsilon \le t \} \subset K_t\). Then F admits a minimum and

$$\begin{aligned} \min \limits _X F = \lim \limits _{\epsilon \rightarrow 0} \inf \limits _X F_\epsilon . \end{aligned}$$

Furthermore, if \(u_\epsilon \) minimizes \(F_\epsilon \) over X, then every cluster point of \((u_\epsilon )\) minimizes F over X.

This ensures not only the convergence of the minimal values, but also of the minimizers themselves, up to a subsequence.

2.3 Phase-Field Approximations of the Area, the Willmore, and the Helfrich Functionals

In this paragraph, we present three classical diffuse approximations that are important to our development. We fix some mathematical notations beforehand.

Notations. Let \(\varOmega \) denote an open bounded connected set in \(\mathbb {R}^3\) with piecewise smooth boundary. The usual Sobolev spaces are denoted by

$$\begin{aligned} W^{k,p}(\varOmega ) = \{ u \in L^p(\varOmega ) ~|~ D^\alpha u \in L^p(\varOmega ), \forall |\alpha | \le k \} \end{aligned}$$

and are the sets of functions u in \(L^p(\varOmega )\) whose mixed partial derivatives \(D^\alpha u\) exist in the weak sense and are in \(L^p(\varOmega )\), up to \(|\alpha | \le k\). A function \(u \in L^1(\varOmega )\) is of bounded variation if the following quantity, denoted by \(\int _\varOmega |Du|\), is finite [4]:

$$\begin{aligned} \sup \left\{ \int _\varOmega u(x) \nabla \cdot \phi (x) \,{\mathrm {d}}x ~|~ \phi \in C^1_c(\varOmega ,\mathbb {R}^3), \Vert \phi \Vert _{L^\infty (\varOmega )} \le 1 \right\} < \infty .\end{aligned}$$

By \(BV(\varOmega ,\{-1,1\})\), we refer to the set of \(L^1\) functions \(u : \varOmega \rightarrow \{-1,1\}\) of bounded variation. For a set \(E \subset \varOmega \), \(\chi _E\) designates the characteristic function of E.

Let \({\mathbf {e}}\) be a fixed unit-norm vector in \(\mathbb {R}^3\). We consider a symmetric double-well function \(W(s) = \frac{1}{4} (1-s^2)^2\) that vanishes at \(-1\) and \(+1\). Note that its derivative is \(W'(s) = s^3 - s\). Let \(\sigma = \int _{-1}^{1} \sqrt{2 W(s)} ~ds = \frac{4}{3 \sqrt{2}}\) denote a constant that only depends on the double-well.

For a function u twice (weakly) differentiable, we define the normal vector field

$$\begin{aligned} \mathbf {n}_u = \left\{ \begin{array}{ll} \frac{\nabla u}{|\nabla u|} &{} \qquad \text {on the set } \{ \nabla u \ne 0 \} \\ {\mathbf {e}} &{} \qquad \text {elsewhere}, \end{array} \right. \end{aligned}$$

that has unit norm, and is orthogonal to the level sets of u. We introduce the matrix field

$$\begin{aligned} \mathscr {M}^\epsilon _u= - \epsilon ~\mathrm {Hess}~u + \frac{W'(u)}{\epsilon } ~ \mathbf {n}_u \otimes \mathbf {n}_u, \end{aligned}$$
(7)

whose trace is equal to

$$\begin{aligned} \mathrm {Tr} \mathscr {M}^\epsilon _u = -\epsilon \varDelta u + \frac{W'(u)}{\epsilon }. \end{aligned}$$

The classical approximations. The Cahn–Hilliard phase-field energy is known to approximate the area (or perimeter) functional, which measures the total area of surfaces in the 3D space. More precisely, let us introduce

$$\begin{aligned} {\mathscr {A}}_\epsilon (u) = {\left\{ \begin{array}{ll} \displaystyle \int _\varOmega \left( \frac{\epsilon }{2} |\nabla u|^2 + \frac{W(u)}{\epsilon } \right) ~{\mathrm {d}}x\qquad ~~\text {if } u \in W^{1,2}(\varOmega ) \\ + \infty \qquad ~~\text {otherwise in } L^1(\varOmega ) \end{array}\right. },\nonumber \\ \end{aligned}$$
(8)

and the area functional

$$\begin{aligned} \mathbf {E}_A(u) = {\left\{ \begin{array}{ll} \frac{1}{2} { \int _\varOmega |Du| } \qquad ~~\text {if } u \in \mathrm {BV}(\varOmega , \{ -1,1 \}) \\ + \infty \qquad ~~\text {otherwise in } L^1(\varOmega ) \end{array}\right. }. \end{aligned}$$
(9)

Following a conjecture of De Giorgi, Modica and Mortola [73] proved the \(\varGamma \)-convergence

$$\begin{aligned} \left[ \varGamma (L^1(\varOmega )) - \lim \limits _{\epsilon \rightarrow 0} {\mathscr {A}}_\epsilon \right] = \sigma \,\mathbf {E}_A. \end{aligned}$$
(10)

This means that, if \(E \subset \varOmega \) is such that \(\mathscr {S}= \partial E \cap \varOmega \) is smooth and of finite area, and setting \(u = 2 \chi _E - 1 \in BV(\varOmega ,\{-1,1\})\), then the \(\varGamma \)-limsup provides a sequence of functions \((u_\epsilon ) \in W^{1,2}(\varOmega )\) such that \(u_\epsilon \rightarrow u\) in \(L^1(\varOmega )\) and \({\mathscr {A}}_\epsilon (u_\epsilon ) \rightarrow \sigma \, \text {area}(\mathscr {S})\), i.e., their diffuse areas converge to the area of \(\mathscr {S}\) up to a factor \(\sigma \).

Subsequently, several authors [7, 9, 74, 78, 91, 105] studied diffuse approximations of the Willmore energy (5). Bellettini and Paolini [9] introduced the phase-field functionals

$$\begin{aligned} {\mathscr {W}}_\epsilon (u) = {\left\{ \begin{array}{ll} \displaystyle \frac{1}{\epsilon } \int _\varOmega \left( \epsilon \varDelta u - \frac{W'(u)}{\epsilon }\right) ^2 ~{\mathrm {d}}x\qquad ~~\text {if } u \in W^{2,2}(\varOmega ) \\ + \infty \qquad ~~\text {otherwise in } L^1(\varOmega ) \end{array}\right. }\nonumber \\ \end{aligned}$$
(11)

Note that the trace term \(\mathrm {Tr} \mathscr {M}^\epsilon _u = -\epsilon \varDelta u + \frac{W'(u)}{\epsilon }\) inside the square is the \(L^2\) gradient of \(\frac{\epsilon }{2} |\nabla u|^2 + \frac{W(u)}{\epsilon }\) which appears in the Cahn-Hilliard phase-field energy (8), in the same way as the mean curvature vector is the \(L^2\) gradient of the area functional.

The \(\varGamma \)-limsup was showed in [9], using the same recovery sequence as for the area functional. The \(\varGamma \)-liminf was studied under several conditions in [7, 74] and completed in [91]. Together with the \(\varGamma \)-limsup, this resulted in the \(\varGamma \)-convergence on smooth points of the form \(u = 2 \chi _E - 1\) where \(E \subset \varOmega \) and \(\partial E \cap \varOmega \) is \(C^2\):

$$\begin{aligned} \left[ \varGamma (L^1(\varOmega )) - \lim \limits _{\epsilon \rightarrow 0} {\mathscr {W}}_\epsilon \right] ( 2\chi _E - 1) = \sigma ~\mathbf {E}_\text {W}(\partial E \cap \varOmega ), \end{aligned}$$

but with the additional assumption that the diffuse surface areas \(A_\epsilon \) remain uniformly bounded.

Finally, Bellettini and Mugnai [8] extended the Willmore phase-field functional to approximate the complete Helfrich energy with

$$\begin{aligned}&{\mathscr {H}}_\epsilon (u) \nonumber \\&\quad = {\left\{ \begin{array}{ll} \displaystyle \int _\varOmega \left[ \frac{\chi _b}{2 \epsilon } \left( \mathrm {Tr} \mathscr {M}^\epsilon _u - \epsilon |\nabla u|H_0 \right) ^2 \right. \\ \displaystyle \quad + \left. \frac{\chi _G}{2\epsilon } \left( (\mathrm {Tr} \mathscr {M}^\epsilon _u )^2 - \Vert \mathscr {M}^\epsilon _u \Vert ^2 \right) \right] ~{\mathrm {d}}x \,\,\text {if } u \in C^2(\varOmega ),\\ \quad + \infty ~~\text {otherwise in } L^1(\varOmega ). \end{array}\right. }\nonumber \\ \end{aligned}$$
(12)

Based on the previous results of Röger and Schätzle [91], and under the assumptions \(H_0 = 0\) and \(- \chi _b< \chi _G < 0\), they showed that the \(\varGamma \)-convergence holds on smooth points \(u = 2 \chi _E - 1\) where \(E \subset \varOmega \) is open and \(\partial E \cap \varOmega \) is \(C^2\):

$$\begin{aligned} \left[ \varGamma (L^1(\varOmega )) - \lim \limits _{\epsilon \rightarrow 0^+} {\mathscr {H}}_\epsilon \right] (2 \chi _E - 1) = \sigma ~ \mathbf {E}_\text {H}(\partial E \cap \varOmega ),\nonumber \\ \end{aligned}$$
(13)

again using an additional uniform bound on the diffuse areas \(A_\epsilon \).

Our aim is precisely to generalize the Helfrich phase-field formula \({\mathscr {H}}_\epsilon \) further to approximate the curvature functional (6), and provide a computational framework to simulate shape textures. We are now ready to construct a new phase-field functional, for which we will study the \(\varGamma \)-limsup property.

3 Construction of the Phase-Field Functional

In this section, we generalize the Helfrich phase-field energy \({\mathscr {H}}_\epsilon \) in (12) to approximate the functional \(\mathbf {F}\) in (6), using the notations introduced in Sect. 2.3. We justify the construction with heuristic arguments, and show that the \(\varGamma \)-limsup is still satisfied, although we do not attempt to show the \(\varGamma \)-liminf.

3.1 Diffuse Curvatures and Second Fundamental Form

Let us notice that the diffuse expressions \({\mathscr {W}}_\epsilon \) and \({\mathscr {H}}_\epsilon \) in (11) and (12) both rely on the trace and the norm of the matrix field \(\mathscr {M}^\epsilon _u\) introduced in (7), which is related to the second fundamental forms and the curvatures of the level sets of u as follows. We define the diffuse second fundamental form \(\mathscr {B}^\epsilon _u\) as well as the diffuse mean and Gaussian curvatures \(\mathscr {H}^\epsilon _u\) and \(\mathscr {K}^\epsilon _u\) using

$$\begin{aligned} \mathscr {B}^\epsilon _u&= \frac{\mathscr {M}^\epsilon _u}{\epsilon |\nabla u|} \end{aligned}$$
(14)
$$\begin{aligned} \mathscr {H}^\epsilon _u&= \frac{\mathrm {Tr} \mathscr {M}^\epsilon _u }{\epsilon |\nabla u|} \end{aligned}$$
(15)
$$\begin{aligned} \mathscr {K}^\epsilon _u&= \frac{1}{2 \epsilon ^2 |\nabla u|^2} \left[ (\mathrm {Tr} \mathscr {M}^\epsilon _u )^2 - \Vert \mathscr {M}^\epsilon _u\Vert ^2 \right] \end{aligned}$$
(16)

if \(\nabla u \ne 0\), and zero otherwise. Informally, \(\mathscr {B}^\epsilon _u\otimes \mathbf {n}_u\) at the point \(x \in \varOmega \) approximates the second fundamental form of the level surface \(\{u = u(x)\}\) (well-defined if \(\nabla u \ne 0\) on this set). \(\mathscr {H}^\epsilon _u\mathbf {n}_u\) approximates the mean curvature vector, with the convention that it points inwards for convex sets, and \(\mathscr {K}^\epsilon _u\) approximates the Gaussian curvature.

Based on the relations (4) linking \((\kappa _1,\kappa _2)\) to (HK), we also introduce the diffuse principal curvatures

$$\begin{aligned} \kappa _{1,u}^\epsilon&= \frac{\mathscr {H}^\epsilon _u+ \sqrt{ \left( (\mathscr {H}^\epsilon _u)^2 - 4 \mathscr {K}^\epsilon _u\right) ^+}}{2} \end{aligned}$$
(17)
$$\begin{aligned} \kappa _{2,u}^\epsilon&= \frac{\mathscr {H}^\epsilon _u- \sqrt{ \left( (\mathscr {H}^\epsilon _u)^2 - 4 \mathscr {K}^\epsilon _u\right) ^+}}{2} , \end{aligned}$$
(18)

where we use the positive part \(x^+ = \max (0,x)\).

It can be shown, using the implicit formulas summarized in [42], that the expressions from (14) to (18) coincide exactly with the second fundamental form and the respective curvatures of the level sets of u, in the special case where the function has a hyperbolic tangent profile

$$\begin{aligned} u = \tanh \left( \frac{\mathrm {dist}_{\partial E}}{\sqrt{2} \epsilon } \right) , \end{aligned}$$
(19)

where \(E \subset \varOmega \) is an open set with smooth boundary \(\partial E \cap \varOmega \in {\mathscr {C}}^2\), and the signed distance from \(\partial E\), denoted by \(\mathrm {dist}_{\partial E}\), is by convention positive on E and negative on \(\varOmega \setminus {\bar{E}}\). In diffuse approximations, the \(\tanh \) profile is optimalFootnote 3 and is generally used to construct the \(\varGamma \)-limsup recovery sequence.

The presence of the positive part in (17) and (18) ensures that the square root term is still defined when \((\mathscr {H}^\epsilon _u)^2 - 4 \mathscr {K}^\epsilon _u< 0\). This can happen, since for a general u, we have \((\mathscr {H}^\epsilon _u)^2 - 4 \mathscr {K}^\epsilon _u= \frac{2 \Vert \mathscr {M}^\epsilon _u \Vert ^2 - (\mathrm {Tr} \mathscr {M}^\epsilon _u )^2}{\epsilon ^2 |\nabla u|^2}\), and the numerator is \(a^2 + b^2 + c^2 - 2 \, (ab + bc + ac)\) which possibly has negative values, where abc are the real eigenvalues of \(\mathscr {M}^\epsilon _u\). However, if one of them is 0, the numerator is a squared difference and the positive part is not useful. This is the case in particular for functions with \(\tanh \) profile.

The expressions (17) and (18) can be reformulated with \(\mathscr {M}^\epsilon _u\), by writing

$$\begin{aligned} \kappa _{1,u}^\epsilon&= \frac{\mathrm {Tr} \mathscr {M}^\epsilon _u + \sqrt{ \left( 2 \Vert \mathscr {M}^\epsilon _u \Vert ^2 - (\mathrm {Tr} \mathscr {M}^\epsilon _u )^2 \right) ^+}}{2 \epsilon |\nabla u|} \\ \kappa _{2,u}^\epsilon&= \frac{\mathrm {Tr} \mathscr {M}^\epsilon _u - \sqrt{ \left( 2 \Vert \mathscr {M}^\epsilon _u \Vert ^2 - (\mathrm {Tr} \mathscr {M}^\epsilon _u )^2 \right) ^+}}{2 \epsilon |\nabla u|}, \\ \end{aligned}$$

if \(\nabla u \ne 0\), and zero otherwise. Note that \(\mathscr {H}^\epsilon _u\) can be retrieved from their sum

$$\begin{aligned} \kappa _{1,u}^\epsilon + \kappa _{2,u}^\epsilon = \mathscr {H}^\epsilon _u\end{aligned}$$

contrarily to \(\mathscr {K}^\epsilon _u\) since their product is

$$\begin{aligned} \kappa _{1,u}^\epsilon \kappa _{2,u}^\epsilon = \frac{1}{4} ~ \left[ (\mathscr {H}^\epsilon _u)^2 - \left( (\mathscr {H}^\epsilon _u)^2 - 4 \mathscr {K}^\epsilon _u\right) ^+ \right] \le \mathscr {K}^\epsilon _u. \end{aligned}$$

3.2 Expression of the Phase-Field Functional

Let \(\mathbf {a}= (a_{2,0},\, a_{1,1},\, a_{0,2},\, a_{1,0},\, a_{0,1},\, a_{0,0}) = (a_\alpha )_{|\alpha | \le 2} \in \mathbb {R}^6\) be a vector of real coefficients. The associated polynomial function is denoted by \(p(x,y) = \sum _{|\alpha | \le 2} a_\alpha (x, y)^\alpha \), so that \(\mathbf {F}(\mathscr {S}) = \int _\mathscr {S}p(\kappa _1,\kappa _2) ~{\mathrm {d}}A \). Consider the following expression,

$$\begin{aligned} \mathscr {E}_\epsilon (u) = \int _\varOmega p(\kappa _{1,u}^\epsilon , \kappa _{2,u}^\epsilon ) \, \epsilon |\nabla u|^2 ~{\mathrm {d}}x. \end{aligned}$$

The heuristic intuition behind is that, if u has a tanh profile with transition parameter \(\epsilon \) as in (19), we can apply the co-area formula to obtain

$$\begin{aligned} \begin{aligned}&\int _{-1}^{1} \left( \int _{ \{u = t\} } p(\kappa _{1,u}^\epsilon , \kappa _{2,u}^\epsilon ) \, \epsilon |\nabla u|~d\mathscr {H}^2 \right) ~{\mathrm {d}}t\\&\quad = \int _{-1}^{1} \sqrt{2 W(t)} ~ \mathbf {F}( \{u = t\} ) ~{\mathrm {d}}t, \end{aligned} \end{aligned}$$

where we use \(|\nabla u|= \frac{(1-u^2)}{\sqrt{2} \epsilon } \ne 0\) and \(\frac{1-t^2}{\sqrt{2}} = \sqrt{2 W(t)}\). This amounts to integrating the curvature functional \(\mathbf {F}\) over all the level surfaces \(\mathscr {S}_t = \{u = t\}\) of the phase-field u, appropriately weighted so that the largest contributions are given by level sets close to \(\{ u = 0\}\). As \(\epsilon \) goes to zero, the level sets \(\{u = t\}\) concentrate around \(\partial E\).

Still under the ansatz of \(\tanh \) profile, \(\mathscr {E}_\epsilon \) can be developed in terms of the matrix field \(\mathscr {M}^\epsilon _u\):

$$\begin{aligned} \begin{aligned} {\widetilde{\mathscr {E}_\epsilon }}(u)&= \int _\varOmega \left[ \frac{a_{2,0} + a_{0,2} - a_{1,1}}{4 \epsilon }~ \left( 2 \Vert \mathscr {M}^\epsilon _u \Vert ^2 - (\mathrm {Tr} \mathscr {M}^\epsilon _u )^2 \right) ^+ \right. \\&\quad + \frac{a_{2,0} + a_{0,2} + a_{1,1}}{4 \epsilon } ~(\mathrm {Tr} \mathscr {M}^\epsilon _u )^2 \\&\quad + \frac{a_{2,0} - a_{0,2}}{2 \epsilon } ~\mathrm {Tr} \mathscr {M}^\epsilon _u \sqrt{\left( 2 \Vert \mathscr {M}^\epsilon _u \Vert ^2 - (\mathrm {Tr} \mathscr {M}^\epsilon _u )^2 \right) ^+} \\&\quad + \frac{a_{1,0} + a_{0,1} }{2} ~|\nabla u|\mathrm {Tr} \mathscr {M}^\epsilon _u \\&\quad + \frac{a_{1,0} - a_{0,1} }{2} ~|\nabla u|\sqrt{(2 \Vert \mathscr {M}^\epsilon _u \Vert ^2 - (\mathrm {Tr} \mathscr {M}^\epsilon _u )^2 )^+} \\&\quad + \left. a_{0,0} ~\epsilon |\nabla u|^2 \right] ~ {\mathrm {d}}x. \end{aligned} \end{aligned}$$

For a general \(u \in W^{2,2}(\varOmega )\), the expressions of \(\mathscr {E}_\epsilon (u)\) and \({\widetilde{\mathscr {E}_\epsilon }}(u)\) coincide if u is such that

$$\begin{aligned} {\mathscr {L}}^3 \left( \{|\nabla u|= 0 \} \cap \{ \mathscr {M}^\epsilon _u\ne 0 \} \right) = 0, \end{aligned}$$

which is satisfied for functions with \(\tanh \) profile.

Finally, \({\widetilde{\mathscr {E}_\epsilon }}(u)\) can be simplified further, by replacing the positive part in the first term outside the square root directly by \(2 \Vert \mathscr {M}^\epsilon _u \Vert ^2 - (\mathrm {Tr} \mathscr {M}^\epsilon _u )^2\). As said earlier, this is true of the special \(\tanh \) case, where \(2 \Vert \mathscr {M}^\epsilon _u \Vert ^2 - (\mathrm {Tr} \mathscr {M}^\epsilon _u )^2 \ge 0\) is \((a - b)^2\), where a, b and 0 are the eigenvalues of \(\mathscr {M}^\epsilon _u\). This leads to the final form, defined for any \(u \in W^{2,2}(\varOmega )\),

$$\begin{aligned} \mathscr {F}_\epsilon (u)&= \int _\varOmega \left[ \frac{a_{2,0} + a_{0,2} - a_{1,1}}{2 \epsilon }~ \Vert \mathscr {M}^\epsilon _u \Vert ^2 + \frac{a_{1,1}}{2 \epsilon } ~ (\mathrm {Tr} \mathscr {M}^\epsilon _u )^2 \right. \nonumber \\&\quad + \frac{a_{2,0} - a_{0,2}}{2 \epsilon } ~\mathrm {Tr} \mathscr {M}^\epsilon _u \sqrt{(2 \Vert \mathscr {M}^\epsilon _u \Vert ^2 - (\mathrm {Tr} \mathscr {M}^\epsilon _u )^2 )^+} \nonumber \\&\quad + \frac{a_{1,0} + a_{0,1} }{2} ~|\nabla u|\mathrm {Tr} \mathscr {M}^\epsilon _u \nonumber \\&\quad + \frac{a_{1,0} - a_{0,1} }{2} ~|\nabla u|\sqrt{(2 \Vert \mathscr {M}^\epsilon _u \Vert ^2 - (\mathrm {Tr} \mathscr {M}^\epsilon _u )^2 )^+} \nonumber \\&\quad + \left. a_{0,0} ~\epsilon |\nabla u|^2 \right] ~ {\mathrm {d}}x. \end{aligned}$$
(20)

This phase-field functional is devised to be a diffuse approximation of the sharp-interface functional \(\mathbf {F}\) (6), up to the multiplicative factor \(\sigma \).

Comparison with the Willmore and the Helfrich diffuse approximations. It can be checked that the proposed formulation \(\mathscr {F}_\epsilon \) is indeed a generalization of the previous formulas \({\mathscr {W}}_\epsilon \) and \({\mathscr {H}}_\epsilon \), by specifying the polynomial coefficients of the Willmore energy,

$$\begin{aligned} p(\kappa _1,\kappa _2) = H^2 \quad \text { with } \quad \mathbf {a}= (1,2,1,0,0,0), \end{aligned}$$

and of the Helfrich energy,

$$\begin{aligned}&p(\kappa _1,\kappa _2) = \frac{\chi _b}{2} (H-H_0)^2 + \chi _G K \quad \text { with } \\&\quad \mathbf {a}= \left( \frac{\chi _b}{2}, \chi _b + \chi _G, \frac{\chi _b}{2}, - \chi _b H_0, - \chi _b H_0, \frac{\chi _b}{2} H_0^2\right) .\end{aligned}$$

3.3 \(\varGamma \)-Limsup Property

As explained in Sect. 2.2, the approximation of the target functional \(\mathbf {F}\) by the sequence \((\mathscr {F}_\epsilon )_{\epsilon > 0}\) can be studied in the \(\varGamma \)-convergence framework. Here, we assert that the phase-field functional \(\mathscr {F}_\epsilon \) satisfies the \(\varGamma \)-limsup property, thus extending the result of [8].

Theorem 2

(\(\varGamma \)-limsup inequality) Let \(E \subset \varOmega \) be a bounded open set, such that \(\partial E \cap \varOmega \) is of class \({\mathscr {C}}^2\). The functionals \(\mathscr {F}_\epsilon \) and \(\mathbf {F}\) are defined as in (20) and (6). Then there exists a sequence of functionals \((u_\epsilon )_{\epsilon > 0} \subset W^{2,2}(\varOmega )\) such that

$$\begin{aligned}&\lim \limits _{\epsilon \rightarrow 0^+} u_\epsilon = 2 \chi _E - 1 \text { in } L^1(\varOmega ), \end{aligned}$$
(21)
$$\begin{aligned}&\lim \limits _{\epsilon \rightarrow 0^+} \epsilon |\nabla u_\epsilon |^2 \, {\mathscr {L}}^3_{| \, \varOmega } = \sigma \, \mathscr {H}^2_{| \, \partial E} \text { as Radon measures}, \end{aligned}$$
(22)
$$\begin{aligned}&\lim \limits _{\epsilon \rightarrow 0^+} \mathscr {F}_\epsilon (u_\epsilon ) = \sigma \, \mathbf {F}(E) \end{aligned}$$
(23)

The proof is given in the Appendix. It consists in showing that the recovery sequence constructed in [8] still satisfies the theorem for our more general formulation \(\mathscr {F}_\epsilon \). The first and third properties correspond to the existence of a recovery sequence. The second property loosely means that the measure whose density is \(\epsilon |\nabla u_\epsilon |^2\) in the 3D volumetric space concentrates into the measure induced by the area on the 2D surface. This intuition is in accordance with the way we constructed \(\mathscr {F}_\epsilon \) (see beginning of Sect. 3.2).

However, whether or not the \(\varGamma \)-liminf holds still remains an open question, except in the special cases of the Willmore and the Helfrich energies with additional assumptions, as seen in Sect. 2.3. Yet, we believe that, even if the \(\varGamma \)-convergence could fail in general, this does not constitute a serious impediment to our phase-field expression being still of interest for generating shape textures.

4 Simulations

In this section, we demonstrate that the phase-field model \(\mathscr {F}_\epsilon \) constructed in the previous section can generate a large range of shape textures (up to a slight regularization; see Sect. 2 of the Online Supplement). We describe curvatubes in Algorithm 1, and then show the results of four numerical experiments. The first one validates the approach by finding well-known Willmore minimizers. We then display a gallery of 10 shape textures. The effect of smoothly varying the generation parameters is shown in the third experiment, with a bilinear interpolation between 4 shape textures, layers, spheres, tubes, and sponges. Finally, 1000 shape textures are generated with random parameters and visualized in an atlas with UMAP. The numerical codes are fully available at

      https://github.com/annasongmaths/curvatubes.

More details on the computation of the phase-field energy can be found in Sect. 2 of the Online Supplement.

4.1 Curvatubes

Shape textures are generated by minimizing the phase-field energy \(\mathscr {F}_\epsilon \) (20) under a constraint of constant volume, with periodic boundary conditions. More exactly, given a random initialization of the phase-field u, we find a point of convergence with low energy of the so-called \(H^{-1}\) flowFootnote 4

$$\begin{aligned} {\dot{u}} = \varDelta \frac{\partial \mathscr {F}_\epsilon }{\partial u}(u). \end{aligned}$$

The \(H^{-1}\) flow is mass-preserving, i.e., keeps constant the mass of u, denoted by \({\bar{u}} := \frac{1}{\varOmega } \int _\varOmega u ~{\mathrm {d}}x\). The preservation of mass approximately encodes a constraint of constant volume on the region enclosed by the surface \(\{u = 0\}\), if the phase-field \(u \simeq \pm 1\) is nearly constant inside and outside.

The \(H^{-1}\) flow can actually be expressed as a standard \(L^2\) flow, by relying on the change of variable

$$\begin{aligned} u = \nabla \cdot A + m_0, \end{aligned}$$
(24)

where \(A : \varOmega \rightarrow \mathbb {R}^3\) is a periodic vector field, and \(m_0 \in \mathbb {R}\) is the desired value of the average \({\bar{u}}\). We then define an energy with respect to A,

$$\begin{aligned} G_\epsilon (A) = \mathscr {F}_\epsilon (\nabla \cdot A + m_0). \end{aligned}$$

It can be checked that

$$\begin{aligned} \frac{\partial G_\epsilon }{\partial A}(A) = - \nabla \frac{\partial \mathscr {F}_\epsilon }{\partial u}(u), \end{aligned}$$

in such a way that a \(L^2\) flow on A becomes a \(H^{-1}\) flow on u:

$$\begin{aligned} {\dot{A}} = - \frac{\partial G_\epsilon }{\partial A} {(A)} \quad \Rightarrow \quad {\dot{u}} = \varDelta \frac{\partial \mathscr {F}_\epsilon }{\partial u} {(u)} \end{aligned}$$

(provided that the derivatives in time and space of A commute). Therefore, the \(H^{-1}\) flow on u starting at \(u_0 = \nabla \cdot A_0 + m_0 \) can be solved as a usual \(L^2\) flow on A.

To generate shape textures, the variable A is initialized as a random white noise vector field \(A_0\) and we reach a point of convergence of the \(L^2\) flow \({\dot{A}} = - \frac{\partial G_\epsilon }{\partial A}\) with Adam [55, 66], a gradient-based stochastic optimization algorithm. The change of variable (24) allows us to benefit from the computation of the \(L^2\) gradient \(\frac{\partial G_\epsilon }{\partial A}\) by the automatic differentiation engine provided by PyTorch [83], combined with the efficiency of Adam.

The generation model is summarized in Algorithm 1. It takes as inputs the initialization \(A_0\), the coefficients \(\mathbf {a}\) and the mass \(m_0\). After convergence, the output shape texture is defined as the level surface \(\{u = 0\}\) of the final phase-field \(u = \nabla \cdot A + m_0\). We color it in beige, and show the level set \(\{ u = 0.05 \}\) in dark red to enhance the visualization. An example of flow is given in Fig. 2, with the corresponding loss curves in Fig. 3.

Fig. 2
figure 2

Evolution of the zero level set of u during the \(H^{-1}\) flow, pictured at iterations 10, 300, 1000, 4000, 8000, with the generation parameters \(\mathbf {a}= (1, 2.4, 9, 30, 170, -195)\) and \(m_0 = -0.66\). Top row: the shape textures. Bottom row: their corresponding curvature diagrams. In the early iterations, the zero level set is not smoothly defined and only few values of u are above zero, but their average remains \(m_0\)

Implementation details. The domain \(\varOmega \) is assimilated to a grid of size \(100 \times 100 \times 100\) pixels with a fixed sampling step \(\varDelta x = 0.01\). We take \(\epsilon = 0.02\), unless specified otherwise. The phase-field u and the vector field A are encoded as matrices whose coefficients specify the sampled values.

The discrete energies \(\mathscr {F}_\epsilon \) (resp. \(G_\epsilon \)) are symbolically defined by a succession of elementary operations on u (resp. A), before being differentiated automatically by PyTorch. In particular, the integral is encoded as a finite sum, while the differential operations \(\nabla u\), \(\mathrm {Hess}~ u\), and \(\nabla \cdot A\), are computed as classical finite differences that take into account the periodicity of the problem. To prevent the formation of artifacts, we apply a Gaussian blur k with a small deviation (typically \(\sigma _k = 2\) pixels) to the phase-field u, before computing the finite differences. The norm of the gradient \(|\nabla u|\) is modified by a small offset \(\xi = 10^{-6}\), as in \(\sqrt{|\nabla u|^2 + \xi ^2}\) or \(1/\sqrt{|\nabla u|^2 + \xi ^2}\), to prevent non-differentiability at zero and division by zero. The positive part function \(x^+\) appearing in \(\mathscr {F}_\epsilon \) is approximated by a smooth function \(x^+ \simeq \xi \log (1 + \mathrm {e}^{x / \xi })\). In Sect. 2 of the Online Supplement, we prove the convergence of the numerical approximations of the energies and their \(L^2\) gradients by their discrete counterparts (computed with finite differences and automatic differentiation) as the resolution of the grid tends to infinity.

figure a

With Adam, the step size and direction at each point are computed in an adaptive way, by taking into account the past history of the gradients to estimate their first and second moments. In the simulations presented thereafter, Adam was run with a learning rate \(lr = 0.001\), \(betas = (0.9, 0.999)\), and no weight decay. We stopped the algorithm typically after 8000 iterations, as the convergence was estimated to be reached, which induced up to 150 seconds of computation time per shape with a simulation domain of size \(100 \times 100 \times 100\) pixels.

Generation parameters, shape textures, curvature diagrams. The generation of shape textures relies on the principle that a generation parameter vector \((\mathbf {a}, m_0)\) should consistently correspond to a single shape texture, across different white noise initializations of \(A_0\). We “measure” the texture of a shape defined by a surface \(\mathscr {S}\) through its curvature diagram, which represents the distribution of the curvatures \((\kappa _1,\kappa _2)\) on \(\mathscr {S}\) (see bottom row of Fig. 2 for instance). More precisely, we are interested in the law of the random variable \((\kappa _1,\kappa _2)\) defined by

$$\begin{aligned} {\mathbb {P}}\left[ (\kappa _1,\kappa _2) \in {\mathscr {B}} \right]&= \frac{1}{\text {Area}(\mathscr {S})} \int _\mathscr {S}\chi _{(\kappa _1,\kappa _2) \in {\mathscr {B}}} ~d\mathscr {H}^2 \\&= \frac{\text {Area}( \{ x \in \mathscr {S}~|~ (\kappa _1,\kappa _2)(x) \in {\mathscr {B}} \} )}{\text {Area}(\mathscr {S})}, \end{aligned}$$

for a Borel set \({\mathscr {B}}\) of \(\mathbb {R}^2\).

The curvature diagram is an indicator of the local behavior of the surface. For a perfect sphere of radius R, it should be a unit Dirac mass \(\delta _{(\frac{1}{R},\frac{1}{R})}\) sitting on the \(\{ y = x, \,x > 0 \}\) half-diagonal, since \(\kappa _1= \kappa _2= \frac{1}{R}\) everywhere on a sphere. Likewise, a cylinder of base radius r should have its diagram reduced to \(\delta _{(\frac{1}{r}, 0)}\) on the horizontal half-line \(\{ y = 0, \,x > 0 \}\); a plane would be represented as \(\delta _{(0,0)}\); finally, a Dirac mass such as \(\delta _{(1,-1)}\) should correspond to a sponge-like shape. Note that, per definition of the curvatures \(\kappa _1\ge \kappa _2\), the distribution is contained in the lower mid-plane \(\{ y \le x \}\).

To obtain a curvature diagram, we first extract the 2D mesh of the surface \(\mathscr {S}= \{ u = 0 \}\) from the 3D volume u, by using the marching cubes algorithm [63]. Then, the diffuse curvatures \((\kappa _{1,u}^\epsilon , \kappa _{2,u}^\epsilon )\) (see (17) and (18)) are interpolated at the barycenter of each cell of the mesh. Their values are of importance proportional to the area of the cell, resulting in a weighted point cloud

$$\begin{aligned} \sum _{\text {cells } c} \text {Area}\,[c] ~\delta _{(\kappa _{1,u}^\epsilon , \kappa _{2,u}^\epsilon )\,[c]} \end{aligned}$$
(25)

which we plot in the curvature diagram. Note that the diffuse curvatures coincide with the curvatures of the levels sets for functions with \(\tanh \) profile (19), but are only approximations in the general case. Hence, the curvature diagrams shown throughout this article are only approximations of the exact curvature diagrams, most precise for those u having nearly a \(\tanh \) profile.Footnote 5

Fig. 3
figure 3

Corresponding loss curves (see Fig. 2). From left to right: the loss \(\mathscr {F}_\epsilon (u)\), the maximal value of \(|\frac{\partial G_\epsilon }{\partial A}|\) and the average \(\frac{1}{|\varOmega |} \int _\varOmega |\frac{\partial G_\epsilon }{\partial A}|\), as u evolves along the iterations

In our simulations, the shapes are rarely perfectly spherical, cylindrical, or flat, so that the distribution is dispersed rather than concentrated into a single Dirac mass. To ease the visualization of the curvature diagrams, the identity diagonal \(\{y = x\}\) is enhanced as a red line and the values truncated between \(-100\) and 100.

Fig. 4
figure 4

Same generation parameters, different initializations. Using the same generation parameters \(\mathbf {a}= (1, -0.35, 1.02, -40, 100, 1600) \) and \(m_0 = -0.69\), we start from five random initializations for \(A_0\). Top row: the shape textures. Bottom row: their corresponding curvature diagrams. The five shapes are visually similar at a mesoscopic scale, but dissimilar at the macroscopic scale. The diagrams and their pairwise Wasserstein distances show that the curvature statistics are not changing much when feeding the same generation parameters to the algorithm. Texture in shapes hence seems to be well captured by curvature diagrams, and to be consistent with the generation parameters at a mesoscopic scale

We compare curvature diagrams with each other using the Wasserstein (or Earth Mover’s) distance. We approximate this quantity with the regularized Sinkhorn algorithm of the geomloss module [38], with the parameters \(p = 2\), \(blur = 1\) and \(reach = 20\). As detailed in [37], these correspond to the resolution of an unbalanced transport problem [102] using a ground cost function of \(\text {C}(x,y)=\tfrac{1}{2}\Vert x-y\Vert ^2\), with a transport plan that is blurred at resolution of 1 and with a maximum transport distance of the order of 20.

Figure 2 shows that the curvature diagrams of the evolving level surface also converge towards a final diagram. In Fig. 4, we check that for a single generation parameter value \((\mathbf {a},m_0)\), 5 different initializations still give similar curvature diagrams. We found that the mean pairwise Wasserstein distance between different curvature diagrams was around 1.32 for these 5 shapes, i.e. only \(10.7 \%\) of the mean pairwise distance 12.35 measured between the curvature diagrams of 1000 random shapes (see Experiment 4). Due to the high dimensionality of the space of curvature diagrams endowed with the Wasserstein metric, this ratio actually indicates a good clustering of these 5 shapes. Indeed, as dimension increases, points easily become sparser: the distance to the farthest neighbor becomes comparable to that to the nearest one due to the “curse of dimensionality” [2, 11]. After embedding the combined dataset of \(1000 + 5\) shapes in 2D with UMAP, similarly to Experiment 4, the 5 shapes are more obviously clustered in low dimension (Online Supplement, Figure 1), since the new pairwise Euclidean distance within them was only 0.115, i.e. only \(2.67\%\) compared to 4.3 for the other 1000 shapes.

Therefore, curvature diagrams and generation parameters seem to capture well the notion of shape texture.

4.2 Experiment 1: Validation with the Willmore Flow and Known Minimizers of Genus 0, 1, and 2

The algorithmic framework, which combines automatic differentiation and control of gradient flows by external optimizers, is validated in the fundamental special case of the \(L^2\) Willmore flow. This flow is computed using Algorithm 2, with the parameters \(\mathbf {a}= (1,2,1,0,0,0)\), and with replicate boundary conditions (which corresponds to the assumption that the gradient \(\nabla u\) is orthogonal to the domain boundary, i.e., \(\nabla u \cdot \mathbf {n}_{\partial \varOmega } = 0\)). Let us recall from Sect. 2.3 that the Willmore phase-field energy writes \(\mathscr {F}_\epsilon = \frac{1}{\epsilon } \int _\varOmega ( \epsilon \varDelta u - \frac{W'(u)}{\epsilon })^2 {\mathrm {d}}x\) and approximates \(\sigma \int _\mathscr {S}H^2 \, {\mathrm {d}}A\). We numerically check that the simulated Willmore flow converges towards known global minimizers of fixed genus 0, 1, and 2, by initializing the flow near them. Here, the gradient descent is controlled by the L-BFGS optimizer, as it was empirically found to converge faster than AdamFootnote 6. L-BFGS approximates the BFGS algorithm, a quasi-Newton method that combines a line search to an estimation of the Hessian of the loss [39, 52].

figure b

The Willmore minimizers of genus 0 are spheres of any radius [110], which achieve the minimal valueFootnote 7

$$\begin{aligned} \int _{\mathscr {S}} H^2 ~{\mathrm {d}}A = \int _\mathscr {S}\left( \kappa _1+ \kappa _2\right) ^2 ~{\mathrm {d}}A = 4 \times 4 \pi .\end{aligned}$$

For surfaces of genus 1, [67] proved that the minimal value \(4 \times 2 \pi ^2\) is achieved by the Clifford torus (up to conformal transformations), defined by a special ratio \(\frac{1}{\sqrt{2}}\) between the radius of the generating circle and the distance to the axis of revolution. However, the proof for genus \(\ge 2\) has still not been completed, although several conjectures have been proposed. It has been shown that the minimum Willmore energy among all (orientable closed) surfaces of genus g is less than \(4 \times 8 \pi \), and converges to this value as the genus \(g \rightarrow \infty \) [61]. The Lawson surfaces have also been conjectured to be the minimizers for a given genus (up to conformal transformations) [45, 60].

Fig. 5
figure 5

Willmore minimizer of genus 0. The flow is stationary on the sphere. The diffuse Willmore energy and the diffuse area are close to their mathematical values

Fig. 6
figure 6

Willmore flow towards minimizer of genus 1. The flow converges to a Clifford torus. The ratio of the torus and the diffuse Willmore energy are close to their mathematical values

Fig. 7
figure 7

Willmore flow towards minimizer of genus 2. The flow converges to a Lawson-like surface, as expected from conjectures

We compare the final value \(\frac{\mathscr {F}_\epsilon }{\sigma }\) to the minimal values mentioned above, where \(\sigma = \frac{4}{3 \sqrt{2}}\) is the constant introduced in Sect. 2. We correctly find that the flow is stationary on spheres (see Fig. 5). The energy \(\frac{\mathscr {F}_\epsilon }{\sigma }\) deviates from \(4 \times 4 \pi \) with only \(0.3 \%\) of relative error. We also check that the value of the Cahn-Hilliard energy \(\int _\varOmega (\frac{\epsilon }{2} |\nabla u|^2 + \frac{W(u)}{\epsilon }) ~{\mathrm {d}}A\), divided by \(\sigma \), is close to the area of the sphere, with \(0.5 \%\) of relative error. When departing from a holed cube, the flow converges to a Clifford torus with a characterizing ratio close to \(\frac{1}{\sqrt{2}}\) up to a relative error of \(3\%\). We also find \(\frac{\mathscr {F}_\epsilon }{\sigma } \simeq 4 \times 2 \pi ^2\) up to a relative error of \(0.4 \%\). Finally, starting from two holed cubes glued together, the flow converges to a surface resembling a Lawson surface of genus 2, with minimal value \(\frac{\mathscr {F}_\epsilon }{4 \sigma } \simeq 22.30\), which has a relative difference of \(1.8 \%\) compared to the value found in [45]. In Figs. 5, 6, and 7, the parameters are \(\epsilon = 0.04\), \(\mathbf {a}= (1,2,1,0,0,0)\) and \(\sigma _k = 1\) pixel. The grid size is \(200 \times 200 \times 200\) in the first two simulations and \(200 \times 300 \times 400\) in the third one. L-BFGS was run with a learning rate \(lr = 1\), a history size \(hs = 10\), and maximum 20 iterations in a line search.

4.3 Experiment 2: A Gallery of Ten Shape Textures

In Figs. 11 and 12, we show ten shape textures generated with Algorithm 1, and visualize the surfaces together with their curvature diagrams. The coefficients \(\mathbf {a}\) and the mass \(m_0 = \frac{1}{|\varOmega |} \int _\varOmega u\) used for the simulations are specified in the tables. The mass is also expressed in percentage of volume enclosed by the surface compared to the total volume of the domain, approximated by \(\frac{m_0 + 1}{2}\) since \(u \simeq \pm 1\).

In practice, we find that the non-reduced polynomial expression

$$\begin{aligned} h_2 (H-H_0)^2 + k_1 K + \alpha (\kappa _1- \kappa _1^{0})^2 + \beta (\kappa _2- \kappa _2^0)^2 \end{aligned}$$
(26)

induces a choice of parameters \(\mathbf {b}= (h_2, H_0, k_1, \alpha , \kappa _1^0, \beta , \kappa _2^0)\) that are more interpretable than the coefficients \(\mathbf {a}\) in the reduced form \(\sum _{|\alpha | \le 2} a_\alpha (\kappa _1,\kappa _2)^\alpha \). Using this formulation (26), it is easier to find reasonable values for which the energy leads to various tubular textures, without resulting in badly-converged phase-fields (we have no theoretical justification to this yet, but this should be explored as a future work). Those phase-fields are often over-diffuse, have a high normalized discrepancy (defined in (27)), and do not present clear transitions between the phases \(\pm 1\). They may have no zero level set, may oscillate in space, which gives rise to pieces of surface concentrically enclosed in each other, or their zero level sets may be broken into irregular fragments of variable size (see Online Supplement, Figure 5). The shapes were hence generated either by choosing \(\mathbf {b}\) manually, or by selecting \(\mathbf {a}\) among random values from Experiment 4 that resulted in interesting shapes.

We found that curvatubes is able to generate very different shape textures (see Figs. 11 and 12, in which they are indexed by letters). Some shapes, such as (d), (e), (g), and (h) are smooth and spatially homogeneous in terms of visual aspect. Other shapes, such as (b), (c), (f), and especially (i), seem to possess a multi-scale texture or “meta-texture” that makes them appear as spatially heterogeneous and anisotropic. The surface can be piecewise-smooth only, as in (c). Tubules are not necessarily smoothly turning cylinders, but can have some tortuosity as in (j). Finally, note that (h) combines flat regions and tubules, in a similar way to trabecular bone.

4.4 Experiment 3: Bilinear Interpolation Between Four Shape Textures

In Fig. 8, we illustrate how continuously varying the generation parameters \((\mathbf {a}, m_0)\) impacts on the morphologies, by interpolating the parameters of four shape textures: layers, spheres, tubes, and sponges. The respective values can be found in Table 1. All simulations are run by starting from the same initialization \(A_0\).

Table 1 Generation parameters of four reference shape textures in Experiment 3 (see Figs. 8 and 9)

We can see that the morphology is smoothly changing throughout the figure: for instance, the transition between spheres and tubes is characterized by tubes terminated on one side by end-caps, while layers increase in proportion compared to tubules when approaching the top left corner. The curvature diagrams are displayed in Fig. 9, and they are quite continuously evolving as we change the generation parameters. The four diagrams at the corners reflect well the typical curvature distribution of layers, spheres, tubes, and sponges, as expected (see Sect. 4.1).

4.5 Experiment 4: Generation of 1000 Shapes Viewed in UMAP

Our final experiment is designed to explore the space of possible shape textures with curvatubes and visualize them in a 2D atlas (see Fig. 10). The generation parameters were chosen randomly. We fixed \(a_{2,0} = 1\), and arbitrarily chose the other coefficients according to a uniform law in the following intervals: \(a_{1,1} \in (-4,4)\), \(a_{0,2} \in (1/15,15)\), \(b_{1,0} \in (-200,200)\), \(b_{0,1} \in (-200,200)\), \(c \in (-3000,3000)\), and the mass \(m_0 \in (-0.75, -0.15)\) which represented from \(12.5\%\) to \(42.5\%\) of relative volume occupied by the phase \(\{ u \simeq 1 \}\). The initialization \(A_0\) was refreshed for each simulation.

By doing this, the algorithm was pushed to its limits, as some values of coefficients chosen in this random way led to an ill-posed geometric minimization problem. Yet, even in these cases, the algorithm did not diverge to NaN values, but the function u simply did not converge to a phase-field with two distinct phases, or had no zero level set, or the zero level set was not smooth and was fragmented into pieces. To reject such situations, we gauged the viability of the parameters by computing the discrepancy \(\int _\varOmega \left| \frac{\epsilon }{2} |\nabla u|^2 - \frac{W(u)}{\epsilon } \right| ~{\mathrm {d}}x\) of the phase-field, normalized by the diffuse area, i.e., the Cahn-Hilliard energy. We call this quantity the normalized discrepancy:

$$\begin{aligned} \mathrm {ND} = \frac{\displaystyle \int _\varOmega \left| \frac{\epsilon }{2} |\nabla u|^2 - \frac{W(u)}{\epsilon } \right| ~{\mathrm {d}}x}{\displaystyle \int _\varOmega \left( \frac{\epsilon }{2} |\nabla u|^2 + \frac{W(u)}{\epsilon } \right) ~{\mathrm {d}}x} \in [0,1]. \end{aligned}$$
(27)
Fig. 8
figure 8

Bilinear interpolation between layers, spheres, tubes, and sponges. Using the same initialization \(A_0\) and interpolating between four reference generation parameters gives rise to a continuum of shape textures

Fig. 9
figure 9

Corresponding curvature diagrams (see Fig. 8). The bilinear interpolation of generation parameters is also reflected into the curvature diagrams as a continuous evolution. Please note that the curvature distributions of the four reference shapes concentrate around (0, 0) for layers, the identity half-line \(\{ y = x, x > 0 \}\) for spheres, the horizontal half-axis \(\{ y = 0, x > 0 \}\) for tubes, and a half-line \(\{ y = -a \,x, x > 0\}\) with \(a > 0\) for sponges. As explained in Sect. 4.1, this is expected from curvature diagrams

The discrepancy measures how much u deviates from a phase-field with \(\tanh \) profile as in (19), and is an indicator of good behavior in numerical experiments. In particular, it vanishes for functions with \(\tanh \) profile. After normalization by the diffuse area, the normalized discrepancy varies between 0 and 1, with 0 indicating a good quality in the numerical approximations. In Online Supplement, Figures 4 and 5, we compare the profiles of phase-fields u with low or high normalized discrepancies to an ideal \(\tanh \) profile (19).

Shapes were deemed viable if the normalized discrepancy was under the threshold 0.75 and if \(\text {max}(u) > 0.1\) and \(\text {min}(u) < -0.1\) to ensure that the zero level set was defined. We chose a lenient threshold 0.75 in order to still include some interesting shape textures in this study, even if they departed from a \(\tanh \) profile (see Online Supplement, Figure 5).

If the random value assigned to \((\mathbf {a},m_0)\) produced a non-viable shape, a new value was drawn uniformly until obtaining a viable shape. We thus generated 1000 shapes meeting the criteria mentioned above. Following this procedure, 1792 random simulations were carried out in total, comprising 1000 viable ones and 792 non-viable ones (\(44\%\) of the total). In Figures 6, 7, and 8 of the Online Supplement, we show some preliminary results on the way high normalized discrepancies seem to be correlated with certain regions of parameters.

We computed the pairwise Wasserstein distance between their curvature diagrams, as described in the last paragraph of Sect. 4.1. To reduce the computation time, in each comparison we restricted the point cloud (25) to 10000 cells randomly taken from the whole mesh. The distance matrix was then given as input to UMAP [70], a manifold learning technique for dimension reduction, with the option metric = ‘precomputed’. The 1000 shapes were embedded in a 2D atlas by considering local neighborhoods of \(n = 25\) points, a minimal distance \(md = 0.05\) between embedded points and a spread \(sp = 1\). For reproducibility, the random seed was set to \(RS = 1\). To enhance the visualization, the embedded points were labeled with Hdbscan [69], with a minimum cluster size \(mcs = 10\) and a minimum number of samples \(ms = 10\). They were colored according to their cluster number, and as black dots if Hdbscan classified them as noise. We picked some shapes from the point cloud and displayed their thumbnails, with their location specified by an arrow. Please note that the thumbnails do not exhaustively cover all the types of morphologies, but may give an idea of their disparity.

Fig. 10
figure 10

Atlas of 1000 shapes visualized in UMAP. The generation parameters were chosen randomly and we applied some criteria to select mainly viable shapes. Three major families can be identified: spheres, layers, and tubules which constitute the principal type of shape textures. Let us highlight the large intra-variation in the family of tubules, that features not only smooth sponges and long tubes, but also irregular and anisotropic tubules with a multi-scale texture. This is a remarkable feature of the generation model, since all pixels of the simulation domain share identical properties with respect to the minimization problem

The atlas in Fig. 10 shows that the shape textures are roughly distributed into three main families, spheres (top, left), layers (top), and tubules (central part) that occupy the largest region. In two marginal regions, we also identified outliers, such as highly packed tubules (bottom, right), and fragmented shapes (bottom, left). This suggest that the selection criteria mentioned above were not selective enough for discarding badly-converged shapes (i.e. over-diffused phase-fields), which is expected given the lenient threshold 0.75. The marginal regions concentrate most of the outliers, but we also noticed a few of them spread inside the main regions. These shapes are characterized by high normalized discrepancies and irregular aspects (see Online Supplement, Figures 3 and 5).

The transition between morphological subtypes is quite smooth when moving continuously in the atlas; however, we did not examine in which way the generation parameters relate to the spatial embedding yet. The family of tubules has a large intra-variation, and features not only smooth sponges or long tubes, but also irregular, tortuous and anisotropic tubules that have a multi-scale texture, as mentioned in Experiments 2. This is a remarkable behavior of the generation model, since in regard of the minimization problem, all points have the same homogeneous properties in space.

Fig. 11
figure 11

Five shape textures (a, b, c, d, e). We indicate the cases where the polynomial in the curvature energy has the form (26). The normalized discrepancy \(\mathrm {ND}\) (27) is also given

Fig. 12
figure 12

Five shape textures (f, g, h, i, j). We indicate the cases where the polynomial in the curvature energy has the form (26). The normalized discrepancy \(\mathrm {ND}\) (27) is also given

5 Discussion

In this final section, we discuss the strengths and limitations of the algorithm, propose a few extensions, and present the important implications of a unifying framework on applied contexts.

5.1 Strengths and Limitations

As seen in the simulations of Sect. 4, curvatubes leads to a wide range of membranous and tubular shapes, some of which have a multi-scale texture. The generation parameters and the curvature diagrams capture well the notion of shape texture. The algorithm is GPU-accelerated and takes advantage of automatic differentiation combined to external algorithms (Adam, L-BFGS) to descend gradient flows. Contrarily to refined numerical schemes, its aim is not to precisely solve the evolution equation, but rather to converge fast to a local minimizer with small energy. The mathematical computation of the gradient is not required either. The coefficients can be chosen in a flexible way, without letting the algorithm diverge numerically, even in mathematically ill-posed cases. The simulation results are reproducible, and seem to behave in accordance with the polynomial of curvatures in the energy especially under the form (26); although much work is still needed to understand mathematically how different polynomial energies are linked to different shape textures, and what are the values of coefficients that correspond to well-posed geometric problems. We leave these difficult questions as future work.

Let us caution the reader that here, the model does not generate tree-like structures, for which junctions are hierarchically organized into parent and children nodes, and cycles are excluded. Thus, it cannot be applied to the respiratory system, and can only model vessels that branch and cycle a lot such as capillaries. This is because the model is devised primarily for reproducing shape texture, but not shape structure. Some extensions of the framework to include structured constraints are proposed in the next subsection. The notion of shape texture is inspired from visual texture in images, characterized by spatially repeated elements whose conformation, such as size, color, orientation, are subject to randomness [46, 62, 85]. Texture is hence a statistically defined property, while structure may be understood as an orthogonal component.

Furthermore, in contrast to the Helfrich biomembrane model and the FCH model of [41], which truly model some physico-chemical energy derived from microscopic interactions, we do not assume any such physical ground to the general curvature functional \(\mathbf {F}\) and the corresponding phase-field functional \(\mathscr {F}_\epsilon \) that we propose. This framework is simply intended to provide a descriptive tool to analyze tubular textures, and may be used to quantify biological shapes in terms of geometry, even without any knowledge of the underlying microscopic interactions.

5.2 Extensions

We can include a constraint on the orientation of the normal vector \(\mathbf {n}_\mathscr {S}\) to the surface \(\mathscr {S}\), by encouraging \(\mathbf {n}_\mathscr {S}\) to be orthogonal to the direction associated to a vector \(\theta \) of unit norm, as in

$$\begin{aligned} {{\widetilde{\mathbf {F}}}}(\mathscr {S}) = \int _\mathscr {S}p(\kappa _1, \kappa _2) ~ {\mathrm {d}}A + \mu \int _\mathscr {S}(\theta \cdot \mathbf {n}_\mathscr {S})^2 ~ {\mathrm {d}}A.\end{aligned}$$

This can be approximated by the phase-field energy

$$\begin{aligned} {\widetilde{\mathscr {F}_\epsilon }}= & {} \mathscr {F}_\epsilon + \mu \int _\varOmega (\theta \cdot \mathbf {n}_u)^2 \, \epsilon |\nabla u|^2 ~ {\mathrm {d}}x\\= & {} \mathscr {F}_\epsilon + \epsilon \mu \int _\varOmega (\theta \cdot \nabla u)^2 ~ {\mathrm {d}}x, \end{aligned}$$

where \(\mathscr {F}_\epsilon \) is our phase-field energy constructed in Sect. 3.2. The effect on tubes is to align their median axis along \(\theta \), while inciting flat layers to be parallel to \(\theta \), as in Fig. 13.

Fig. 13
figure 13

Including orientation in the loss aligns tubes and layers. The tubes were generated with \(\mathbf {a}= (1,2,6,-40,-40,400)\), which corresponds to \(\mathbf {F}= (H-20)^2 + 5 \kappa _2^2\), \(m_0 = -0.6\), and \(\mu = 0\) or 1000 for the first and second shapes. The layers were generated using \(\mathbf {a}= (1,1,1,0,0,0)\), which corresponds to \(\mathbf {F}= (H^2 + \kappa _1^2 + \kappa _2^2)/2\), \(m_0 = -0.4\), and \(\mu = 0\) or 800 for the third and fourth shapes. When \(\mu \ne 0\), the direction of \(\theta \) is indicated by the arrow. The curvature diagrams show that after alignment, the curvatures are more densely clustered around the dirac masses associated to perfectly cylindrical or perfectly flat shapes, namely, \(\delta _{(20,0)}\) for tubes and \(\delta _{(0,0)}\) for layers

Another way to give some structure to the shape is to use space-dependent generation parameters \((\mathbf {a}(x),m(x))\), i.e., make them spatialized instead of constant, as in Fig. 1. In the current version of the algorithm, since u is periodic, the coefficients \(\mathbf {a}(x)\) but also the mass m are required to be periodic. The change of variable of Sect. 4.1 becomes

$$\begin{aligned} u(x) = \nabla \cdot A (x) + m(x).\end{aligned}$$

In Fig. 1, we took four reference generation parameters \(p_1\), \(p_2\), \(p_3\), and \(p_4\) (see Table 2), and linearly interpolated them along the horizontal axis, by taking into account the periodicity. We also repeated the first and last values (following the order \(p_1\), \(p_1\), \(p_2\), \(p_3\), \(p_4\), \(p_4\)), and cropped the shape by dropping the first and last cubes. The spatialized parameters hence coincide with \(p_1\), \(p_2\), \(p_3\), \(p_4\) at the vertical midplanes of the four cubes delimited by the dashed lines.

Table 2 Generation parameters used in the spatialized interpolation of Fig. 1, associated with the central regions of the four cubes delimited by dashed lines (from left to right)

Many other extensions to this framework are also possible and could be explored in the future. For instance, it is compatible with inclusion or exclusion constraints, by forcing u to take positive or negative values in some spatial regions, so that the shape contains or excludes them. Another possibility is to extend the framework to phase-fields with three phases or more, to generate shapes intertwined in each other, without intersecting, while minimizing different curvature energies.

5.3 Importance of a Unifying Theory, and Future Applications

Finally, we have identified several implications that a generation model unifying tubular and membranous shapes could have in other contexts.

  • Design bio-inspired shape textures and porous materials: the generation model could help in the design of bio-fabricated vascular networks for tissue regeneration [94]; the design of scaffolds for bone tissue engineering [36] and cellular solids in architecture [77], both inspired by the structure of bone trabeculae; or the design of porous materials [59, 111].

  • Model morphological states and trajectories: if generation parameters can be inferred from morphological states, a morphological transformation can be modeled as a trajectory in the lower-dimensional space of parameters, and then analyzed as a longitudinal trajectory [31]. In particular, the biological transformations mentioned in the Introduction would be modeled in a continuous way.

  • Provide regularization prior for tubular segmentation: the generation model could be included as a regularizing loss in variational segmentation methods of vascular structures [33, 71, 107], to select certain tubular morphologies against others. It could also be combined with 3D reconstruction from 2D slices methods [13, 53, 64].

  • Build a synthetic database of textures: the generation algorithm could provide, at a low cost, a complete panel of synthetic textures on which to test and train vascular shape analysis methods [50, 84, 89], including topological analysis methods [15, 47, 79], segmentation algorithms, microvascular blood flow simulations [5, 86], but also simulations in porous materials [65, 95, 109]. It could also provide a database to research in shape and texture perception [108]; the way we perceive shapes is intimately linked to the way we want to quantify them.

We of course did not cover all these applications here, but intend to focus on two of the points aforementioned as future work.

The first one is to model morphological states or trajectories of biological tissues as static values or trajectories of generation parameters \((\mathbf {a}(t),m(t))\), which supposes that parameters can be inferred from shapes. This can be done naively, by visual inspection and trial-and-error; or, by first producing an atlas of reference shapes densely sampling a region with the desired morphologies, similarly to Experiment 4. Using the curvature diagram of the query shape \(u_0\), the shapes closest to it in terms of the Wasserstein distance are found. We can then initialize \((\mathbf {a},m_0)\) at these values, and minimize the loss

$$\begin{aligned} \mathscr {F}_\epsilon [u_0 ; \mathbf {a}, m_0 ] \end{aligned}$$

with respect to the parameters \((\mathbf {a}, m_0)\) instead of the phase-field \(u_0\), by using nearly the same algorithmic framework as Algorithm 1.

The second related application is to include the curvature energy as a regularizing loss in order to segment vascular structures. The energy would then select certain tubular morphologies over others. This could be used for instance to reconstruct 3D tubular structures captured in several 2D images at different depths of a biological sample (as done in optical sectioning), provided that there are not filaments too thin compared to the diffusion width \(\epsilon \). The method is most effective if there is some knowledge of the shape textures that need to be segmented, so that the parameters can be appropriately tuned by inference, as previously explained.