Special Issue

## Operations Research in Engineering Problems: Potential Applications and Perspectives

View this Special Issue

Research Article | Open Access

Volume 2021 |Article ID 5582034 | https://doi.org/10.1155/2021/5582034

Gergely Kovács, Benedek Nagy, Gergely Stomfai, Neşet Deni̇z Turgay, Béla Vizvári, "On Chamfer Distances on the Square and Body-Centered Cubic Grids: An Operational Research Approach", Mathematical Problems in Engineering, vol. 2021, Article ID 5582034, 9 pages, 2021. https://doi.org/10.1155/2021/5582034

# On Chamfer Distances on the Square and Body-Centered Cubic Grids: An Operational Research Approach

Revised30 Mar 2021
Accepted03 Apr 2021
Published22 Apr 2021

#### Abstract

Linear programming is used to solve optimization problems. Thus, finding a shortest path in a grid is a good target to apply linear programming. In this paper, specific bipartite grids, the square and the body-centered cubic grids are studied. The former is represented as a “diagonal square grid” having points with pairs of either even or pairs of odd coordinates (highlighting the bipartite feature). Therefore, a straightforward generalization of the representation describes the body-centered cubic grid in 3D. We use chamfer paths and chamfer distances in these grids; therefore, weights for the steps between the closest neighbors and steps between the closest same type points are fixed, and depending on the weights, various paths could be the shortest one. The vectors of the various neighbors form a basis if they are independent, and their number is the same as the dimension of the space studied. Depending on the relation of the weights, various bases could give the optimal solution and various steps are used in the shortest paths. This operational research approach determines the optimal paths as basic feasible solutions of a linear programming problem. A directed graph is given containing the feasible bases as nodes and arcs with conditions on the used weights such that the simplex method may step from one feasible basis to another one. Thus, the optimal bases can be determined, and they are summarized in two theorems. If the optimal solution is not integer, then the Gomory cut is applied and the integer optimal solution is reached after only one Gomory iteration. Chamfer distances are frequently used in image processing and analysis as well as graphics-related subjects. The body-centered cubic grid, which is well-known in solid state physics, material science, and crystallography, has various applications in imaging and graphics since less samples are needed to represent the signal in the same quality than on the cubic grid. Moreover, the body-centered cubic grid has also a topological advantage over the cubic grid, namely, the neighbor Voronoi cells always share a full face.

#### 1. Introduction

Grids have a significant role not only in crystallography, material science, and solid state physics but also in various engineering applications, e.g., in image processing and in digital geometry [1]. There is a large variety of ways to tessellate the plane and the three dimensional space. Regular grids in 2D are the square, the hexagonal, and the triangular grids, and the only regular grid in 3D is the cubic grid [2, 3]. The square and the cubic grids are most popular grids since their coordinate systems are the Cartesian coordinate systems. They are considered as the traditional grids. One of the earliest results on the square grid is the introduction of chessboard and cityblock motions which is given in [4]. The dual of the square grid is again a square grid, whereas the hexagonal and the triangular grids are duals of each other. The hexagonal grid has a useful symmetric coordinate frame, and every pixel, also called hexel [5], has six neighbors. The triangular grid is also described by the symmetric coordinate system. The useful descriptions of these grids by three coordinates are given in [68]. These two regular grids are also studied from various points of view such as topological/combinatorial coordinate systems [9] and applied in discrete tomography [5, 10, 11].

Irregular grids are also applied in various places, e.g., triangulation in computer graphics. These grids are usually ad hoc and miss any type of structure. On the other hand, there are various well-structured grids. Two of the nontraditional grids in 3D are the body-centered Cubic (BCC) and the face-centered cubic (FCC) grids. They provide structures of various solid materials, and thus they play crucial importance in crystallography. They are alternative to the cubic grid in various engineering applications. These grids have many application areas, e.g., image processing [12], visualization [13], and topology preserving digitization [14]. It is worth noting that the FCC and BCC grids are point lattices. Further, BCC and FCC grids are generalizations of the hexagonal grid to 3D. Especially, in the hexagonal grid, there is only one usual neighborhood relation among the hexagon-shaped tiles/pixels, and two neighbor hexagons share a full side. The BCC grid generalizes this property to 3D, i.e., both of the used types of neighbor relations are among voxels such that either a full hexagon face or a square face is shared between the neighbor voxels. This topological advantage of the BCC grid can be used, e.g., by combinatorial coordinate systems in boundary tracking [15]. Moreover, the BCC grid is proven to have some better properties in applications than the cubic grid [1618] highlighting the importance of our study. In electronic imaging, it is important what kind of mesh we scan the object according to. BCC grid is often used for this purpose [19]. Further, the BCC grid also plays an important role in the latest chapters of material science [20].

In 2D, one of the irregular grids is the Khalimsky grid. In this grid, the 4-neighbor and the 8-neighbor relations are used for the points of the grid, alternately, depending on their positions. Khalimsky’s topology on the integers is introduced by Efim Khalimsky [21, 22]. This topology is a digital counterpart of the Euclidean topology on the real line and is useful in connection with digital geometry. Digital geometry of the 2D Khalimsky grid is studied, e.g., in [23].

In digital geometry, the distance between two points is defined by the number of steps in a shortest path connecting these points [1, 3, 4]. An algorithm which finds the shortest path and also their number between arbitrary two points in the square grid is given in [24]. Distance on the hexagonal grid is computed in [25]. Moreover, in [8], an algorithm, which produces the shortest path between two arbitrary points of the hexagonal grid is introduced. Weighted distances play also an important role in image processing, e.g., morphological filtering [26]. Weighted distances (chamfer distances) are also studied in various grids [23, 27, 28]. One may think about to finding a minimal path (and so, to determine the digital distance) as an optimization problem. We should note here that there are various shortest path algorithms in graph theory and in artificial intelligence [29], but those algorithms, e.g., Dijkstra algorithm (see, e.g., in [1]), are very general and do not take into account the very definite structures of the grids used in digital geometry. For this reason, both of their space and time complexities are much worse than the complexities of some more specific algorithms ([8]) and computations. Our aim here is to provide direct formulae for the distance computation.

Another important subject of our work is linear programming. Linear programming is an optimization problem. The objective function is linear, the constraints are linear equations, and the variables are nonnegative. The linear programming was discovered by George Dantzig in 1947. He published the simplex method in 1949 [30]. It is still one of the most effective methods of linear optimization. A great advantage of the simplex method is that its theory is a complete geometric description of the structure of the problem. In this paper, the results are based on the optimality criterion of the method. It is important to know that if optimal solution exists, then an optimal solution must exist among finitely many points. They are the so-called basic feasible solutions. Each such point belongs to a linear basis of the columns of the matrix of the equation system.

In the next section, as a preliminary part, we recall the simplex method and the Gomory cut [31] from operational research. In this paper, the 2D square grid and the 3D BCC grid are studied. Their formal description is given in Section 3. Both of these grids are bipartite grids (according to the new concept, we investigate in Subsection 3.1). Actually, we use an unusual description of the square grid which is somewhat related to the coordinate system we have invented for the Khalimsky grid (see, e.g., [23]). In this novel representation that we named as “diagonal square grid,” the closest neighbor points are represented by coordinates with different parities (see the details in Subsection 3.2). Although the square grid is the most known, the new description gives us a new way of view that allows us to make an analogous study in nontraditional higher dimensional grids, as we do also in the 3D BCC grid. Section 4 shows our linear programming model for each grid in its subsections, respectively. Depending on the relation of the weights assigned to the two types of neighbors, various bases could give the optimal solution, i.e., various types (and directions) of steps could be used in the shortest paths. If the optimal solution is not integer (one case of both problems), then the so-called Gomory cut cuts the noninteger solutions, and the integer optimal solution is reached after only one Gomory iteration. Our theorems can easily be applied by knowing the fixed weights for the two types of neighbors; the distance of any two points can be computed directly, as we show it in examples. It is widely known that weighted distances were already studied both in the square and the BCC grids; however, our approach has not been applied yet, by giving a nice relation between digital geometry and linear programming. Moreover, our approach, up to our knowledge, is more general than the study, e.g., in [32, 33] since the case when closest neighbors get a larger weight than the second closest neighbors is not studied yet in detail for the BCC grid. In this way, our results also complement the previous knowledge on this field. Finally, the paper is closed by a concluding section.

#### 2. Methods: On the Simplex Method and the Gomory Cuts

The simplex method of linear programming solves an optimization problem given in the form as follows:where A is an m × n matrix, b is an m-dimensional vector, c is an n-dimensional vector of constants, and x is the n-dimensional vector of variables.

The constraints determine a polyhedral set. What is called the corner point in the usual geometry is called extreme point here. A point is an extreme point of the polyhedral set if it is the only intersection point of the polyhedral set and a hyperplane. The extreme points of the polyhedral set of the linear programming problem are the so called basic feasible solutions. For the sake of simplicity, assume that the rank of matrix A is m. Let B be a subset of the columns of A such that the vectors of B form a basis. The matrix formed from the elements of B is an m × m matrix. It is also denoted by B. Assume that matrix A and vector x are partitioned accordingly, i.e., A = (B, N) and . The basic solution of basis B is obtained if x satisfies the equation system, and its xN part is 0. It can be obtained as follows:

Hence,

Thus, the xB part of the basic solution is B−1b. The basic solution is feasible if B−1b ≥ 0.

An important consequence of the linearity, that if optimal solution exists, then at least one basic feasible solution is optimal.

Roughly speaking, the finite versions of the simplex method start from a basic feasible solution. It improves the solution by stepping to another basic feasible solution along an edge of the polyhedral set. It repeats this step until it recognizes that the current extreme point is optimal. This property also proves that the set of edges of a convex polyhedral set is a connected graph.

Gomory’s method of integer programming is based on the observation that the basic variables are expressed by the other variables in the form of the equation system (3). Assume that one of this equation iswhere K is the index set of the nonbasic variables. Assume further on, that di0 is noninteger. It is the current value of the integer variable xi. Let fj be the fractional part of the coefficient, i.e., the fractional part of dtj:

Let us substitute these quantities into the equation. If the equation is rearranged such that all terms which are integer for sure are in the left-hand side, the new form of the equation is obtained as follows:

Hence,

All the coefficients of this relation are between 0 and 1. Thus, the two sides can be congruent only if the value of the right-hand side is in the set {f0, f0 + 1, f0 + 2, … }. Hence, the inequalitymust be satisfied. This inequality is not satisfied by the current basic feasible solution as the values of the variables in the sum are all 0. This inequality is the Gomory cut.

#### 3. Formal Descriptions of the Diagonal Square Grid and the BCC Grid

In this paper, we are focusing on two grids, the first is the 2D square grid but with a nontraditional description, while the second one is the body-centered cubic grid. We use a nontraditional view to represent the square grid in such a way that its description generalizes to 3D exactly in a way that produces a description of the BCC grid.

##### 3.1. On Bipartite Grids

One may connect the closest neighbor point pairs of a grid by edges. Therefore, grids can be seen as infinite graphs with a kind of regular, periodic structure. Various grids could have various (graph-theoretic) properties. We call a graph and thus also a grid “bipartite” if there it does not contain any odd cycle. It is easy to see that the square grid is bipartite, and this well-known property is reflected, e.g., by the coloring of a chessboard: the two partitions of the points (i.e., pixels and fields in the usual square grid terminology) are colored by two different colors, e.g., black and white. The cubic and also the BCC grids are bipartite, as well as, the triangular and the diamond grids (moreover, these two latter grids are not point lattices, the relation of the two partitions—called also types or parities of the points in these cases—does not provide closure under translations). On the other hand, it is also easy to show grids which are not bipartite, e.g., the hexagonal or the FCC grids (in both of these grids, 3 cycles—i.e., triangles—exist among closest neighbor points). Now, for bipartite grids, it is interesting to see what is the grid structure of the partitions and what is the type of the subgrids. At the case of triangular grid, each of the partitions of the even and odd points forms a hexagonal subgrid. The even and odd points of the diamond grid have the structure of two separate FCC subgrids. The two partitions of the BCC grid are cubic subgrids. Finally, each partition of the square grid is again a square grid. In the next subsection, by showing an unusual coordinate system for the square grid, we underline its bipartite property.

##### 3.2. The Diagonal Square Grid: Reflecting the Bipartite Property of the Grid

We use a 45° rotation of the usual square grid, and we call this representation and description as the diagonal square grid (see Figure 1). The two coordinates are used in a similar manner, as we have described the so-called Khalimsky grid in [23, 34], but in this paper, we consider every point/pixel of the grid with the same connectedness, i.e., the same neighborhood. In this way, although the coordinate pairs of the represented points/pixels are similar to those that are used for the Khalimsky grid, our description fits to the square grid, which is in fact, a regular grid and it represents a point lattice at the same time. We note here that in the mentioned papers, integer coordinate pairs addressed half of the points of the grid, while coordinate pairs having value integer plus a half the other half of the points. In contrast to this, here, we prefer to use only integer coordinates (by multiplying each of the Khalimsky coordinates by 2); thus, we have two subgrids as follows. The even-subgrid is built up by the points (or squares, depending on the representation used) addressed by a pair of even coordinates. The odd-subgrid is built up by points addressed by odd coordinate pairs. Consequently, we call the points even or odd depending on the fact which subgrid they belong. It is worth noting that both the even and the odd subgrids are square grids themselves, and our grid which is the union of these two subgrids is also a square grid. The traditional 4-neighborhood relation consists of pairs of points that are different types and closest to each other (i.e., always an even and an odd point). They are depicted by vectors (±1, ±1). Additionally, the traditional 8-neighborhood contains also the pairs of the closest same type points (i.e., two even or two odd points). They are described by vectors (±2, 0) and (0, ±2). In Figure 2, part (a) shows also a part of this grid (in the dual representation, showing “grid points”—i.e., midpoints of the pixels—instead of pixels) with the assigned coordinate pairs of the points, and the neighbors of the point (0, 0) are also shown. Chamfer distances are defined first on the square grid [35, 36]. Based on the two classical neighborhoods, assigning weight a for steps between the closest neighbors (examples are shown by pink lines) and weight b for the steps between the second closest neighbors (examples are shown by black lines), the shortest weighted path between two points gives their chamfer (or weighted) distance. The paths we refer here are built in graph-theoretic sense by consecutive steps between (various type of) neighbor points of the grid.

##### 3.3. A (Usual) Coordinate System for the BCC Grid

Now, as a straightforward generalization of the previous description, one can obtain the grid which is the union of the two 3D subgrids: the grid of even points (addressed by triplets of even numbers) and the grid of odd points (addressed by triplets of odd numbers). Here, both the even and the odd subgrids are cubic grids, and their union is actually the BCC grid [32, 33] (see also Figure 2, part (b)), where the “grid point” representation of the diagonal square grid can easily be generalized from two to three dimensions. For explanation, we recall that, e.g., the caesium chloride (CsCl) has such 3D structure: the caesium ions are represented by black balls and the chloride ions are represented by red-while balls. In the BCC grid, there are also two usual neighborhoods. The closest neighbor points are different type, and each point has 8 of them (as a chloride ion has 8 caesium ion neighbors). They are described by vectors (±1, ±1, ±1) (in Figure 2, part (b), the eight closest neighbors of the point (−1, 1, 1) are also highlighted, pink color is used to connect those neighbors, and their Euclidean distance is times the length of the edge of the cubes of the unit cell, which is 2 here to ensure to use only integer coordinates to address the points of the grid). On the other hand, the second closest neighbors are actually the closest neighbors inside a given subgrid; that is, they are the closest same type points. Each point has 6 such neighbors, and they are described by vectors of the form (±2, 0, 0), (0, ±2, 0) and (0, 0, ±2) as, e.g., a chloride ion has 6 closest chloride ion neighbors. Actually, every point pair having their distance exactly the same as the length of the edge (shown by black lines on the figure) of a unit cell are representing two such neighbors. By our coordinate system, this length is exactly 2. Chamfer distances on the BCC grid can be defined analogously to the way they have been defined on the (diagonal) square grid: steps between two closest neighbor points (shown, e.g., by pink line in Figure 2) have weight a, while between the closest same type points (connected, e.g., by black line) weight b is used. Then, the weighted length of a corresponding shortest path connecting the points gives the chamfer distance of the points. We note here that in the mentioned literature, one may found also results about the weighted distances; however, in this paper, we use an approach coming from operational research. Moreover, we study also the case in which the steps to the second closest neighbors have a smaller weight than the steps to the closest neighbors, i.e., b < a. Therefore, we present not only a new approach but also some new results. We should also note here, that in 2D, the square grid and the diagonal square grid have the same structure, same number of neighbors, and so on. However, in 3D, the cubic and the BCC grids are two essentially different grids. The BCC grid is more compact than the cubic grid; both the number of closest neighbors and its packing density are larger than the corresponding values of the cubic grid.

#### 4. Results and Discussion: The Linear Programming Model

Many problems of combinatorial optimization are actually linear programming problems. The shortest path problem in a finite graph has also its linear programming version. A grid can be represented by an infinite graph. Therefore, the linear programming model is different.

The matrices of the steps of the diagonal square grid and the 3-dimensional BCC grid are given in the matrices shown in formulae (9) and (10), respectively.

The matrix of the diagonal square grid is as follows:

The matrix of the BCC grid is as follows:

It can be seen immediately that the matrix of the BCC grid is the generalization of the matrix of diagonal square grid to 3-dimension.

It is supposed that the paths start at the origins and those go to the target points which are (p, q)T and (p, q, r)T, respectively. As the grids are highly symmetric, it is enough to investigate just a segment of the plane. Therefore, it is supposed that p > q > 0 and p > q > r > 0, respectively. All the components of the target points must be either even numbers or odd numbers. The lengths of the steps are positive numbers. The lengths of the vertical and horizontal steps are equal and are denoted by b. The lengths of the cross steps are equal, too, and it is denoted by a.

##### 4.1. The Diagonal Square Grid

The optimization model in the case of the diagonal square grid is as follows:

Models (11)–(15) areinteger programming models as (15) claims the integrality of the variables. First, the linear programming problem (11)–(14) is solved based on the theory of the simplex method. If the solution is not integer, then the Gomory method of integer programming is applied.

There are 28 pairs of the columns of matrix (9). However, there are only six out of the 28 which give a feasible, i.e., nonnegative, solution of the equation system. According to the theory of linear programming, an optimal solution must be among these solutions. The optimal solution depends on the right-hand sides. Table 1 summarizes the six solutions. Instead of the columns, the variables are given.

 Number Basic variables Solution The value of the objective function 1 x1, x2 2 x1, x5 3 x1, x7 4 x2, x6 5 x4, x5 6 x5, x6 pa

The only basis which may produce a fractional solution is basis 1. All other solutions are integer because the parities of p and q are the same. It is easy to see that the objective function value of the solution of basis 2 is smaller than the objective function values of the solutions of bases 3, 4, and 5. Thus, only bases 1, 2, and 6 can be linearly optimal. If either basis 2 or basis 6 is linearly optimal, then it is the optimal solution of the integer programming problem, i.e., the optimal linear solution provided with the steps of the optimal path.

The solution of basis 2 is better than the solution of basis 1 if and only if

It is equivalent to

Similarly, the solution of basis 6 is better than the solution of basis 2 if and only if

It is equivalent to

Another calculation shows that the solution of basis 6 is better than the solution of basis 1 if and only if

The multiplier is between 1 and 2. Thus, when the solution of basis 6 is better than the solution of basis 2, it is already better than the solution of basis 1. The results can be summarized as follows.

Theorem 1. Assume that p > q > 0 are integers such that either both of them are even or both of them are odd.(i)If both p and q are even and b < a, then the minimal path from the polygon of the origin to the target polygon (p, q) consists of p horizontal and q vertical steps.(ii)If a < b < 2a, then the minimal path from the polygon of the origin to the target polygon (p, q) consists of horizontal steps and q steps which go at 45° to right and up.(iii)If b > 2a, then the minimal path from the polygon of the origin to the target polygon (p, q) consists of steps which go at 45° to right and up and steps which go at 45° to right and down.

The only case which is not discussed yet is when b < a and both p and q are odd numbers. The starting point is the origin. Its coordinates are even numbers. Thus, at least one step must exists such that the parities of the coordinates change. It is equivalent to the inequality

The first method of integer programming such that it could solve problems with unbounded integer variables was the Gomory method. It is still the most general method. It is a cutting plane method. It starts from the linear programming relaxation. If the optimal linear programming solution is not integer, then a cut is generated. It is called Gomory cut. It cuts the last linear programming optimal solution which is not integer. However, it does not cut any integer feasible solution. A new linear programming problem is generated in this way. It is solved by the lexicographic simplex method. Interestingly, the first Gomory cut is (21).

The cut generation in this particular case is as follows. The simplex method works in a way such that the basic variables are expressed with the nonbasic variables. If x1 and x2 are the two basic variables, then the expression of x1 is obvious.

Collecting all terms which are integer to the left-hand side, the new form of the equation is

The right-hand side must be integer. As every term with the exception of the constant are nonpositive on the right-hand side, the value of the right-hand side is a nonpositive integer implying that

It is equivalent to (21).

The lexicographic simplex method makes only one simplex iteration and immediately gets the integer optimal solution which is

After describing our method in detail in this 2D case, we are ready to go to 3D and discuss and apply it on the BCC grid to obtain our main and most important results.

##### 4.2. The BCC Grid

The matrix of (10) must be used in the linear programming model of the BCC grid. Thus, there are 14 variables. The lengths of the horizontal and vertical steps are again b, and the lengths of the other steps are a. There are 17 bases which can give basic feasible solutions. These bases are shown on Figure 3. Table 2 summarizes the solutions.

 Number Basic variables Solution The value of the objective function 1 x1, x2, x3 2 x1, x2, x7 3 x1, x2, x9 4 x1, x2, x11 5 x1, x3, x8 6 x1, x6, x7 7 x1, x7, x8 8 x1, x7, x12 9 x1, x8, x11 10 x2, x7, x10 11 x2, x8, x9 12 x3, x8, x9 13 x6, x7, x10 14 x7, x8, x9 pa 15 x7, x8, x10 pa 16 x7, x10, x12 (p + q − r)a 17 x8, x9, x11 (p + q + r)a

If the optimal solution belonging to basis 1 is not integer, then the Gomory cut is

The first lexicographic simplex iteration again finds the optimal solution which is

As it can be seen from Figure 3, only five bases can be optimal. They are in the rows 1, 2, 7, 14, and 15 of Table 2. The order of steps of the minimal paths can be interchanged.

Theorem 2. If the steps are made according to the values of the variables, then the optimal paths of the BCC grid are as follows:(i)If 3b < 2a and p, q, and r are even numbers, then the path consists of , , and steps parallel to the three axis.(ii)If 3b < 2a and p, q, and r are odd numbers, then the path consists of , , and steps parallel to the three axis and one step into the direction (1, 1, 1)T.(iii)If 3b > 2a and b < a, then the path makes r steps of type (1, 1, 1)T and get to the (r, r, r)T point. It continues parallel with the first two axis.(iv)If 2a > b > a, then the path goes first to the (p − q, 0, 0)T point with steps parallel to the first axis. Then, it continues by steps of type (1, 1, 1)T. Finally, it completes by steps of type (1, 1, −1)T.(v)If b > 2a, then the path makes steps of type (1, 1, 1)T. It continues with steps of type (1, 1, −1)T. Finally, it completes by steps of type (1, −1, 1)T. An alternative solution exists. The path makes steps of type (1, 1, 1)T. It continues with steps of type (1, 1, −1)T. Finally, it completes by steps of type (1, −1, −1)T.

Example 1. Let a = 4, b = 3, and (p, q, r) = (5, 3, 1). It is the third case of Theorem 2. Then, the optimal basis is basis (1, 2, 7). In this case, x1 = 2, x2 = 1, x7 = 1, and the length of the minimal path is 13.

Example 2. Let a = 1, b = 3, and (p, q, r) = (5, 3, 1). It is the fifth case of Theorem 2. Then, the optimal basis is basis (7, 8, 9) or basis (7, 8, 10). In the case of the basis (7, 8, 9), the solution is x7 = 2, x8 = 2, and x9 = 1, and the length of the minimal path is 5. In the case of the basis (7, 8, 10), the solution is x7 = 3, x8 = 1, and x10 = 1, and the length of the minimal path is 5, too.
As we have proven, based on the respective ratio of the weight, the case can be easily determined, and direct formulae give the weighted distance. One may think that Dijkstra or other well-known shortest path algorithms from graph theory could be used, and it is true. However, their complexity is much worse, i.e., the time we need to get the result will be much longer. On the one hand, we cannot use the upper bound as the size of the graph since our grids are infinite. On the other hand, practically, of course only a finite segment of the grid could and will play role in shortest paths between two fixed points. However, the size of this segment is proportional to the third power of the largest coordinate difference of the points, which also implies a relatively large time complexity with respect to our approach. This means that the results presented in this paper give a more efficient way to determine weighted distances.

#### 5. Conclusions

In this paper, it is shown that linear programming gives an efficient tool to find optimal solutions in some digital geometry problems. Chamfer distances on the square grid and on the BCC grid are studied. The BCC grid plays importance in solid state physics, crystallography, and material science since it describes the structure of the atoms/ions in various materials. This structure is more compact than the simple cubic structure and has various advantages also in engineering applications. The distances we have computed are based on weighted paths among the grid points. These distances are useful in various applications (e.g., 2D and 3D image processing) since they could provide relatively good approximations of the Euclidean distance, but since they are step-based, efficient incremental algorithms, e.g., distance transform [37] can easily be adapted. Feasible and optimal bases are found for various cases of the used weights. We have also studied the case when the second closest neighbors can be reached by a smaller weighted step than the closest neighbors (up to our knowledge this has not been done before on the BCC grid). The structure of all optimal paths is explicitly given. Moreover, one needs to check only the respective ratio of the weights and then can easily choose the case, thus, an optimal path and the chamfer distance.

We believe that our method can easily be applied for other similar grids, similarly as we also used in the second part of the paper, where n-dimensional generalizations of the BCC are considered [38].

#### Data Availability

No data were used to support this study.

#### Conflicts of Interest

The authors declare that they have no conflicts of interest regarding the publication of this article.

#### References

1. S. Marchand-Maillet and Y. M. Sharaiha, Binary Digital Image Processing: A Discrete Approach, Elsevier Publishing Company, Amsterdam, Netherlands, 2000.
2. C. O. Kiselman, Elements of Digital Geometry, Mathematical Morphology, and Discrete Optimization, World Scientific, Singapore, 2021.
3. R. Klette and A. Rosenfeld, Digital Geometry: Geometric Methods for Digital Picture Analysis, Morgan Kaufmann Publishers Inc., San Francisco, CA, USA, 1 edition, 2004.
4. A. Rosenfeld and J. L. Pfaltz, “Distance functions on digital pictures,” Pattern Recognition, vol. 1, no. 1, pp. 33–61, 1968. View at: Publisher Site | Google Scholar
5. S. Matej, A. Vardi, G. T. Herman, and E. Vardi, “Binary tomography using Gibbs priors,” in Discrete Tomography: Foundations, Algorithms and Applications, G. T. Herman and A. Kuba, Eds., pp. 191–212, Birkhäuser, Basel, Switzerland, 1999. View at: Google Scholar
6. I. Her, “A symmetrical coordinate frame on the hexagonal grid for computer graphics and vision,” Journal of Mechanical Design, vol. 115, no. 3, pp. 447–449, 1993. View at: Publisher Site | Google Scholar
7. I. Her, “Geometric transformations on the hexagonal grid,” IEEE Transactions on Image Processing, vol. 4, no. 9, pp. 1213–1222, 1995. View at: Publisher Site | Google Scholar
8. B. Nagy, “Shortest paths in triangular grids with neighbourhood sequences,” Journal of Computing and Information Technology, vol. 11, no. 2, pp. 111–122, 2003. View at: Publisher Site | Google Scholar
9. B. Nagy, “Cellular topology and topological coordinate systems on the hexagonal and on the triangular grids,” Annals of Mathematics and Artificial Intelligence, vol. 75, no. 1-2, pp. 117–134, 2015. View at: Publisher Site | Google Scholar
10. S. Matej, G. T. Herman, and A. Vardi, “Binary tomography on the hexagonal grid using Gibbs priors,” International Journal of Imaging Systems and Technology, vol. 9, no. 2-3, pp. 126–131, 1998. View at: Publisher Site | Google Scholar
11. B. Nagy and T. Lukić, “Binary tomography on the isometric tessellation involving pixel shape orientation,” IET Image Processing, vol. 14, no. 1, pp. 25–30, 2020. View at: Publisher Site | Google Scholar
12. R. Strand and G. Borgefors, “Distance transforms for three-dimensional grids with non-cubic voxels,” Computer Vision and Image Understanding, vol. 100, no. 3, pp. 294–311, 2005. View at: Publisher Site | Google Scholar
13. R. Strand and P. Stelldinger, “Topology preserving marching cubes-like algorithms on the face-centered cubic grid,” in Proceedings of 14th International Conference on Image Analysis and Processing (ICIAP 2007), pp. 781–788, Modena, Italy, 2007. View at: Publisher Site | Google Scholar
14. P. Stelldinger and R. Strand, “Topology preserving digitization with FCC and BCC grids,” in Lecture Notes in Computer Science, Combinatorial Image Analysis, et al., Ed., pp. 226–240, Springer, Berlin, Germany, 2006. View at: Publisher Site | Google Scholar
15. L. Comic and B. Nagy, “A combinatorial coordinate system for the body-centered cubic grid,” Graphical Models, vol. 87, pp. 11–22, 2016. View at: Publisher Site | Google Scholar
16. B. Csébfalvi, “An evaluation of prefiltered B-spline reconstruction for quasi-interpolation on the body-centered cubic lattice,” IEEE Transactions on Visualization and Computer Graphics, vol. 16, no. 3, pp. 499–512, 2010. View at: Publisher Site | Google Scholar
17. L. Ibáñez, C. Hamitouche, and C. Roux, “Ray-tracing and 3-D objects representation in the BCC and FCC grids,” Discrete Geometry for Computer Imagery, Springer, Berlin, Germany, 1997. View at: Publisher Site | Google Scholar
18. L. X. Mei, L. Jin, and Y. X. Xia, “3D visualization technology based on BCC-grid shear-warp algorithm,” in The Proceedings of the Multiconference on “Computational Engineering in Systems Applications, pp. 1454–1459, Beijing, China, October 2006. View at: Google Scholar
19. F. Labelle, Tetrahedral Mesh Generation with Good Dihedral Angles Using Point Lattices, PhD Dissertation, University of California, Berkeley, CA, USA, 2007.
20. E. Moreno, P. González, R. Emadi, J. B. Roldán, and E. A. Michael, “BCC-Grid versus SC-Grid in the modeling of a sheet of graphene as a surface boundary condition in the context of ADE-FDTD,” Mathematics and Computers in Simulation, vol. 186, pp. 52–61, 2021. View at: Publisher Site | Google Scholar
21. E. Khalimsky, “Topological structures in computer science,” Journal of Applied Mathematics and Simulation, vol. 1, no. 1, pp. 25–40, 1987. View at: Publisher Site | Google Scholar
22. E. Khalimsky, R. Kopperman, and P. Meyer, “Computer graphics and connected topologies on finite ordered sets,” Topology and Its Applications, vol. 36, no. 1, pp. 1–17, 1990. View at: Publisher Site | Google Scholar
23. G. Kovács, B. Nagy, and B. Vizvári, “Weighted distances and digital disks on the Khalimsky grid,” Journal of Mathematical Imaging and Vision, vol. 59, no. 1, pp. 2–22, 2017. View at: Publisher Site | Google Scholar
24. P. P. Das, “An algorithm for computing the number of minimal paths in digital images,” Pattern Recognition Letters, vol. 9, no. 2, pp. 107–116, 1988. View at: Publisher Site | Google Scholar
25. E. Luczak and A. Rosenfeld, “Distance on a hexagonal grid,” IEEE Transactions on Computers, vol. 25, no. 5, pp. 532-533, 1976. View at: Publisher Site | Google Scholar
26. M. A. Butt and P. Maragos, “Optimum design of chamfer distance transforms,” IEEE Transactions on Image Processing, vol. 7, no. 10, pp. 1477–1484, 1998. View at: Publisher Site | Google Scholar
27. B. Nagy, “Weighted distances on a triangular grid,” in Lecture Notes in Computer Science IWCIA 2014, R. P. Barneva, V. E. Brimkov, and J. Slapal, Eds., pp. 37–50, Springer, Cham, Switzerland, 2014. View at: Publisher Site | Google Scholar
28. R. Strand and B. Nagy, “Weighted neighbourhood sequences in non-standard three dimensional grids–metricity and algorithms,” in DGCI 2008. LNCS, D. Coeurjolly, I. Sivignon, L. Tougne, and F. Dupont, Eds., pp. 201–212, Springer, Berlin, Germany, 2008. View at: Google Scholar
29. S. J. Russel and P. Norvig, Artificial Intelligence: A Modern Approach, Prentice-Hall, Hoboken, NJ, USA, 1995.
30. G. B. Dantzig, “Programming in a linear structure,” Econometrica, vol. 17, pp. 73-74, 1949. View at: Publisher Site | Google Scholar
31. R. E. Gomory, “Outline of an algorithm for integer solutions to linear programs,” Bulletin of the American Mathematical Society, vol. 64, no. 5, pp. 275–279, 1958. View at: Publisher Site | Google Scholar
32. B. Nagy and R. Strand, “Approximating euclidean distance using distances based on neighbourhood sequences in non-standard three-dimensional grids,” in Lecture Notes in Computer Science IWCIA 2006, R. Reulke, U. Eckardt, B. Flach, U. Knauer, and K. Polthier, Eds., pp. 89–100, Springer, Heidelberg, Germany, 2006. View at: Publisher Site | Google Scholar
33. R. Strand and B. Nagy, “Distances based on neighbourhood sequences in non-standard three-dimensional grids,” Discrete Applied Mathematics, vol. 155, no. 4, pp. 548–557, 2007. View at: Publisher Site | Google Scholar
34. G. Kovács, B. Nagy, and B. Vizvári, “On weighted distances on the Khalimsky grid,” in Discrete Geometry for Computer Imagery, N. Normand, J. Guédon, and F. Autrusseau, Eds., pp. 372–384, Springer, Cham, Switzerland, 2016. View at: Publisher Site | Google Scholar
35. H. G. Barrow, J. M. Tenenbaum, R. C. Bolles, and H. C. Wolf, “Parametric correspondence and chamfer matching: two new techniques for image matching,” in Proceedings of the 5th international joint conference on Artificial intelligence, pp. 659–663, Cambridge, MA, USA, 1977. View at: Google Scholar
36. G. Borgefors, “Distance transformations in arbitrary dimensions,” Computer Vision, Graphics, and Image Processing, vol. 27, no. 3, pp. 321–345, 1984. View at: Publisher Site | Google Scholar
37. R. Strand, B. Nagy, and G. Borgefors, “Digital distance functions on three-dimensional grids,” Theoretical Computer Science, vol. 412, no. 15, pp. 1350–1363, 2011. View at: Publisher Site | Google Scholar
38. G. Kovács, B. Nagy, G. Stomfai, N. D. Turgay, and B. Vizvári, “Discrete optimization: the case of generalized BCC lattice,” Mathematics, vol. 9, no. 3, p. 208, 2021. View at: Publisher Site | Google Scholar

Copyright © 2021 Gergely Kovács et al. This is an open access article distributed under the Creative Commons Attribution License, which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited.