 # Beyond the Hausdorff Metric in Digital Topology

Two objects may be close in the Hausdorff metric, yet have very different geometric and topological properties. We examine other methods of comparing digital images such that objects close in each of these measures have some similar geometric or topological property. Such measures may be combined with the Hausdorff metric to yield a metric in which close images are similar with respect to multiple properties.

## Authors

##### This week in AI

Get the week's most popular data science and artificial intelligence research sent straight to your inbox every Saturday.

## 1 Introduction

A key question in digital image processing is whether two digital images and represent the same object. If, after magnification or shrinking and translation, copies and of the respective images have been scaled to approximately the same size and are located in approximately the same position, a Hausdorff metric may be employed: if is small, then perhaps and represent the same object; if is large, then and probably do not represent the same object. However, the Hausdorff metric is very crude as a measure of similarity. In this paper, we consider other comparisons of digital images.

## 2 Preliminaries

Much of this section is quoted or paraphrased from .

We use to indicate the set of natural numbers, for the set of integers, and for the set of real numbers.

A digital image is a graph , where is a subset of for some positive integer , and is an adjacency relation for the points of . The -adjacencies are commonly used. Let , , where we consider these points as -tuples of integers:

 x=(x1,…,xn),   y=(y1,…,yn).

Let , . We say and are -adjacent if

• There are at most indices for which .

• For all indices such that we have .

Often, a -adjacency is denoted by the number of points adjacent to a given point in using this adjacency. E.g.,

We write , or when is understood, to indicate that and are -adjacent. Similarly, we write , or when is understood, to indicate that and are -adjacent or equal.

A subset of a digital image is -connected , or connected when is understood, if for every pair of points there exists a sequence such that , , and for .

### 2.2 Digitally continuous functions

The following generalizes a definition of .

###### Definition 2.1.

 Let and be digital images. A single-valued function is -continuous if for every -connected we have that is a -connected subset of .

When the adjacency relations are understood, we will simply say that is continuous. Continuity can be expressed in terms of adjacency of points:

###### Theorem 2.2.

[17, 5] A function is continuous if and only if in implies . ∎

### 2.3 Pseudometrics and metrics

###### Definition 2.3.

 Let be a nonempty set. Let be a function such that for all ,

• ;

• ;

• ; and

• .

Then is a pseudometric for . If, further, implies then is a metric for .

Pseudometrics that can be applied to pairs of nonempty subsets of a digital image include the absolute values of the differences in their

• deviations from convexity. Several such deviations are discussed in [18, 4], for each of which it was shown that two objects can be “close” in the Hausdorff metric yet quite different with respect to the deviation from convexity. These can be adapted to digital images with respect to digital convexity as defined in .

• Euler characteristics. I.e., the function

 sχ(A,B)=|χ(A)−χ(B)|,

where is the Euler characteristic of , is a pseudometric for digital images in . An improper definition of the Euler characteristic for digital images was given in . An appropriate definition is given in .

• Lusternik-Schnirelman category  . I.e., the function

 sLS,κ(A,B)=|catκ(A)−catκ(B)|,

where is the Lusternik-Schnirelman category of , is a pseudometric for digital images in .

• diameters. This is discussed below.

The following is easily verified and extends an assertion of .

###### Lemma 2.4.

Let be a pseudometric, . Then is a pseudometric. Further, if at least one of the is a metric, then is a metric.

Here we mention metrics we use in this paper for or . Let , .

• Let . The metric for is given by

 dp(x,y)=(n∑i=1|xi−yi|p)1/p.

The special case gives the Manhattan or city block metric , given by

 d1(x,y)=n∑i=1|xi−yi|.

The special case gives the Euclidean metric , given by

 d2(x,y)=(n∑i=1|xi−yi|2)1/2.
• The shortest path metric : Let be a connected digital image. For , let

 dκ(x,y)=min{n| there is a κ-path of length n in X% from x to y.}
• The Hausdorff metric based on a metric  : Let be a metric where . The Hausdorff metric for nonempty bounded and closed subsets and of (hence, in the case , finite subsets of ) based on is

 H(A,B)=min{ε>0 | ∀(a,b)∈A×B, ∃ (a′,b′)∈A×B such that ε≥d(a,b′) and ε≥d(a′,b)}.

We make the following modification of the Hausdorff metric based on as presented in .

###### Definition 2.5.

Let , , . Let be an adjacency on . Then

 H(X,κ)(A,B)=min⎧⎪⎨⎪⎩ε≥0 | ∀(a,b)∈A×B, ∃(a′,b′)∈A×B such that there are κ-paths in X of length≤ε from a to b′ and from b to a′⎫⎪⎬⎪⎭.

In the version of the Hausdorff metric based on in , . We show below that we can get very different results for the more general situation .

We use the notations for the Hausdorff metric based on the metric , for the Hausdorff metric based on the metric (i.e., ), and for the Hausdorff metric based on for subsets of (i.e., ).

Another metric from classical topology that is easily adapted to digital topology is Borsuk’s metric of continuity [2, 3] based on a metric which is typically, but not necessarily, the Euclidean metric. For digital images and in , define the metric of continuity as the greatest lower bound of numbers such that there are -continuous and with

 d(x,f(x))≤t for all x∈X and d(y,g(y))≤t for all% y∈Y.
###### Proposition 2.6.

Given finite digital images and in and a metric for , .

###### Proof.

This is largely the argument of the analogous assertion in . Let . Since and are finite, without loss of generality, there exists such that . Then for all -continuous , . Therefore, . ∎

An example for which the inequality of Proposition 2.6 is strict is given in the following.

###### Theorem 2.7.

Let . Let . Then, using the Manhattan metric for and , we have and .

###### Proof.

It is clear that .

Notice there is an isomorphism to a subset of . Let be -continuous. By , there is a pair of antipodal points such that . Since is an isomorphism, we must have . We will show that either or , as follows.

If then . Then:

• If then , so .

• Note so cannot equal .

• If for then , so .

The cases , , and are similar. Thus . ∎

We say the diameter of a nonempty bounded set with respect to a metric is

 diamd(A)=max{d(a,b)|a,b∈A}.

We will use the notations for , and for .

We define a function for pairs of nonempty bounded sets in by

 sd(A,B)=|diamd(A)−diamd(B)|.

We use notations for , and for .

The following is easily verified.

###### Lemma 2.8.

The function is a pseudometric.

## 3 Comparing (pseudo)metrics on digital images

In this section, we compare the use of some of the (pseudo)metrics discussed above.

###### Theorem 3.1.

Let and be nonempty, bounded subsets of . Let be the Hausdorff metric based on the metric and suppose . Then .

###### Proof.

There exist such that . There exist such that and . So

 diamp(A)=dp(a,a′)≤dp(a,b)+dp(b,b′)+dp(b′,a′)≤m+diamp(B)+m
 =diamp(B)+2m.

Similarly, . The assertion follows. ∎ Figure 1: Left: Q=[0,n]2Z (here, n=6). Right: S=Q∖[(⋃k∈Z{4k+1}×[1,n]Z)∪(⋃k∈Z{4k+3}×[0,n−1]Z)] (here, n=6). Q and S are within 1 with respect to the Hausdorff metric based on the Manhattan metric; however, they differ considerably with respect to diameter in the shortest path metric.

By contrast, we have the following.

###### Example 3.2.

Let such that is even. Let . Let

 S=Q∖[(⋃k∈Z{4k+1}×[1,n]Z)∪(⋃k∈Z{4k+3}×[0,n−1]Z)].

(See Figure 1.) Then , but while , we have . Thus .

###### Proof.

It is easy to see that both and have diagonally opposed points that are maximally distant in the metric. Therefore, , so .

Diagonally opposed points of are maximally separated with respect to , so . Maximally separated points of with respect to are

 (0,n) and (n,n)if n=4k+2 for some k∈Z;(0,n) and (n,0)if n=4k for some k∈Z.

In either case, the unique shortest -path between maximally separated points requires horizontal steps. The number of vertical steps is computed as follows. There are vertical line segments that must be traversed, each of length , so the number of vertical steps is . Thus the number of steps between maximally separated members of is .

Hence for we have . ∎

We do not get an analog of Theorem 3.1 by using the Hausdorff metric based on an adjacency instead of . This is shown in the following example.

###### Example 3.3.

Let . Let . (See Figure 2.) Then . However, we have the following.

• For , and , so .

• For , and , so . Figure 2: Digital images A (left) and B (right) for Example 3.3, using n=5. Using the shortest path metric and either κ=c1 or κ=c2, maximally distant points in A are (0,0) and (n,2), and maximally distant points in B are (n,0) and (n,2).
###### Theorem 3.4.

Let and be finite, nonempty -connected subsets of a -connected subset of , where . Suppose we have for some . Then .

###### Proof.

By hypothesis, given and , there exist , , and -paths from to and from to in such that each of and has length of at most . Since each -adjacency corresponds to a Euclidean distance of at most , it follows that and . It follows that . ∎

We do not get a converse for Theorem 3.4, as the following shows.

###### Example 3.5.

Let as in Example 3.3. (See Figure 2.) Let . Then . However, and .

###### Proof.

It is easy to see that .

Since , finding a Hausdorff distance between and comes down to considering a furthest point of from . With respect to and also with respect to , the furthest point of from in the shortest path metric is and its closest point of is . Since and , the assertion follows. ∎

Roughly, it appears that the great differences found in Examples 3.3 and 3.5, between measures based in metrics and measures based on the shortest path metric, are due to significant deviations from convexity. If we consider for a set such as a digital cube, we may find and are more alike, as we see below.

Let , . Then .

###### Proof.

Let . Let . Then there exists such that . By definition of , it follows that there is a -path in of length at most from to . Similarly, given in , there is a -path in of length at most from to a point . Therefore, .

Now let . Then given , there is a -path in of length at most from to some . Similarly, given , there is a -path in of length at most from to some . Since every adjacency represents a distance of 1, it follows that and . Thus . The assertion follows. ∎

Using the observation that a -adjacency in , , represents a distance between the adjacent points that is between and , we can generalize the argument used to prove Proposition 3.6, getting the following.

###### Theorem 3.7.

Let , . Then for , .

## 4 Further remarks

The Hausdorff metric is often used to compare objects and . It is easy to compute efficiently [19, 9] and gives a good indication of how well each of its arguments approximates the other with respect to location.

However, two objects may be close in the Hausdorff metric and yet have very different geometric or topological properties. Lemma 2.4 tells us that by adding other pseudometrics or metrics, such as those we have discussed, to the Hausdorff metric, we can get another metric in which closeness is more likely to validate the parameters as digital images representing the same physical object.

The suggestions and corrections of an anonymous reviewer are gratefully acknowledged.

## References

•  A. Borat and T. Vergili, Digital Lusternik-Schnirelmann category, Turkish Journal of Mathematics 42 (2018), 1845-1852
•  K. Borsuk, On some metrizations of the hyperspace of compact sets, Fundamenta Mathematicae 41 (1954), 168-202
•  K. Borsuk, Theory of Retracts, Polish Scientific Publishers, Warsaw, 1967.
•  L. Boxer, Computing Deviations from Convexity in Polygons, Pattern Recognition Letters 14 (1993), 163-167
•  L. Boxer, A classical construction for the digital fundamental group, Journal of Mathematical Imaging and Vision 10 (1999), 51-62
•  L. Boxer, Continuous maps on digital simple closed curves, Applied Mathematics 1 (2010), 377-386.
•  L. Boxer, Convexity and freezing sets in digital topology, Applied General Topology 22 (1) (2021), 121 - 137
•  L. Boxer, I. Karaca, and A. Oztel, Topological Invariants in Digital Images, Journal of Mathematical Sciences: Advances and Applications 11(2), 2011, 109-140.
JMSAALaurenceBoxeretal.
D.pdf
•  L. Boxer and R. Miller, Coarse grained gather and scatter operations with applications, Journal of Parallel and Distributed Computing 64 (2004), 1297-1320
•  L. Boxer and P.C. Staecker, Fundamental groups and Euler characteristics of sphere-like digital images, Applied General Topology 17(2), 2016, 139-158.
•  L. Chen, Gradually varied surfaces and its optimal uniform approximation, SPIE Proceedings 2182 (1994), 300-307.