1 Introduction

Max-plus algebra [1] is a class of algebraic systems and is obtained from linear algebra by replacing addition with maximum and multiplication with addition. This results in many analogues in the max-plus algebra to the conventional algebra. Therefore, it is mainly used to cast nonlinear relationships in a linear-like structure. The max-plus algebra emerged from problems in graph theory and operations research [2]. It has subsequently been used in other areas such as discrete event systems [3,4,5], approaches to optimal control [6] and dynamic systems and control [7, 8]. Another area of application for this algebra, to which we will devote particular attention here, is mathematical morphology.

Mathematical morphology is a theory for the analysis of spatial structures in images. It has evolved over decades to a very successful field in image processing, see, for example, [9,10,11] for an overview. There are two main building blocks of usual morphological operators. The first one is the structuring element (SE), characterised by its shape, size and centre location. There are in addition two types of SEs: flat and non-flat [12]. A flat SE basically defines a neighbourhood of the centre pixel where morphological operations take place, whereas a non-flat SE also contains a mask of finite values used as additive offsets. The SE is translated over an image and often implemented as a sliding window. The second building block is a mechanism performing a comparison of values within a SE. The basic operations in mathematical morphology are dilation and erosion, where a pixel value is set to the maximum or minimum of the discrete image function within the SE centred upon it, respectively. Many morphological filtering processes of practical interest, e.g. opening, closing or top hats, can be formulated by combining dilation and erosion. As dilation and erosion are dual operations, it is often sufficient to focus on one of it for algorithm construction.

From the interaction of these two theories, a first fundamental question arises, namely how nonlinear morphological dilation relates to its linear analogue when one makes the transition between max-plus algebra and linear algebra. From this connection arises a relation between the Fourier transform in linear signal processing and the slope transform in morphology. This relation was introduced by Maragos [13] and by Dorst and van den Boomgaard [14]. This suggested a logarithmic relationship between these two transformations, which Burgeth and Weickert, among others, analysed in their work [15]. For this purpose, they naturally identified the convolution in the max-plus algebra with the Laplace transformation and its conjugate with the Cramer transformation. They called the resulting connection the logarithmic connection.

We want to take up the analysis of Burgeth and Weickert and investigate an alternative approach in order to find a direct access to the logarithmic relationship without having to take a diversion via the Laplace and Cramer transformation. To achieve this, we will replace the maximum operator in the dilation by an approximation and show that the max-plus algebra is still a commutative semifield (with respect to multiplication) by this approximation. Further, we will compare the resulting equations with respect to the dilation via the Fourier or slope transformation theorem.

Another question arising from this connection with the approximated max-plus algebra, which is still partly open, relates to the work [16] by Kahra, Sridhar and Breuß. This represents an extension of the work [17] of Tuzikov, Margolin and Grenov, where the calculation of the dilation by means of Fourier transforms for binary images was discussed, to the case of greyscale images. They have adopted the approaches and approximated the dilation by an approximation of the maximum. In doing so, the authors posited that the procedure using the approximated max-plus algebra mentioned above does not depend on the shape or flatness of the SE, but solely on its size. However, an analytical observation supporting this has been missing so far.

We will therefore close this gap here by giving two estimates for it. One in a heuristic sense in the form of an energy estimate and a more direct variant identifying the convolution with the k-norm. Both will demonstrate the presumed independence of the method from the form of the SE. Further, we will also address the question of when this approximation is of sufficiently good quality with respect to the exact calculation in practice.

2 General Definitions

We will first give some basic definition concerning dilation, erosion, Fourier and slope transformations. Here we will use the discrete formulation when switching between the plus-prod and the max-plus algebra and the continuous formulation when referring exclusively to the Fourier transform.

We start by investigating how the morphological dilation and erosion for a greyscale image \(f: {\mathbb {R}}^2 \rightarrow {\mathbb {R}}\) with a (flat) structuring function \(b: {\mathbb {R}}^2 \rightarrow \bar{{\mathbb {R}}}\) according to

$$\begin{aligned}&(f \oplus b)(x) := \sup _{y \in {\mathbb {R}}^2}\left( f(y) + b(x-y) \right) , \quad x \in {\mathbb {R}}^2 \end{aligned}$$
(1)
$$\begin{aligned}&(f \ominus b)(x) := \inf _{y \in {\mathbb {R}}^2}\left( f(y) - b(x-y) \right) , \quad x \in {\mathbb {R}}^2 \end{aligned}$$
(2)

behaves. To do this, we consider the generalisation (called “tangential dilation”) used by Dorst and van den Boomgaard [14]

$$\begin{aligned} (f \check{\oplus } b)(x) := \underset{y \in {\mathbb {R}}^2}{\text {stat}} \left( f(y) + b(x-y) \right) , \quad x \in {\mathbb {R}}^2 \end{aligned}$$
(3)

with

$$\begin{aligned} \underset{y \in {\mathbb {R}}^2}{\text {stat}} f(y) := \left\{ f(z) : \nabla f(z) = 0, z \in {\mathbb {R}}^2 \right\} , \end{aligned}$$

where the following connection exists:

$$\begin{aligned} \sup (f \check{\oplus } b)(x) = (f \oplus b)(x), \quad x \in {\mathbb {R}}^2. \end{aligned}$$
(4)

Under this premise, one considers the slope transform \({\mathcal {S}}\), which satisfies

$$\begin{aligned} {\mathcal {S}}[f](y) := \underset{x \in {\mathbb {R}}^2}{\text {stat}} \left( f(x) - \langle y, x \rangle \right) , \quad y \in {\mathbb {R}}^2, \end{aligned}$$
(5)

as a morphological analogy to the Fourier transform

$$\begin{aligned} \mathcal {F}[f](y) := \int \limits _{{\mathbb {R}}^2}^{} f(x) \textrm{e}^{-2\pi \textrm{i}\langle y, x \rangle } \textrm{d}x, \quad y \in {\mathbb {R}}^2, \end{aligned}$$
(6)

since \({\mathcal {S}}\) in a certain sense satisfies a convolution theorem similar to the Fourier transform:

$$\begin{aligned} {\mathcal {S}}[f \check{\oplus } b] = {\mathcal {S}}[f] + {\mathcal {S}}[b]. \end{aligned}$$
(7)

For further details regarding the slope transform and corresponding connections to other transformations, please refer to “Appendix A.3” and the references listed there.

3 Approximation of the Max-Plus Algebra

In this section, we will look at the properties of max-plus algebra [4]. To be more precise, we want to investigate to what extent an approximation of the maximum preserves the max-plus algebra properties.

To do this, we first consider a convolution in the plus-prod algebra of f with b from the previous section. If we now switch from the (discrete) convolution in the plus-prod algebra to the max-plus algebra or min-plus algebra, we see that this gives rise to two new convolutions (cf. [15]) for \(x \in {\mathbb {R}}^2\):

$$\begin{aligned} (f *_d b)(x)&= \sup _{y \in {\mathbb {R}}^2} \left( f(x-y) + b(y) \right) \nonumber \\ {}&= \sup _{y \in {\mathbb {R}}^2} \left( f(y) + b(x-y) \right) = (f \oplus b)(x), \end{aligned}$$
(8)
$$\begin{aligned} (f *_e \bar{b})(x)&= \inf _{y \in {\mathbb {R}}^2}\left( f(x-y) + \bar{b}(y) \right) \nonumber \\ {}&= \inf _{y \in {\mathbb {R}}^2}\left( f(y) - b(y-x) \right) = (f \ominus b)(x), \end{aligned}$$
(9)

where \(\bar{b}(x) = - b(-x)\). Furthermore, we know that we can approximate the dilation by the smooth maximum with Fourier transforms according to [16]:

$$\begin{aligned} \begin{aligned} (f \oplus b)(x)&= \sup _{y \in {\mathbb {R}}^2}\left( f(y) + b(x-y) \right) \\ {}&= \lim _{n \rightarrow \infty } \frac{1}{n} \ln \left( \sum _{y \in {\mathbb {R}}^2} \textrm{e}^{n f(y)} \textrm{e}^{n b(x-y)} \right) \\&= \lim _{n \rightarrow \infty } \frac{1}{n} \ln \left( \textrm{e}^{n f(x)} * \textrm{e}^{n b(x)} \right) \\&= \lim _{n \rightarrow \infty } \frac{1}{n} \ln \left( \mathcal {F}^{-1} \left[ \mathcal {F} \left[ \textrm{e}^{nf}\right] \cdot \mathcal {F} \left[ \textrm{e}^{nb}\right] \right] (x) \right) , \quad x \in {\mathbb {R}}^2. \end{aligned} \end{aligned}$$
(10)

In particular, the expression in the third line of this equation is important because it is possible to speed up these calculations using a fast Fourier transform (see [16] for greyscale images and [18] for colour images). This was demonstrated by the algorithm cited here, which combines advantageous properties. Most obviously, its complexity does not depend on the size or shape of the structuring element, but only on the size of the input image, which distinguishes it from other fast methods. Therefore, one can assume that it is particularly suitable for large images or filters. In addition, non-flat filters can also be used. However, since this is more indirectly related to our result, we will revisit this topic in Sect. 5.

Remark 1

The last expression in the first line of Eq. (10) is better known as an approach by Maslov [19], who introduced it as a log-sum-exponentiation approximation of the maximum function. However, this approach is now also used in other areas, for example in convex analysis [20] or as a tool in tropical geometry to convert classic polynomials into max-plus polynomials describing geometric objects [21].

This brings us to the idea of creating a new max-plus algebra \({\mathbb {R}}_{\max _n^*}= ({\mathbb {R}} \cup \{-\infty \}, \frac{1}{n} \ln \left( \sum \textrm{e}^{n\cdot (...)} \right) , +, -\infty , 0)\) which resembles the normal max-plus algebra \({\mathbb {R}}_{\max } = ({\mathbb {R}} \cup \{-\infty \}, \max , +, -\infty , 0)\) except for the change that instead of the maximum we use the smooth maximum without the limit transition \(\frac{1}{n} \ln \left( \sum \textrm{e}^{n\cdot (...)} \right) \) for the link \(\tilde{\oplus }\). For better readability, we use \(\,\tilde{\oplus }\,\) and \(\,\tilde{\otimes }\,\) for the general operations of addition and multiplication concerning the field axioms to avoid confusion with the notation of dilation and erosion, respectively. See “Appendix A.2” for more details to max-plus algebras. To check this, we only have to prove that \({\mathbb {R}}_{\max _n^*}\) is an idempotent commutative semifield.

For this purpose, we prove the following theorem, which already appears in [22] but is not explicitly proved there:

Theorem 1

Let the approximated smooth maximum be given by

$$\begin{aligned}&\max {}_n^*(x_1, \dots , x_k)\\ {}&\quad := \frac{1}{n} \ln \left( \sum _{i=1}^k \textrm{e}^{n x_i} \right) , \quad x_i \in {\mathbb {R}}, \quad i = 1,...,k, \quad k \in \mathbb {N}, \quad n \in {\mathbb {R}}_{> 0}. \end{aligned}$$

Then \({\mathbb {R}}_{\max _n^*}= ({\mathbb {R}} \cup \{-\infty \}, \max {}_n^*, +, -\infty , 0)\) represents for all \(n \in {\mathbb {R}}_{> 0}\) a commutative (with respect to multiplication) semifield.

Remark 2

We have used the terms “smooth maximum”, respectively, “approximated smooth maximum” here, depending on whether we have formed the limit, respectively, not. This expression is also called “log-sum-exponentiation” (LSE) in convex analysis or “SoftMax” in tropical geometry and neural networks (see the relevant references from remark 1).

Proof

For this, we calculate for arbitrary \(a,b,c \in {\mathbb {R}} \cup \{-\infty \}\):

$$\begin{aligned}&\bullet \quad a \,\tilde{\oplus }\,(b \,\tilde{\oplus }\,c) = \frac{1}{n} \ln \left( \textrm{e}^{na} + \textrm{e}^{\frac{n}{n} \ln \left( \textrm{e}^{nb} + \textrm{e}^{nc} \right) } \right) \\&\qquad \quad = \frac{1}{n} \ln \left( \textrm{e}^{na} + \textrm{e}^{nb} + \textrm{e}^{nc} \right) \\&\qquad \quad = \frac{1}{n} \ln \left( \textrm{e}^{\frac{n}{n} \ln \left( \textrm{e}^{na} + \textrm{e}^{nb} \right) } + \textrm{e}^{nc} \right) = \frac{1}{n} \ln \left( \textrm{e}^{na} + \textrm{e}^{nb} \right) \,\tilde{\oplus }\,c \\&\qquad \quad = (a \,\tilde{\oplus }\,b) \,\tilde{\oplus }\,c \\&\bullet \quad a \,\tilde{\oplus }\,b = \frac{1}{n} \ln \left( \textrm{e}^{na} + \textrm{e}^{nb} \right) = \frac{1}{n} \ln \left( \textrm{e}^{nb} + \textrm{e}^{na}\right) = b \,\tilde{\oplus }\,a \\&\bullet \quad a \,\tilde{\otimes }\,\left( b \,\tilde{\otimes }\,c \right) = a \,\tilde{\otimes }\,(b + c) = a + (b + c)\\&\qquad \quad = (a+b)+c = (a \,\tilde{\otimes }\,b) \,\tilde{\otimes }\,c \\&\bullet \quad a \,\tilde{\otimes }\,(b \,\tilde{\oplus }\,c) = a + \frac{1}{n} \ln \left( \textrm{e}^{nb} + \textrm{e}^{nc} \right) \\&\qquad \quad = \frac{1}{n} \ln \textrm{e}^{na}+ \frac{1}{n} \ln \left( \textrm{e}^{nb} + \textrm{e}^{nc} \right) \\&\qquad \quad = \frac{1}{n} \ln \left( \textrm{e}^{n(a+b)} + \textrm{e}^{n(a+c)} \right) = (a \,\tilde{\otimes }\,b) \,\tilde{\oplus }\,(a \,\tilde{\otimes }\,c) \\&\bullet \quad (a \,\tilde{\oplus }\,b) \,\tilde{\otimes }\,c = \frac{1}{n} \ln \left( \textrm{e}^{na} + \textrm{e}^{nb} \right) + c\\ {}&\qquad \quad = \frac{1}{n} \ln \left( \textrm{e}^{n(a+c)} + \textrm{e}^{n(b+c)} \right) = (a \,\tilde{\otimes }\,c) \,\tilde{\oplus }\,(b \,\tilde{\otimes }\,c) \\&\bullet \quad - \infty \,\tilde{\oplus }\,a = \frac{1}{n} \ln \left( \textrm{e}^{-\infty } + \textrm{e}^{na} \right) = \frac{1}{n} \ln \textrm{e}^{na} = a \\&\bullet \quad 0 \,\tilde{\otimes }\,a = 0 + a = a = a+0 = a \,\tilde{\otimes }\,0 \\&\bullet \quad a \ne - \infty \Rightarrow \exists \tilde{a} \in {\mathbb {R}} \cup \{- \infty \} \text { mit } a \,\tilde{\otimes }\,\tilde{a} = 0 = \tilde{a} \,\tilde{\otimes }\,a : \\&\qquad \tilde{a} = -a \in {\mathbb {R}} \cup \{- \infty \} \\&\bullet \quad a \,\tilde{\otimes }\,b = a + b = b+a = b \,\tilde{\otimes }\,a. \end{aligned}$$

Corollary 1

Let the approximated smooth maximum be given as in Theorem 1. Then \(\lim \limits _{n \rightarrow \infty } {\mathbb {R}}_{\max _n^*}\) represents a max-plus algebra.

Proof

For this, we only have to prove the idempotence with respect to addition, since all other properties have already been proved in Theorem 1:

$$\begin{aligned} \lim _{n \rightarrow \infty } a \,\tilde{\oplus }\,a&= \lim _{n \rightarrow \infty } \frac{1}{n} \ln \left( \textrm{e}^{na} + \textrm{e}^{na} \right) = \lim _{n \rightarrow \infty } \frac{1}{n} \ln \left( 2\textrm{e}^{na} \right) \\ {}&= \lim _{n \rightarrow \infty } \frac{1}{n} \left( \ln 2 + na \right) \\&= \lim _{n \rightarrow \infty } \frac{\ln 2}{n} + a = a, \quad a \in {\mathbb {R}} \cup \{-\infty \}. \end{aligned}$$

Thus, \({\mathbb {R}}_{\max _n^*}\) does not represent a max-plus algebra, but at least a commutative (with respect to multiplication) semifield. For sufficiently large n, however, we again obtain the property of idempotence (with respect to addition), where in the morphological case the size of n must be considered in relation to \(\ln (k)\). Here \(k \in \mathbb {N}\) represents the size of the mask under consideration.

4 Connection of the Fourier Transform and the Slope Transform

Next, we will deal with the logarithmic connection between morphological and linear systems. To do this, we will use the max-plus algebra (or min-plus algebra) to derive a connection between the Fourier and slope transforms and their analogue from convex analysis, the Legendre transform, in particular on the basis of dilation. See “Appendix A.1” for a short introduction to mathematical morphology and A.2 for a connection with the max-plus algebra.

We first formulate the dilation by means of slope transformations using the smooth maximum:

$$\begin{aligned} \begin{aligned} (f \oplus b)(x)&= \sup _{y \in M} (f \check{\oplus } b)(x) = \sup _{y \in M} {\mathcal {S}}^{-1} \left[ {\mathcal {S}} \left[ f \check{\oplus } b \right] \right] (x) \\&= \sup _{y \in M} {\mathcal {S}}^{-1} \left[ {\mathcal {S}} \left[ f \right] + {\mathcal {S}} \left[ b \right] \right] (x) \\&= \lim _{n \rightarrow \infty } \frac{1}{n} \ln \sum _{y \in M} \textrm{e}^{n {\mathcal {S}}^{-1} \left[ {\mathcal {S}} \left[ f \right] + {\mathcal {S}} \left[ b \right] \right] (x)}, \quad x \in {\mathbb {R}}^2, \end{aligned} \end{aligned}$$
(11)

where \(M := \{ y \in {\mathbb {R}}^2 : \nabla (f(y) + b(x-y)) = 0 \}\). Note that the supremum and the sum over all \(y \in M\) used here are to be understood in a symbolic sense, since the expressions do not depend directly on y but on x. The y is used here in the stat function to ensure that the result is really unique, and thus, Eq. (4) is fulfilled. Due to

$$\begin{aligned}&n {\mathcal {S}}^{-1} \left[ {\mathcal {S}} \left[ f \right] + {\mathcal {S}} \left[ b \right] \right] (x) = n \underset{y \in {\mathbb {R}}^2}{\text {stat}} \left\{ {\mathcal {S}}[f](y) + {\mathcal {S}}[b](y) + \langle x, y \rangle \right\} \\&\quad = \underset{y \in {\mathbb {R}}^2}{\text {stat}} \left\{ n {\mathcal {S}}[f](y) + n {\mathcal {S}}[b](y) + \langle nx, y \rangle \right\} \\&\quad = \underset{y \in {\mathbb {R}}^2}{\text {stat}} \left\{ n \underset{z \in {\mathbb {R}}^2}{\text {stat}} \left\{ f(z) - \langle y, z \rangle \right\} + n \underset{z \in {\mathbb {R}}^2}{\text {stat}} \left\{ b(z) - \langle y, z \rangle \right\} + \langle nx, y \rangle \right\} \\&\quad = \underset{y \in {\mathbb {R}}^2}{\text {stat}} \left\{ \underset{z \in {\mathbb {R}}^2}{\text {stat}} \left\{ n f(z) - \langle ny, z \rangle \right\} + \underset{z \in {\mathbb {R}}^2}{\text {stat}} \left\{ n b(z) - \langle ny, z \rangle \right\} + \langle nx, y \rangle \right\} \\&\quad = \underset{y \in {\mathbb {R}}^2}{\text {stat}} \left\{ {\mathcal {S}}[nf](ny) + {\mathcal {S}}[nb](ny) + \langle nx, y \rangle \right\} \\&\quad = {\mathcal {S}}^{-1} [ {\mathcal {S}}[nf](ny) + {\mathcal {S}}[nb](ny) ] (nx), \quad x \in {\mathbb {R}}^2, \end{aligned}$$

we can also write Eq. (11) as

$$\begin{aligned} (f \oplus b)(x) = \lim _{n \rightarrow \infty } \frac{1}{n} \ln \sum _{y \in M} \textrm{e}^{{\mathcal {S}}^{-1} [ {\mathcal {S}}[nf](ny) + {\mathcal {S}}[nb](ny) ] (nx)}, \quad x \in {\mathbb {R}}^2. \end{aligned}$$
(12)

If we now compare Eqs. (10) and (12) by dragging the factor \(\frac{1}{n}\) into the logarithm for both and then dragging the limit transition into the logarithm as well, we find that

$$\begin{aligned} \begin{aligned}&\lim _{n \rightarrow \infty } \left( \sum _{y \in M} \textrm{e}^{{\mathcal {S}}^{-1} [ {\mathcal {S}}[nf](ny) + {\mathcal {S}}[nb](ny) ] (nx)} \right) ^{\frac{1}{n}} \\&\quad = \lim _{n \rightarrow \infty } \left( \mathcal {F}^{-1} \left[ \mathcal {F} \left[ \textrm{e}^{nf}\right] (z) \cdot \mathcal {F} \left[ \textrm{e}^{nb}\right] (z) \right] (x) \right) ^{\frac{1}{n}}, \quad x \in {\mathbb {R}}^2. \end{aligned} \end{aligned}$$
(13)

This represents the relationship between the Fourier transform and the slope transform using morphological dilation.

In the following, we will examine the case that is often considered in practice, namely that we disregard the limit and instead assume a fixed n. Thus, by now removing the limit transition and subsequently performing an exponentiation with n, we transform Eq. (13) into the form

$$\begin{aligned}&\sum _{y \in M} \textrm{e}^{{\mathcal {S}}^{-1} [ {\mathcal {S}}[nf](ny) + {\mathcal {S}}[nb](ny) ] (nx)}\\ {}&\quad = \mathcal {F}^{-1} \left[ \mathcal {F} \left[ \textrm{e}^{nf}\right] (z) \cdot \mathcal {F} \left[ \textrm{e}^{nb}\right] (z) \right] (x), \quad x \in {\mathbb {R}}^2. \end{aligned}$$

By applying the Fourier transform on both sides, we get because of the linearity of the Fourier transform

$$\begin{aligned}{} & {} \mathcal {F} \left[ \textrm{e}^{nf}\right] (z) \cdot \mathcal {F} \left[ \textrm{e}^{nb}\right] (z)\nonumber \\ {}{} & {} \quad = \mathcal {F} \left[ \sum _{y \in M} \textrm{e}^{{\mathcal {S}}^{-1} [ {\mathcal {S}}[nf](ny) + {\mathcal {S}}[nb](ny) ] (nx)} \right] (z) \nonumber \\{} & {} \quad = \sum _{y \in M} \mathcal {F} \left[ \textrm{e}^{{\mathcal {S}}^{-1} [ {\mathcal {S}}[nf](ny) + {\mathcal {S}}[nb](ny) ] (nx)} \right] (z), \quad z \in {\mathbb {R}}^2. \nonumber \\ \end{aligned}$$
(14)

Alternatively, we can completely remove the Fourier transforms again by using the convolution theorem instead of the linearity of the Fourier transform in Eq. (14) and then applying the inverse Fourier transform to it again. This yields

$$\begin{aligned}&\mathcal {F} \left[ \sum _{y \in M} \textrm{e}^{{\mathcal {S}}^{-1} [ {\mathcal {S}}[nf](ny) + {\mathcal {S}}[nb](ny) ] (nx)} \right] (z) = \mathcal {F}\left[ \textrm{e}^{nf} * \textrm{e}^{nb} \right] (z) \\&\quad \Longleftrightarrow \sum _{y \in M} \textrm{e}^{{\mathcal {S}}^{-1} [ {\mathcal {S}}[nf](ny) + {\mathcal {S}}[nb](ny) ] (nx)} = \left( \textrm{e}^{nf} * \textrm{e}^{nb}\right) (x)\\ {}&\quad = \sum _{y \in {\mathbb {R}}^2} \textrm{e}^{n (f(y) + b(x-y))} \end{aligned}$$

or

$$\begin{aligned} \sum _{y \in M} \textrm{e}^{n {\mathcal {S}}^{-1} [ {\mathcal {S}}[f](y) + {\mathcal {S}}[b](y) ] (x)} = \sum _{y \in {\mathbb {R}}^2} \textrm{e}^{n (f(y) + b(x-y))}, \quad x \in {\mathbb {R}}^2. \end{aligned}$$
(15)

We summarise the above considerations into

Theorem 2

Let \(f: {\mathbb {R}}^2 \rightarrow {\mathbb {R}}\) and \(b: {\mathbb {R}}^2 \rightarrow {\mathbb {R}}\) are given. Then the sequences of the functions

$$\begin{aligned} \lim _{n \rightarrow \infty } \frac{1}{n} \ln \left( \sum _{y \in {\mathbb {R}}^2} \textrm{e}^{n f(y)} \textrm{e}^{n b(x-y)} \right) \end{aligned}$$

and

$$\begin{aligned} \lim _{n \rightarrow \infty } \frac{1}{n} \ln \sum _{y \in M} \textrm{e}^{n {\mathcal {S}}^{-1} \left[ {\mathcal {S}} \left[ f \right] + {\mathcal {S}} \left[ b \right] \right] (x)} \end{aligned}$$

coincide in every element of the sequence.

Remark 3

Equation (15) in this context reflects the relationship between the convolution theorems of the Fourier and the slope transformation with the dilation terms when the equation is contrasted in the plus-prod algebra

$$\begin{aligned} \sum _{y \in M} \textrm{e}^{n (f \check{\oplus } b)}&= \sum _{y \in M} \textrm{e}^{n {\mathcal {S}}^{-1} [ {\mathcal {S}}[f] + {\mathcal {S}}[b] ]} = \textrm{e}^{nf} * \textrm{e}^{nb}\\ {}&= \mathcal {F}^{-1} \left[ \mathcal {F} \left[ \textrm{e}^{nf}\right] \cdot \mathcal {F} \left[ \textrm{e}^{nb}\right] \right] \end{aligned}$$

and in the max-plus algebra using the monotonicity of the exponential function

$$\begin{aligned}&\sup _{y \in M} {\mathcal {S}}^{-1} \left[ {\mathcal {S}} \left[ f \right] (y) + {\mathcal {S}} \left[ b \right] (y) \right] (x)\\ {}&\quad = \sup _{y \in {\mathbb {R}}^2}\left( f(y) + b(x-y) \right) = (f \oplus b)(x). \end{aligned}$$

In the plus-prod algebra, we recognise a convolution which we can express by means of Fourier transformations, and which we can now also determine in this context by means of the generalised dilation shown in Eq. (3). In the case of the max-plus algebra, we see that the application of the convolution theorem of the slope transformation leads to an analogue of the well-known dilation.

5 Independence of the Fourier Dilation from the Shape of the Structuring Element

At this point, we would like to take a closer look at the choice of the smooth maximum as a substitute for the ordinary maximum and examine which properties result from the example of a dilation. To do this, we look at the work of Kahra, Sridhar and Breuß on the calculation of a fast dilation by means of Fourier transforms and using the smooth maximum. In their work, Kahra, Sridhar and Breuß describe that their method is independent of the shape of the chosen structuring element and that it does not matter for their method whether it is a flat or non-flat structuring element. Although the corresponding algorithm in [16] has been discussed in detail, they do not give any proof of this property. Instead, they only refer to their observations and results there. For this purpose, we want to present two possible ways, both of which prove the above statement, but which yield slightly different results in the process.

To evaluate this, we estimate the error resulting from the difference between the exact dilation and the approximated one. As a first step, we prove the following lemma:

Lemma 1

Let \(f_{\text {ex}} : {\mathbb {R}}^2 \rightarrow [0,255]\) and \(f_{\text {app}} : {\mathbb {R}}^2 \rightarrow [0,255]\) be the results of the exact dilation and the approximated dilation of the greyscale image \(f : {\mathbb {R}}^2 \rightarrow [0,255]\) with the structuring element \(B \subset {\mathbb {R}}^2\):

$$\begin{aligned} f_{\text {ex}}(x) = \lim _{k \rightarrow \infty } \frac{1}{k} \ln \left( \sum _{y \in {\mathbb {R}}^2} \textrm{e}^{k f(y)} \chi _B(x-y) \right) \\ f_{\text {app}}(x) = \frac{1}{n} \ln \left( \sum _{y \in {\mathbb {R}}^2} \textrm{e}^{n f(y)} \chi _B(x-y) \right) , \quad n \in \mathbb {N}, \end{aligned}$$

where

$$\begin{aligned} \chi _B(x) = {\left\{ \begin{array}{ll} 1, \quad x \in B \\ 0, \quad otherwise \end{array}\right. } . \end{aligned}$$

Then applies

$$\begin{aligned} (f_{\text {ex}} - f_{\text {app}})(x) \le \lim _{k \rightarrow \infty } \frac{1}{k} \ln \left( \textrm{e}^{(k-n) f} * \chi _B \right) (x), \quad x \in {\mathbb {R}}^2. \end{aligned}$$
(16)

Proof

We first consider

$$\begin{aligned}&(f_{\text {ex}} - f_{\text {app}})(x)\\ {}&\quad = \lim _{k \rightarrow \infty } \frac{1}{k} \ln \left( \textrm{e}^{k f} * \chi _B \right) (x) - \frac{1}{n} \ln \left( \textrm{e}^{n f} * \chi _B \right) (x) \\&\quad = \lim _{k \rightarrow \infty } \ln \left[ \left( \textrm{e}^{k f} * \chi _B \right) ^{\frac{1}{k}}(x) \right] - \ln \left[ \left( \textrm{e}^{n f} * \chi _B \right) ^{\frac{1}{n}}(x) \right] \\&\quad = \lim _{k \rightarrow \infty } \ln \frac{\left( \textrm{e}^{k f} * \chi _B \right) ^{\frac{1}{k}}}{\left( \textrm{e}^{n f} * \chi _B \right) ^{\frac{1}{n}}} (x) = \ln \left[ \lim _{k \rightarrow \infty } \frac{\left( \textrm{e}^{k f} * \chi _B \right) ^{\frac{1}{k}}}{\left( \textrm{e}^{n f} * \chi _B \right) ^{\frac{1}{n}}} (x) \right] \end{aligned}$$

or

$$\begin{aligned} \textrm{e}^{(f_{\text {ex}} - f_{\text {app}})(x)}&= \lim _{k \rightarrow \infty } \frac{\left( \textrm{e}^{k f} * \chi _B \right) ^{\frac{1}{k}}}{\left( \textrm{e}^{n f} * \chi _B \right) ^{\frac{1}{n}}} (x)\\ {}&\le \lim _{k \rightarrow \infty } \left[ \frac{\left( \textrm{e}^{k f} * \chi _B \right) }{\left( \textrm{e}^{n f} * \chi _B \right) } \right] ^{\frac{1}{k}} (x). \end{aligned}$$

Next, we estimate the fraction by proving the following more general inequality:

$$\begin{aligned} \frac{\sum _{i = 1}^m a_i b_i}{\sum _{j=1}^m \tilde{a}_j b_j} \le \sum _{i=1}^m \frac{a_i}{\tilde{a}_i}, \quad a_i, \tilde{a}_i \in [1,\infty ), \quad b_i \in \{0,1\}. \end{aligned}$$

Without restriction of generality, let the \(b_i\) be ordered such that \(b_i = 0\) \(\forall i \in \{ 1, \dots , l\}\) for a fixed \(l \in \{0, \dots , m\}\). Then it applies

$$\begin{aligned} \frac{\sum _{i = 1}^m a_i b_i}{\sum _{j=1}^m \tilde{a}_j b_j}&= \frac{\sum _{i = l+1}^m a_i b_i}{\sum _{j=l+1}^m \tilde{a}_j b_j} = \sum _{i=l+1}^m \underbrace{ \left( \frac{a_i b_i}{\sum _{j=l+1}^m \tilde{a}_j b_j} \right) }_{\le \frac{a_i}{\tilde{a}_i} b_i}\\ {}&\le \sum _{i=1}^m \frac{a_i}{\tilde{a}_i}. \end{aligned}$$

So from this, we get

$$\begin{aligned} \textrm{e}^{(f_{\text {ex}} - f_{\text {app}})(x)} \le \lim _{k \rightarrow \infty } \left( \textrm{e}^{(k-n) f} * \chi _B \right) ^{\frac{1}{k}} (x), \quad x \in {\mathbb {R}}^2. \end{aligned}$$
(17)

Due to the monotonicity of the logarithm function, we finally obtain the inequality we are looking for.

The first possibility to carry out the mentioned proof does not represent an exact calculation in the conventional sense, but rather a heuristic, which, however, delivers an expected result. We summarise this calculation as

Lemma 2

Let the conditions from Lemma 1 be fulfilled and be \(f_{\text {ex}}, f_{\text {app}}, f \in L^2({\mathbb {R}}^2)\). Then it holds

$$\begin{aligned} \big \Vert (f_{\text {ex}} - f_{\text {app}})(x)\big \Vert _2^2 \lessapprox \big \Vert f(x)\big \Vert _2^2 \cdot A(B) , \quad x \in {\mathbb {R}}^2, \end{aligned}$$
(18)

where A(B) represents the area of \(B \subset {\mathbb {R}}^2\).

Proof

We begin with

$$\begin{aligned}&\big \Vert \int \limits _{{\mathbb {R}}^2} (f_{\text {ex}} - f_{\text {app}})(x) \,\textrm{e}^{-\textrm{i} x\omega } \textrm{d}x\big \Vert _2\\&\quad \overset{(16)}{\le } \big \Vert \int \limits _{{\mathbb {R}}^2} \lim _{k \rightarrow \infty } \frac{1}{k} \ln \left( \textrm{e}^{(k-n) f} * \chi _B \right) (x) \,\textrm{e}^{-\textrm{i} x\omega } \textrm{d}x\big \Vert _2\\&\quad = \big \Vert \lim _{k \rightarrow \infty } \frac{1}{k} \int \limits _{{\mathbb {R}}^2} \ln \left( \textrm{e}^{(k-n) f} * \chi _B \right) (x) \,\textrm{e}^{-\textrm{i} x\omega } \textrm{d}x\big \Vert _2 \end{aligned}$$

and use the Taylor linearisation of \(\ln (x)\) at \(x_0 = 1\)

$$\begin{aligned} \ln (x) \overset{\cdot }{\approx }\ \ln (x_0) + \frac{\textrm{d}}{{\textrm{d}x}} \ln (x) \vert _{x = x_0} \cdot (x-x_0) = x-1. \end{aligned}$$

Here we almost always have the case that \(\ln (x) \le x-1\) applies, so in the following we write \(\ln (x) \overset{\cdot }{\le }\ x-1\). If we substitute this into the above inequality, we get

$$\begin{aligned}&\big \Vert \int \limits _{{\mathbb {R}}^2} (f_{\text {ex}} - f_{\text {app}})(x) \,\textrm{e}^{-\textrm{i} x\omega } \textrm{d}x\big \Vert _2 \\&\quad \overset{\cdot }{\le }\ \big \Vert \lim _{k \rightarrow \infty } \frac{1}{k} \int \limits _{{\mathbb {R}}^2} \left[ \left( \textrm{e}^{(k-n) f} * \chi _B \right) (x) - 1 \right] \,\textrm{e}^{-\textrm{i} x\omega } \textrm{d}x\big \Vert _2 \\&\quad = \big \Vert \lim _{k \rightarrow \infty } \frac{1}{k} \int \limits _{{\mathbb {R}}^2} \left( \textrm{e}^{(k-n) f} * \chi _B \right) (x) \,\textrm{e}^{-\textrm{i} x\omega } \textrm{d}x\\ {}&\qquad - \underbrace{\lim _{k \rightarrow \infty } \frac{1}{k} \int \limits _{{\mathbb {R}}^2} \textrm{e}^{-\textrm{i} x\omega } \textrm{d}x}_{=0}\big \Vert _2 \\&\quad = \big \Vert \lim _{k \rightarrow \infty } \frac{1}{k} \mathcal {F} \left[ \textrm{e}^{(k-n) f} * \chi _B\right] (\omega )\big \Vert _2\\ {}&\quad = \big \Vert \lim _{k \rightarrow \infty } \frac{1}{k} \left( \mathcal {F}\left[ \textrm{e}^{(k-n) f}\right] \cdot \mathcal {F}\left[ \chi _B\right] \right) (\omega )\big \Vert _2 \\&\quad = \big \Vert \lim _{k \rightarrow \infty } \frac{1}{k} \mathcal {F}\left[ \textrm{e}^{(k-n) f}\right] (\omega )\big \Vert _2 \cdot \big \Vert \mathcal {F}\left[ \chi _B\right] (\omega )\big \Vert _2. \end{aligned}$$

Next we estimate the two norms and start with the aid of Parseval’s theorem

$$\begin{aligned} \big \Vert \lim _{k \rightarrow \infty } \frac{1}{k} \mathcal {F}\left[ \textrm{e}^{(k-n) f}\right] (\omega )\big \Vert _2&= \lim _{k \rightarrow \infty } \frac{1}{k} \big \Vert \mathcal {F}\left[ \textrm{e}^{(k-n) f}\right] (\omega )\big \Vert _2\\ {}&= \lim _{k \rightarrow \infty } \frac{1}{k} \big \Vert \textrm{e}^{(k-n) f(x)}\big \Vert _2. \end{aligned}$$

To achieve the desired result, we still need to remove the exponential function. For this reason, we reintroduce the logarithm that we previously removed with the Taylor linearisation by performing the said linearisation backwards in an approximate sense (see Remark 2):

$$\begin{aligned}&\lim _{k \rightarrow \infty } \frac{1}{k} \big \Vert \textrm{e}^{(k-n) f(x)}\big \Vert _2\\ {}&\quad = \big \Vert \lim _{k \rightarrow \infty } \frac{1}{k} \textrm{e}^{(k-n) f(x)}\big \Vert _2 = \big \Vert \lim _{k \rightarrow \infty } \frac{1}{k} \left( \textrm{e}^{(k-n) f(x)} - 1 \right) \big \Vert _2 \\&\quad \gtrapprox \big \Vert \lim _{k \rightarrow \infty } \frac{1}{k} \ln \left( \textrm{e}^{(k-n) f(x)} \right) \big \Vert _2\\ {}&\quad = \big \Vert \lim _{k \rightarrow \infty } \left( \frac{k-n}{k} \right) f(x)\big \Vert _2 \\&\quad = \big \Vert f(x)\big \Vert _2. \end{aligned}$$

For the second norm, we also use Parseval’s theorem to derive

$$\begin{aligned} \big \Vert \mathcal {F}\left[ \chi _B\right] (\omega )\big \Vert _2&= \big \Vert \chi _B(x)\big \Vert _2 = \left( \int \limits _{{\mathbb {R}}^2} |\chi _B(x)|^2 \textrm{d}x \right) ^{\frac{1}{2}}\\ {}&= \left( \int \limits _{{\mathbb {R}}^2} \chi _B(x) \textrm{d}x \right) ^{\frac{1}{2}} = \sqrt{A(B)} \end{aligned}$$

from it. From this, we finally deduce the assertion

$$\begin{aligned} \big \Vert \int \limits _{{\mathbb {R}}^2} (f_{\text {ex}} - f_{\text {app}})(x) \,\textrm{e}^{-\textrm{i} x\omega } \textrm{d}x\big \Vert _2 \lessapprox \big \Vert f(x)\big \Vert _2 \cdot \sqrt{A(B)}, \end{aligned}$$

which results in the approximate estimate we are looking for.

Remark 4

The backward linearisation may actually break the chain of inequalities in an exact calculation, which is why we spoke of a heuristic. However, on the one hand because we have only used equalities since the linearisation and on the other hand because we get reasonable results in the form of (18), it appears evident that the backward use of the same linearisation may only slightly violate the inequality.

Another way (and not a heuristic) to substantiate the observation of Kahra, Sridhar and Breuß, we summarise as the

Lemma 3

Let the conditions from Lemma 1 be fulfilled. Then it holds

$$\begin{aligned} (f_{\text {ex}} - f_{\text {app}})(x) \le \sup _{y \in B} \big \Vert f(x-y)\big \Vert , \quad x \in {\mathbb {R}}^2, \quad B \subset {\mathbb {R}}^2. \end{aligned}$$
(19)

Proof

We start from the inequality (17) and rewrite it as follows:

$$\begin{aligned} \textrm{e}^{(f_{\text {ex}} - f_{\text {app}})(x)}&\le \lim _{k \rightarrow \infty } \left( \textrm{e}^{(k-n) f} * \chi _B \right) ^{\frac{1}{k}} (x)\\ {}&= \lim _{k \rightarrow \infty } \left( \int \limits _{{\mathbb {R}}^2} \textrm{e}^{(k-n) f(y)} \chi _B(x-y) \,\textrm{d}y \right) ^{\frac{1}{k}} \\&= \lim _{k \rightarrow \infty } \left( \int \limits _B \textrm{e}^{(k-n) f(x-z)} \,\textrm{d}z \right) ^{\frac{1}{k}}\\ {}&= \lim _{k \rightarrow \infty } \left( \int \limits _B \left( \textrm{e}^{\frac{k-n}{k} f(x-z)} \right) ^k \,\textrm{d}z \right) ^{\frac{1}{k}} \\&= \lim _{k \rightarrow \infty } \left( \int \limits _B | \,\textrm{e}^{\frac{k-n}{k} f(x-z)} |^k \,\textrm{d}z \right) ^{\frac{1}{k}} = \lim _{k \rightarrow \infty } \big \Vert \textrm{e}^{\frac{k-n}{k} f(x-\cdot )}\big \Vert _k \\&= \sup _{y \in B} \big \Vert \textrm{e}^{ f(x-y)}\big \Vert \le \sup _{y \in B} \textrm{e}^{\big \Vert f(x-y)\big \Vert }. \end{aligned}$$

By applying the logarithm on both sides, we obtain the required result.

Both inequalities (18) and (19) show that the observation that in the approximation of the smooth maximum for the dilation, the shape or flatness of the structuring element used does not matter. This is particularly evident from the fact that the error depends on the area of the structuring element, i.e. its size, and on the original image at the searched position or on the original image in the area given by the structuring element. In both cases, all required values for the searched pixel are constant and thus show the validity of the observation made.

Lemma 4

Let the conditions from Lemma 1 be fulfilled. Then it holds

$$\begin{aligned} (f_{\text {ex}} - f_{\text {app}})(x) \le \big \Vert f(x)\big \Vert + \ln \sqrt{A(B)}, \quad x \in {\mathbb {R}}^2, \quad B \subset {\mathbb {R}}^2. \end{aligned}$$
(20)

Proof

We begin by expressing, for a non-negative integrable function h, the inequality

$$\begin{aligned} \int h(x) \,\textrm{d}x&= \int |h(x)| \,\textrm{d}x = \big \Vert h(x)\big \Vert _1 \le \big \Vert h(x)\big \Vert _{\frac{1}{n}}\\ {}&= \left( \int h^\frac{1}{n}(x) \,\textrm{d}x \right) ^n, \quad n \in \mathbb {N}, \end{aligned}$$

due to the monotonicity of the p-norm and exponentiate it with \(\frac{1}{n}\):

$$\begin{aligned} \left( \int h(x) \,\textrm{d}x \right) ^\frac{1}{n} \le \int h^\frac{1}{n}(x) \,\textrm{d}x, \quad n \in \mathbb {N}. \end{aligned}$$
(21)

With the help of this inequality we can now estimate as follows:

$$\begin{aligned} \mathcal {F} \left[ \textrm{e}^{f_{\text {ex}} - f_{\text {app}}} \right] (\omega )&= \int \limits _{{\mathbb {R}}^2} \textrm{e}^{(f_{\text {ex}} - f_{\text {app}})(x)} \,\textrm{e}^{-\textrm{i}\omega x} \,\textrm{d}x \\&\overset{(17)}{\le } \lim _{k \rightarrow \infty } \int \limits _{{\mathbb {R}}^2} \left( \textrm{e}^{(k-n) f} * \chi _B \right) ^{\frac{1}{k}} (x) \,\textrm{e}^{-\textrm{i}\omega x} \,\textrm{d}x\\&= \lim _{k \rightarrow \infty } \int \limits _{{\mathbb {R}}^2} \left( \int \limits _{{\mathbb {R}}^2} \textrm{e}^{(k-n) f(y)} \chi _B(x-y) \,\textrm{d}y \right) ^{\frac{1}{k}} \,\textrm{e}^{-\textrm{i}\omega x} \,\textrm{d}x\\&\overset{(21)}{\le } \lim _{k \rightarrow \infty } \int \limits _{{\mathbb {R}}^2} \left( \int \limits _{{\mathbb {R}}^2} \textrm{e}^{\frac{k-n}{k}f(y)} \chi _B^\frac{1}{k}(x-y) \,\textrm{d}y \right) \,\textrm{e}^{-\textrm{i}\omega x} \,\textrm{d}x \\&= \lim _{k \rightarrow \infty } \int \limits _{{\mathbb {R}}^2} \left( \textrm{e}^{\frac{k-n}{k} f} * \chi _B \right) (x) \,\textrm{e}^{-\textrm{i}\omega x} \,\textrm{d}x \\&= \lim _{k \rightarrow \infty } \mathcal {F} \left[ \textrm{e}^{\frac{k-n}{k} f} * \chi _B \right] (\omega )\\ {}&= \lim _{k \rightarrow \infty } \mathcal {F} \left[ \textrm{e}^{\frac{k-n}{k} f} \right] (\omega ) \cdot \mathcal {F} \left[ \chi _B \right] (\omega ), \end{aligned}$$

where we have used the convolution theorem in the last equality. We next form the norm over this inequality and estimate the norm of the first Fourier transform using Parseval’s theorem:

$$\begin{aligned} \lim _{k \rightarrow \infty } \big \Vert \mathcal {F} \left[ \textrm{e}^{\frac{k-n}{k} f} \right] (\omega )\big \Vert&= \lim _{k \rightarrow \infty } \big \Vert \textrm{e}^{\frac{k-n}{k} f(x)} \big \Vert \\ {}&= \big \Vert \lim _{k \rightarrow \infty } \textrm{e}^{\left( 1-\frac{n}{k}\right) f(x)} \big \Vert = \big \Vert \textrm{e}^{f(x)} \big \Vert \\&\le \textrm{e}^{\big \Vert f(x)\big \Vert } \end{aligned}$$

and we estimate the norm of the second Fourier transform, as in the proof of Lemma 1, with \(\sqrt{A(B)}\). By applying Parseval’s theorem again for the backward direction, we get

$$\begin{aligned} \big \Vert \textrm{e}^{(f_{\text {ex}} - f_{\text {app}})(x)} \big \Vert&= \big \Vert \mathcal {F} \left[ \textrm{e}^{f_{\text {ex}} - f_{\text {app}}} \right] (\omega ) \big \Vert \\ {}&\le \big \Vert \lim _{k \rightarrow \infty } \mathcal {F} \left[ \textrm{e}^{\frac{k-n}{k} f} \right] (\omega ) \cdot \mathcal {F} \left[ \chi _B \right] (\omega ) \big \Vert \\&\le \lim _{k \rightarrow \infty } \big \Vert \mathcal {F} \left[ \textrm{e}^{\frac{k-n}{k} f} \right] (\omega )\big \Vert \cdot \big \Vert \mathcal {F} \left[ \chi _B \right] (\omega ) \big \Vert \\ {}&\le \textrm{e}^{\big \Vert f(x)\big \Vert } \sqrt{A(B)}. \end{aligned}$$

Furthermore, we can use this inequality to achieve the desired result:

$$\begin{aligned} (f_{\text {ex}} - f_{\text {app}})(x)&= \ln \underbrace{\textrm{e}^{(f_{\text {ex}} - f_{\text {app}})(x)}}_{\ge 0} = \ln \big \Vert \textrm{e}^{(f_{\text {ex}} - f_{\text {app}})(x)}\big \Vert \\&\le \ln \left( \textrm{e}^{\big \Vert f(x)\big \Vert } \sqrt{A(B)} \right) \\&= \big \Vert f(x)\big \Vert + \ln \sqrt{A(B)}. \end{aligned}$$

The bound derived above is apparently weaker than the ones from previous result. However, it demonstrates the same kind of independence from shape of the structuring element, and within the proof, one may observe that it is a relatively pessimistic (and thus unsharp) estimate.

6 Practical Error Estimation

From this context, the question automatically arises for which n this error becomes negligible in practice. To answer this question, we evaluate the error range. The largest error is in the case that all considered k pixels have the same value, i.e. we obtain \(\frac{\ln (k)}{n}\) as error, see proof of Corollary 1. Consequently, the smallest error results if we have a single maximum grey value \(x_i\):

$$\begin{aligned} \frac{1}{n} \ln {\sum _{j=1}^k \textrm{e}^{n x_j}} = x_i + \frac{1}{n} \ln {\sum _{j=1}^k \textrm{e}^{n (x_j - x_i)}}. \end{aligned}$$

The error that occurs here can vary between

$$\begin{aligned} \frac{1}{n} \ln {\sum _{\begin{array}{c} j=1 \end{array}}^k \textrm{e}^{n (x_j - x_i)}}&\ge \frac{1}{n} \ln {\sum _{\begin{array}{c} j=1 \end{array}}^k \textrm{e}^{-255n}} = \frac{1}{n} \left( \ln (k) - 255n \right) \\ {}&= \frac{\ln (k)}{n} - 255 \end{aligned}$$

and

$$\begin{aligned} \frac{1}{n} \ln {\sum _{\begin{array}{c} j=1 \end{array}}^k \textrm{e}^{n (x_j - x_i)}}&\le \frac{1}{n} \ln {\sum _{\begin{array}{c} j=1 \end{array}}^k \textrm{e}^{-n}} = \frac{1}{n} \left( \ln (k) - n \right) \\ {}&= \frac{\ln (k)}{n} - 1, \end{aligned}$$

i.e.

$$\begin{aligned} \frac{1}{n} \ln {\sum _{j=1}^k \textrm{e}^{n (x_j - x_i)}} \in \left[ \frac{\ln (k)}{n} - 255,\frac{\ln (k)}{n} - 1\right] , \end{aligned}$$

depending on the composition of the remaining (not maximum) grey values.

We consider an error to be negligible in practice if it is smaller than \(\frac{1}{2}\), because we assume natural grey values from the interval [0, 255] and we round up or down the floating point numbers resulting from the calculation according to the usual rounding rules in order to continue calculating with natural numbers. This means that we can estimate the smallest possible scaling factor for which the error can disappear as follows:

$$\begin{aligned} \frac{\ln (k)}{n} - 255 \overset{!}{<}\ \frac{1}{2} \Longleftrightarrow n \overset{!}{>}\ \frac{2\ln (k)}{511} \end{aligned}$$

and for the largest error

$$\begin{aligned} \frac{\ln (k)}{n} \overset{!}{<}\ \frac{1}{2} \Longleftrightarrow n \overset{!}{>}\ 2 \ln (k). \end{aligned}$$

Thus, in practice, it is sufficient to choose a \(n\in \mathbb {N}\) which, depending on the mask and grey value distribution, is larger than the corresponding value from the interval

$$\begin{aligned} n \in \left[ \frac{2\ln (k)}{511} , 2 \ln (k)\right] , \end{aligned}$$
(22)

so that \({\mathbb {R}}_{\max }^*\) behaves like a max-plus algebra. At this point, we would like to point out that the smallest possible value is of a purely theoretical nature and will be significantly larger in practice. We will deal with this in more detail in the following chapter.

In the following, we will test this accuracy criterion using the example of the error observation of the previous section. That means we have to set \(n > 2 \ln |B|\). Let \(p := |B|\) and set \(n := 4 \ln (p)\) for simplicity’s sake. Let the pixels within the structuring element at position \(x \in {\mathbb {R}}^2\) be given by \(x_j\), \(j \in \{ 1, \dots , p\}\). Furthermore, the largest greyscale value in the neighbourhood B of pixel x should be located at position \(x_i\), \(i \in [1,p]\), so that \(f_{\text {ex}}(x) = f(x_i)\). We can then estimate the approximated dilation accordingly with

$$\begin{aligned} f_{\text {app}}(x)&= \frac{1}{4 \ln (p)} \ln \sum _{j=1}^p \textrm{e}^{4 \ln (p) f(x_j)}\\ {}&= f(x_i) + \frac{1}{4 \ln (p)} \ln \sum _{\begin{array}{c} j=1 \end{array}}^p \textrm{e}^{4 \ln (p) (f(x_j) - f(x_i))} \\&\le f(x_i) + \frac{1}{4 \ln (p)} \ln (p) = f(x_i) + \frac{1}{4}. \end{aligned}$$

It therefore follows that \(|(f_{\text {ex}} - f_{\text {app}})(x)| \le \frac{1}{4}\) and we also see that the error, as expected, is less than \(\frac{1}{2}\). Thus, when rounding, it disappears and we get the correct result.

Fig. 1
figure 1

Filtering results for dilation with a \(3 \times 3\) SE. Original image of size \(40 \times 40\) (a) and exact dilated image (b). Approximated dilation with \(n = 0.05\) (c), \(n = 0.1\) (d), \(n = 0.2\) (e) and \(n = 4.5\) (f)

Example 1: Stairs

To illustrate our findings, we consider a greyscale image of size \(40 \times 40\) and perform a dilation with a \(3 \times 3\) SE, see Fig. 1. The comparison of the different scaling factors n for the values 0.05, 0.1, 0.2 and 4.5 shows that the resulting grey value shift becomes smaller and smaller with increasing n and in the case of \(n = 4.5\) even disappears completely. This supports the inequality shown above, since \(2 \ln (9) \approx 4.3944\).

Fig. 2
figure 2

Comparison of filtering results for dilation of a \(40 \times 40\) image of squares of graduated grey values 0,1,2 and 3 with a \(3 \times 3\) SE. The exact dilation is indicated in each case with light grey and the approximated dilations with quantisation grey and without quantisation dark grey. Top:From left to right: Approximation with scaling factor 0.1,0.2 and 1.0. Bottom:From left to right: Approximation with scaling factor 1.5,2.0 and 4.5

Example 2: Squares

In order to make the effect of the grey value shift and the quantisation, which arises through the now more targeted rounding, even clearer, we consider another example. For this, we again choose a greyscale image of the size \(40 \times 40\) and a SE with \(3 \times 3\), see Fig. 2. The image is created by superimposing smaller centred squares with different brightness levels, where the largest square is \(40 \times 40\) and has the grey value 0 and the smallest in the middle is \(10 \times 10\) and has the grey value 3. The squares in between have corresponding edge lengths of 20 and 30 and grey values of 1 and 2. Here we see in the histograms how the approximated dilation with (grey) and without quantisation (dark grey) relates to the exact dilation (light grey). For relatively small n, such as 0.1 or 0.2, quite large deviations from the correct result occur. The quantised approximation approaches the exact solution more quickly and more accurately than the non-quantised approximation, as we can see in the diagrams for \(n \in \{1, 1.5, 2, 4.5\}\). Here, too, the quantised approximation finally agrees with the exact solution for \(n=4.5\).

7 Supplementary Discussion

In this section, we will discuss again one of our main results, namely that the approximation error that occurs depends only on the size of the SE and how much maximal values are in the neighbourhood of the SE. Therefore, here we will look at what happens when we change the mask size and the meaning for the interval (22) of the scaling factor. Remember, this interval tells us when the error in the grey shift can possibly disappear. To illustrate this, we choose the bridge image and dilate it in a first experiment with a \(3\times 3\) mask for different sizes of n in Fig. 3.

Fig. 3
figure 3

Comparison of filtering results for dilation of the \(256 \times 256\) bridge image with a \(3 \times 3\) mask. Top: From left to right: Original image, exactly dilated image, approximately dilated image with factor \(n = 2.5\). Bottom: From left to right: Approximation with scaling factor 0.05, 0.1 and 1

Here we can again see a clear grey value shift for small n such as \(n = 0.05\) or \(n = 0.1\). If we increase the factor further, e.g. to one or higher, it becomes difficult to perceive differences with the human eye. Likewise, with our interval for this case (\(k = 9\)), i.e. for approximately \(n \in [0.0086,4.3944]\), we cannot draw any conclusions as to whether one of these images is necessarily error-prone or error-free, since the values 1 and 2.5 both lie in the interval mentioned.

To create a first comparison, let us look at the same image, but this time dilate it with a larger SE, namely a \(5 \times \)5 mask. According to our previous findings, the approximate interval for the smallest possible error-free scaling factor would be [0.0126, 6.4378]. This would indicate that we must expect to use larger values to obtain comparable results. Therefore, we extend our reference images with an additional image for \(n = 3.5\) and summarise these images in Fig. 4.

Fig. 4
figure 4

Comparison of filtering results for dilation of the \(256 \times 256\) bridge image with a \(5 \times 5\) mask. Top: From left to right: Exactly dilated image, approximately dilated image with factor \(n = 3.5\) and \(n = 2.5\). Bottom: From left to right: Approximation with scaling factor 0.05, 0.1 and 1

In this case, too, we first see clear grey value shifts for low n. In particular, we also see that the grey value shifts are more pronounced than in the previous experiment with the \(3 \times 3\) mask. This indicates that our assessment that we need a larger scaling factor for a larger SE is correct. Larger values such as 1, 2.5 or 3.5, however, do not seem to show a visible grey shift. This would imply that our approximation becomes “accurate” relatively quickly, at least for the human eye. To better measure these possible small differences, we consider the corresponding average error curves for these experiments for \(n \in [0.05,2.5]\), see Fig. 5.

In Fig. 5a for the range [0.05, 0.5], we see what we had already conjectured. The two graphs have a similar shape but the one for the \(5 \times 5\) SE shows a larger difference, respectively, takes longer to reach the same grey value difference as the \(3 \times 3\) graph. In addition, we also see that the differences become very small already at 0.5, so that visually one can hardly recognise them.

By Fig. 5b, we study possible errors in higher detail. We can still see that the curves are relatively similar, as can be seen, for example, at 1.95, where both are almost synchronous. As we can see here, the exactness may be reached, but is not maintained up to a small numerical error. This also continues for larger values of n, which are not shown here. Nevertheless, these errors are so small in magnitude that we conjecture that they can be neglected in practice. This can be illustrated by looking at the comparatively large difference at 2.4, which has an average error of about 0.007, which means that about every 140th pixel has a grey value shift of one, which may be considered as of the same order as a quantisation error.

Fig. 5
figure 5

Averaged error curve of approximations of Figs. 3 (continues line) and 4 (dashed line with circles) from \(n = 0.05\) to 0.5 (a) and from \(n = 1.4\) to 2.5 (b) over all pixels

8 Conclusion

We have shown a short and simple way to demonstrate the logarithmic relationship between the Fourier and slope transforms. In doing so, we have established that a convolution can be calculated by means of a generalised dilation in the plus-prod algebra and that the convolution theorem of the slope transformation in the max-plus algebra yields an ordinary dilation.

We also proved that the dilation by Fourier transforms is independent of the shape of the SE and depends exclusively on its size. In this respect, we gave an estimate for the scaling factor n at which point it leads to the approximated solution not differing from the exact solution by more than half a grey value, in the sense of a grey value scale from 0 to 255. In particular, it becomes obvious that the grey value shift, which arises through the approximation, can be eliminated through appropriate choice of the factor n by means of rounding off.