1 Introduction

Image segmentation is an important image processing technology that has been widely used in many application domains, such as computer vision [19, 20, 22], pattern recognition [5, 37, 47], biomedical image processing [6, 21, 23, 33] and so on. In the last decades, a large number of image segmentation methods based on different mathematical theories have been proposed [7, 12, 35], among which variational level set method have been widely concerned due to its sound theoretical basis and promising experimental performance.

The variational level set method is based on the level set representation and curve evolution. It uses a partial differential equations (PDE) obtained by variational method to control the motion of the active contour to achieve image segmentation, where the active contour is represented by the zero level set of a level set function. The variational level set method has the following advantages over the classical parametric curve evolution methods: (1) It can handle the change of curve topology more effectively; (2) It is easier to incorporate the image information in the model, such texture, shape, structure and so on; (3) It is easier to be solved by using many classical PDE numerical methods.

The variational level set models can typically be classified into two categories: edge-based model [16, 36, 40] and region-based model [8, 24, 31]. In edge-based models, the image gradient information is used to drive the contour moving towards the target boundary. It can effectively segment images with sharp edges, but fails for ones with weak edges that may cause boundary leaking. In addition, it cannot capture the deep concave boundary and the boundary that is far away from the initial contour. The region-based models can conquer these drawbacks, in which the region information (such as mean value, variance, statistical distribution, etc) is used to drive the curve. The most famous one is the active contours without edges proposed by Chan and Vese (CV) [9] that is an approximation of the Mumford-Shah (MS) [32] functional. CV model uses the mean difference between the inner and outer regions of the active contour to drive the contour, which can effectively deal with weak edges. In addition, it is robust to the initialization of the active contour. Later, many scholars studied CV model and proposed many improved models [17, 41, 42, 48]. For example, Tang et al. [41] proposed an improved CV model using L1 fitting term that can effectively segment image contaminated by salt and pepper noise. Chan et al. [9] proposed a piecewise smooth model to solve the problem of CV which can only segment piecewise constant images. Gu et al. [17] proposed a multiphase level set model that can capture more than two target objects. In [48], Zhang et al. proposed a variational level set model for multiscale image segmentation (MCV). However, the models mentioned above only use the global information of the images, so called global region-based model, which cannot effectively segment images with intensity inhomogeneity.

To address this problem, many local region-based models are proposed [2, 3, 13, 26, 35, 38, 43, 49], which model the image in different small local regions, as contrasted to the global ones that model the image only in the target and background regions. Such local scheme enables us to capture the local changes of the image intensity. The local binary fitting (LBF) model [27] is a very famous one in which a local Gaussian fitting term with varying mean is used to model the image in a local region. So it can effectively segment the images with intensity inhomogeneity. Later, Zhang et al. [50] proposed a local image fitting (LIF) model that achieves image segmentation by seeking the best local fitting image. Compared to the LBF model, LIF model has a comparable experimental performance, but higher computational efficiency. Wang et al. [44] combined the local information with the CV (LCV) energy and Liu et al. [28] proposed a local region Chan-Vese (LRCV) model. These two models combine the advantages of the local and the global models, which are robust to the initialization, and have higher efficiency. Darolti et al. [14] proposed to locally characterize the image by using local region descriptors (LRDs) to improve the segmentation efficiency. Wang et al. [45] proposed a local Gaussian distribution fitting (LGDF) model that uses both varying mean and variance in the Gaussian distribution fitting term. Such scheme can model the image more accurately. Moreover, some local region-based models are proposed to achieve simultaneous image segmentation and bias correction [10, 15, 29, 46, 49] by uneven grayscale image modelling. The local region-based models mentioned above can effectively segment images with intensity inhomogeneity since they can capture the local changes of the intensity. However, they are very sensitive to noise because noise can also cause local intensity changes that will be captured by the active contour and leads to missegmentation.

To address the drawbacks of the local and global models mentioned above, based on MAP criterion we propose a variational level set model to segment image with intensity inhomogeneity and noise in this paper. Two terms are introduced in the model, one is a local fitting energy that uses a Gaussian distribution with both varying mean and variance to fit the intensity in the local regions. Minimizing it we can drive the active contour moving towards the object boundary; and the other is a MRF regularization term defined by a Gibbs energy function that is related to the total variation (TV). The proposed model can effectively capture the local changes of the intensity, while eliminating the effect of noises. To solve the model, an alternating direction iterative algorithm combining with fixed point iteration and gradient descent is introduced. Finally, numerical experiments for both synthetic and real images are conducted to validate of the proposed model.

The remainder of this paper is organized as follows. In Section 2 we review the famous LBF and LGDF model that are very relative to our present study. The Section 3 introduces the proposed model and the numerical algorithm. In Section 4, we test the models using some synthetic and real images. The paper is summarized in Section 5.

2 Background

2.1 The LBF model

The LBF [27] model uses local image information to segment images with intensity inhomogeneity. In the model, two functions f1(x)and f2(x) are used to approximate the intensity in a local region centered at x inside and outside the contour. By incorporating the regularization terms, the LBF energy is defined as,

$${\displaystyle \begin{array}{c}{E}^{LBF}={\lambda}_1{\iint}_{\varOmega }{K}_{\sigma}\left(x-y\right){\left(I(y)-{f}_1(x)\right)}^2{M}_1\left(\phi (y)\right) dydx\\ {}+{\lambda}_2{\iint}_{\varOmega }{K}_{\sigma}\left(x-y\right){\left(I(y)-{f}_2(x)\right)}^2{M}_2\left(\phi (y)\right) dydx\kern0.1em \\ {}+\upsilon {\int}_{\varOmega}\mid \nabla H\left(\phi (x)\right)\mid dx+\mu {\int}_{\varOmega}\frac{1}{2}{\left(|\nabla \phi (x)|-1\right)}^2 dx\end{array}}$$
(2.1)

where λ1, λ2, υ and μ are positive weighting parameters, Kσis a kernel function with a local property that is set as a Gaussian function in the numerical implementation, and ϕ(x) is the level set function [34] that is defined as,

$$\phi (x)=\left\{\begin{array}{c}<0\kern0.5em ifx\in in(C),\\ {}\begin{array}{cc}=0& ifx\in C,\end{array}\\ {}\begin{array}{cc}>0& ifx\in out(C).\end{array}\end{array}\right.$$

in which C is the active contour, and M1(ϕ) and M2(ϕ) can be seen as the indicator functions of in(C)and out(C), respectively, which are often defined as M1(ϕ) = H(ϕ) and M2(ϕ) = H(−ϕ) = 1 − H(ϕ), where H is the Heaviside function.

In energy (2.1), the first two terms are the fitting energy that drives the active contour moving towards to the boundary of the object, the last two are regularization terms that stabilize the active contour during the evolution. By using calculus of variation and gradient descent, the minimizer of the level set function ϕ of the energy (2.1) can be expressed as the stationary solution of the following PDE,

$$\frac{\partial \phi }{\partial t}=-{\delta}_{\varepsilon}\left(\phi \right)\left({\lambda}_1{e}_1-{\lambda}_2{e}_2\right)+\nu {\delta}_{\varepsilon}\left(\phi \right)\mathit{\operatorname{div}}\left(\frac{\nabla \phi }{\mid \nabla \phi \mid}\right)+\mu \left({\nabla}^2\phi -\operatorname{div}\left(\frac{\nabla \phi }{\mid \nabla \phi \mid}\right)\right)$$
(2.2)

with

$${e}_i(x)={\int}_{\varOmega }{K}_{\sigma}\left(x-y\right){\left|I(y)-{f}_i(x)\right|}^2 dy$$

where δε(·) is a Dirac function, div(·)is a divergence operator.

By calculus of variations, the optimal function f1(x) and f2(x) must satisfy the following Euler-Lagrange equations,

$$\int K_\sigma\left(x-y\right)(I(y)-f_i\;(x))M_i(\phi(y))dy=0$$
(2.3)

Solvingfi(x)from the last equation, we obtain,

$$f_i\left(x\right)=\frac{K_\sigma\left(x\right)\ast\left[M_i\left(\phi\left(x\right)\right)I\left(x\right)\right]}{K_\sigma\left(x\right)\ast M_i\left(\phi\left(x\right)\right)},\;i=1,\;2$$

In the LBF model, a local Gaussian fitting energy with varying mean is used, which enables it to better capture the local changes of the intensity, and effectively deal with intensity inhomogeneity. However, it is sensitive to the initialization, and it is easy to fall into a local minimum and leads to the missegmentation. In addition, it can not segment noisy images.

2.2 The LGDF model

In order to model the image more accurately, Wang et al. [45] proposed a local Gaussian distribution fitting (LGDF) model that uses both varying mean and variance in the Gaussian fitting term energy, by incorporating the regularization terms, which is defined as,

$${\displaystyle \begin{array}{c}{E}^{LGDF}=\sum_{i=1}^2{\iint}_{\varOmega }w\left(x-y\right)\left(\log {\sigma}_i(x)+\frac{{\left(I(y)-{u}_i(x)\right)}^2}{2{\sigma}_i^2(x)}\right){M}_i\left(\phi \right) dydx\\ {}+\nu {\int}_{\varOmega}\mid \nabla H\left(\phi (x)\right)\mid dx+\mu {\int}_{\varOmega}\frac{1}{2}{\left(|\nabla \phi (x)|-1\right)}^2 dx\end{array}}$$
(2.4)

By using calculus of variation and gradient descent, the minimizer of the level set function ϕ of the energy (2.4) can be written as the stationary solution of the following PDE,

$$\frac{\partial \phi }{\partial t}=-{\delta}_{\varepsilon}\left(\phi \right)\left({e}_1-{e}_2\right)+\nu {\delta}_{\varepsilon}\left(\phi \right)\mathsf{\operatorname{div}}\left(\frac{\nabla \phi }{\mid \nabla \phi \mid}\right)+\mu \left({\nabla}^{\mathsf{2}}\phi -\mathsf{\operatorname{div}}\left(\frac{\nabla \phi }{\mid \nabla \phi \mid}\right)\right)$$
(2.5)

where

$${e}_i(x)={\int}_{\varOmega}\omega \left(x-y\right)\left(\log \left({\sigma}_i(x)\right)+\frac{{\left(I(y)-{u}_i(x)\right)}^2}{2{\sigma}_i^2(x)}\right) dy$$

By using calculus of variation, the minimizers of ui(x) and \({\sigma}_i^2(x)\) of energy (2.4) can be written as the following closed-formulation,

$${u}_i(x)=\frac{\int \omega \left(x-y\right)I(y){M}_i\left(\phi (y)\right) dy}{\int \omega \left(x-y\right){M}_i\left(\phi (y)\right) dy}$$
(2.6)

and

$${\sigma}_i^2(x)=\frac{\int \omega \left(x-y\right){\left(I(y)-{u}_i(x)\right)}^2{M}_i\left(\phi (y)\right) dy}{\int \omega \left(x-y\right){M}_i\left(\phi (y)\right) dy}$$
(2.7)

Different from the LBF model in which varying mean is only used in the Gaussian fitting energy, while LGDF model uses both varying mean and variance in the Gaussian fitting term. Such scheme enables us to capture the local changes of the intensity more accurately, and obtain the better performance in image segmentation. However, compared to the LBF model, the additional update of the variance in the LGDF will cost more computing time.

3 The proposed model

3.1 Model description

In this section, based on the MAP criterion, a variational level set model combing with local Gaussian fitting and Markov random field regularization is proposed, referred to simply as LGM. Let I(x) : Ω → R be an given observed image that contains intensity inhomogeneity and noise, where Ω is the image domain. u(x) : Ω → Ris the true image, and n(x) : Ω → R is noise. Assuming that the image can be divided into foreground and background respectively denoted as Ω1and Ω2, we have the following formulation,

$$I\left(x\right)=\left\{\begin{array}{lc}u_1\left(x\right)+n\left(x\right)&if\;x\in\Omega_1\\u_2\left(x\right)\;+n\left(x\right)&if\;x\in\Omega_2\end{array}\right.$$

which is equivalent to,

$$I(x)={u}_i(x)+n(x),x\in {\varOmega}_i,i=1,2.$$
(3.1)

Two assumptions are introduced in the following, which will be used to statistically model the image. (1)The observed image I(x) is piece-wise smooth and contains intensity inhomogeneity, which obeys a local Gaussian distribution in a small subregion, and (2) u(x)is a denoised version of the observation I(x), which conforms to a Markov random field stochastic mode.

3.2 Estimate u(x) using MAP

In this section, we use the observed image I(x) to estimate the true image u(x) by MAP criterion. By using Bayes formula, it is equivalent to maximizing the following posterior probability,

$$P\left(u(x)|I(x)\right)=\frac{P\left(I(x)|u(x)\right)P\left(u(x)\right)}{P\left(I(x)\right)}$$
(3.2)

where P(u(x)| I(x)) is the posterior probability of u(x) under the observation condition I(x); P(I(x)| u(x)) is the conditional probability distribution of the observed image I(x), also known as the likelihood function. The structure of it is a probability of the observation I(x) in the case of true image u(x), so it is a likelihood function, which indicates the degree of similarity between the observed image and the true situation u(x). P(u(x)) is the prior probability of u(x), which imposes some prior information to the true image u(x). And the denominator p(I(x)) is the marginal likelihood of the observation I(x), which is actually a normalized parameter. It is always a positive constant and does not play no role in the optimization. We can neglect it and rewrite Eq.(9) as,

$$P\left(u(x)|I(x)\right)\propto P\left(I(x)|u(x)\right)P\left(u(x)\right)$$
(3.3)

which implies that maximizing posterior probability P(u(x)| I(x)) is equivalent to maximize P(I(x)| u(x))P(u(x)). In the following, we compute P(I(x)| u(x)) and P(u(x)) based on the assumptions in the subsection 3.1.

  1. A.

    The calculation of P(I(x)| u(x))

With the assumption (1) that the observed image I(x) obeys a local Gaussian distribution in a small subregion, we firstly model the image in a local region. For each pointx ∈ Ωi, we consider a circular neighborhood centered at x with a small radius ρ > 0, which is defined as. Fory ∈ Ωi ∩ Ox, let Pi, x(I(y)| ui(x)) be the conditional probability of the observation I(y) in the subregionsΩi ∩ Ox. Since the observed image obeys a local Gaussian distribution in the subregion Ωi ∩ Ox, i.e.,\(I(y)\sim \mathcal{N}\left({u}_i(x),{\sigma}_i(x)\right)\), whereui(x)and σi(x) are the mean and standard deviation, respectively, Pi, x(I(y)| ui(x)) can be computed by,

$${P}_{i,x}\left(I(y)|{u}_i(x)\right)=\frac{1}{\sqrt{2\pi }{\sigma}_i(x)}\exp \left(-\frac{{\left(I(y)-{u}_i(x)\right)}^2}{2{\sigma}_i^2(x)}\right)$$

With the fact that the image intensity is i.i.d., we can obtain the joint probability P(I(x)| u(x)) in the whole image domain Ω by multiplying each Pi, x(I(y)| ui(x)) fori = 1, 2, y ∈ Ωi ∩ Ox andx ∈ Ω,

$${\displaystyle \begin{array}{c}P\left(I(x)|u(x)\right)=\prod_{x\in \varOmega}\prod_{i=1}^2\prod_{y\in {\varOmega}_i\cap {O}_x}{P}_{i,x}\left(I(y)|{u}_i(x)\right)\\ {}=\prod_{x\in \varOmega}\prod_{i=1}^2\prod_{y\in {\varOmega}_i\cap {O}_x}\frac{1}{\sqrt{2\pi }{\sigma}_i(x)}\exp \left(-\frac{{\left(I(y)-{u}_i(x)\right)}^2}{2{\sigma}_i^2(x)}\right)\end{array}}$$
(3.4)

which describes the joint probability density of the observation I(x) under the real conditionu(x).

  1. B.

    The calculation of P(u(x)

Next, we compute the prior probability P(u(x)) of u(x). Let Pi(ui(x)) be the probability of u(x) in the subregion Ωi. With the assumption (2) that the true image u(x) conforms to a Markov random field, it means that the property of one pixel is only related to its nearby neighborhoods rather than the others away from it. And by Hammersly-Clifford theorem [20], Markov random field is equivalent to a Gibbs one that can be described by a Gibbs distribution [16]. In this paper, we use the following formulation,

$${P}_i\left({u}_i(x)\right)=\frac{1}{Z}\exp \left(-\frac{1}{T}|\nabla {u}_i(x)|\right)$$

that is closely related to the total variation, in which Z is the normalized parameter; and T the regularization parameter that controls the flatness ofPi. Similarly, supposing u(x) is i.i.d., we can obtain the joint probability P(u(x)) in the whole image domain Ω by multiplying each Pi(ui(x)) for x ∈ Ωi and i = 1, 2,

$$P\left(u(x)\right)=\prod_{i=1}^2\prod_{x\in {\varOmega}_i}{P}_i\left({u}_i(x)\right)=\prod_{i=1}^2\prod_{x\in {\varOmega}_i}\frac{1}{Z}\exp \left(-\frac{1}{T}|\nabla {u}_i(x)|\right)$$
(3.5)

which describes the joint probability density of the true image u(x). Combining Eqs. (10), (11) and (12), we obtain the posterior probability,

$${\displaystyle \begin{array}{c}P\left(I(x)|u(x)\right)\propto \prod_{x\in \varOmega}\prod_{i=1}^2\prod_{y\in {\varOmega}_i\cap {O}_x}{P}_{i,x}\left(I(y)|{u}_i(x)\right)\prod_{i=1}^2\prod_{x\in {\varOmega}_i}{P}_i\left({u}_i(x)\right)\\ {}=\prod_{x\in \varOmega}\prod_{i=1}^2\prod_{y\in {\varOmega}_i\cap {O}_x}\frac{1}{\sqrt{2\pi }{\sigma}_i(x)}\exp \left(-\frac{{\left(I(y)-{u}_i(x)\right)}^2}{2{\sigma}_i^2(x)}\right)\\ {}\times \prod_{i=1}^2\prod_{x\in {\varOmega}_i}\frac{1}{Z}\exp \left(-\frac{1}{T}|\nabla {u}_i(x)|\right)\end{array}}$$

By using MAP criterion, seeking the maximum posterior probability P(u(x)| I(x)) is equivalent to.

maximizing the following formula,

$$\max P\left(I(x)|u(x)\right)\Rightarrow \max \left\{\prod_{x\in \varOmega}\prod_{i=1}^2\prod_{y\in {\varOmega}_i\cap {O}_x}{P}_{i,x}\left(I(y)|{u}_i(x)\right)\prod_{i=1}^2\prod_{x\in {\varOmega}_i}{P}_i\left({u}_i(x)\right)\right\}$$
(3.6)

Taking a negative logarithm for (3.6), the maximization can be converted to the minimization of the following energy,

$$\begin{array}{c}\min\left\{-\log\;P{\mathit(\mathit I\left.\mathit(\mathit x\mathit)\right|\mathit u\mathit{(x)}\mathit)}\right\}\Rightarrow\;\\\min\left\{\sum_{i=1}^2\int_{x\in\mathrm\Omega}\int_{y\in{\mathrm\Omega}_1\cap{\mathit\bigcirc}_{\mathrm x}}-\log\;P_{i\mathit,x}{\mathit(\mathit I\left.\mathit(\mathit y\mathit)\right|{\mathit u}_{\mathit i}\mathit{(x)}\mathit)}\mathit+\sum_{i=1}^2\int_{x\in{\mathrm\Omega}_i}-\log\;P_i{\mathit({\mathit u}_{\mathit i}\mathit{(x)}\mathit)}\right\}\end{array}$$

i.e., minimize the following energy, here the constants that cannot affect the minimization are neglected,

$${\displaystyle \begin{array}{c}E=\sum_{i=1}^2{\int}_{x\in \varOmega }{\int}_{y\in {\varOmega}_i\cap {O}_x}\left(\log {\sigma}_i(x)+\frac{{\left(I(y)-{u}_i(x)\right)}^2}{2{\sigma}_i^2(x)}\right) dydx\\ {}+a\sum_{i=1}^2{\int}_{x\in {\varOmega}_i}\mid \nabla {u}_i(x)\mid dx\end{array}}$$
(3.7)

where \(a=\frac{\log Z}{T}\). For the convenience of calculation, we extend the integral region to the whole image domain Ω by using level set function and weighting function method.

3.3 Level set formulation

By introducing a weighting function ω(x − y) into the function (3.7), the objective function can be rewritten as,

$${\displaystyle \begin{array}{c}E=\sum_{i=1}^2{\int}_{x\in \varOmega }{\int}_{y\in {\varOmega}_i}\omega \left(x-y\right)\left(\log {\sigma}_i(x)+\frac{{\left(I(y)-{u}_i(x)\right)}^2}{2{\sigma}_i^2(x)}\right) dydx\\ {}+a\sum_{i=1}^2{\int}_{x\in {\varOmega}_i}\mid \nabla {u}_i(x)\mid dx\end{array}}$$
(3.8)

Here, the weighting function ω(x − y) can be selected as a indicator function for Ox or a Gaussian function Gσ(x − y). By using level set functionϕ, the objective function (3.8) can be rewritten as,

$${\displaystyle \begin{array}{c}E=\sum_{i=1}^2{\iint}_{\varOmega}\omega \left(x-y\right)\left(\log {\sigma}_i(x)+\frac{{\left(I(y)-{u}_i(x)\right)}^2}{2{\sigma}_i^2(x)}\right){M}_i\left(\phi \right) dydx\\ {}+a\sum_{i=1}^2{\int}_{\varOmega}\mid \nabla {u}_i(x)\mid {M}_i\left(\phi \right) dx\end{array}}$$
(3.9)

Where M1(ϕ) = H(ϕ) and M2(ϕ) = 1 − H(ϕ), in which H(·) is the Heaviside function. In practice, the H(ϕ) is approximated by a smooth version Hε(x)defined as,

$${H}_{\varepsilon }(x)=\frac{1}{2}\left[1+\frac{2}{\pi}\arctan \left(\frac{x}{\varepsilon}\right)\right]$$

The derivative of Hε is defined as the following smooth Dirac function,

$${\delta}_{\varepsilon }(x)={H}_{\varepsilon}^{\prime }(x)=\frac{1}{\pi}\frac{\varepsilon }{\varepsilon^2+{x}^2}$$

which will be used in the following numerical implementation.

In order to keep the level set function ϕ to be stable during the evolution, we employ a distance regularizing term in level set formulation [51] to penalize the deviation of the level set function ϕ from a signed distance function [30], that is defined as,

$$D\left(\phi \right)=\frac{1}{2}{\int}_{\varOmega }{\left(|\nabla \phi (x)|-1\right)}^2 dx$$
(3.10)

By minimizing energy D(ϕ) w.r.t ϕ it has ∇ϕ → 1, which means that ϕ is close to a signed distance function. As in typical level set methods, we need to regularize the zero level set by penalizing its length to derive a smooth contour during the evolution,

$$L\left(\phi \right)={\int}_{\varOmega}\mid \nabla H\left(\phi (x)\right)\mid dx$$
(3.11)

Combining the energy (3.9), (3.10) and (3.11), we obtain the total energy of the proposed LGM model,

$$\begin{array}{c}E_{LGM}=E+vD\left(\phi\right)+\mu L\left(\phi\right)\\=\sum_{i=1}^2\;\iint_{\mathrm\Omega}\omega\left(x-y\right)\left(\log\;\sigma_i\left(x\right)+\frac{\left(I\left(y\right)-u_i\left(x\right)\right)^2}{2\sigma_i^2\left(x\right)}\right)\;M_i\left(\phi\left(y\right)\right)dydx\\+\alpha\sum_{i\mathit=1}^2\int_{\mathrm\Omega}{\mathit\vert\mathit\nabla{\mathit u}_{\mathit i}{\mathit(\mathit x\mathit)}\mathit\vert}\mathit\;M_i{\mathit(\mathit\phi\mathit{(x)}\mathit)}dx\\+\frac12v\int_{\mathrm\Omega}\left(\left|\nabla\phi\left(x\right)-1\right|\right)^2dx\\+\mu\int_\Omega\left|\nabla H\left(\phi\left(x\right)\right)\right|dx\end{array}$$
(3.12)

where the first two terms are data fidelity terms, the last two terms are regularization terms, and ν and μ are two positive parameters that weight the D(ϕ) and L(ϕ), respectively.

Remark

According to the above analysis, we note that the proposed LGM model is actually a lcoal region-based model. We here illustrate the differences and advantages of it over two classical lcoal region-based models: LBF and LGDF. Compared to the LBF model, the proposed model uses a Gaussian distribution with varying mean and variance to fit the image in a local region, while LBF model only uses varying mean. Such scheme enables us to capture the local changes of image intensity more precisely and thus obtain accurate segmentation. Compared to the LGDF model, in addition to using the same fitting energy, the proposed model uses a MRF regularization term that is related to the famous total variation to regularize the mean image ui(x). Such prior constraint enables the proposed model to better eliminate the effects of intensity inhomogeneity and noise while capturing the real features of the image.

3.4 Numerical implementation

In this section, an alternating direction iteration algorithm is introduced to numerically solve the minimizer of energy ELGM in (3.12) w.r.t.ui,σiand ϕ. That is to say, it minimizes ELGM w.r.t. one variable while others are fixed.

• Minimize ELGM w.r.t. ui,σiand ϕ being fixed. By calculus of variations, the optimal uimust satisfy the following Euler-Lagrange equation,

$$-{\int}_{\varOmega}\omega \left(x-y\right)\frac{\left(I(y)-{u}_i(x)\right)}{\sigma_i^2(x)}{M}_i\left(\phi (y)\right) dy-\mathit{\operatorname{div}}\left(\frac{\nabla {u}_i(x)}{\mid \nabla {u}_i(x)\mid}\right){M}_i\left(\phi (x)\right)=0$$
(3.13)

To avoid the singularity of ∣ ∇ ui(x) ∣  = 0 as the denominator, a regularized |∇ui(x)|ϵ is used in practice, which is defined as,

$${\left|\nabla {u}_i(x)\right|}_{\epsilon }=\sqrt{{\left({\nabla}_{x_1}{u}_i(x)\right)}^2+{\left({\nabla}_{x_2}{u}_i(x)\right)}^2+\epsilon }$$

where ϵ is a very small constant. Obviously, it is very difficult to solve ui(x) directly from the Eq.(20) due to the existence of gradient and divergence operators whose inverse are ill-posed. A fixed point iterative algorithm is employed to approximate the true solution of Eq.(20). The iterative scheme is given as following,

$${u}_i^{n+1}(x)=\frac{\omega (x)\ast \left(I(x){M}_i\left(\phi (x)\right)\right)+{\sigma}_i^2(x)\mathit{\operatorname{div}}\left(\frac{u_i^n(x)}{{\left|{u}_i^n(x)\right|}_{\varepsilon }}\right){M}_i\left(\phi (x)\right)}{\omega (x)\ast {M}_i\left(\phi (x)\right)}$$
(3.14)
  • MinimizeELGMw.r.t. σiwith ui and ϕ being fixed. The optimal σi(x) must satisfy the following Euler-Lagrange equation,

    $${\int}_{\varOmega}\omega \left(x-y\right)\left({\sigma}_i^2(x)-{\left(I(y)-{u}_i(x)\right)}^2\right){M}_i\left(\phi (y)\right) dy=0$$

Solving \({\sigma}_i^2(x)\) from the last equation, we obtain,

$${\sigma}_i^2(x)=\frac{\int_{\varOmega}\omega \left(x-y\right){\left(I(y)-{u}_i(x)\right)}^2{M}_i\left(\phi (y)\right) dy}{\int_{\varOmega}\omega \left(x-y\right){M}_i\left(\phi (y)\right) dy}$$
(3.15)
  • MinimizeELGMw.r.t. ϕ with ui and σi being fixed. By using calculus of variations and gradient descent method, the minimizer of the energy functional ELGM w.r.t ϕ is equal to the steady-state solution of the following gradient descent flow equation,

$${\displaystyle \begin{array}{c}\frac{\partial \phi }{\partial t}=-{\delta}_{\varepsilon}\left(\phi \right)\left({e}_1-{e}_2\right)-{\delta}_{\varepsilon}\left(\phi \right)\left(|\nabla {u}_1(x)|-|\nabla {u}_2(x)|\right)\\ {}+\nu {\delta}_{\varepsilon}\left(\phi \right)\mathit{\operatorname{div}}\left(\frac{\nabla \phi }{\mid \nabla \phi \mid}\right)+\mu \left(\varDelta \phi -\mathit{\operatorname{div}}\left(\frac{\nabla \phi }{\mid \nabla \phi \mid}\right)\right)\end{array}}$$
(3.16)

where

$${e}_i={\int}_{\varOmega}\omega \left(x-y\right)\left[\log \left({\sigma}_i(x)\right)+\frac{{\left(I(y)-{u}_i(x)\right)}^2}{2{\sigma}_i^2(x)}\right] dx$$

To numerically solve the PDE (3.16), the finite difference method is used, which leads to the following iterative scheme,

$${\displaystyle \begin{array}{c}{\phi}^{n+1}={\phi}^n+\varDelta t\Big({\delta}_{\varepsilon}\left({\phi}^n\right)\left({e}_2-{e}_1\right)-{\delta}_{\varepsilon}\left({\phi}^n\right)\left(|\nabla {u}_1(x)|-|\nabla {u}_2(x)|\right)\\ {}+\nu {\delta}_{\varepsilon}\left({\phi}^n\right)\mathit{\operatorname{div}}\left(\frac{\nabla {\phi}^n}{\mid \nabla {\phi}^n\mid}\right)+\mu \left(\varDelta {\phi}^n-\mathit{\operatorname{div}}\left(\frac{\nabla {\phi}^n}{\mid \nabla {\phi}^n\mid}\right)\right)\end{array}}$$
(3.17)

where Δt is the time step.

In the above, we give the methods to solve each subproblem in the alternating direction iteration algorithm in detail. In the following, we state main steps of the algorithm for the proposed model. With an initializationϕ0, it alternately solves each subproblem until the convergence condition is met.

In the following, we analyze the computation complexity of the Algorithm 1. Supposing the number of pixels of the test image is M, the radius of the local window function ω is k, and the number of the loops is n, we can deduce that the complexity of the Eqs. (21), (22) and (24) is O(k2M2) since they involve matrix convolution and multiplication. Therefore the total computation complexity of the proposed algorithm is O(3k2nM2) which can be further simplified as O(3k2nM2) ≈ O(M2) since k and n satisfies k, n ≪ M, which can be ignored in complexity analysis.

4 Experiment result

In this section, we test the proposed model and the corresponding algorithm by using some synthetic and real images. Furthermore, the proposed model is compared with several state-of-the-art variational level set models to show its superior performance. The experiments are performed on a PC with Intel(R)Core(TM)i5-7500CPU@3.40GHz 3.40GHz, 8GB RAM, Windows7 operating system (64-bit operating system based on ×64 processor). The algorithms are programmed in MATLAB. The parameters of the model and algorithm are set as the following. Since the proposed model employs two regularization terms to regularize the level set function, the initialization of the level set function can be flexible, and it doesn’t have to be initialized to a signed distance function. In this paper, it is defined as,

$${\phi}^0(x)=\left\{\begin{array}{c}\begin{array}{cc}+1,& x\in \mathrm{inside}(C)\end{array}\\ {}\begin{array}{cc}0,& x\in C\end{array}\\ {}\begin{array}{cc}-1,& \kern0.1em x\in \mathrm{outside}(C)\end{array}\end{array}\right.$$

where C is an initial contour. The regularization parameter ν in the proposed model weights the level set function close to a signed distance function. In the experiment, we tested it over a wide range ν ∈ [0.01, 1], and noted that the results are not very sensitive to it, so it is set as ν = 0.1 in all experiments. The parameter μ weights the arc length of the zero level set (i.e., active contour), which is assigned according to the following criteria. If the test data is a noise-free image, the parameter μ is set as a smaller value to alleviate the penalty for the arc length and achieve a fine segmentation (i.e., most details be detected); Conversely, if the test data is a noisy image, the parameterμ is set as a larger value to boost the penalty for the arc length and eliminate the effects of noise points. The parameter a weights the prior constraint of the image. We set a as a larger value to increase the prior constraint for noisy test data, and a smaller value to reduce the prior constraint for the noise-free test data. The other parameters are set as time step Δt = 0.1, the regularization parameter of Hε(ϕ) is set as ε = 3, the regularization parameter of |∇ui(x)|ϵ is set as ϵ = 10−6, the stopping criterion parameter κ = 10−3.

4.1 The experiments for noise free images

  1. A.

    The performance of the proposed LGM model

This experiment aims to show the performance of the proposed LGM model and the algorithm for several noise-free images. The experimental results are shown in Fig. 1 test images are a synthetic image and three real images (flower, plane and leaf), which are shown in the first column. The synthetic image contains intensity inhomogeneity and blurring edges. In addition, there are two holes in the object, which is difficult to be extracted during the evolution of the contour. The three real images contain complex background, obvious intensity inhomogeneity and deep concave edges. The second column shows the initializations of the active contour, where the first two are drawn by hand, and the last two are drawn by a circle equation. The third column shows the segmentation results of the proposed model and the last column shows the final convergent contour. From the results, we observe that the proposed model can eliminate the effects of the intensity inhomogeneity and the complex background, and accurately extract the desired target objects. In addition, the blurring and deep concave edges are successfully captured by the proposed model. We note that the initializations obtained by hand or a circle equation both can achieve accurate segmentation. So, in the following experiments, the initial contours are set as a circle automatically obtained by a equation.

Fig. 1
figure 1

The segmentation results of the proposed model for noise-free images. aTest images b Initialization c Segmentation results d Convergent contour

To demonstrates the convergency of the algorithm, the plots of the LGM energy versus the iterations are shown in Fig. 2, where the test data are the four images in the first experiment, and the LGM energy is computed by (3.12). We can see from Fig. 2 that the LGM energy first decays sharply and then gradually stabilizes to a constant with the iteration increasing, which demonstrates that the proposed algorithm converges well numerically.

  1. B.

    The comparisons with LBF and LGDF

Fig. 2
figure 2

The plots of the LGM energy versus the iterations. a synthetic image b flower c plane d leaf

In this experiment, the proposed LGM model is compared with two famous local variational level set models, LBF [27] and LGDF [45], where LBF is the first one to incorporate local information in the model to capture the local changes of the intensity, which can effectively segment image with intensity inhomogeneity; and LGDF is an improved version of LBF, in which the Gaussian distribution with both varying mean and variance is used to fitting the image in a local region. Such scheme enables us to obtain a finer segmentation than LBF.

Firstly, three synthetic images are used as the test data, which contain intensity inhomogeneity, uneven background, deep concave boundary. The segmentation results are shown in Fig. 3. The first column show the initialization, the following three columns respectively show the segmentation results of LBF, LGDF and the proposed LGM, and the last column shows the convergent contours of LGM. It can be seen that the proposed LGM can eliminate the influence of intensity inhomogeneity and uneven background, and accurately capture the desired objects. In addition, deep concave boundary and the holes in the object are also detected. LGDF also can obtain the satisfactory results, and there are few pseudo edges in the segmentation results. LBF has the worst performance, and a lot of pseudo edges are appeared in the segmentation results.

Fig. 3
figure 3

The segmentation result s or noise free synthetic images. a Initialization b LBF c LGDF d LGM e Contour of LGM

Next, three natural images are used as the test data, which contain more complex objects and backgrounds than synthetic images. The segmentation results are shown in Fig. 4. Again, the proposed LGM is compared with LBF (second column) and LGDF (third column). From the results, we observe that the LBF model over-segments the images with severe intensity inhomogeneity, there are a lot of pseudo edges appeared in the segmentation results. The LGDF model can obtain the satisfactory segmentation, only a few of the targets are missegmented. In contrast, the LGM model has the best performance, the objects are accurately detected and there is no missegmentation in the results.

Fig. 4
figure 4

The segmentation results for noise free natural images. a Initialization b LBF c LGDF d LGM e Contour of LGM

At last, the models are tested on three medical images that are particularly challenging to segment due to the presence of severe intensity inhomogeneity, complex backgrounds, and low contrast. The segmentation results are shown in Fig. 5. It can be seen that the proposed LGM model can accurately capture the desired objects, and there is no missegmentation and boundary- leakage in the results. While the LBF model often over-segments the images, and there are lots of pseudo contours appeared in the segmentation results. The LGDF model can yield the satisfactory segmentation results. However, from the Table 1, we observe that compared with the proposed model, LGDF requires more computing time.

Fig. 5
figure 5

The segmentation results for noise free medical images. a Initialization b LBF c LGDF d LGM e Contour of LGM

Table 1 The CPU time of the three models for noise free images(/s)

From the experiment above, we conclude that LBF model can deal with intensity inhomo- geneity to a certain extent, it is still unable to segment images with complex foreground or back- ground. Compared with LBF, LGDF can better segment images with intensity inhomogeneity and complex foreground or background because the more precise fitting energy with varying means as well as variances is used in the model. The proposed LGM has the best performance because besides the use of the precise fitting energy, the MRF regularization term is introduced in the model, which can further eliminate the interference of intensity inhomogeneity and complex background. In addition, Table 1 shows that compared to LGDF, LGM requires less computing time.

4.2 The experiments for noisy images

  1. A.

    The experiments for noisy synthetic images

In this experiment, we test the models for noisy synthetic images. The Jaccard similarity coefficient (JSC) [39] is employed to quantitatively evaluate the segmentation performance, which is defined as,

$$JSC\left(A,B\right)=\frac{N\left(A\cap B\right)}{N\left(A\cup B\right)}$$

where A and B are two sets respectively representing the ground truth and the segmentation results obtained by the models, and N(·) is the potential of the set counted by the number of the pixels in the set.

Test data are two synthetic images that are contaminated by Gaussian noise with variance ofσ2 = 10, 30, 60. In addition, the model is compared with CV [9], LBF [27], LIF [50], and LSACM [49] models. The segmentation results of two images are shown in Figs. 6 and 7, respectively. In the two figures, we show the segmentation results of the noisy images with noise variance of σ2 = 10, 30, 60 from top to bottom. From the results, we observe that all these five models can accurately segment the images contaminated by weak noises (see first rows). But for the images with strong noises, the proposed model has the best performance due to the use of MRF regularization. And the segmentation results obtained by the other four models contain more or less pseudo boundaries (see last rows). The JSC line charts shown in Fig. 8 further demonstrate this point.

Fig. 6
figure 6

The segmentation results of noisy synthetic image I. Nosiy images CV LBF LIF LSACM LGM Contours Noisy image CV LBF LIF LSACM LGM Contours

Fig. 7
figure 7

The segmentation results of noisy synthetic image II

Fig. 8
figure 8

The JS coefficients of the segmentation results of the two noisy synthetic images

  1. B.

    The experiments for Gaussian noisy images

In this experiment, several real and synthetic images contaminated by Gaussian noise with different variances are used to test the models. In addition, the proposed LGM model is compared with six state-of-the-art variational level set models (LBF, MCV [48], CV, LSACM, LIF and LGDF). Figures 9, 10 and 11 show the segmentation results of the images contaminated by Gaussian noise with 10, 20 and 30 variance, respectively. Table 2 lists the CPU time consumed by the models. From the experimental results, it can be observed that the proposed model has the superior performance than LBF, MCV, CV, LSACM and LIF models. It can accurately capture the contours of the desired targets, and there are few pseudo boundaries appeared in the segmentation results. While the segmentation results obtained by the other five models contain more or less pseudo boundaries due to the influence of the complex background, noise and texture. LGDF can get satisfactory segmentation results, but it consumes more CPU time than the proposed LGM model as shown in Table 2. The reason is that compared to LGDF, the MRF regularization is used in the LGM model, which takes very few iterations to converge.

  1. III.

    The experiments for speckle noisy and salt and pepper noisy images

Fig. 9
figure 9

The comparisons with MCV and LBF for Gaussian noisy images (σ2 = 10) (a) Initialization (b) MCV (c) LBF (d) LGM (e) Contours

Fig. 10
figure 10

The comparisons with CV and LSACM for Gaussian noisy images (σ2 = 20) (a) Initialization (b) CV (c) LSACM (d) LGM (e) Contours

Fig. 11
figure 11

The comparisons with LIF and LGDF for Gaussian noisy images (σ2 = 30) (a) Initialization (b) LIF (c) LGDF (d) LGM (e) Contours

Table 2 The CPU time of the different models(/s)

This experiment aims to test the models for the images contaminated by speckle noise or salt and pepper noise. Again, the proposed model is compared with CV, LBF, LIF, LGDF, LSACM and MCV models. The segmentation results are shown in Fig. 12, in which the first two rows show the results of Star and Horse images contaminated by speckle noise of 0.01 intensity, and the last two rows show the results of Ventricle and Bird images contaminated by salt and pepper noise of 0.01 intensity; the first column shows the initialization, and the following columns respectively show the segmentation results of the seven models. Table 3 lists the CPU time costed by the models. From the results, we observe that LGDF and the proposed LGM have the best performance among these seven models, both of which can eliminate the effects of noise and intensity inhomogeneity, and accurately capture the desired targets, but Table 3 shows that LGM model requires less CPU time and is more efficient than LGDF model due to the use of MRF regularization. The other five models can not accurately capture the objects, and more or less pseudo contours are appeared in the result.

Fig. 12
figure 12

The segmentation results of the images contaminated by speckle noise and salt and pepper noise. Initial CV LBF LIF LGDF LSACM MCV LGM

Table 3 The CPU time consumed by the different models(/s)

4.3 Quantitative analysis on Weizmann dataset

In this section, to further verify the effectiveness and the adaptability of the proposed model, we test the model on Weizmann dataset [1] that contains 200 images with one or two salient objects. The ground truths in this dataset are given by the providers, which are binary maps. Three matching coefficient indexes concluding JSC, Dice similarity coefficient (DSC) [39] and Volumetric overlap error (VOE) [11] are used to quantitatively evaluate the performance, which are defined as,

$$DSC\left(A,B\right)=\frac{2N\left(A\cup B\right)}{N(A)+N(B)}, VOE\left(A,B\right)=\frac{N\left(A-B\right)}{N\left(A\cup B\right)}$$

where A and B indicate the segmentation result obtained by the models and the ground truth, respectively. We note that the closer the JSC and DSC approaches 1, or VOE approaches 0, the higher the matching degree between segmentation A and ground truth B is, and the better the segmentation quality is. Again, we compare the proposed model with several level set models including CV, LBF, LGDF and MCV.

Figure 13 shows the segmentation results of three images in the Weizmann dataset. From the results, we observe that the proposed model can extract the object contour very accurately. There are very few pseudo contours appeared in the segmentation results. The DSC, JSC and VOE values are listed in Table 4. It can be seen that the proposed model has the largest DSC and JSC values and the smallest VOE values for the three images, which further demonstrates the visualization results in Fig. 13. The last three rows show the mean DSC, JSC and VOE values of the models tested in the whole Weizmann dataset. We can see that the proposed model still has the best performance in terms of the three indexes among the five models, which further verify the effectiveness and the adaptability of the proposed model.

Fig. 13
figure 13

The segmentation results the three images in Weizmann dataset. (a) Initialization (b)CV (c)LBF (d)LGDF (e)MCV (f)LGM

Table 4 The three index values of different models

4.4 The adaptive initialization of active contour

Because the proposed model is a local region-based model, it is sensitive to the initialization of the active contour. In experiments, we found that if the initial contour is far away from the object, it cannot accurately capture the object. Therefore, we use the man-machine interaction method to select the initial contour to obtain satisfactory segmentation result. In the last experiment, we introduce a method to automatically select the initial active contour for different images. The main steps are as follows,

  • Step 1: Binary segmentation: Selecting a proper grayscale threshold based on histogram to segment the image as a binary map.

  • Step 2: Computing the center of the initial contour: Selecting the barycenter of the object area in the binary map as the center of the initial contour, which is computed by,

    $$\overline{X}=\frac{1}{N}\sum_{i=1}^N{x}_i$$

where xi is the coordinates of the pixels in the object area, and N is the number of pixels.

  • Step 3: Designing initial contour: Plotting a circle centered at \(\overline{X}\) with ρ radius as the initial contour.

In the last experiment, we test the automatic initialization scheme stated as the above. Figure 14 shows the segmentation results of the proposed model with such automatic initialization scheme for three test images. The first column is test image, and the following three columns show binary map by threshold method based on histogram, initial contour obtained by the automatic initialization scheme, and segmentation contour by the proposed model. From the results, we can see that the proposed model with such automatic initialization scheme can obtain satisfactory segmentation results for simple images, such as the images in the first and second rows. However, for complex images such as the X-ray finger image in the last row, it cannot obtain the optimal segmentation result.

Fig. 14
figure 14

The segmentation results of the proposed model with automatic initialization (a)Test image (b) Binary map (c) Initial contour (d) Segmentation result

5 Conclusion

In this paper, based on MAP criterion, we proposed a variational level set model to segment images in the presence of intensity inhomogeneity and noise. A local Gaussian fitting term with varying means and variances and a MRF regularization term that is related to total variation are introduced in the energy. By energy minimization, the local Gaussian fitting term can effectively capture the local changes of the intensity, and MRF regularization term can eliminate the effects of noise. The experiments demonstrate the effectiveness and efficiency of the proposed model. In addition, we compared the proposed model with several state-of-the-art variational level set models. The results show that it has the best performance. However, we noted that the proposed model is sensitive to the initialization, and can only detect a single target. In the future, we will focus on automatically initialization and multi-target detection techniques that combine variation level set and deep learning.