A view of computational models for image segmentation

Image segmentation is a central topic in image processing and computer vision and a key issue in many applications, e.g., in medical imaging, microscopy, document analysis and remote sensing. According to the human perception, image segmentation is the process of dividing an image into non-overlapping regions. These regions, which may correspond, e.g., to different objects, are fundamental for the correct interpretation and classification of the scene represented by the image. The division into regions is not unique, but it depends on the application, i.e., it must be driven by the final goal of the segmentation and hence by the most significant features with respect to that goal. Thus, image segmentation can be regarded as a strongly ill-posed problem. A classical approach to deal with ill posedness consists in incorporating in the model a-priori information about the solution, e.g., in the form of penalty terms. In this work we provide a brief overview of basic computational models for image segmentation, focusing on edge-based and region-based variational models, as well as on statistical and machine-learning approaches. We also sketch numerical methods that are applied in computing solutions to these models. In our opinion, our view can help the readers identify suitable classes of methods for solving their specific problems.


Introduction
Image segmentation is a fundamental task of image processing, image analysis, image understanding, and pattern recognition.It has a very long history, whose origin may be dated back to about 50 years ago.A seminal paper is [1], where the authors pointed out that an important component of the Stanford Research Institute automation project was a set of programs providing the automaton with a means of interpreting visual data.
While it is possible to accurately represent the information in a real scene by an image, this representation alone does not enable us to highlight specific properties of the scene.Conversely, a description in terms of "natural" elements of the image, such as regions and boundaries of the visualized objects, represented in a uniform manner, provides easy access to useful global information, thus allowing recognition and extraction of specific image features.Thus, to generate a description of specific elements of the image, it is customary to segment the image into more parts (or segments).Figure 1 shows an example of two main types of segmentation, i.e., instance segmentation, which identifies the object instance of each pixel for every known object within an image, and semantic segmentation, which identifies the object category of each pixel for every known object within an image.
Image segmentation is used in many application fields, such as medical imaging [2], microscopy imaging [3], remote sensing [4], and document image analysis [5].The choice between semantic and instance segmentation is generally dependent on the goal of the classification or object detection step that follows the segmentation phase.For example, in the segmentation of terrain in satellite imagery, we may use the semantic segmentation to distinguish different land areas, like vegetation, ground, water and building, or we may use the instance segmentation to distinguish different common weeds in agricultural fields (i.e., separate instances of objects belonging to the same class).
Since different applications may require different partitions to extract significant features, there is no single standard method for image segmentation.Thus, the segmentation problem has not a unique result, as shown in Figure 2, where different segmentations of the same image are shown, resulting from different segmentation criteria.On the other hand, different methods are not equally effective in segmenting a specific type of image (real scenes, synthetic images, medical images, etc.), and the criteria to define a successful segmentation depend on the desired goal of the segmentation itself.Therefore, segmentation remains a challenging problem in image processing and computer vision, in spite of several decades of research.We present image segmentation as a highly ill-posed problem, and discuss basic models that take into account a-priori information about the solution, attempting to put these models into a coherent mathematical framework.We look at the inclusion of a-priori information as a sort of regularization approach and show that it is ubiquitous in image segmentation models, from older "classical" ones to machine learning approaches, revealing links and similarities between them.Note that we focus on basic models in order to keep our discussion easy and get rid of technical details.We also sketch some numerical methods used in the application of the various models.Although this is only a simplified and partial view of image segmentation, we believe that it may give a contribution towards a better understanding of this huge field.
The rest of this paper is organized as follows.In Section 2 we present a mathematical formulation of image segmentation, and in Section 3 we discuss basic segmentation models, focusing on edge-based, region-based, statistical and machine learning ones.In Section 4 we give a quick overview of numerical techniques that may be used to solve the aforementioned models.Finally, we give some conclusions in Section 5.

Mathematical formulation of image segmentation
Let I be the set of the images defined in a domain Ω ⊂ R d (d ≥ 2), I 0 ∈ I the observed image, and P 1 , . . ., P n logical predicates used to check n statements, expressed using features of the image, e.g., edges, smoothness, texture or color, so that P k (A) = true if all the points of A ⊆ Ω satisfy the k-th statement.Just to give an example, in order to compute a two-region segmentation of a normalized gray-level image I 0 , we can define n = 2 simple statements as follows, which involve the gray level of the intensity light to separate the background from the foreground: where I * is a suitable approximation of I 0 and α ∈ (0, 1) is a suitable value.Generalizing the definition in [6], the instance segmentation S of I 0 according to the predicates P k , k = 1, . . ., n, consists of finding a decomposition of Ω into m components Ω i , with i = 1, . . ., m and m ≥ n, such that 4. ∀i ∈ {1, . . ., m} ∃! k ∈ {1, ..., n} such that i. P k (Ω i ) = true; ii.P k (Ω i Ω j ) = false, ∀ j ∈ {1, . . ., m} with j = i.
we also obtain the semantic segmentation.
We can define the segmentation S of I 0 as follows too.Let Σ be the set of possible segmentations of the images in I according to some criteria defined by the predicates P k .Then S can be expressed as where u * is a curve that matches the boundaries of the decomposition of Ω, i.e., u * = ∪ i ∂Ω i 1 , and I * is a piecewise-smooth function defined on Ω that approximates I 0 .In particular, we may assume that the restriction of I * to any set • Ω i is piecewise differentiable.The segmentation S may be also identified directly by using a labeling operator Φ, i.e., where is the value of I associated with x, and l i ∈ N = {l 1 , l 2 , . . ., l m } is a label.

Basic segmentation models
We look at image segmentation as an ill-posed problem, whose solution is highly undetermined.Classical approaches for computing a solution of an illposed problem require additional information that enforces uniqueness and stability.To this end, suitably defined penalty terms can be applied.Then, the solution is obtained by minimizing an energy functional E containing a fidelity term F that measures the consistency of the candidate segmentation with the observed image, and a penalty term P that promotes solutions with suitable properties: Here λ > 0 is a parameter that generally needs careful tuning to suitably balance F and P (see, e.g., [7] and the references therein).
The minimization problem (2) can be solved by writing the Euler-Lagrange equations, which can be derived by integrating by parts the energy functional and using the Gauss theorem along with the fundamental lemma of the calculus of variations.Then a numerical solution can be computed by applying a gradient descent approach, where the descent direction is parameterized through an artificial time, and by a finite-difference discretization.A widely used and effective alternative consists in discretizing problem (2) and then solving it by a numerical optimization method.We will come back to these two approaches in Section 4.
Recently, machine learning techniques have been successfully applied to segmentation problems.The key idea is to tune a generic model to a specific solution through learning against sample data (training data).The learning phase extracts prior information to be embedded into the penalty term from a large dataset containing pairs of type (image, ground-truth label) [8].Machine learning approaches using unlabeled image data as training datasets are also available.Although these techniques successfully solve image segmentation problems, sometimes outperforming state-of-the-art variational models, they have been often designed on-demand for specific tasks used as "black-box" models and require a large amount of data to produce results.
In the next subsections we provide some examples of image segmentation models.Note that we focus on basic models, with the aim of providing a general idea of these approaches while avoiding technical details that are outside the scope of this work.It is also worth observing that these models are the basis of modern ones, developed either to improve the effectiveness of the original models in some applications [9] or to complement and refine Machine Learning techniques for segmentation [10].

Edge-based models
Edge-based models aim at finding u * = ∪ i ∂Ω i by solving the minimization problem (2) with respect to the curve u (note that I and I * are not explicitly considered in this case).These models include the so-called Active Contours [11] or Snakes.Here the fidelity and regularization terms act as an internal force and an external force, respectively, which move the curve within the image to find the boundaries of the sets Ω i .More precisely, the energy functional takes the form where I 0 is the observed image, g is an edge-detector function and the curve u is parametrized by s ∈ [0, 1].The first term attracts the curve toward the boundaries, whereas the second one controls its smoothness, and as a result the curve u changes its shape like a snake.The evolving curve is driven by surface properties, such as curvature and normal direction, and by image features, such as gray levels, hue or saturation in color images, and intensity gradient in 2D images or change in slope in 3D ones.For example, the mean curvature can be used and in this case the edgedetector function is also responsible for stopping the curve on the edges.The function g may be defined as where g is a positive and decreasing function, G σ is the Gaussian kernel with standard deviation σ, and * denotes the convolution operator.
In a Lagrangian approach, an initial curve is evolved by where L is a differential operator.The simplest evolution is given by L(u) = F N , where N is the normal to the curve and F is a constant that determines the speed of evolution.More generally, the evolution is driven by an external force.For example, in the mean-curvature evolution, L(u) = κN , where κ is the Euclidean curvature of u [12].When u has an explicit representation, it is not easy to deal with topological changes like merge and split, and a re-parametrization of the curve may be required.Therefore, the evolution of the curve u is commonly described by level-set methods [13], thanks to their ability to follow topology changes, cusps and corners.In a level set approach, the curve u is implicitly represented by the zero-level set of a function φ(t, x), i.e., u = {x ∈ Ω : φ(t, x) = 0}.The level set formulations of the simplest evolution and the mean-curvature one read, respectively:

Region-based models
Region-based models provide directly the segmentation by means of the image partition {Ω i , i = 1, . . ., m}.Region-growing models are among the simplest models falling in this class, and in order to obtain accurate segmentations they have been merged with variational approaches where the evolution changes according to the minimization of an energy functional including region-based terms [14].
A very popular region-growing model was proposed by Mumford and Shah [15].In this case, the functional E in (2) takes the form where len(u) denotes the length of u, and λ and µ are positive parameters.The term F attempts to achieve the minimum distance between I 0 and its piecewise-smooth approximation I, and P attempts to reduce the variation of I within each set Ω i while keeping the curve u as short as possible.Minimizing (5) in a suitable space provides an optimal pair (I * , u * ) representing a simplified description of I 0 by means of a function with bounded variation and a set of edges [15].Finally, in [16] the Mumford and Shah model is formulated as a deterministic refinement of a probabilistic model for image restoration.
A simplified version of the Mumford-Shah model is its restriction to piecewise-constant functions.The Chan-Vese model [17] is a particular case of the simplified version, aimed at obtaining a two-phase segmentation where the piecewise-constant function assumes only two values.Its functional E takes the following form: where H is the Heaviside function and c in and c out are the average values of the intensity in the foreground and background of the image, respectively.The solution I * is the best approximation to I 0 among all the functions that take only two values.Minimizing ( 6) is a nonconvex problem, thus solution methods may get stuck into local minima and result in unsatisfactory segmentations.Aiming to overcome this drawback, some strategies have been proposed, including the convexification of the functional by taking advantage of its geometric properties.An example is given by the two-phase partitioning model introduced by Chan, Esedoḡlu and Nikolova [18]: with 0 ≤ I ≤ 1 and c in , c out > 0.

Statistical models
Statistical models usually provide a conditional probability, P (S|I 0 ), of a segmentation S ∈ Σ given the observed image I 0 , and then select the segmentation with the highest probability.In the Maximum a Posteriori (MAP) approach the segmentation is given by According to the Bayes rule, P (S|I 0 ) = P (I 0 |S)P (S) P (I 0 ) , where P (S) is the prior probability measuring how well S satisfies certain properties of the given image, and P (I 0 |S) is the conditional probability measuring the likelihood of I 0 given S (see, e.g., [19]).Since the probability P (I 0 ) is constant, the segmentation can be obtained by maximizing P (I 0 |S)P (S).Markov Random Field (MRF) models offer a framework to define prior and likelihood by capturing properties of the image such as texture, color, etc. [20].The segmentation is formulated within an image labeling framework, i.e., S = Φ(I(x)), where the problem is reduced to find the labeling which maximizes the posterior probability.Label dependencies are modeled by an MRF.Then, using the Hammersley-Clifford theorem, we get the Gibbs distribution where the energy function U takes the form

Machine learning models
Machine learning approaches, and in particular deep learning ones, are more and more used in solving image segmentation problems, also outperforming the previous approaches.Roughly speaking, machine learning approaches do not benefit from prior information on the solution as described above, but "learn" the segmentation from large training datasets.The aim of a machine learning approach is to define a segmentation model f θ : I −→ Σ such that the segmentation of I 0 can be obtained as I * = f θ (I 0 ).The function f θ is usually nonlinear and θ is a large vector of parameters.The learning phase selects θ in order to minimize a loss functional L that measures the accuracy of the predicted segmentation f θ (I 0 ).In supervised machine learning, training data are available from databases of annotated segmentations, which provide a large number of pairs (I 0 , I * ) ∈ X × Y ⊂ I × Σ (X × Y is named training set).The vector of parameters θ is obtained by minimizing a loss function plus a penalty term.For the sake of simplicity, we first consider a mean-square-error loss: Another widely used loss functions is the Binary Cross Entropy (BCE) loss, which measures the difference in information content between the actual and the predicted image segmentation: It is based on the Bernoulli distribution and works well with equal data distributions among classes.Some variants of BCE, such as the Weighted BCE and the Balanced CE are also used for tuning false negatives and false positives, respectively.The Shape-aware (Sa) loss calculates the average point-to-thecurve Euclidean distance among points around the curve of the predicted segmentation, u * , to the ground truth, ū, and use it as a coefficient to the cross-entropy (CE) loss function: where Σ contains the set of points where the prediction curve does not match the ground-truth curve, and E i = d(u * i , ūi ).The Dice loss, based on the wellknown Dice coefficient metric, is also widely used to measure the similarity between two segmentations, and is defined as In unsupervised machine learning, the training set is not equipped with annotated segmentations and the goal is to train f θ to recognize specific patterns or image features in the data.This approach is sometimes referred to as self-supervised learning [21], because the information is extracted from the data themselves rather than from a set of "predictions" (i.e., given segmentations).Then the fidelity term in (8) takes the form where Φ is the labeling operator defined in (1).
In order to progressively extract higher-level features from the data, machine learning models use a multi-layer structure called neural network, consisting of successive function compositions.The number of layers is the depth of the model, hence the terminology deep learning.A neural network with L layers is a function where f i : R di−1 × H i −→ R di are the activation functions (each depending on a component θ i of θ), d 0 = d and d L = n, with n equal to the number of features.The adjective "neural" comes from the fact that those networks are loosely inspired by neuroscience.
Neural network structures successfully used in image segmentation are the Multilayer Perceptron (MLP), the Deep Auto-Encoder (DAE) and the Convolutional Neural Network (CNN) [22][23][24].Their basic schemes are shown in Figure 3.The MLP is a neural network connecting multiple layers in a directed graph, which means that the signal path through the nodes only goes one way.Each node, apart from the input nodes, has a nonlinear activation function.An MLP uses backpropagation as a supervised learning technique.The DAE network structure typically consists of 2L layer functions, where the first L layers act as an encoding function with the input to each layer being of lower dimension than the input to the previous layer, and the remaining L layers increase the size of their inputs until the final layer has the same dimension as the image input.The first L layers are an MLP.CNNs divide the image into small areas and scan it one area at a time, to identify and extract features that are used to classify the image.A CNN mainly consists of three layers: • convolutional layer : the image is analyzed a few pixels at a time to extract low-level features (edges, color, gradient orientation, etc.); • nonlinear layer : an element-wise activation function creates a feature map with probabilities that each feature belongs to the required class; • pooling or downsampling layer : the amount of features and computations in the network is reduced, hence controlling overfitting.

Numerical techniques for segmentation models
The minimization in ( 2) is usually nontrivial and requires appropriate methods, taking into account the specific application.In this section we provide a brief summary of numerical methods that can be applied to segmentation models.We consider two approaches: first discretize then optimize and first optimize then discretize.In the former, all the quantities in (2) are discretized a priori and then optimization methods are applied to the resulting minimization problem in R n .In the latter, we first write optimality conditions for (2), which are generally partial differential equations (PDEs), and then solve those equations by suitable numerical methods, which discretize the equations.Finally, we also sketch some filtering techniques used in image segmentation, although they are not directly applied to the minimization problem (2).This is motivated by their use in some segmentation approaches, such as those based on deep learning.
We also identify each pixel with its center and denote by S i,j the value of S in (i, j).Finally, we consider the forward and backward difference operators defined as follows: where we assume i.e., we define by replication the values of I with indices outside Ω nx,ny .Likewise, for 3D images the discretization of the image domain consists of a grid of n x × n y × n z voxels, Ω nx,ny,nz = {(i, j, k) : i = 1, ..., n x , j = 1, ..., n y , k = 1, ..., n z }, and the forward and backward difference operators are defined as follows: For simplicity, henceforth we consider d = 2.

First discretize then optimize
Numerical optimization offers a large variety of methods to compute the segmentation by solving the minimization problem coming from a discretization of (2), possibly subject to constraints that can drive the segmentation towards particular features.The choice of the optimization method depends on the properties of the objective function and/or the constraints.
Roughly speaking, at iteration k, optimization methods for nonlinear problems generate a function E(I; I k ) that approximates the discretized objective function E around I k , and minimize it to obtain the next iterate (see, e.g., [28]).For example, given I k , the (k + 1)-st iteration may be written as Define E(I; I k ) that approximates E(I; I 0 ) where the step length α k satisfies some criterion.
"Classical" optimization techniques, such as gradient or Newton-type methods, require regularity assumptions on the objective function (and the constraints, if any).However, many segmentation models are modeled as nonsmooth optimization problems.There are two main approaches to deal with non-differentiability: smoothing and non-smoothing [29].The former formulates the problem as a suitable smooth one and applies the aforementioned classical optimization methods.The latter does not modify the mathematical model, and thus uses methods not requiring smoothness.For the purpose of illustration, here we focus on (7), where non-smoothness comes from a discretization of the TV term.
A regularized discrete TV may be obtained as follows: where > 0 is "suitably small", but other regularized versions may be considered, e.g., based on Huber-like functions [30].In this case, gradient and higher-order methods [31][32][33][34][35] can be used efficiently.Another way of introducing smoothness consists in splitting the variables into their positive and negative parts (thus doubling the number of unknowns) and introducing new constraints, and then applying first-or higher-order methods for smooth problems, such as in [36][37][38].
Non-smoothing approaches avoid regularization of the non-smooth terms in the optimization problem.This is the case, for example, of methods based on forward-backward splitting techniques, such as proximal-gradient methods [39,40], and the forward-backward Expectation Maximization (EM) method in [41].ADMM and split Bregman methods do not use smooth approximations too [7,[42][43][44][45][46].The success of these approaches is based also on the availability in closed (and cheap) form of the proximal operator of the 1 norm by means of the well-known soft-thresholding, defined as [S(x, γ)] i,j = sign(x i,j ) • max |x i,j | − γ, 0 , with γ > 0. The difficulties associated with the non-differentiability of the TV functional may be also overcome by reformulating the minimization problem as a saddle-point problem and solving it by a primal-dual algorithm such as the Chambolle-Pock one [47,48].
EM algorithms [49] are also widely used to solve statistical models.They are based on the idea of splitting the (negative) log-likelihood into two terms and alternating between the computation of the expectation and its minimization.
Finally, stochastic versions of the previous methods are used in segmentation with deep learning, to limit the computational cost.The idea is to use only random samples of the data at each iteration, to estimate first-order and possibly second-order information according to the loss function, with the aim of significantly reducing the computation and hence the time [50,51].

First optimize then discretize
Reducing imaging problems to PDEs is many years old, because of the availability of a large amount of methods and software for solving PDEs.PDE-based methods have been introduced in different ways, such as the Perona-Malik filtering [52], directly based on properties of the PDE [53], and the axiomatic scale space theory [54,55].
In a variational approach, one derives the first-order optimality conditions via smoothing regularization, if it is needed.Let us consider, for example, the level-set formulation of the Chan-Vese model (6), where I is represented by a function φ such that φ(x) = 0 provides the curve separating two regions of I (when I = I * the two regions identify the segmentation).Keeping c in and c out fixed and writing the Euler-Lagrange equations in a gradient-flow approach, we get where δ ε is a regularized version of the Dirac measure, φ 0 is the initial-level function, and N is the exterior normal to the boundary ∂Ω [17].
Finite-difference schemes are popular methods for the numerical solution of (9).Of course, the discretization used in image segmentation must take into account the nature and the properties of the operators involved in the model.For example, edge preserving is similar to shock capturing in computational fluid dynamics, and hence finite-difference schemes based on hyperbolic conservation laws can be used [56].Just to give an example, the level-set equation ∂φ ∂t = F |∇φ| in Subsection 3.1 can be solved by using an upwind numerical scheme:

Filters
Discrete filters are often used in image segmentation, e.g., in machine learning approaches.A digital filter can be represented as an operator where W ij ⊂ Ω nx,ny .A popular discrete filter in image segmentation is the convolution filter, defined by Edge-detection kernels are frequently used in image segmentation, especially in CNNs.For example, the first layer of a CNN is often responsible for capturing low-level features such as edges, color, and gradient orientation.In general, the choice of H determines the type of features to be extracted.The kernel matrix is a vertical edge-detection kernel [57].Another example is the Sobel operator, used to create an image emphasizing the edges [58].It allows us to obtain either the gradient amplitude or the gradient direction of the image intensity at each point, by convolving the image with the kernel matrices The gradient magnitude, G, and the angle of orientation of the edges, θ, are given by |G i,j | = (H x S * I) 2 i,j + (H y S * I) 2 i,j , θ i,j = arctan((H y S * I) i,j /(H x S * I) i,j ).
A padding process is commonly used to preserve the dimension of the image after the convolution.It usually consists in the replication or reflection of the pixel values at the image border, or in adding an average gray or even zeros symmetrically around the border of the image.A pooling layer is usually inserted between two successive convolution layers, which is obtained by applying basic functions, such as max and mean, in a small window.

Conclusion
We presented a view of image segmentation, focusing on simple computational models and attempting to put them into a coherent framework where the inclusion of a-priori information about the solution is obtained by using penalty terms.We first introduced image segmentation and then outlined basic edge-based, region-based, statistical and machine learning models.We also sketched some numerical methods that can be employed to compute solutions to the models.We believe that our view of models and methods for image segmentation, although very far from being exhaustive, can help the readers understand much modern and sophisticated segmentation techniques, as well as select computational tools for their problems.

Fig. 1 Fig. 2
Fig. 1 Illustration of instance and semantic segmentation of the Berkeley database image #323016.The results displayed in (a) and (b) were produced by using Adobe Photoshop.
the set of cliques of S, V c (S c ) is the potential of the clique c ∈ C having the label configuration S c , and Z is a normalizing constant.The conditional probability P (I 0 |S) can be modeled by a Gaussian distribution.Then the original MAP estimation is equivalent to the following energy minimization problem: S * = arg max S P (S|I 0 ) = arg min S U (S).

Fig. 3
Fig. 3 Some neural network architectures used in image segmentation.

1 2 and b ≤ ny− 1 2,
,b [I; W i,j ] = t I i−s,j−t ,(10) with a and b positive integers such that a ≤ nx−W i,j = {(s, t) : s = −a, . . ., a, t = −b, . . ., b}, and h s,t ∈ R. The matrix H = (H i,j ) = (h −a+i,−b+j ) ∈ R (2a+1)×(2b+1) is called kernel matrix and depends on the features we want to extract from the image.Common choices of a and b are a = b = 3 and a = b = 5.