1 Introduction

Active contours have become one of the most widely-used techniques for image segmentation [1]. Early parametric contours used a Lagrangian description of the discretized boundary to solve the Euler-Lagrange equation derived from an appropriate energy functional. Their most important difficulties are the need for periodic redistribution of the points and efficiently tracking topology changes.

The first problem was solved, and the second partially addressed, with the advent of geometric active contours [2, 3]. These used an implicit representation of the contour as the zero level set of an appropriately constructed function, subsequently discretized on a fixed grid (Eulerian description). The level set method based on the Hamilton-Jacobi formulation was introduced in [4].

The level set function is usually initialized to signed distance function. During the contour evolution however, the distance property (required for the stability and accuracy) is not retained without specific handling. This is a major drawback. Different solutions were proposed to cope with this problem. The two main approaches are (a) reinitialization and (b) extension of the PDE associated with the original problem with a term that penalizes the deviations from the distance function. Beyond the theoretical incoherence with the Hamilton-Jacobi formulation [5], rebuilding the signed distance function in the whole domain is slow. The partial remedy for this problem can be the narrow band technique [6] for the price of higher complexity. The extension of the original PDE with a distance regularization term [7] may add instability (see [8]) and increase complexity [9]. More importantly, these approaches may move the zero level set away from the expected stopping location. We propose a solution to overcome this problem.

The Ginzburg-Landau phase field model was used in image segmentation in [10] as an alternative to the Hamilton-Jacobi formulation. It possesses interesting advantages as greater topological freedom, the possibility of a ‘neutral’ initialization. Here we stress another aspect: phase field models automatically form narrow band, a useful property that can only be achieved using additive regularization [9] in the case of Hamilton-Jacobi formulation. Moreover, unlike the reaction-diffusion model [8, 11], it exhibits fast shape recovery due to the double well potential term incorporated in its functional. On the other hand, the Ginzburg-Landau phase field energy is proportional to the length of the contour that causes curvature dependent shrinking of the level sets. In some cases they are rather destructive and the Euler’s elastica is used instead (e.g. [12]).

The calculation of the fundamental quantities requires a smooth transition across a certain neighbourhood of the zero level set. On the other hand, any method dedicated to this transitional shape maintaining should have the least possible interference with the segmentation PDE. Specifically, any curvature dependent behaviour should be an intentionally designed part of the segmentation model itself. The Ginzburg-Landau phase field obviously violates this ‘least possible interference’ requirement. In this paper we propose a balanced phase field model that eliminates the curvature driven shrinking, while maintains the smooth transition around the zero level set.

2 The Phase Field Model

2.1 Minimizing the Contour Energy Using Phase Field

In the level set framework, the representation of contours is given by a level set function of two variables \(\phi \left( x,y\right) \). The quantities of the segmentation problem are extracted from this function, such as the unit normal vector \(\mathbf {n}=\frac{\nabla \phi }{\left| \nabla \phi \right| }\) or the curvature \(\kappa =-\nabla \cdot \left( \frac{\nabla \phi }{\left| \nabla \phi \right| }\right) \) where \(\nabla \) is the gradient operator and “\(\cdot \)” stands for the scalar (dot) product, i.e. \(\nabla \cdot \mathbf {v}\) is the divergence of the vector field \(\mathbf {v}\). The level set function is usually maintained on a uniform grid and its derivatives are approximated by finite differences. Such calculation requires the level set function to be approx. Linear around a small neighborhood of the zero level.

For its simplicity and the fast transition-developing property we chose the phase field model [10]. The Ginzburg-Landau functional is defined as

$$\begin{aligned} \iint _{\varOmega }\frac{D_{o}}{2}\left| \nabla \phi \right| ^{2}+\lambda _{o}\left( \frac{\phi ^{4}}{4}-\frac{\phi ^{2}}{2}\right) dA,\quad dA = dxdy \end{aligned}$$
(1)

\(D_{o}\) and \(\lambda _{o}\) are weights. Its solution is the scalar field \(\phi \) with \(\pm 1\) stable values representing the local minimal energies of the field and - due to the first term - a localized transition between these values that naturally represents narrow band.

Albeit the energy (1) could be incorporated into any segmentation functional, this would extremely complicate the analysis of such a complex system. There is though another way using the phase field equation: that is using it in “shape maintaining” role, solving its associated Euler-Lagrange equation independently of and before the segmentation. In either case we wish the phase field equation ideally to maintain the shape of \(\phi \) without moving its level sets. This idea is similar to the regularization of the level set by reinitialization or the diffusion phase of the reaction-diffusion model.

First, we assess the results of the Ginzburg-Landau phase field analysis using linear ansatz (see [10]). One can show that the width of the transition is

$$\begin{aligned} w_{o*}=\sqrt{\frac{15D_{o}}{\lambda _{o}}}, \end{aligned}$$
(2)

and the energy of the transitional band is approximately proportional to the perimeter of the innermost (zero) level set. These approximations are valid wherever \(w_{o*}\left| \kappa \right| \ll 1\). The associated Euler-Lagrange equation is

$$\begin{aligned} -D_{o}\triangle \phi +\lambda _{o}\left( \phi ^{3}-\phi \right) =0\,. \end{aligned}$$
(3)

3 Higher Order Smoothness Terms for Phase Field Model

In this section we examine a phase field \(\phi \left( x,y\right) \) with Laplacian smoothness \(\left( \triangle \phi \right) ^{2}\)- as a potential candidate for our purpose. Note that the origin of the energy can be chosen freely. If the phase field satisfies the condition of constancy almost everywhere except the regions of transitions, the origin is expediently chosen to be the energy level of \(\phi =\pm 1\). In this case, the whole energy is equivalent to the energy of the transitions and can be written as

$$\begin{aligned} \iint _{\Omega }\frac{D}{2}\left( \triangle \phi \right) ^{2}+\lambda \left( \frac{\phi ^{4}}{4}-\frac{\phi ^{2}}{2}+\frac{1}{4}\right) dxdy\,. \end{aligned}$$
(4)

The Euler-Lagrange equation associated with this functional is

$$\begin{aligned} D\triangle \triangle \phi +\lambda \left( \phi ^{3}-\phi \right) =0\,. \end{aligned}$$
(5)

To estimate the energy (4) we use curvilinear coordinates.

3.1 Approximate System Energy

In the vicinity of the curve \(\mathbf {r}\left( s\right) \) (s is the arc length parameter), the plane can be parameterized as \(\mathbf {R}\left( s,p\right) =\mathbf {r}\left( s\right) +p\mathbf {n}\left( s\right) \), where \(\mathbf {n}\left( s\right) \) is the unit normal vector of the curve at s and p is the coordinate in the normal direction. The metric tensor components are the scalar (dot) products of the covariant basis vectors \(\mathbf {R}_{s}=\frac{\partial \mathbf {R}}{\partial s}\), \(\mathbf {R}_{p}=\frac{\partial \mathbf {R}}{\partial p}\) and takes the form \(\left[ g_{ik}\right] =\mathrm {diag}\left[ \left( 1-p\kappa \right) ^{2},1\right] \), where \(\kappa =\kappa \left( s\right) \) is the curvature of the curve \(\mathbf {r}\) at s given by the Frenet-Serret formula \(\mathbf {n}_{s}=-\kappa \mathbf {e}\) (\(\mathbf {e}\) is the unit tangent vector). The invariant infinitesimal area is \(dA=\sqrt{g}dsdt\) where \(g=\det \left[ g_{ik}\right] \). Using these, the Laplacian \(\triangle \phi \) in the curved system \(\left( u^{1},u^{2}\right) =\left( s,p\right) \) is given by the Laplace-Beltrami operator \(\triangle \phi =\frac{1}{\sqrt{g}}\frac{\partial \sqrt{g}g^{ik}\frac{\partial \phi }{\partial u^{k}}}{\partial u^{i}}=\frac{1}{1-p\kappa }\left[ \frac{\partial \left( 1-p\kappa \right) ^{-1}\frac{\partial \phi }{\partial s}}{\partial s}+\frac{\partial \left( 1-p\kappa \right) \frac{\partial \phi }{\partial p}}{\partial p}\right] \) (in the general expression the components of the inverse metric \(\left[ g^{ik}\right] =\left[ g_{ik}\right] ^{-1}\) and the Einstein summation convention are used). It can be rearranged as

$$\begin{aligned} \triangle \phi =\frac{1}{\left( 1-p\kappa \right) ^{2}}\frac{\partial ^{2}\phi }{\partial s^{2}}+\frac{p}{\left( 1-p\kappa \right) ^{3}}\frac{d\kappa }{ds}\frac{\partial \phi }{\partial s}+\frac{\partial ^{2}\phi }{\partial p^{2}}-\frac{\kappa }{1-p\kappa }\frac{\partial \phi }{\partial p}\,. \end{aligned}$$
(6)

Now we choose \(\mathbf {r}\left( s\right) \) to be the zero level set and use the following simplifications:

  1. 1.

    the constant level sets are equidistant to \(\mathbf {r}\left( s\right) \) i.e. \(\phi =const\rightarrow \frac{\partial ^{n}\phi }{\partial s^{k}\partial p^{n-k}}=0\), \(k\in \left[ 1,n\right] \) along the parameter lines \(p=const\)

  2. 2.

    the transition is confined to a stripe \(\left( -\frac{w}{2},\frac{w}{2}\right) \) along the zero level set contour

  3. 3.

    the osculating circle is significantly bigger than the stripe width: \(1-p\kappa \thickapprox 1\)

then energy (4) expressed in the \(\left( s,p\right) \) system becomes

$$\begin{aligned} \oint {\int _{-\frac{w}{2}}^{\frac{w}{2}}}\frac{D}{2}\left( \phi ^{\prime \prime }-\kappa \phi ^{\prime }\right) ^{2}+\lambda \left( \frac{\phi ^{4}}{4}-\frac{\phi ^{2}}{2}+\frac{1}{4}\right) dpds \end{aligned}$$
(7)

\(\phi \left( s,p\right) =\phi \left( p\right) \) and \(\kappa =\kappa \left( s\right) \) is the curvature measured on the zero level set and prime notation is used for the derivatives wrt p.

3.2 Cubic Ansatz

In the presence of the second derivative \(\phi ^{\prime \prime }\) in (7), the linear ansatz is not applicable. The next simplest choice is a cubic ansatz with boundary conditions \(\phi \left( -\frac{w}{2}\right) =-1,\;\phi \left( \frac{w}{2}\right) =1\text { and }\phi ^{\prime }\left( -\frac{w}{2}\right) =\phi ^{\prime }\left( \frac{w}{2}\right) =0\,.\) The function satisfying these conditions is

$$\begin{aligned} \phi \left( p\right) =-\frac{4}{w^{3}}p^{3}+\frac{3}{w}p\,. \end{aligned}$$
(8)

Its derivatives are:

$$\begin{aligned} \phi ^{\prime }=-\frac{12}{w^{3}}p^{2}+\frac{3}{w},\quad \phi ^{\prime \prime }=-\frac{24}{w^{3}}p,\quad \phi ^{\prime \prime \prime }=-\frac{24}{w^{3}}\,. \end{aligned}$$
(9)

The square of the approximate Laplacian, obtained from (6) is \(\left( \phi ^{\prime \prime }-\kappa \phi ^{\prime }\right) ^{2}=\left[ -\frac{24}{w^{3}}p-\kappa \left( -\frac{12}{w^{3}}p^{2}+\frac{3}{w}\right) \right] ^{2}\). The inner integral in (7) is symmetrical, therefore the terms having odd powers of p do not contribute to the energy. Integrating this smoothness term results \(\frac{24D}{w}\left( \frac{1}{w^{2}}+\frac{\kappa ^{2}}{10}\right) \). Now it can be seen that the appearance of the curvature in the energy violates the assumptions 1 and 2 given in Sect. 3.1. The contribution of the second term \(\frac{\kappa ^{2}}{10}=\frac{1}{10r_{O}^{2}}\ll \frac{1}{w^{2}}\) is however, very modest thus omitted in the subsequent calculations. Similarly, the inner integral of the phase field double well potential term \(\lambda \left( \frac{\phi ^{4}}{4}-\frac{\phi ^{2}}{2}+\frac{1}{4}\right) \) is approximately \(0.1\lambda w\), hence the approximate energy of (7) is \(L\left( \frac{24D}{w^{3}}+\frac{\lambda w}{10}\right) \) (L is the contour length). Deriving it wrt w, the optimal width of the transitional region is

$$\begin{aligned} w_{*}=\root 4 \of {\frac{720D}{\lambda }}\,. \end{aligned}$$
(10)

3.3 The Motion of the Level Sets

The Euler-Lagrange equation (5) can be expressed in the curvilinear system aligned with the zero level set applying the Laplace-Beltrami operator once again to the Eq. (6) (and multiplying the result by \(\sqrt{g}=1-p\kappa \)). The Euler-Lagrange terms having the derivatives of \(\phi \) by the contour parameter s can be omitted in the result. This approximate equation is

$$\begin{aligned}&D\left( -A\phi ^{\prime }-2\kappa \phi ^{\prime \prime \prime }-\kappa ^{2}\phi ^{\prime \prime }+\phi ^{\prime \prime \prime \prime }\right) +\lambda \left( \phi ^{3}-\phi \right) =0\nonumber \\&\qquad \qquad \quad A=3p\left( \frac{d\kappa }{ds}\right) ^{2}+\frac{d^{2}\kappa }{ds^{2}}+\kappa ^{3}\,. \end{aligned}$$
(11)

The shape of the numerical solution for (11) is close to the cubic ansatz (see Fig. 2). Due to the assumed symmetry of the zero level set, its motion is governed by \(-D\left( \frac{d^{2}\kappa }{ds^{2}}+\kappa ^{3}\right) \phi ^{\prime }-2D\kappa \phi ^{\prime \prime \prime }=0\) or using the cubic ansatz at \(p=0\) and (10):

$$\begin{aligned} \frac{48D}{w_{*}^{3}}\kappa -\left( \frac{d^{2}\kappa }{ds^{2}}+\kappa ^{3}\right) \frac{3D}{w_{*}}=0\,. \end{aligned}$$
(12)

Equation (12) describes either a static state wherever the curvature is identically zero or shrinking proportional to the curvature where the radius \(r_{O}\) of the osculating circle is significantly bigger than the thickness of the transition and this width varies slowly (Fig. 1).

Fig. 1.
figure 1

Alteration of the phase field function in normal direction (thin blue line). Left column: small curvature, the cubic ansatz (thick violet line) is valid. Right column: high curvature, cubic approximation is invalid. (Color figure online)

For contours with constant curvature a static solution would be at radius \(\frac{48\kappa }{w_{*}^{3}}=\frac{3\kappa ^{3}}{w_{*}}\rightarrow r=\frac{w_{*}}{4}\), however this is not the case. Around this curvature value neither the assumption \(1-p\kappa \thickapprox 1\) nor the cubic ansatz approximation are valid. Under these circumstances the phase field function can no longer be modeled with cubic ansatz (see Fig. 2 right column). The theoretical minimum value while the phase field is shape-retaining is \(\frac{w_{*}}{2}\).

Therefore, we conclude that energy ( 4 ) does not fulfill our expectation stated in the beginning of this section because it still has a curvature dependent term.

3.4 Motion of the Level Sets of the Original Model

Assuming again that the conditions that led to the simplified energy expression (7) are valid, the Euler-Lagrange equation of the Ginzburg-Landau phase field (3) reduced to the normal direction using the Laplacian (6) at \(1-p\kappa \thickapprox 1\) and \(\frac{\partial ^{n}\phi }{\partial s^{n}}=0\) is: \(-D_{o}\left( \phi ^{\prime \prime }-\kappa \phi ^{\prime }\right) +\lambda _{o}\left( \phi ^{3}-\phi \right) =0\). From this expression, the motion of the zero level set is governed by

$$\begin{aligned} D_{o}\kappa \phi ^{\prime }=0, \end{aligned}$$
(13)

that is a pure curvature-driven motion.

4 Phase Field Model for Reinitialization Purpose

The motion of the zero level set is basically curvature driven both for the Ginzburg-Landau (13) and the higher order smoothness (12) models. This effect can be eliminated by the appropriate combination of the smoothness terms \(\left( \nabla \phi \right) ^{2}\) and \(\left( \triangle \phi \right) ^{2}\). First we calculate the optimal width for the functional

$$\begin{aligned} \iint _{\Omega }\frac{D}{2}\left| \triangle \phi \right| ^{2}-\frac{D_{o}}{2}\left| \nabla \phi \right| ^{2}+\lambda \left( \frac{\phi ^{4}}{4}-\frac{\phi ^{2}}{2}+\frac{1}{4}\right) dA\,. \end{aligned}$$
(14)

The approximate energy - using simplifications 1.-3. introduced in Sect. 3.1 - is

$$\begin{aligned} L{\int _{-\frac{w}{2}}^{\frac{w}{2}}}\frac{D}{2}\left( \phi ^{\prime \prime }+\kappa \phi ^{\prime }\right) ^{2}-\frac{D_{o}}{2}\left( \phi ^{\prime }\right) ^{2}+\lambda \left( \frac{\phi ^{4}}{4}-\frac{\phi ^{2}}{2}+\frac{1}{4}\right) dp, \end{aligned}$$
(15)

where the length of the contour is \(L=\oint ds\) is independent of w. Substituting the cubic ansatz (8), the integral (15) (divided by L) becomes

$$\begin{aligned} 24D\left( \frac{1}{w^{3}}+\frac{\kappa ^{2}}{10w}\right) -\frac{12D_{o}}{5w}+\frac{\lambda w}{10}\,. \end{aligned}$$
(16)

The term dependent on the square of the curvature is again negligible, hence omitted. From expression (16), the optimal width is given by derivation wrt w

$$\begin{aligned} \boxed {\lambda w^{4}-24D_{o}w^{2}-720D=0} \end{aligned}$$
(17)

that can be solved for the optimal width \(w_{*}\). The solution is

$$\begin{aligned} w_{*}=\sqrt{\frac{12}{\lambda }\left( -D_{o}+\sqrt{D_{o}^{2}+5D\lambda }\right) }\,. \end{aligned}$$
(18)

Now we use the approximate Euler-Lagrange equation associated with (15)

$$\begin{aligned} D\left( -A\phi ^{\prime }-2\kappa \phi ^{\prime \prime \prime }-\kappa ^{2}\phi ^{\prime \prime }+\phi ^{\prime \prime \prime \prime }\right) +D_{o}\left( \phi ^{\prime \prime }-\kappa \phi ^{\prime }\right) +\lambda \left( \phi ^{3}-\phi \right) =0 \end{aligned}$$
(19)

to derive condition for the curvature-independent solution (here A is defined in (11)). From (19) the curvature-dependent term is eliminated with the condition: \(-D_{o}\phi ^{\prime }-2D\phi ^{\prime \prime \prime }\doteq 0\). Substituting the cubic ansatz (8) (at \(p=0\)) we get:

$$\begin{aligned} \boxed {-D_{o}\frac{3}{w}+D\frac{48}{w^{3}}=0}\,\rightarrow \, D=\frac{w^{2}}{16D_{o}}\,. \end{aligned}$$
(20)

The width (17) and the curvature (20) constraints determine the weights for the solution with curvature driven shrinking effect removed. There are other terms, e.g. terms included in factor A, but the influence of those is much weaker. In fact the impact of the term \(D\left( \frac{d^{2}\kappa }{ds^{2}}+\kappa ^{3}\right) \) is similar to that of the solution of the Euler’s elastica \(\oint \frac{D}{2}\kappa ^{2}ds\) with associated Euler-Lagrange equation: \(D\left( \frac{d^{2}\kappa }{ds^{2}}+\frac{1}{2}\kappa ^{3}\right) =0\). The numerical tests confirm that the phase field used in this manner - satisfying Eqs. (17), (20) - essentially fulfills the “transitional shape maintenance” role while standing still.

4.1 Determining Weights

Given two constraints (17), (20) for the energy (14), one of the weights can be chosen freely (say \(D_{o}=1\)). The calculation of the remaining weights are as follows. First determine the width: depending on the highest order of the derivatives n (occurring either in the segmentation model or the phase field itself), we need at least \(n+1\) grid points around the zero level set using finite central difference schemes. This suggests about twice as big (as a cautious choice) thickness of the phase field transition to remain within the range where it is approximately linear, i.e. \(w\geqq 2\left( n+1\right) \) is recommended. Second, solving (17) and (20), the weights the functions of the width parameter w such as:

$$\begin{aligned} D_{o}=1,\; D=\frac{w^{2}}{16},\;\lambda =\frac{21}{w^{2}}\,. \end{aligned}$$
(21)

The Euler-Lagrange equation associated with the proposed energy (14), using the calculated weights (21) dependent on the width parameter w is therefore

$$\begin{aligned} \boxed {\frac{w^{2}}{16}\triangle \triangle \phi +\triangle \phi +\frac{21}{w^{2}}\left( \phi ^{3}-\phi \right) =0}\,. \end{aligned}$$
(22)

In (22) the Laplace operator can be expressed wrt the standard basis as \(\triangle \Phi =\frac{\partial ^{2}\Phi }{\partial x^{2}}+\frac{\partial ^{2}\Phi }{\partial y^{2}}\), \(\Phi \in \left\{ \phi ,\triangle \phi \right\} \) and discretized on a uniform grid using finite differences. Its gradient descent was used in the tests. The method can be efficiently implemented as a \(5\times 5 \) linear filter plus a point-wise cubic term acting on the uniform grid used to discretize the level set function. The approximation \(r_{min}\approx X\left( n+1\right) \) (where X is the grid size that can be smaller or greater than a pixel) also determines the size of the segmentable smallest image-feature.

5 Experimental Evaluation

In this section, we show that our balanced phase field model (a) maintains a smooth transition of the level set in a narrow band during the evolution, while (b) it has minimal side effect on the contour at the same time. This section is organized as follows: first, we compare the Ginzburg-Landau phase field model to the proposed one to show that the latter has much better contour preserving performance. Next, we compare the proposed model, the reaction diffusion model [8] and a reinitialization method [6] on synthetic and real data.

5.1 Stability Tests: Comparing to the Ginzburg-Landau Model

The test environment is prepared to guarantee the synchronous snapshot production for the illustrations: the simulation space is splitted in the middle such that the phase field evolutions are governed by the proposed energy (14) on one side and the Ginzburg-Landau energy (1) on the other.

For the first test, the pure phase field equations were used. Figure 2 left shows the initial contour preserving capability of the balanced phase field model compared with the Ginzburg-Landau model on the right side.

Fig. 2.
figure 2

Alteration after the same iteration numbers of the phase fields when \(w=10\), left: the balanced phase field - interfaces are barely moved; right: the Ginzburg-Landau phase field: interfaces are displaced significantly. Weights are set according to (21) and (2) for the balanced model and the Ginzburg-Landau model respectively.

The proposed phase field model was also applied to real data segmentation, using a selective segmentation model [12]. The energy to be minimized is: \(E=\mathcal {\alpha S}+\mathcal {\beta P}+\gamma \mathcal {D}+\delta \mathcal {E}\), where \(\mathcal {P}=\frac{1}{2}\left[ \oint dA-q\left( \oint ds\right) ^{2}\right] ^{2}\) is the “plasma shape” prior (q is the shape parameter, the ratio of the enclosed area and the square of the perimeter), the data term of the original model was replaced by the simplest anisotropic edge energy \(\mathcal {D}=\oint \nabla I\cdot \mathbf {n}ds\) (see [13]); the \(\mathcal {E}\) is the Euler elastica, while \(\alpha ,\,\beta ,\,\gamma ,\,\delta \) are weights. This segmentation model was chosen, because of its sensitivity to any size decreasing effect due to the term \(\mathcal {S}=\frac{1}{3}\left( \oint dA-A_{0}\right) ^{3}\) which is used at its inflection point at the preferred size \(A_{0}\). The initial contours were produced by simple thresholding. Segmentation steps and the sequence of the phase field sectional values along a horizontal line are shown in Fig. 3.

Fig. 3.
figure 3

Left: Evolution of the selective segmentation example (grid size: 1 pixel, w = 10). Segmentation result: First column: the balanced; Second column: the Ginzburg-Landau phase fields. Right: Details of evolution along the blue horizontal line using reinitializing iterations 2, 5, 15 for shape maintenance. First column: the balanced phase field; Second column: Ginzburg-Landau phase field. (Color figure online)

For the test \(X=1\) pixel grid size and \(w=10\) width values were used; the maximum speed of the evolution by the segmentation model was set such that its maximal value could not exceed the grid size. Preceding the segmentation step, the gradient descent equation of (22) is iterated and the phase field is updated in a reinitialization loop to recover a reasonably smooth interface. Then the segmentation gradient descent moves the contour towards the solution (but deteriorates its shape).

The transitional-shape recovery and the segmentation results using the balanced and the Ginzburg-Landau models, depending on the number of the phase field iterations in the reinitialization step (denoted by n) are assessed here: At \(n=2\) neither the balanced nor the Ginzburg-Landau models can be considered stable, at \(n=5\) both models provide stable transition, however the Ginzburg-Landau model develops extremely steep slopes, while at \(n = 15\), both models exhibit high degree of stability as well as widths close to the designed/predicted ones. Regardless the number of the phase field iterations used, the selective segmentation [12] combined with the Ginzburg-Landau model ends up in the collapse of the contour, whilst its combination with the balanced phase field model provides the expected solution.

5.2 Comparing to the Reaction-Diffusion Model

Fig. 4.
figure 4

First two columns: initial level sets; second: level set during evolution (intersection at \(x=50\)); third: final level sets, fourth: final contours. In each group - top: DI, RM, bottom: RD, BPF.

The reaction diffusion model (RD) [8] is also proposed to diminish the interference with the segmentation (active) model. The shape maintenance of the level set function is achieved by adding a diffusion term \(\varepsilon \Delta \phi \) to the gradient descent of the active model, therefore \(\phi _t = \varepsilon \Delta \phi +\frac{1}{\varepsilon }F|\nabla \phi |\), where \(\varepsilon \) is a small constant and F represents the gradient descent equation of the active model. We first show that both the RD and the proposed balanced phase field model fulfill the shape maintenance role. Next, we show that RD moves the interface more significantly compared to the proposed model. In case of RD, this shrinking side-effect eventually leads to the disappearing of some objects. For the quantitative results, we borrowed a Jaccard-distance based metric similar to the one used in the 2018 Data Science Bowl (DSB2018) competition [14]. The only modification is that we used the threshold levels \(t=0.1 \) to \(t=0.95\) with steps 0.5 (inclusive).

Fig. 5.
figure 5

Left: sample synthetic masks encoding initial contours; right: level set evolutions on a sample image from the left side with RM/RD/BPF from top to bottom, respectively.

Shape Maintenance Tests: We compared three different models to ours. We tested the reaction diffusion method (RD), the balanced phase field model (BPF), a reinitialization method (RM) [6] using the reinitialization equation: \(\phi _t + S(\phi _0)(|\nabla \phi |-1)=0\), where \(S(\phi )=\frac{\phi }{\sqrt{\phi ^2+(|\nabla \phi |\Delta x)^2}}\), (the same method as the one used in the RD paper and referred to as re-initialization. (For the implementation, see the online supplementary material of that paper), and lastly, no shape maintenance) (DI - direct implementation). The first test inherits from Fig. 5 of the RD paper [8], \(\Delta t_1, \Delta t_2\) (used for the numerical solution of the RD equation, see the RD paper for details) are 0.1. For the RM, \(\Delta x\) and \(\Delta y\) is 1 and \(\alpha =0.5\), while \(w=8\) in the BPF model. The force term in the gradient descent of the active contour model is simply 1, grid dimensions: \(100 \times 100\), number of iterations: 200. The results are shown in Fig. 4.

Synthetic Tests: The models are compared to each other by performing a level set evolution using 11 synthetic initial contours (subset of these masks are shown in Fig. 5) using 0 as a force term in the active model. In this setting, we would assume that the initial contours are not moving. A sample evolution is visualized in Fig. 5 using the RM, RD and the BPF methods. The same test performed with all of the synthetic initial contours. The quantitative results using the modified DSB2018 metric presented in Fig. 6 left. The ground truth is the initial contour and the accuracy is measured during the evolution on every image. Simple statistics summarizes the results in Table 1 left.

Table 1. Segmentation accuracy of the synthetic and the real tests. Peak: the best scores reached during the evolution. RD can not keep the accuracy of the active model in long term, it has massive side-effects while the BPF behaves similarly to the reinitialization method.
Fig. 6.
figure 6

Left: quantitative results for the synthetic test. From top to bottom: RM, RD, BPF. Columns: first: accuracy on each image during the evolution, second: peak (maximum acc. on an image, blue) and the final acc. for the images. Right: results on patches extracted from the DSB2018 training set, GAC model (\(\nu =0.5\)). From top to bottom: RM, RD, BPF. (Color figure online)

Real Tests: We also compared the methods to each other using the geodesic active contour model (GAC) [15] on 51 real images containing nuclei extracted from the DSB2018 training set with random sampling. In the GAC model, the force term in the gradient descent equation is: \(\nabla \cdot \Big (g(I)\frac{\nabla \phi }{|\nabla \phi |}\Big )+\nu g(I)\), where \(g(I)=\frac{1}{1+(\nabla G(15,1.5)*I)^2}\) is the edge indicator function (the same as the one used in the RD paper for the tests). The quantitative results with this model are presented in Fig. 6 right. The parameters are unchanged. A sample test image used for this test is shown in Fig. 7. Simple statistics presented in Table 1 right. The parameters left unchanged since the last test, except the \(\Delta t_2\) that is 0.001 in this case. In conclusion, the BPF outperformed RD both for the synthetic and real tests and produced results that are comparable to the RM method.

Fig. 7.
figure 7

Active contour evolutions with different reinitialization methods on a patch from the DSB2018 dataset: red: BPF, green: RD, blue: RM. Even if the active model is able to achieve good accuracy (Fig. 7a) the contour vanishes by the time if we use the RD method (serious side effect on the active model). The proposed model has contour preserving ability comparable to the reference method (marginal side effect on the active model) (Fig. 7b). (Color figure online)

6 Discussion

In this paper we proposed and analyzed a balanced phase field model as an alternative to the Ginzburg-Landau level set framework. The proposed model exhibits very fast shape recovery (essentially) without moving the level sets i.e. its interference with the “active” (e.g. segmentation) PDE is negligible. This important property makes this level set formulation suitable for accurate segmentation. Similar balancing could be used for any model that includes Laplacian smoothness term in their gradient descent equation such as the reaction-diffusion model.