Keywords

1 Introduction

The medial axis is a shape representation tool that has been used in a wide variety of applications like pattern recognition, robotic motion planning [23], skinning for animation [14] and other domains as well. The notion of medial axis was originally proposed by Blum in 1967 [7] where it was defined as the set of points where different fire fronts meet.

In the continuous Euclidean space two definitions can be used to describe the medial axis [8]:

  • (a) the medial axis is formed by the center of balls included in the shape and not included in any other ball in the shape

  • (b) the medial axis consists of points that have more than one nearest points on the boundary of the shape.

In the state of art many methods were used to filter medial axis from some undesirable or spurious points or some branches [4, 5, 8, 10, 16]. Among those methods, we considered the method that uses filtering based on the bisector function [10].

The bisector function was introduced by Talbot and Vincent [22] where they generalize a notion proposed by Meyer [18]. Informally the bisector function associates to each point p of an object, the maximal angle formed by p and the points of the background that are nearest to p (Fig. 1 gives an example of the bisector function at two distinct point x and y). The first algorithms proposed to compute bisector function used vectors obtained from the distance transform [12]. One vector indicates the location of the closest background point. The main drawback of such algorithms [15, 22] is that points from a same distance may be ignored. In [11] authors proposed a new definition and algorithm to compute a discrete bisector function which was revisited and improved in [10] based on the use of Voronoi diagram of a shape. Authors noticed that the projection of the point is not sufficient due to some configurations in the discrete space and extended the notion of projection of a point to the extended projection (see Sect. 2).

Fig. 1.
figure 1

Example of the bisector function. \(\beta \) is the angle at point x and \(\alpha \) the angle at point y.

This paper contains one major contribution which is a new way to compute the bisector function based on an annulus and an algorithm to compute such bisector function based on digital annulus generation algorithm [2, 3]. We are mainly interested in this work at points having a high bisector angles since points belonging to a skeleton or important points of the medial axis are supposed to be center of a maximal ball that must hit the background in more than one point. Different filtering results are conducted on the bisector function and showed that as the filtering increases important point of the medial axis are detected. This article presents the method in 2D however it should be stated that this work can be extended to 3D and higher dimensions.

The paper is organized as follows: in Sect. 2 we provides some basic notions and definitions. In Sect. 3 we details our method of bisector function based on annulus, present the algorithm and provide some experimental results. The final sections state some conclusion and perspectives.

2 Basic Notions and Definitions

In this section we present some basic notions and definitions. Let us denote by \(\mathbb {Z}\) the set of integers, by \(\mathbb {N}\) the set of non-negative integers and by E the discrete plane \(\mathbb {Z}^2\). A point x in E is defined by \((x_1,x_2)\). Let \(x,y \in E\) be two points, we denote by \(d^2(x,y)\) the squared Euclidean distance between x and y. Let \(Y\subset E\), we denote by \(d^2(x,Y)\) the square of the Euclidean distance between x and the set Y, that is \(d^2(x,Y)=min\left\{ d^2(x,y);y\in Y\right\} \). Let \(X \subset E\) (the object), we denote by \(D^{2}_{X}\) the map from E to \(\mathbb {N}\) which associates, to each point x of E, the value \(D^{2}_{X}(x)=d^2(x,\overline{X})\), where \(\overline{X}\) denotes the complementary of X (the background). The map \(D^{2}_{X}\) is called the squared Euclidean distance map of X. Let \(x \in E\), \(r\in \mathbb {N}\), we denote by \(B_r(x)\) the ball of (squared) radius r centered on x, defined by \(B_r(x)=\left\{ y\in E, d^2(x,y)<r\right\} \). Note that the value \(D^{2}_{X}(x)\) is the radius of a ball centered on the point \(x \in X\) and not included in any other ball centered on x and included in X.

The considered discrete neighborhood \(N_4\) is defined as follows :

$$N_4(x)=\left\{ y\in E;\left| y_1-x_1\right| +\left| y_2-x_2\right| \le 1\right\} $$

Let X be a non empty subset of E and let \(x\in X\), the projection of x on \(\overline{X}\) [10], denoted by \(\varPi _{\overline{X}}(x)=\left\{ y\in \overline{X},\forall z\in \overline{X},d(y,x)\le d(z,x)\right\} \). For example, in Fig. 2, \(\varPi _{\overline{X}}(x)=\left\{ a,b\right\} \) and \(\varPi _{\overline{X}}(y)=\left\{ c\right\} \).

Let X be a non empty subset of E and let \(x\in X\), the extended projection of x on \(\overline{X}\) [10], denoted by \(\varPi ^{e}_{\overline{X}}(x)\) is the union of the sets \(\varPi _{\overline{X}}(y)\), for all \(y \in N_4(x)\) such that \(d^2(y,\overline{X})\le d^2(x,\overline{X})\).

Fig. 2.
figure 2

An object X (represented by the ellipse) and its medial axis. The projection of the point x is \(\left\{ a,b\right\} \) and the projection of the point y is \(\left\{ c\right\} \). The ball centered on y is included in another ball (the dashed ball) and thus y does not belong to the medial axis of X.

3 Bisector Function Based on Digital Annulus

In this section we detail our method for computing the bisector function using an annulus, describe the algorithm used and present the results.

3.1 Digital Annulus

A digital annulus \(\mathbb {A}(C,r,w)\) is defined by an offset of thickness \(\omega \) on a 2D regular square grid [2, 3]:

$$\begin{aligned} \mathbb {A}(C,r,\omega ) = \left\{ (i,j) \in \mathbb {Z}^2 : r^2 \le (i-C_x)^2 + (j-C_y)^2 < (r+\omega )^2\right\} \end{aligned}$$
(1)

Where \(C(C_x,C_y)\in \mathbb {R}^2\) is the center and \(r+\frac{\omega }{2} \in \mathbb {R}\) is the radius. In this work we refer to r as the inner radius.

In this work \(C(C_x,C_y)\in \mathbb {Z}^2\) since we are considering integer coordinates of the image as X. We also need to include the equality from both sides of (2) for practical reasons. This gives us the equation of an annulus of thickness \(\omega \) represented by the following equation:

$$\begin{aligned} \mathbb {A}_w(C,r,\omega ) = \left\{ (i,j) \in \mathbb {Z}^2 : r^2 \le (i-C_x)^2 + (j-C_y)^2 \le (r+\omega )^2\right\} \end{aligned}$$
(2)

3.2 Bisector Function: New Definition and Exact Algorithm

Definition 1

Annulus projection : Let X be a non empty subset of E and let \(x\in X\), the annulus projection of x on \(\overline{X}\), is given by:

$$\begin{aligned} A\varPi ^{\omega }_{\overline{X}}(x)=\left\{ y\in \overline{X},D^2_X(x)\le d^2(x,y)\le \left( D_X(x)+\omega \right) ^2\right\} \end{aligned}$$
(3)

where \(\omega \) is the thickness of the annulus and \(D_X(x)\), as stated in Sect. 2, is the value of the distance map at point x. (See Fig. 3c).

Now we can propose a definition of the bisector function.

Definition 2

Bisector angle and bisector function: Let \(X\subset E\), and let \(x\in X\). The bisector angle, denoted by \(\varphi ^{\omega }_{X}(x)\) of x in X, denoted is the maximal unsigned angle between the vectors \(\overrightarrow{xy}\), \(\overrightarrow{xz}\), for all y, z in \(A\varPi ^{w}_{\overline{X}}(x)\). The bisector function of X, denoted by \(\varphi ^{\omega }_{X}\), is the function which associates to each point x of X, its bisector angle in X.

Fig. 3.
figure 3

(a) A set X. (b) Distance transform \(D^2_X\) of X. A point x encircled in black and its extended projection [10], points encircled in red; the bisector angle \(\theta _X(x)\) at point x is \(\pi \) (c) Annulus projection of x on \(\overline{X}\), \(A\varPi ^{\omega }_{\overline{X}}(x)\) represented by the points encircled in dashed red; the bisector angle \(\varphi ^{\omega }_{X}\) at x is also \(\pi \). (Color figure online)

The last step to obtain the bisector angle is the computation of the maximum unsigned angle between all the pairs of vectors \(\overrightarrow{xy},\overrightarrow{xz}\) for all y, z in \(A\varPi ^{\omega }_{\overline{X}}(x)\). As stated in [10, 11] this problem reduces to the problem of finding the maximum diameter of a convex polygon in 2D which has been solved in [21] by a linear time algorithm.

Fig. 4.
figure 4

a, b and c show three original images of an ellipse, a flower and a square with their medial axis colored blue. d, e and f show the bisector functions \(\varphi ^{\omega }_{X}\) obtained using an annulus of width \(\omega =1\). (Color figure online)

Figure 3a shows an original set X, Fig. 3b shows the extended projection [10, 11] of the point x encircled in black on \(\overline{X}\); the resulting points are encircled in dashed red. Figure 3c shows an example of the annulus projection of the point x (encircled in black) on \(\overline{X}\) using a thickness \(\omega =1\); the resulting points are encircled in dashed red.

Figure 4a, b and c show three original images of an ellipse, a flower and a square extracted form the digital library DGtal [1] with their medial axis colored blue computed using the exact euclidean medial axis algorithm of [19]. Figure 4d, e and f show the bisector function \(\varphi ^{\omega }_{X}\) computed using a thickness \(\omega \) of 1.

figure a
Fig. 5.
figure 5

The result of different filtering angle \(\varphi ^{\omega }_{F}\) applied on the bisector function \(\varphi ^{\omega }_{X}\) of the flower of Fig. 4b the filtering value is \(\varphi ^{\omega }_{F}\) in radians. We can notice that when \(\varphi ^{\omega }_{F}\) is too small we have noisy contour that disappear when \(\varphi ^{\omega }_{F}\) increases.

3.3 Algorithm

This section presents two different algorithms that allow to compute the bisector function based on annuli. The algorithms to compute the bisector function are based on the information of the distance map generated by a distance map algorithm [13, 17, 20]. Let us first start by the naive algorithm that is obvious but has a high time complexity and then present a second algorithm based on a slightly modified digital annulus generation algorithm adapted to our annuli definition with a “‘\(\le \)”’ on both side of the equation as stated in Sect. 3.1.

Naive Algorithm. The naive algorithm consists in taking for every point \(x(x_1,x_2)\) of the set X a square window of size \(\left( D_{X}(x)-\omega ,D_{X}(x)+\omega \right) \), centered at the point x and computing \(A\varPi ^{\omega }_{\overline{X}}(x)\) which means all the points of \(\overline{X}\) that are inside the annulus \(\mathbb {A}_\omega (C,D_{X}(x),\omega )\). This algorithm has a high time complexity that depends directly on the size of the annulus.

Fig. 6.
figure 6

The result of fixing the filtering angle \(\varphi ^{\omega }_{F}\) to 1.8 and varying the thickness from \(\omega =0.75\), \(\omega =1\), \(\omega =1.25\). As we can see that a width \(\omega =0.75\) is not sufficient to compute a correct angle and some important information are missed.

Fig. 7.
figure 7

(a) The result of [10, 11] with an angle \(\theta _{F}=1.3\). (b) our approach with \(\varphi ^{\omega }_{F}=1.3\) and \(\omega =1\).

Algorithm Based on Incremental Digital Annulus Generation. We can decrease the time complexity by looking only into points inside the annulus using the incremental digital annulus generation algorithm detailed in [2, 3]. It should be noted that in our case we use double equality from both side of the equation and therefore the algorithm of [2, 3] should be slightly adapted to our case; also the thickness can vary however this is not a problem since one can think of generating digital annulus one after another when the thickness increases. For example for thickness \(\omega =2.7\) and inner radius r we must generate points inside digital annulus of inner radius r and \(\omega =1\), then those inside digital annulus of inner radius \(r+1\) and \(\omega =1\) (Lines 7 and 8 of Algorithm 1) and then those inside annulus of inner radius \(r+2\) and \(w=0.7\) (Lines 9–11 of Algorithm 1). Algorithm 1 shows the detailed algorithm for computing annulus projection of a point x on \(\overline{X}\) the inner radius of the digital annulus at point x is determined by \(D^2_{X}(x)\). As we can see when w is less or equal to 1 one annulus is generated and Algorithm 2 is called only once. When w increases, Algorithm 2 may be called many times depending on the integer part of w denoted by \(w*\). Algorithm 2 details the digital annulus generation of [2, 3] adapted to our application. The starting point of the algorithm is the point \((x_d,y_d)\)=(0,\(\left\lceil r \right\rceil \)), the algorithm generates all points inside annulus of radius 1 and that belong to \(\overline{X}\), however when w is less than 1 only points inside annulus thickness and belonging to \(\overline{X}\) are added (Lines 5–9). One can also benefit from the symmetry condition of digital annulus and generate points only in the first octant and then apply the eight symmetry (Line 6 of Algorithm 2 eightsymmetry) to points to generate points in other octants.

3.4 Results and Discussion

This section details the results obtained using our algorithm. We tested different filterings based on the bisector angle \(\varphi ^{\omega }_{X}\) and studied also the effect of changing the width of the annulus. The original images used for the testing are shown in Fig. 4 a, b and c.

For experiments, let us denote by \(\varphi ^{\omega }_{F}\) the filtering angle applied on the bisector function \(\varphi ^{\omega }_{X}\) which consists in setting to black all points \(x\in X\) having an angle \(\varphi ^{\omega }_{X}(x)\) less than \(\varphi ^{\omega }_{F}\) (the display of the images takes into account the value of the angles). Let us denote also by \(\theta _{F}\) the filtering angle applied on the bisector function of [10, 11].

Fig. 8.
figure 8

(a) The result of [10, 11] with an angle \(\theta _{F}=2.0\). (b) our approach with \(\varphi ^{\omega }_{F}=2.0\) and \(\omega =1\). (c) our approach with \(\varphi ^{\omega }_{F}=2.0\) and \(\omega =1.25\).

Figure 5 shows the effect of the filtering applied on the bisector function of the flower for different \(\varphi ^{\omega }_{F}\) and a fixed annulus width \(\omega =1.0\). We can see in this image that for small angles we have some noisy contours and as \(\varphi ^{\omega }_{F}\) increases, this noisy effect disappear. For every image the angle is increased to see the filtering effect. When the angle is too high we lose some important information that we would like to preserve. It should be noted also that one could imagine to omit points with small distances to have only the points inside the image and not close to boundary however for our experiments we kept all the points and didn’t omit any point.

Fig. 9.
figure 9

(a) The result of [10, 11] with an angle \(\theta _{F}=2.3\). (b) our approach with \(\varphi ^{\omega }_{F}=2.3\) and \(\omega =1\). (c) our approach with \(\varphi ^{\omega }_{F}=2.3\) and \(\omega =1.25\).

Figure 6 shows the effect of changing the thickness while fixing \(\varphi ^{\omega }_{F}\) to 1.8 applied on the three images of ellipse, flower and square. The three thickness considered are 0.75, 1.0 and 1.25. We can see that a small thickness, less than 1, is not sufficient for most of the images since we lose some important information or branches. When the thickness increases we could capture more points which give us some nice branches.

Figure 7a and b shows a comparison of the result of [10, 11] with the annulus approach proposed in this paper. The filtering angle \(\theta _{F}\) and \(\varphi ^{\omega }_{F}\) are equal to 1.3 and the annulus thickness is fixed to 1. We can notice that our approach produced some noisy contours compared to [10, 11]. When \(\theta _{F}\) and \(\varphi ^{\omega }_{F}\) increases to 2.0 while keeping the same thickness of 1, we can notice that noise almost disappears as shown in Fig. 8.

Figure 8a shows the result of [10, 11] with an angle \(\theta _{F}=2.0\) and Fig. 8b and c shows our result for \(\varphi ^{\omega }_{F}=2.0\) and a thickness of respectively \(\omega =1\) and \(\omega =1.25\). We can see that as the filtering angle increases we have better result than [10, 11] and increasing the thickness can compensate for some information loss. Figure 9 shows the same result as Fig. 8 but with \(\theta _{F}=2.3\) and \(\varphi ^{\omega }_{F}=2.3\).

Figure 10b and c shows a comparison of our approach with the approach of [10, 11] with filtering angle of 2.0 applied on Fig. 10a extracted from [1]. The points detected after filtering are the red ones and constitute a subset of the medial axis points; blue points represent the other points of the medial axis. Figure 11 shows the results of applying our method for filtering only medial axis points. The bisector function is thus applied only on the medial axis points. Blue points are points of the medial axis that are removed and red points are points kept.

Fig. 10.
figure 10

(a) original image (b) results of [10, 11] with an angle \(\theta _{F}=2.0\) (c) our approach with \(\varphi ^{\omega }_{F}=2.0\) and \(\omega =1\). The points detected after filtering are the red ones; blue points represent medial axis points of the image. (Color figure online)

Fig. 11.
figure 11

Applying our method only on the medial axis points: red points are points kept and blue points are points removed. (Color figure online)

3.5 Complexity and Extensions

In Sect. 3.3 we have proposed an incremental algorithm for digital annulus generation, that is less complex than the naive algorithm. The proposed algorithm is not linear in time: for each point x of the image, we are considering an annulus whose number of points is linear to the distance map \(D_{X}(x)\). Let us state that the thickness does not have a large influence on the complexity since it is expected to fluctuate between 0.5 to 2 so the range is limited and this changes the overall complexity only by a constant factor. As for higher dimensions the generation of a digital hypersphere is well known and is dimensions dependent, we expect the approach to be feasible for moderate image size. We would like also to state the possibility to improve the time complexity of the algorithm when the filtering angle is known in advance. This idea remains theoretical; more tests are needed to prove its results and convergence. The idea is to memorize for each point x of the object the closest background point when computing the distance map. Once this information is memorized, filtering the image according to a known bisector angle \(\varphi ^{w}_{X}\) can be done while looking only at a small subsection of the annulus and neglecting the other parts making thus the computation quasi linear.

4 Conclusion

We introduced a way to compute the discrete bisector function based on an annulus. This approach shows some promising results for filtering skeletons. The results were most promising when the angles become bigger. This method can be extended to 3D and higher dimensions since both the notion of bisector function as well as digital annulus are defined in arbitrary dimensions. One of the perspectives of this work is to use homotopic thinning process and compute skeleton in 2D and higher dimension based on the bisector function information. It should be noted also that filtering using only the angle criteria is most of the time not sufficient [6] and some works combining angle and distance criteria such as [8, 9] would be also a future perspective of this work.