1 Introduction

Image vectorization is a classic problem with potential impacts and applications in computer graphic domains. Taking a raw bitmap image as input, this process allows us to recover geometrical primitives such as straight segments, arcs of circles and Bézier curved parts. Such a transformation is exploited in design softwares such as Illustrator or Inkscape in particular when users need to import bitmap images. This domain is large and also concerns document analyses and a variety of graphical objects such as engineering drawings [1], symbols [2], line drawings [3], or circular arcs [4]. Related to these applications, different theoretical advances are regularly proposed in the domains of pattern recognition and digital geometry. In particular, their focus on digital contour representations concerns various methodologies: dominant point detection [5, 6], relaxed straightness properties [7], multi-scale analysis [8], irregular isothetic grids and meaningful scales [9] or curvature-based approach [10].

These last advances are limited to digital shapes (i.e. represented within a crisp binary image). Indeed, even if a digital contour can be extracted from a non-binary image, their adaptation to other types of images such as greyscale and color images is not straightforward. There are other methods, which are designed to handle greyscale images; for example, Swaminarayan and Prasad proposed a method to vectorize an image by using its contours (from simple Canny or Sobel filters) and by performing Delaunay triangulation [11]. Despite its interest, the proposed approach does not take into account the geometrical characteristics of edge contours and other information obtained from low intensity variations. More oriented to segmentation methods, Lecot and Levy introduced an algorithm based on Mumford and Shah’s minimization process to decompose an image into a set of vector primitives and gradients [12]. Inspired from this technique, which includes a triangulation process, other methods were proposed to represent a digital image by using a gradient mesh representation allowing to preserve the topological image structure [13]. We can also mention the method proposed by Demaret et al. [14], which is based on linear spline over adaptive Delaunay triangulation or the work of Xia et al. [15] exploiting a triangular mesh followed of Bézier curves patch based representation. From a more interactive process, the vectorization method of Price and Barrett [16] was designed for interactive image edition by exploiting graph cut segmentation and hierarchical object selections.

In this article, we propose to investigate the solutions exploiting the geometric nature of image contours, and apply these advanced representations to handle greyscale images. In particular, we will mainly focus on recent digital-geometry based approaches of different natures: (i) the approach based on dominant point detection by exploiting the maximal straight segment primitives [6, 17], (ii) the one from the digital level layers with the algorithms proposed by Provot et al. [18, 19], (iii) the one using the Fréchet distance [20, 21], and (iv) the curvature based polygonalization [10].

In the next section (Sect. 2), we first present a strategy to reconstruct the image by considering the greyscale image intensities. Different strategies are presented with pros and cons. Afterwards, in Sect. 3, we recall different polygonalization methods. Then, we present the main results and comparisons obtained with different polygonalization techniques (Sect. 4).

2 Vectorizing Images from Level Set Contours

The proposed method is composed of two main steps. The first one is to extract the level set contours of the image. This step is parameterized by the choice of the intensity step (\(\delta _I\)), which defines the intensity variations from two consecutive intensity levels. From these contours, the geometric information can then be extracted and selected by polygonalization algorithms (as described in Sect. 3). The second step concerns the vectorial image reconstruction from these contours.

Step 1: Extracting Level Set Contours and Geometrical Information

The aim of this step is to extract geometrical information from the image intensity levels. More precisely, we propose to extract all the level set contours by using different intensity thresholds defined from an intensity step \(\delta _I\). For this purpose, we apply a simple boundary extraction method defined from an image intensity predicate and from a connectivity definition. The method is based on the definition of the Khalimsky space and can work in N dimension [22]. This algorithm has the advantage to be implemented in the DGtal library [23] and can be tested online [24].

Fig. 1.
figure 1

Extraction of the level set contours (b, c) from the input image (a) and sampling resulting contours (d)

Figure 1 illustrates such a level set extraction (Fig. 1(b, c)) with a basic contour sampling defined from a point selection taken at the frequency of 20 pixels (Fig. 1(d)). Naturally, the more advanced contour polygonalization algorithms, as described in section Sect. 3, will be exploited to provide better contours, with relevant geometrical properties.

Step 2: Vectorial Image Reconstruction

We explore several choices for the reconstruction of the resulting vectorial images: the application of a triangulation based process, a reconstruction from sequence of intensity intervals, and a component tree representation.

Representation from Delaunay triangulation: A first solution was inspired from the method proposed by Swaminarayan and Prasad [11], which uses a Delaunay triangulation defined on the edges detected in the image. However the strategy is different since the triangulation is performed after an extraction of the main geometric features like dominant points, curvature or Fréchet distance. The first direct integration of the triangulation was performed by using the Triangle software [25] and by reconstructing the image with the mean intensity represented in the triangle barycenter. Though, even if such strategy appears promising, the quality is degraded if we have a closer view to the digital structure, as illustrated for the DGCI logo in Fig. 2. To obtain a better quality of image reconstruction, the level set intensity has to be integrated into the reconstruction structure in order to make a better decision for the triangle intensity value.

Fig. 2.
figure 2

Illustration of the Delaunay based reconstruction from sampled level set contours: resulting mesh representation (a–c) and final vectorial rendering (d–f)

Representation by filling single intensity intervals: The filling of the polygonal region boundaries of the input image could be a possibility to obtain a better image reconstruction. For instance, the image in Fig. 4(a) can be reconstructed by filling inside the region \(\mathcal {R}_0\) defined from its borders (\(\delta ^0_{\mathcal {R}_0}\), \(\delta ^1_{\mathcal {R}_0}\), and \(\delta ^2_{\mathcal {R}_0}\)) and in the same way for the other regions \(\mathcal {R}_1\), \(\mathcal {R}_2\), \(\mathcal {R}_3\), \(\mathcal {R}_4\) and \(\mathcal {R}_5\). However, such a strategy may depend on the quality of the polygonalization, which has no guarantee to generate the polygonal contours with correspondence between the polygon vertices (according to the border of the current region and the border of their adjacent region). For instance, the vertices of the polygonal representations of \(\delta ^2_{\mathcal {R}_0}\) and \(\delta ^0_{\mathcal {R}_2}\) do not necessarily share the same vertices. Such limitations are illustrated in the Fig. 3(a–e) where numerous defects are present with null-color areas which are not filled by any color.

Fig. 3.
figure 3

Comparisons of the quality of the two reconstructions types: single intensity interval (a–e) and component tree based (f–j)

Component tree based representation: To overcome the limitations of the previous reconstruction, we propose to exploit a mathematical morphology based representation defined on the component tree [26, 27]. This method allows to represent an image by considering the successive intensity levels and by maintaining the tree representing inclusions of connected components. As an illustration, Fig. 4(d) shows such a representation with the root \(\mathcal {R}_0\) associated to the first level; it contains all the pixels of the image (with values higher or equal to 0). The edge between the nodes \(\mathcal {R}_4\) and \(\mathcal {R}_2\) indicates that the region \(\mathcal {R}_4\) is included in the region \(\mathcal {R}_2\).

With such a representation, each region is -by definition- included in its anchors and as a consequence a reconstruction starting from the root region can be executed without any non-filled areas (even with poor-quality polygonalization algorithms). As shown in Fig. 3(f–j), the reconstruction results have no empty-color region.

Fig. 4.
figure 4

Image border extraction from a simple intensity predicate (images (a–c)) and illustration of its component tree representation

Algorithm 1 describes the global process of the proposed method where we can use the different polygonalization methods that are detailed in the next section.

figure a

3 Overview of Polygonalization Methods

In the proposed vectorization method, the polygonalization step can play an important role in the resulting image quality. Before showing some results, we overview several methods with different principles.

3.1 Dominant Points Based Polygonalization

The polygonalization method proposed by Nguyen and Debled-Rennesson allows to find the characteristic points on a contour, called dominant points, to build a polygon representing a given contour. The method consists in using a discrete curve structure based on width \(\nu \) tangential cover [28] (see Fig. 5(a)). This structure is widely used for studying geometrical characteristics of a discrete curve. More precisely, the width \(\nu \) tangential cover of a contour is composed of a sequence of all maximal blurred segments of width \(\nu \) [29] along the contour. Using this structure, a method proposed in [6, 17] detects the dominant points of a contour. The key idea of the method is that the candidates to be dominant points are located in common zones of successive maximal blurred segments. By a simple measure of angle, the dominant point in each common zone is determined as the point having the smallest angle with respect to the left and right endpoints of the left and right maximal blurred segments constituting the common zone. Then, the polygon representing the contour is constructed from the detected dominant points (see Fig. 5(b)). In the next section the acronym DPP will refer to this method.

Fig. 5.
figure 5

(a) Width 2 tangential cover of a curve. (b) Dominant points detected on the curve in (a) and the associated polygonal representation. (c) Polygonalization result based on Fréchet distance

3.2 DLL Based Polygonalization [18, 19]

A method of curve decomposition using the notion of digital level layers (DLL) has been proposed in [18, 19]. Roughly speaking, DLL is an analytical primitive which is modeled by a double inequality \(-\omega \le f(x) \le \omega \). Thanks to this analytic model of DLL, the method allows a large possible classes of primitives such as lines, circles and conics.

Based on a DLL recognition algorithm, the method consists in decomposing a given curve into the consecutive DLL and, by this way, an analytical representation of the curve is obtained. Figure 6 illustrates the DLL decomposition using line, circle and conic primitives. As the shape contains many line segments and arcs, the decompositions based on circle and conic primitives uses less primitives than the one with line primitives.

Fig. 6.
figure 6

Decomposing results of DLL based method using different primitives

3.3 Fréchet Based Polygon Representation

Using the exact Fréchet distance, the algorithm proposed in [20, 21] computes the polygonal simplification of a curve. More precisely, given a polygonal curve P, the algorithm simplifies P by finding the shortcuts in P such that the Fréchet distance between the shortcut and the associated original part of the curve is less than a given error e. As a consequence, this method guarantees a minimum number of vertices in the simplified curve according to the Fréchet distance and a maximal allowed error e (see Fig. 5(c)).

3.4 Visual Curvature Based Polygon Representation

The method was introduced by Liu, Latecki and Liu [10]. It is based on the measure of the number of extreme points presenting on a height function defined from several directions. In particular, the convex-hull points are directly visible as extreme points in the function and a scale parameter allows to retain only the extreme points being surrounded by large enough concave or convex parts. Thus, the non significant parts can be filtered from the scale parameter. The main advantage of this estimator is the feature detection that gives an interesting multi-scale contour representation even if the curvature estimation is only qualitative. Figure 7 illustrates some examples.

Fig. 7.
figure 7

Illustration of the visual curvature obtained at different scales

4 Results and Comparisons

In this section, we present some results obtained with the proposed method using the previous polygonalization algorithms. Figure 8 shows the results with their execution times (t) in link to the number of polygon points (#). The comparisons were obtained by applying some variations on the scale parameter (when exists: \(\nu \) for DPP, e for Fréchet) and on the intensity interval size s (\(s=255/iStep\), with iStep of Algorithm 1). From the presented results, we can observe that the Fréchet polygonalization methods provides a faster reconstruction but contains more irregular contours. By comparing DLL and DPP, the DLL looks, at low scale, slightly smoother than the others (Fig. 8(a) and (f)). The execution time mainly depends of the choice of the input parameter s and the choice of the method (see time measure given in Fig. 8). Due to page limitation the results obtained with the visual-curvature based polygonalization method are not presented but they can be obtained from an Online demonstration available at:

http://ipol-geometry.loria.fr/~kerautre/ipol_demo/DGIV_IPOLDemo/

Fig. 8.
figure 8

Experiments of the proposed level set based method on the Lena image with three polygonalization algorithms: (a–d) dominant points (DPP), (e–h) digital level layers with line primitive (DLL) and (i–l) Fréchet distance based

To conclude this section we also performed comparisons with Inkscape, a free drawing software [30] (Fig. 9). We can observe that our representation provides fine results, with a lighter PDF file size.

Fig. 9.
figure 9

Comparisons of vectorization obtained with Inkscape and Fréchet (resp. DLL) based vectorization (first row, resp. second row).

5 Conclusion and Perspectives

Exploiting recent advances from the representation of digital contours, we have proposed a new framework to construct a vectorial representation from an input bitmap image. The proposed algorithm is simple, can integrate many other polygonalization algorithms and can be reproduced online. Moreover, we propose a vectorial representation of the image with a competitive efficiency, w.r.t. Inkscape [30]. This work opens new perspectives with for instance the integration of the meaningful scale detection to filter only the significant intensity levels [31]. Also, we would like to evaluate the robustness of our approach with different polygonalization algorithms, by testing images corrupted by noise.