An Approach to the Computation of the Euler Number by means of the Vertex Chain Code

We present an approach to compute the number of holes in binary images using the Vertex Chain Code (VCC); the VCC was developed for representing and analyzing 2D shapes composed of cells. Using this code, it is possible to relate the outer to inner vertices of any 2D shape and to ﬁ nd interesting properties. Now, in this paper, we describe more properties of the VCC, such as the computation of the connected regions in a hole, the analysis of complementary chains, the computation of the number of holes in a binary shape or image, the computation of the Euler number, and the detection of convex and concave shapes. Finally, in order to illustrate the capabilities of proposed methods, we present the computation of topological properties of examples of objects of the real world.


Introduction
This work focuses on image representation by means of the Vertex Chain Code (VCC) [1], in order to obtain different properties of binary shapes, such as the computation of the connected regions in a hole and the computation of the Euler number.Also, the study of the geometrical and topological properties of binary shapes is an important topic in computer vision and pattern recognition.The Euler number or genus is a basic topological property of shapes.The Euler number is a fundamental feature in many applications: in character recognition, in graph theory, in the computation of porosity of objects, in biological imaging, in the recognition of industrial parts [2], and so forth.
In order to compute the Euler number, some authors have used the VCC [1].For instance, Wulandhari and Haron [14] proposed an interesting approach to compute the Euler number by means of the chain elements.They analyzed shapes with only one hole and obtained two VCC chains of the outer and inner boundaries of the analyzed shape.Afterwards, they add all chain elements and compare with the number of elements of both chains multiplied by two.approach to compute the Euler number by means of the VCC.They count the number of both "1" and "3" vertices and compute the number of holes by a simple formula.In Ref. [16], the authors propose two equations based on the pixel geometry and connectivity properties, which can be used to efficiently compute the Euler number of a binary digital image with either thick or thin boundaries.Despite computing this feature, the authors' technique extracts the underlying topological information provided by the shape pixels of the given image.The correctness of computing the Euler number using the new equations is also established theoretically.The performance of the proposed method is compared against other available alternatives.Experimental results on a large image database demonstrate that the authors' technique for computing the Euler number outperforms the earlier approaches significantly in terms of the number of basic arithmetic operations needed per pixel.Both equations are specialized only for 4connectivity cases.
In order to present our approach to the computation of the Euler number, we use some concepts of the VCC.The VCC of a 2D shape composed of side-connected pixels is based on the number of pixel vertices which are in touch with the bounding contour of the shape.Among the main properties of the VCC, we can mention the following: (1) The VCC elements represent real values not symbols such as other chain codes, are part of the shape, and indicate the number of pixel vertices of the contour nodes, for instance, a chain which has no elements "3" represents a convex shape.(2) Using the VCC, it is possible to represent shapes composed of triangular, rectangular, i.e., squared (pixels), and hexagonal cells.(3) The VCC is invariant under translation and rotation and optionally may be invariant under starting point and mirroring transformation.(4) In order to define a chain element, most chain codes use information of the previous ones (mainly, the chain codes which are invariant under rotation).Thus, if a chain element is missing, next chain elements are affected.On the other hand, VCC is more robust to missing data because each chain element does not depend on a previous one.
In this work, we present the computation of the connected regions in a hole, the analysis of complementary chains, the computation of the number of holes in a binary shape or image, the computation of the Euler number, and the detection of convex and concave shapes.This paper is organized as follows.In Section 2, we present some concepts and definitions.Section 3 describes shapes without holes.Section 4 gives an analysis for shapes with holes.In Section 5, we describe the computation of the Euler number via the VCC.Section 6 presents some results of the computation of topological features of objects of the real world and a comparison of the proposed techniques with other previous methods.Section 7 shows computational comparative analyses.Finally, in Section 8, we give some conclusions.

Concepts and Definitions
In order to introduce our approach to the computation of the number of holes in binary images via the VCC, a number of concepts and definitions are presented below: (i) Shape is referred to as shape-of-object, and an object is considered to be a geometric entity composed of side-connected pixels [17], i.e., pixels with fourconnectivity.There are two ways of connecting pixels: four-connectivity and eight-connectivity.In the content of this paper, we only consider pixels with four-connectivity (ii) Binary shape is a shape in which each pixel takes either the value zero or the value one [18].Generally speaking, in the content of this paper, shape is referred as binary shape (iii) The length of all the sides of pixels is considered equal to one (iv) A chain A is an ordered sequence of elements and is represented by where n indicates the number of chain elements (v) An element a i of a chain indicates the number of pixel vertices, which are in touch with the bounding contour of the shape in that element position An important consideration is the assumption that an entity has been isolated from a digital image of the real world.This is called the shape and is defined as a result of previous processing.Shapes are composed of side-connected pixels, i.e., pixels with four-connectivity.In order to obtain the VCC of a 2D shape, Figure 1 illustrates an example of a discrete 2D shape.Figure 1(a) shows the abovementioned example of a shape composed of pixels.Figure 1(b) presents the chain elements and its chain of the shape illustrated in (a).The origin of the chain is represented by a circle in the abovementioned shape, and the arrow indicates the direction of the encoding.Note that there are only three different numbers of pixel vertices for the bounding contour: "1," "2," and "3."

Shapes without Holes
In this subsection, we present an analysis for 2D shapes without holes by means of the VCC.Definition 1.The outer vertices V1, V2, and V3 of a shape correspond to the number of vertices "1," "2," and "3" (respectively) of the chain which represents the bounding contour of the shape.
The numbers of the outer vertices of the shape shown in Figure 1 Proof.There are four possible cases of vertices: the outer vertices "1," "2," and "3" and the inner vertices "4" (see Figure 2).For the base case, when the shape has only one pixel we have m = 1, V1 = 4, V2 = 0, V3 = 0, and V4 = 0.By direct calculation, using Equation (1), we have For the next pixel added and depending on the four possible cases, Equation ( 1) is satisfied.
For example, substituting the values of the outer and inner vertices of the shape shown in Figure 1(a), where the number of pixels m is equal to 15, Equation ( 1) is satisfied.Using Equation ( 1), the number of inner vertices V4 is defined as follows: Theorem 4. The perimeter P of a shape without holes is equal to the sum of the numbers of its outer vertices, i.e., Proof.Trivial.
For example, the perimeter of the shape shown in Figure 1(a) is equal to 24.  3 Computational and Mathematical Methods in Medicine Theorem 5.For any discrete shape composed of m pixels.If V3 = 0, then the shape is convex.

Proof. Trivial.
A convex shape is a shape which lies entirely in one-half plane of any line containing one of its sides; otherwise, it is concave [19].Corollary 6.For any discrete shape composed of m pixels.If V3 ≠ 0, then the shape is concave.
Proof.Trivial.For example, using Corollary 6, the shape shown in Figure 1 corresponds to a concave shape.Theorem 7.For any discrete shape (without holes) composed of pixels, the number of vertices V1 is equal to the number of vertices V3 plus 4, i.e., Proof.Any chain must have at least four elements "1"; this is due to the fact that only closed shapes are considered and they are composed of pixels.For the base case, when the shape has only one pixel, we have V1 = 4 and V3 = 0. Therefore, Equation ( 5) is satisfied.For the next steps, we have to add more pixels.There are only five possible ways to add pixels for generating no hole in the analyzed shape: Figure 3(a) shows the most primitive shape only composed of one pixel.1 and V3 was incremented by 1, too. Figure 3(d) shows the third case, where both variables V1 and V3 were incremented by 2. Figure 3(e) presents the fourth case, where V1 and V3 were decremented by 1. Finally, Figure 3(f) illustrates the fifth case, where both variables V1 and V3 were decremented by 2. Thus, Equation ( 5) is satisfied for all cases, which we know is true.Yip and Klette [20] presented angle counts for isothetic polygons and polyhedra.Thus, any isothetic simple polygon can be partitioned into a finite number of isothetic rectangles.In our case, our approach only considers discrete shapes composed of pixels.
We present an important theorem, which relates the sum of the chain elements to chain length (number of chain elements) for shapes (without holes) composed of pixels.This theorem was presented in [1]; however, in order to describe our proposed approach, this theorem should be considered.
Theorem 8.For any shape (without holes) composed of pixels.The sum of the chain elements of the shape is equal to 2n − 4, i.e., The proof of this theorem is not included.

Shapes with Holes
Definition 9.The complement of a chain of a shape composed of pixels is another chain (named complementary chain) whose elements "1" are replaced by "3" and vice versa.
Figure 4(a) shows a shape and its chain.Figure 4(b) illustrates the complementary chain of the chain presented in (a).Note that now the shape of the complementary chain is a hole preserving the same contour.
Definition 10.The complementary chain of a shape corresponds to a hole, in which the contour of the original object is preserved.For example, see Figure 4. Corollary 12.For any hole of a discrete shape composed of pixels, the number of vertices V3 is equal to the number of vertices V1 plus 4, i.e.,  5), and the concept of the complement of a shape, Corollary 12 is proved.Klette and Rosenfeld [21] described the "proper hole" which corresponds to a hole with four-connectivity.On the other hand, they also defined the "improper hole" with eight-connectivity.Thus, we recommend that all the shapes and their inner complements (holes) should consider sideconnected ("proper holes").Figure 5 shows an invalid case of a hole.Figure 5(a) illustrates an example of a shape with an "improper hole." Figure 5(b) shows the "improper hole," this is due to the fact that the "improper hole" has no fourconnectivity.

How to Compute the Euler Number via the VCC
Based on the concepts of the number of the outer vertices V1 and V3, Equation ( 5), and the approach proposed in [15], we have the following theorem.
Theorem 13.The number of holes H of any shape composed of side-connected pixels is defined as follows: Proof.For the base case, when the shape has only one hole, we have V1 = 4 and V3 = 4 (see Figure 6).Therefore, using Equation ( 8), H = 1.For the next holes in the same binary  Computational and Mathematical Methods in Medicine shape, according to Equation ( 7), V3 − V1 will be incremented by 4 for each new hole in the shape.Figure 6(b) presents the same shape shown in (a) now with two holes, (c) with three holes, (d) with four holes, and (f) with five holes, respectively.In each new step, V3 − V1 is incremented by 4, which we know is true.
Theorem 14.The number of holes H of any binary image composed of side-connected pixels is defined as follows: where C corresponds to the number of connected regions.
Proof.The proof of this theorem is similar like the proof of Theorem 13, just considering the variable C. Substituting H from Equation ( 9) in the Euler-number equation E = C − H, we have.
For example, for the shape shown in Figure 1(b), V1 = 11 and V3 = 7, in this case, C = 1 because we only have a connected region.Substituting these numerical values in Equation (9), H = 0 which is true; this shape has no hole.Therefore, the Euler number of the abovementioned shape is equal to one, i.e., E = 1. Figure 7 illustrates four examples of the computation of the Euler number.Figure 7(a) presents an example of a binary shape without holes, where V1 = 20,   Proof.This is proved by direct calculation using Equation ( 8).
Corollary 16.For any binary image, if the number of vertices V1 is equal to the number of vertices V3, i.e., V1 = V3, then the Euler number is equal to zero, i.e., E = 0 Proof.This is proved by direct calculation using Equation (10).

How to Compute the Number of Connected Regions without Holes in a Hole
Theorem 17.The number of connected regions without holes C in any "proper hole" is defined as follows: Proof.Refer to proof of Theorem 14. Figure 8 illustrates an example of connected regions in a hole.The hole shown in Figure 8 has three connected regions, where V1 = 31 and V3 = 23.Using Equation (11), we obtain that the number of connected regions (without holes) is equal to three, i.e., C = 3.

Results
In order to illustrate the capabilities of the proposed method, we present two different applications: the first one, the computation of the number of holes of a slide of a piece of polyurethane; and the second one, two examples which show the Euler number computation applied to two images of single segments from tumorous glands of cribriform cases of prostate cancer (PCa).

Computation of the Number of Holes in Polyurethanes.
Polyurethanes are polymers composed of units of organic chains joined by carbamate links.Flexible polyurethane foams are used as cushioning for a great variety of commercial products, such as bedding, furniture, packaging, carpet underlay, and in the automotive industry.In this kind of materials, it is important to know the number of holes and the hole sizes.Thus, using the proposed method, we will compute the numbers of holes of a slide of a piece of polyurethane.This is due to the fact that the proposed method only works in the 2D domain.In order to have a digital representation of this kind of objects, a previous process was developed.Thus, Figure 9 shows an example of a piece of polyurethane.Figure 10 illustrates the voxels of the piece of polyurethane shown in Figure 9; the 3D array of voxels is equal to 150 × 150 × 150. Figure 11 shows the bubbles in the polyurethane presented in Figure 10; note that these bubbles have different sizes.Finally, Figure 12 shows a slide of the object illustrated in Figure 10; notice that this slide corresponds to the first slide of the front of the object.Thus, the slide shown in Figure 12 is considered a binary image.Using the proposed method, the number of holes was computed and is equal to   method to obtain the Euler number of a binary object via its skeleton; the number of terminal points and the number of three-edge points in the graph are used to compute this invariant.In [13], the concept of the contact perimeter [22] was used to compute the Euler number.Thus, using the contact perimeter P c , the number of holes H for any unitwidth shape was defined by the following equation: where P is the perimeter of the shape.Note the similarity with Equations ( 8) and ( 12).Some authors have used the VCC to compute the Euler number.The aforementioned method presented in [14] is a fast algorithm to compute the Euler number.However, this method only considers shapes with one hole.Sossa-Azuela et al. [15] count the number of vertices "1" and "3" of the VCC and compute the number of holes by a simple formula.We based, in part, our approach on this technique.

Computational Comparative Analyses
In this section, we compare our proposed method with two of the methods reported in the literature.In particular, we compare our proposal against the method used by the commercial tool of MATLAB, which deploys the original algorithm introduced by Gray in [23], and the method described in [16].
The experiments were carried out on a Acer laptop with Intel, Core i7, 7th Generation, i7-7700HQ, 2.80 GHz, Quad-Core, and RAM 16GB; all the processes were computed on CPU, running under Windows 10 operating system; Figure 16 was used as the comparison example.Table 1 presents the complexity and execution time of the abovementioned methods.Note that the shortest execution time corresponds to the method proposed here.Furthermore, using the VCC notation, various shape features may be computed directly from this representation in an easy way.

Conclusions
We have found out more properties of the VCC.An important property of the VCC is that its chain elements represent real values not symbols such as other chain codes; they are    11 Computational and Mathematical Methods in Medicine part of the shape and indicate the number of cell vertices of the shape nodes.Thus, the VCC descriptor of any shape has all its geometrical information.We have concluded that it is possible to obtain a part of topological information of a shape by means of its VCC description.
A number of definitions, corollaries, and theorems were presented, which allowed us to find out interesting properties, such as the computation of the connected regions in a hole, the analysis of complementary chains, the computation of the number of holes in a binary image or shape, the com-putation of the Euler number, and the detection of convex and concave shapes.Finally, in order to prove the abovementioned concepts, we presented some examples of images of the real world.
Suggestion for further work would be to extend the VCC and the abovementioned concepts from 2D to 3D domain.

1 . 3 .
(b) are V1 = 11, V2 = 6, and V3 = 7. Definition 2. The inner vertices V4 of a shape correspond to the number of vertices "4" with the largest number of pixel vertices.These vertices do not belong to the vertices of the 2 Computational and Mathematical Methods in Medicine bounding contour; they belong to the interior of the shape and always have four neighbor pixels.The number of the inner vertices of the shape illustrated in Figure 1(b) is equal to 4, i.e., V4 = 4. Figure 2 shows the outer (Figure 2(a)) and inner vertices (Figure 2(b)) of the shape presented in Figure Theorem For any discrete shape composed of m pixels.The following equation is satisfied:

Figure 1 :
Figure 1: The VCC: (a) an example of a discrete 2D shape composed of side-connected pixels; (b) the chain elements defined by means of the VCC and its chain.

Figure 2 :
Figure 2: Vertices: (a) outer vertices of the shape illustrated in Figure 1; (b) inner vertices of the shape presented in Figure 1.

Figure 4 :
Figure 4: Complementary chains: (a) an example of a 2D shape and its outer vertices; (b) the complementary chain of the shape shown in (a).Now, this shape corresponds to a hole; (c) the set ∨, i.e., G ∪ G′ = ∨:

Figure 3 :
Figure 3: Proof of Theorem 7: (a) the basic case; (b-f) all possible cases.

Definition 11 .Figure 4
Figure 4 represents binary images as sets.Thus, if the binary image shown in Figure 4(a) corresponds to the set G, then the binary image described in Figure 4(b) corresponds to the complement of set G, represented by G′.Finally, Figure 4(c) represents G ∪ G ′ = ∨ (in set theory).

Figure 5 :
Figure 5: An invalid case: (a) an example of a 2D shape; (b) the inner complement (hole) of the shape shown in (a) which has no fourconnectivity.

Figure 6 :
Figure 6: Proof of Theorem 13: (a) a binary shape with one hole; (b-e) the shape shown in (a) with two holes (b), with three holes (c), with four holes (d), and with five holes (e), respectively.

Figure 7 :
Figure 7: Examples of the computation of the number of holes and the Euler number: (a) an example of a 2D shape, where H = 0 and E = 1; (b) an example of a binary shape with one hole, where H = 1 and E = 0; (c) an example of a shape, where H = 2 and E = −1; (d) an example of a binary shape with three holes, i.e., H = 3 and E = −2.

7Theorem 15 .
Computational and Mathematical Methods in Medicine V3 = 16, and C = 1; therefore, H = 0 and E = 1. Figure 7(b) shows an example where V1 = 16, V3 = 16, and C = 1; therefore, H = 1 and E = 0.Figure 7(c) presents another example, where V1 = 28, V3 = 32, C = 1, H = 2, and E = −1.Finally, for the shape shown in Figure 7(d), V1 = 18, V3 = 26, C = 1, H = 3, and E = −2, respectively.Note that the computation of the Euler number of the abovementioned examples was computed in an easy way by means of the number of vertices V1 and V3.Now, if we consider the four binary shapes of the abovementioned examples shown in Figure 7 as a unique binary image composed of four connected regions, we have C = 4, V1 = 82, and V3 = 90.Therefore, H = 6 and E = −2.For any binary shape, if the number of vertices V1 is equal to the number of vertices V3, i.e., V1 = V3, then this binary shape only has one hole, i.e., H = 1:

Figure 9 :
Figure 9: An example of a piece of polyurethane.

Figure 10 :
Figure 10: The voxels of the piece of polyurethane shown in Figure 9.

Figure 11 :
Figure 11: The bubbles in the polyurethane shown in Figure 10.

Figure 12 :
Figure 12: The front slide of the example of polyurethane shown in Figure 10.
[12]ods have been proposed by means of graphs, such as Chiavetta and Di Gesù[8]who presented a method of parallel computation of the Euler number via connectivity graph.Bishnu et al.[10]define a pipeline architecture for computing the Euler number of a binary image.Other methods are based on the skeleton representation; for example, Díaz-De-León and Sossa-Azuela[12]present a

Table 1 :
Comparison of abovementioned methods.