Properties of Morphological Dilation in Max-Plus and Plus-Prod Algebra in Connection with the Fourier Transformation

The basic filters in mathematical morphology are dilation and erosion. They are defined by a structuring element that is usually shifted pixel-wise over an image, together with a comparison process that takes place within the corresponding mask. This comparison is made in the grey value case by means of maximum or minimum formation. Hence, there is easy access to max-plus algebra and, by means of an algebra change, also to the theory of linear algebra. We show that an approximation of the maximum function forms a commutative semifield (with respect to multiplication) and corresponds to the maximum again in the limit case. In this way, we demonstrate a novel access to the logarithmic connection between the Fourier transform and the slope transformation. In addition, we prove that the dilation by means of a fast Fourier transform depends only on the size of the structuring element used. Moreover, we derive a bound above which the Fourier approximation yields results that are exact in terms of grey value quantisation.


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, B Marvin Kahra marvin.kahra@b-tu.de Michael Breuß breuss@b-tu.de 1 Institute for Mathematics, Brandenburg Technical University Cottbus-Senftenberg, Platz der Deutschen Einheit 1, 03046 Cottbus, Brandenburg, Germany [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 maxplus 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.

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 : R 2 → R with a (flat) structuring function b : R 2 →R according to behaves. To do this, we consider the generalisation (called "tangential dilation") used by Dorst and van den Boomgaard [14] ( f⊕b)(x) := stat where the following connection exists: Under this premise, one considers the slope transform S, which satisfies as a morphological analogy to the Fourier transform since S in a certain sense satisfies a convolution theorem similar to the Fourier transform: For further details regarding the slope transform and corresponding connections to other transformations, please refer to "Appendix A.3" and the references listed there.

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 plusprod 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 ∈ R 2 : (9) whereb(x) = −b(−x). Furthermore, we know that we can approximate the dilation by the smooth maximum with Fourier transforms according to [16]: 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 R max * n = (R ∪ {−∞}, 1 n ln e n·(...) , +, −∞, 0) which resembles the normal max-plus algebra R max = (R ∪ {−∞}, max, +, −∞, 0) except for the change that instead of the maximum we use the smooth maximum without the limit transition 1 n ln e n·(...) for the link⊕. For better readability, we use⊕ and⊗ 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 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:

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 ∈ R∪{−∞}: Corollary 1 Let the approximated smooth maximum be given as in Theorem 1. Then lim n→∞ 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: Thus, 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 ∈ N represents the size of the mask under consideration.

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: where M := {y ∈ R 2 : ∇( f (y) + b(x − y)) = 0}. Note that the supremum and the sum over all y ∈ 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 we can also write Eq. (11) as If we now compare Eqs. (10) and (12) by dragging the factor 1 n into the logarithm for both and then dragging the limit transition into the logarithm as well, we find that 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 By applying the Fourier transform on both sides, we get because of the linearity of the Fourier transform 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 We summarise the above considerations into coincide in every element of the sequence. (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

Remark 3 Equation
and in the max-plus algebra using the monotonicity of the exponential function 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.

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: Then applies Proof We first consider Next, we estimate the fraction by proving the following more general inequality: Without restriction of generality, let the b i be ordered such So from this, we get 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 ex , f app , f ∈ L 2 (R 2 ). Then it holds where A(B) represents the area of B ⊂ R 2 .
Proof We begin with and use the Taylor linearisation of ln(x) at Here we almost always have the case that ln(x) ≤ x − 1 applies, so in the following we write ln(x) · ≤ x − 1. If we substitute this into the above inequality, we get Next we estimate the two norms and start with the aid of Parseval's theorem 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): For the second norm, we also use Parseval's theorem to derive from it. From this, we finally deduce the assertion 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
Proof We start from the inequality (17) and rewrite it as follows: 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
Proof We begin by expressing, for a non-negative integrable function h, the inequality due to the monotonicity of the p-norm and exponentiate it with 1 n : With the help of this inequality we can now estimate as follows: (17) ≤ lim 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: and we estimate the norm of the second Fourier transform, as in the proof of Lemma 1, with √ A(B). By applying Parseval's theorem again for the backward direction, we get Furthermore, we can use this inequality to achieve the desired result: 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.

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 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 : The error that occurs here can vary between 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 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: and for the largest error Thus, in practice, it is sufficient to choose a n ∈ N which, depending on the mask and grey value distribution, is larger than the corresponding value from the interval n ∈ 2 ln(k) 511 , 2 ln(k) , (22) so that 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 ∈ R 2 be given by x j , j ∈ {1, . . . , p}. Furthermore, the largest greyscale value in the neighbourhood B of pixel x should be located at position We can then estimate the approximated dilation accordingly with It therefore follows that |( f ex − f app )(x)| ≤ 1 4 and we also see that the error, as expected, is less than 1 2 . Thus, when rounding, it disappears and we get the correct result.

Example 1: Stairs
To illustrate our findings, we consider a greyscale image of size 40 × 40 and perform a dilation with a 3 × 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) ≈ 4.3944.

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 × 40 and a SE with 3 × 3, see Fig. 2. The image is created by superimposing smaller centred squares with different brightness levels, where the largest square is 40 × 40 and has the grey value 0 and the smallest in the middle is 10 × 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 nonquantised approximation, as we can see in the diagrams for n ∈ {1, 1.5, 2, 4.5}. Here, too, the quantised approximation finally agrees with the exact solution for n = 4.5.

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 × 3 mask for different sizes of n in Fig. 3.
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 ∈ [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×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.
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 × 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 ∈ [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×5 SE shows a larger difference, respectively, takes longer to reach the same grey value difference as the 3 × 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.

Conclusion
We have shown a short and simple way to demonstrate the logarithmic relationship between the Fourier and slope trans-forms. 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 Acknowledgements The work of the authors is partially supported by the European Regional Development Fund, EFRE 85037495. On the mathematical side, the authors would like to thank Joachim Weickert for an inspiring remark on the possible logarithmic relation of the approximate Fourier framework and the slope transform.
Funding Open Access funding enabled and organized by Projekt DEAL.
Open Access This article is licensed under a Creative Commons Attribution 4.0 International License, which permits use, sharing, adaptation, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons licence, and indicate if changes were made. The images or other third party material in this article are included in the article's Creative Commons licence, unless indicated otherwise in a credit line to the material. If material is not included in the article's Creative Commons licence and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder. To view a copy of this licence, visit http://creativecomm ons.org/licenses/by/4.0/. + as binary relations for⊕ and⊗ . This is sometimes also called an ordered group. In this context, one can specify the natural order by means of⊕ : In particular, R max fulfils all requirements for an idempotent commutative semifield K, i.e.: • The operation⊕ is associative, commutative and has a zero element ε = −∞; • The operation⊗ defines a group on K \ {ε} = R, it is distributive with respect to⊕ and its identity element e = 0 satisfies ε⊗ e = e⊗ ε = ε; • The first operation is idempotent, that is, if a⊕ a = a for all a ∈ K; • The group is commutative.
At this point, we would also like to point out the connection with mathematical morphology. By considering mappings from R 2 to R max , one can define the necessary operations as follows: • ( f⊕ g)(x) = f (x)⊕ g(x) = max( f (x), g(x)), x ∈ R 2 ; • ( f⊗ g)(x) = sup y∈R 2 ( f (x − y) + g(y)), x ∈ R 2 ; It should be noted here, however, that for arbitrary mappings f , g : R 2 → R max , the new "max-plus algebra" R R max thus declared is not closed under supremum convolution. However, by restricting ourselves to mappings that are bounded from above (for example, greyscale images in mathematical morphology), it again becomes a max-plus algebra. This gives us an analytical approach to the formation of dilation or erosion in mathematical morphology.

A.3 Slope Transform
In this section, we would like to give a brief introduction to the theory of slope transform. The concept of slope trans-form goes back to the idea that with the tangential dilation (3) the slopes are maintained locally and only the point that carries the slope is translated. This translates a function with a constant slope as a whole, which leads us to the theory of morphological eigenfunctions, see [14] for more details. The slope transform resulting from these considerations is denoted by and the inverse transform In order to give an overview of the most important properties of the slope and Fourier transformation in this respect, we have summarised them in Table 1. The slope transform is also a generalisation of the Legendre transformation [14,24] known from mathematical physics [25]: This can be generalised to the conjugacy operation (also called "Young-Fenchel conjugate" in [14] or "Legendre-Fenchel transform" in [15]) in convex analysis [26]: which is also closely related to the slope transform. This yields real-valued functions in contrast to the slope transform, which only yields set-valued functions. It is worth mentioning in connection with mathematical morphology that structuring functions in the form of paraboloids retain their shape under the slope transform. The resulting scale spaces for dilation and erosion were studied by Jackway and Deriche [27].