Keywords

1 Introduction

Image segmentation plays a very fundamental role in image processing and computer vision. Over the past decades, many scholars studied a significant amount of image segmentation methods. The level set method (LSM) is a famous one of them. Although the level set image segmentation has been widely studied and utilized for decades, it is still a hot research problem. The LSM can be classified into edge-based methods [1], global region-based methods [2] and hybrid methods [3]. Global region-based methods have a better result when the segmented images which have weak boundaries and are less sensitive to initial placement. Among them, the Chan-Vese (CV) model [2] is the most famous one. It has better performance for images containing homogeneous regions with distinct intensity means. However, CV model cannot segment the image with intensity inhomogeneity, and the method is sensitive to the placement of the initial contour and set of initial parameters, and the convergence is slow and apt to plunge into local minimal value. To improve the performance of global region-based methods, some local region-based methods were proposed. The classical ones include, the local Chan-Vese (LCV) model [4], the region-scalable fitting (LBF) model [5] the local intensity clustering (LIC) model [6], etc. Recently, some hybrid methods [3] had been studied, which combined global and local image information to stabilize and accelerate process of the evolution convergence. Wang [7] discussed global and local region-based active contours with cosine fitting energy, but the parameters of the model are challenging to set.

Most of the region based image segmentation methods mentioned above are based on energy minimization which is performed by different techniques. The most widely used method of energy minimization is the gradient descent (GD) method. One must solve the partial differential equation (PDE) until it reach the minimum and can meet local minimal value in this process. To ensure the steady evolution, it must be satisfied with Courant Friedrichs Lew (CFL) condition. The evolution is time-consuming. After the PDE was obtained, some scholars present many methods to solve the PDE, such as implicit difference [1], Hermite differential operator [8], additional operator splitting [9], operator splitting [10] and so on. Recently, many scholars constructed many new algorithms to get better image segmentation results. The authors [11] use the max-flow algorithm to optimize local Chan-Vese model. The authors [12,13,14] use the sweeping principle algorithm of Chan Vese model to get the optimization of the energy functional of the region based level set model. In this paper, we present a new image segment method named local Chan Vese model by employing cosine fitting energy and give two algorithms. The model can segment image with severe intensity inhomogeneity or edge blurred.

The remaining of this paper is structured as follows: In Sect. 2, the Local Chan Vese model based on cosine fitting energy model is constructed, and finite difference algorithm of Local Chan Vese by employing cosine fitting energy (LCVCF) is given. In Sect. 3, the sweeping optimization principle algorithm (SLCVCF) of the model is presented. In Sect. 4, some examples are given to show the effectiveness of the proposed method. Finally, some conclusions are provided in Sect. 5.

2 Local Chan Vese Model by Employing Cosine Fitting Energy

In this section, we present the Local Chan Vese by employing cosine fitting energy model and then propose its numerical algorithm based on the gradient descent method.

2.1 Data Fitting Energy Functional Term

Let \( \Omega \subset \Re^{2} \) be the two-dimensional image domain and \( I:\Omega \to \Re \) be the intensity image. For a given grayscale image on the interval [0, 1], the cosine power error preserves smaller error and more gentle than L2 norm on the interval [0, 1], so we think the cosine fitting energy is less sensitive to the interference of the noise and robust to low contrast than the fitting energy in the LCV model. The fitting data energy of the Local Chan Vese by employing cosine fitting energy model is defined by

$$ \begin{aligned} & E_{data}^{LCVCF} (c_{1} ,c_{2} ,d_{1} ,d_{2} ,\phi ) = \alpha \int_{\Omega } {( - \cos (I - c_{1} ))H(\phi (x)) + \beta \int_{\Omega } {( - \cos (g_{k} * I - I - d_{1} ))H(\phi (x))} dx} \\ & \quad \quad \quad \quad \quad + \alpha \int_{\Omega } {( - \cos (I - c_{2} ))(1 - H(\phi (x))) + \beta \int_{\Omega } {( - \cos (g_{k} * I - I - d_{2} ))H(\phi (x))} dx} \\ \end{aligned} $$
(1)

Where and β are two nonnegative constants. The meaning of c1 and c2 are the intensity means of the evolving contour as the same as that of global cosine fitting (GCF) model [7]. d1 and d2 are the intensity means of \( ( {\text{g}}_{k} * I ( {\text{x)}} - I ( {\text{x))}} \) inside and outside of the evolving contour. Here H(z) and δ(z) denote Heaviside function and Dirac delta function respectively, gk computes the averaging convolution in a k × k size window.

For a fixed level set function ϕ, we minimize the energy functional in (1) concerning two pairs of constants: c1 and c2, d1 and d2. By calculus of variations, it can be shown that the constant functions c1c2d1 and d2 that minimize E LCVCF data (c1c2d1d2ϕ) for a fixed function ϕ are given by

$$ c_{1} (\phi ) = \arctan \frac{{\int_{\Omega } {\sin (I(x))H(\phi (x))dx} }}{{\int_{\Omega } {\cos (I(x))H(\phi (x))dx} }}, c_{2} (\phi ) = \arctan \frac{{\int_{\Omega } {\sin (I(x))(1 - H(\phi (x)))dx} }}{{\int_{\Omega } {\cos (I(x))(1 - H(\phi (x)))dx} }} $$
(2)
$$ d_{1} (\phi ) = \arctan \frac{{\int_{\Omega } {\sin ( {\text{g}}_{k} * I ( {\text{x)}} - I ( {\text{x))}}H(\phi (x))dx} }}{{\int_{\Omega } {\cos ( {\text{g}}_{k} * I ( {\text{x)}} - I ( {\text{x))}}H(\phi (x))dx} }} $$
(3)
$$ d_{2} (\phi ) {\text{ = arctan}}\frac{{\int_{\Omega } {{\text{sin(g}}_{k} * I ( {\text{x)}} - I ( {\text{x))}} \cdot (1 - H(\phi (x)) )dx} }}{{\int_{\Omega } {{\text{cos(g}}_{k} * I ( {\text{x)}} - I ( {\text{x))(}}1 - H(\phi (x)) )dx} }} $$
(4)

2.2 Regularization Energy Term

To prevent small and isolated curves happening in the final segmentation result, we use energy term as Eq. (5).

$$ L(\phi ) = \int_{\Omega } {\delta (\phi (x))\left| {\nabla \phi (x)} \right|dx} $$
(5)

We use the following function as distance penalty energy term to naturally maintain level set function being a signed distance function (SDF) during the contour evolution

$$ R\left( \phi \right)\, = \,\smallint _{\Omega } P(|\nabla \phi \left( x \right)|)dx\quad where\,P(s) = \left\{ {\begin{array}{*{20}l} {\frac{1}{2}{\text{s}}^{2} (s - 1)^{2} ,} \hfill & {if} \hfill & {s \le 1} \hfill \\ {\frac{1}{2}(s - 1)^{2} ,} \hfill & {if} \hfill & {s \ge 1} \hfill \\ \end{array} } \right. $$
(6)

Where is a double-well potential function based on interpolant polynomial. In paper [3], P(s) is a sixth times polynomial. In this paper, we only use the fourth times to avoid high order instability of polynomial. By utilizing distance regularization penalty energy term in (6), the level set function can be maintained as an SDF [3].

Thus, the final regularization energy term ER of our method was given in Eq. (7)

$$ E^{R} (\phi ) = \mu \cdot L(\phi ) + v \cdot R(\phi )\; = \mu \cdot \int_{\Omega } {\delta (\phi (x))\left| {\nabla \phi (x)} \right|dx} + v \cdot \int_{\Omega } {P(\left| {\nabla \phi (x)} \right|)} dx $$
(7)

where μ and v are constants to control the length penalization effect and signed distance function maintaining effect separately.

2.3 Level Set Formulation for the Proposed Model

Due to the introduction of distance regularization energy term in (6), a binary step function can be used to the initial level set function. Thus, the total energy functional is reformulated as follows:

$$ \begin{aligned} E^{{^{LCVCF} }} (c_{1} ,c_{2} ,d_{1} ,d_{2} ,\phi ) & = \alpha \int_{\Omega } {( - \cos (I - c_{1} ))H(\phi (x)){ + }\beta \int_{\Omega } {( - \cos (g_{k} * I - I - d_{1} ))H(\phi (x))} dx} \\ & + \alpha \int_{\Omega } {( - \cos (I - c_{2} ))(1 - H(\phi (x))){ + }\beta \int_{\Omega } {( - \cos (g_{k} * I - I - d_{2} ))H(\phi (x))} dx} \\ & + \mu \cdot \int {\delta_{\varepsilon } (\phi )\left| {\nabla \phi } \right|} dxdy + v \cdot \int_{\Omega } {P(\left| {\nabla \phi (x)} \right|)} dx, \\ \end{aligned} $$
(8)

Like other methods, the level set function ϕ(x) can be updated according to the Eq. (9):

$$ \begin{aligned} \frac{\partial \phi }{\partial t} & = \delta (\phi )[ - (\alpha \cdot ( - \cos (I - c_{1} )) + \beta \cdot ( - \cos (g_{k} * I - I - d_{1} ))) + (\alpha \cdot ( - \cos (I - c_{2} )) \\ & + \beta \cdot ( - \cos (g_{k} * I - I - d_{2} )))] + [\mu \cdot \delta (\phi )div(\frac{\nabla \phi }{{\left| {\nabla \phi } \right|}}) + v \cdot div(d(\left| {\nabla \phi } \right|)\nabla \phi )], \\ \end{aligned} $$
(9)

Where H(x) is Heaviside function, δɛ(x) is the regularized approximation of Dirac delta function, d(s) = P(s)/s. We use the finite difference scheme to solve the above equation. We call the finite difference scheme algorithm of the proposed model LCVCF.

3 Fast Algorithm to Minimize the Local Chan Vese Model by Employing Cosine Fitting Energy

In the last section, we give a finite difference scheme of the model. However, finite difference scheme in level set method has some drawbacks, such as lager approximation error and time-cost consuming and so on. Inspired from work published by Song [12] and Boutiche [13, 14], we propose a sweeping optimization principle algorithm to minimize the local Chan Vese model by employing cosine fitting energy. The algorithm doesn’t need to solve any PDE and have numerical stability conditions. We only sweep all the pixels of the given image and then test each pixel to check the energy change when we change a pixel from the outside of the curve to inside and vice versa.

In the local Chan Vese model by employing cosine fitting energy functional (1), the curve evolution is dominated by the fidelity to data term which is written as follows:

$$ \begin{aligned} F & = [\alpha (- { \cos }\left( {I(x) - c_{1} } \right)) + \beta \cdot ( - \cos (g_{k} * I - I - d_{1} )))] - \\ & [\alpha (- { \cos }\left( {I(x) - c_{2} } \right)) + \beta \cdot ( - \cos (g_{k} * I - I - d_{2} )))] \\ \end{aligned} $$
(10)

Remind that the first and the third terms indicate the global region fitting energy and the second and the fourth terms present the local statistical information fitting energy. However, the outside and inside energy are deducted as follows:

$$ \left\{ {\begin{array}{*{20}l} {\alpha (- {\text{cos(}}I(x) - c_{1} )) + \beta \cdot ( - \cos (g_{k} * I - I - d_{1} ))} \hfill & {if} \hfill & {\phi (x) > 0} \hfill \\ {\alpha (- { \cos }(I(x) - c_{2} )) + \beta \cdot ( - \cos (g_{k} * I - I - d_{2} ))} \hfill & {if} \hfill & {\phi (x) < 0} \hfill \\ \end{array} } \right. $$
(11)

From Eq. (11), we define the old and the new energy change according to the energy inside and outside of the evolving curve:

$$ \begin{aligned} \Delta F_{12} & = [\alpha (- { \cos }\left( {I(x) - c_{1} } \right)) + \beta \cdot ( - \cos (g_{k} * I - I - d_{1} )))]\frac{m}{{m{ + }1}} - \\ & [\alpha (- { \cos }\left( {I(x) - c_{2} } \right)) + \beta \cdot ( - \cos (g_{k} * I - I - d_{2} )))]\frac{n}{n - 1} + \nu P \\ \end{aligned} $$
(12)
$$ \begin{aligned} \Delta F_{21} & = [\alpha (- { \cos }\left( {I(x) - c_{2} } \right)) + \beta \cdot ( - \cos (g_{k} * I - I - d_{2} )))]\frac{n}{n + 1} \\ & - [\alpha (- { \cos }\left( {I(x) - c_{1} } \right)) + \beta \cdot ( - \cos (g_{k} * I - I - d_{1} )))]\frac{m}{m - 1} + \nu P \\ \end{aligned} $$
(13)

Where m and n are the areas (number of pixels) inside and outside the initial level set curve ϕ respectively, ν is a nonnegative small constant. We have added a length term P to increase the capability of segmentation with noisy images. For intensity image, we don’t need this term.

The length term P is approximated by Eq. (14).

$$ P = \sum\limits_{i,j} {\sqrt {({\text{H}}(\phi (i + 1,j) - {\text{H}}(\phi (i,j)))^{2} + ({\text{H}}(\phi (i,j{ + }1) - {\text{H}}(\phi (i,j)))^{2} } } $$
(14)

We call the sweeping optimization principle algorithm of the model SLCVCF.

The steps of the sweeping optimization principle algorithm are given as follows.

Step 1::

Change the given grayscale image to the interval [0, 1].

Step 2::

Place the initial level set on the given image on the interval [0, 1]. Initialize the level set function \( \phi = 1 \) for one part and \( \phi = - 1 \) for another one.

Step 3::

Initialize the parameters ε (for computing H(z) and δ(z)) and kv, α, β

Set F is a matrice of the size ϕ set to 1.

Step 4::

Compute c1, c2, d1, d2 by Eqs. (24),

Compute m, n which are the area (number of pixels) inside and outside of the evolving curves for \( \phi = 1 \) and \( \phi = -1 \) For each pixel of ϕ do

If \( \phi = 1 \) then compute ΔF12 as shows in Eq. (12),

  • If ΔF12 < 0 then change ϕ from +1 to 1.

    • If \( \phi = - 1 \) then compute ΔF12 as shows in Eq. (13),

  • If ΔF21 < 0 then change ϕ from −1 to +1.

  • F = ΔF21 + ΔF12

Step 5::

Repeat the step 4 until the total energy F remains unchanged

As it is shown, the algorithm scan all the pixels of image and then check the energy change for every pixel when the pixel is moved from the inside to the outside of the evolving curve and vice versa. The algorithm needn’t derivative calculations and does not require any numerical stability condition. There is no need for F to be differentiable, the re-initialization step and the distance regularization term. Furthermore, sweeping principle algorithm allows using a binary level set function during the minimization process, avoiding its negative effects and speeding up the optimization process. So we have greatly saved the time of calculation.

4 Experimental Results

In this section, we shall present the experiments of the proposed algorithm on several synthetic and real images. The proposed algorithm was implemented by Matlab R2016a on a computer with Intel Core (TM) i7-6700 2.6 GHz CPU, 16G RAM, and 64 bit Windows 10 operating system. Here, for algorithm LCVCF, we used the same parameters \( \varepsilon = 1,\lambda_{1} = \lambda_{2} = 255,r = 35,\sigma = 25,\Delta t = 0.4,\mu = 15,\nu = 0.4 \) for all experiments unless mentioned otherwise. For algorithm SLCVCF, we used the same parameters \( \varepsilon = 1,\alpha = 4,\beta = 1, \) r = 35, σ = 35 for all experiments unless mentioned otherwise, the initial level set is a binary level set function, the outside of the evolving curve is set to −1, and the inside is set to 1. We use the green line to represent the initial contour and the red line for final evolution results.

Firstly, we present an example to show the effectiveness of our model on the images with intensity inhomogeneity. The first two images are severe intensity inhomogeneity. The initial contours were all placed as shown in the upper row of Fig. 1. The parameters of SLCVCF are chosen as follows: r = 35, σ = 35, for the image (a) \( \alpha = 22,\beta = 3 \) or image (b), \( \alpha = 22,\beta = 5 \) for the image (c), (d) and (e) \( \alpha = 5,\beta = 1 \). The final evolving contours of our algorithm LCVCF and SLCVCF are presented in the lower row of Fig. 1. All five images have good segmented performance as expected with algorithm SLCVCF, but for algorithm LCVCF, it extract only last two object’s boundaries successfully. It can be seen that our algorithm SLCVCF can achieve good performance on the synthetic image with severe intensity inhomogeneity.

Fig. 1.
figure 1

Segmentation comparisons of the computation of the proposed algorithm LCVCF and SLCVCF on synthetic images. The first row: Different intensity inhomogeneity image. The second row: Final segmentation results of the proposed algorithm LCVCF. The third row: Final segmentation results of the proposed algorithm SLCVCF. Image size: 100 × 100. (Color figure online)

In the second experiment, we give some real image segmentation results based on the LCVCF and SLCVCF algorithms. The parameters of SLCVCF are chosen as follows: r = 25, σ = 45, \( \alpha = 4,\beta = 1 \) for the image (a); r = 35, σ = 35, \( \alpha = 4,\beta = 1 \), for the image (b), (c) and (e); r = 25, σ = 35, \( \alpha = 4,\beta = 1 \), for the image (d). The final evolving contours of our algorithm LCVCF and SLCVCF are presented in the lower row of Fig. 2. All five images were well segmented as expected with algorithm SLCVCF, but for algorithm LCVCF, it cannot extract object’s boundaries successfully. It can be seen that algorithm SLCVCF can achieve good performance on the real image with intensity inhomogeneity by using very few iterations and time.

Fig. 2.
figure 2

Segmentation comparisons of the computation of the proposed algorithm LCVCF and SLCVCF on real images. The first row: given images. The second row: Final segmentation results of SLCVCF. The third row: Final segmentation results of SLCVCF. Image size: 217 × 161, 209 × 193, 256 × 256, 400 × 266, 141 × 139.

To show the segment performance of the proposed algorithm SLCVCF, we compare the proposed two algorithms with the LCV [4] model and LBF [5] model. Segmentation results are presented for different types of images in Fig. 3 (the same initial evolving curve). For LCV model, we choose the parameters as follows, Δt = 0.1, α = 0.1, β = 1, h = 1, ɛ = 1, r = 35, k = 20, μ = 0.01 × 2552 and v = 0. For LBF model, the parameters are set as follows: λ1 = 1, λ2 = 2, ɛ = 1, \( \sigma = 3 \), r = 25, Δt = 0.1, μ = 1 and v = 0.04 × 2552. All the above methods used the same initialization. The parameters of SLCVCF are chosen as follows: r = 35, σ = 45, \( \alpha = 4,\beta = 1 \) for the image (a), r = 25, σ = 45, \( \alpha = 4,\beta = 1 \), for the image (b), (c), (d) and (e). The second row shows that segmentation results for the SLCVCF algorithm. It has the best performance and can completely segment all the images and use the least time even though the images with serious intensity inhomogeneity. The third to the fifth rows show that the LCVCF, LCV, LBF models cannot obtain a satisfactory segmentation model for images in some cases. Compared with the above algorithms or models from Table 1, we can get our algorithm SLCVCF obtaining satisfactory segmentation results at a faster convergence speed than the LCVCF, LCV and LBF model.

Fig. 3.
figure 3

Segmentation comparisons of the computation of the proposed algorithm SLCVCF and LCVCF, LCV, LBF on synthetic images. The first row: given images. The second to the seventh row: Final segmentation results of SLCVCF, LCVCF, LCV, LBF. Image size: 154 × 152, 108 × 130, 114 × 101, 200 × 200, 143 × 145.

Table 1. Comparison of the computation cost (times (s))/iteration numbers of the proposed algorithm SLCVCF and LCVCF, LCV, LBF on synthetic images in Fig. 3

In the fourth example, we shall show the performance of the proposed algorithm LCVCF and SLCVCF of the local Chan Vese model by employing cosine fitting energy, when comparing the proposed algorithms with the LCV model, the LBF model on medical images. The parameters of SLCVCF, LCV model and the LBF model are chosen as the third example. Segmentation results are obtained for medical images as shown in Fig. 4. The second column shows that segmentation results for the SLCVCF. The SLCVCF model can get better performance for the medical images with weak boundaries. The LCVCF model in the third column cannot extract target. In addition, the LCVCF model is more sensitive to initial contour, and the contour can quickly fall into the local minimum. The fourth and the fifth columns show the segment results of LCV and LBF models. Compared with the LCVCF, LCV and LBF models, our algorithms SLCVCF can drive satisfactory segmentation results at a faster convergence speed.

Fig. 4.
figure 4

Segmentation comparisons of the computation of the proposed algorithm SLCVCF and LCVCF, LCV, LBF model on medical images. The first column: given images. The second column: Final segmentation results of the proposed algorithm SLCVCF. The third column: Final segmentation results of the proposed algorithm LCVCF. The fourth column: Final segmentation results of LCV model. The fifth column: Final segmentation results of LBF model. Image size: 147 × 99, 128 × 128, 122 × 91.

Fig. 5.
figure 5

Segmentation comparisons of the computation of the proposed algorithm SLCVCF and LCVCF, LCV, LBF model. The first column: given images. The second column: Final segmentation results of the proposed algorithm LCVCF. The third column: Final segmentation results of the proposed algorithm SLCVCF. The fourth column: Final segmentation results of LCV model. The fifth column: Final segmentation results of LBF model. Image size: 100 × 87, 152 × 152, 111 × 94, 84 × 84, 118 × 93.

In the fifth example, we shall show the performance of the proposed algorithm LCVCF and SLCVCF, when comparing the proposed method with the LCV model, the LBF model on complex images. The parameters of SLCVCF are chosen as the fourth example. The parameters of LCVCF are chosen as, \( \lambda_{1} = \lambda_{2} = 255, \) \( \varepsilon = 1,\mu = 15,\nu = 0.4 \), for image (a) and (c) r = 15, σ = 45, Δt = 1.6, image (b) r = 15, σ = 45, Δt = 118.6, image (d) r = 25, σ = 45, Δt = 16.4, image (e) r = 35, σ = 45, Δt = 1.6. Segmentation results are presented for different types of complex images in Fig. 5 (the same initial evolving curve). The second column shows the segmentation results for the LCVCF. The LCVCF model can completely segment images with weak boundaries. The SLCVCF model in the third column can’t extract target. The fourth and fifth columns show that the LCV and LBF models can’t get a satisfactory segmentation model for images in some cases. Compared with the SLCVCF, LCV and LBF models, our algorithm LCVCF can achieve satisfactory segmentation results. Just as shown in Table 2, the SLCVCF algorithm use least time and iteration numbers, it couldn’t get satisfy results. The LCVCF algorithm use less time and iteration numbers for most cases, it can get better segment results than the LCV and LBF model.

Table 2. Comparison of the computation cost (times (s)) and iteration numbers of the proposed algorithm SLCVCF and LCVCF, LCV, LBF on images in Fig. 5

5 Conclusion

In this paper, we present a new model to segment image based on LCV model with the cosine fitting energy and give two algorithms of the new model. The LCVCF is an algorithm based on gradient decent method which can segment the image with the complex background. The SLCVCF is a fast algorithm based on a sweeping algorithm. For the SLCVCF, there is neither need to CFL condition nor re-initialize level set. It can avoid solving any partial differential equation. When the segment ends, the program terminates automatically. Furthermore, the distance regularization term doesn’t needed, which speeds up the energy functional optimization process, and makes the algorithm convergence very fast by using only some sweeping steps, which is very suitable to real-time applications. Successful and accurate segmentation results are obtained on synthetic and real images, and the speed is very fast when compared with the LCVCF algorithm. The results demonstrate the performance of the proposed algorithm SLCVCF and LCVCF in weak boundaries and serve intensity inhomogeneity, edge blurred and simple background image.

SLCVCF and LCVCF are the two algorithms of the local Chan Vese model by employing cosine fitting energy. The algorithm SLCVCF is very fast with some advantages, but it still has some shortcomings. For example, it can’t segment image with strong noise, complex images or texture images. Although the algorithm LCVCF is slow, it can segment the image with complex background. We will combine the proposed two algorithms with some new methods and image features to deal with those complex images. We will extend our algorithm to the multiphase segmentation model and segment the White Matter, Gray Matter and cerebrospinal fluid for MRI of brain image in future.