1 Introduction

This paper is a sequel of the first part of our study of flat morphology [1].

Many morphological operators on grey-level or multivalued images are what one calls flat operators: for instance the median filter, or the dilation, erosion, opening and closing by a flat structuring element. They are obtained from an operator on binary images (or sets) through the method of flat extension [2]. It works by thresholding the image, applying the binary operator on the thresholds, then superposing the modified thresholds. Let us briefly describe it.

We consider a space of points E, which can be the Euclidean (\(E=\mathbb {R}^n\)) or digital (\(E=\mathbb {Z}^n\)) space, or a subset of such a space. Write \(\mathcal {P}(E)\) for the set of all subsets of E (i.e., binary images). For \(X\in \mathcal {P}(E)\), write \(X^c\) for \(E{\setminus } X\), its complement in E. Image intensities are numerical values; they range in a closed subset T of \(\overline{\mathbb {R}}= \mathbb {R}\cup \{-\infty ,+\infty \}\); for example in the digital case, one can take T to be an interval in \(\overline{\mathbb {Z}}= \mathbb {Z}\cup \{-\infty ,+\infty \}\). Let V be the set of image values, either \(V=T\) for grey-level images, or \(V=T^m\) (\(m>1\)) for multivalued images. Then V is ordered, numerically for \(V=T\), and by componentwise (or marginal) order for \(T^m\):

$$\begin{aligned} (x_1,\ldots ,x_m) \le (y_1,\ldots ,y_m)&\nonumber \\ \iff x_i \le y_i \text{ for } i=1,\ldots ,m .&\end{aligned}$$
(1)

Since T is closed, V is a complete lattice [3]: every subset of V has a supremum and an infimum for the order. Write \(\bot \) and \(\top \) for the least and greatest elements of V, and \(\bigvee \) for the supremum operation in V; when \(V=T\), \(\bigvee \) is the numerical supremum, and when \(V=T^m\), it is the componentwise numerical supremum. We consider images \(E\rightarrow V\), for instance grey-level images \(E\rightarrow T\) or multivalued images \(E\rightarrow T^m\); write \(V^E\) for the set of images \(E\rightarrow V\).

For an image \(F:E\rightarrow V\) and \(v\in V\), the threshold set [4] is

$$\begin{aligned} \textsf{X}_v(F) = \{ p\in E \mid F(p)\ge v \} . \end{aligned}$$
(2)

The set \(\textsf{X}_v(F)\) is decreasing in v: \(w>v \;\Rightarrow \;\textsf{X}_w(F) \subseteq \textsf{X}_v(F)\).

For \(B\subseteq E\) and \(v\in V\), the cylinder of base B and level v is the function \(C_{B,v}\) given by setting for \(p\in E\): \(C_{B,v}(p) = v\) if \(p\in B\), and \(C_{B,v}(p) = \bot \) if \(p\notin B\). Then every function \(F: E\rightarrow V\) is the upper envelope of the sets \(\{v\} \times \textsf{X}_v(F)\), in other words, \(F = \bigvee _{v\in V} C_{\textsf{X}_v(F),v}\). In other words, F can be recovered by superposing its thresholdings at all values \(v\in V\).

Consider now an increasing operator \(\psi : \mathcal {P}(E) \rightarrow \mathcal {P}(E)\) on binary images: \(X \subseteq Y\;\Rightarrow \;\psi (X) \subseteq \psi (Y)\). Then for any \(F:E\rightarrow V\), we take the upper envelope \(\psi ^V(F)\) of the sets \(\{v\} \times \psi \left( \textsf{X}_v(F)\right) \), in other words:

$$\begin{aligned} \psi ^V(F) = \bigvee _{v\in V} C_{\psi \left( \textsf{X}_v(F)\right) ,v} . \end{aligned}$$
(3)

For every point \(p\in E\) we have:

$$\begin{aligned} \psi ^V(F)(p) = \bigvee \bigl \{ v\in V \bigm \vert p\in \psi (\textsf{X}_v(F)) \bigr \} . \end{aligned}$$
(4)

Then \(\psi ^V: V^E\rightarrow V^E: F \mapsto \psi ^V(F)\) is the flat operator corresponding to \(\psi \), or the flat extension of \(\psi \) [2, 5].

An advantage of this method is that it works for any complete lattice V of image values, it is not restricted to the cases \(V=T\) or \(V=T^m\) (grey-level or multivalued images) that we consider here. Indeed, [2] considered an arbitrary complete lattice V of values, and gave examples with images having non-numerical values, for instance in the lattice of labels (see Figs. 2, 6 and 7 in that paper).

However, it has a fundamental limitation: it is restricted to increasing operators, in other words, operators that preserve the inclusion order. Thus, it cannot be applied to non-increasing operators such as the morphological gradient and Laplacian, the top-hat, or the hit-or-miss transform. We illustrated this failure in Subsection 1.1 of [1] with the simple example of the set difference between a dilation and an erosion on binary images, see Figs. 3 and 4 there: the method of [2] does not give what we would expect, namely the arithmetical difference between the corresponding flat dilation and erosion.

In [1] we proposed to replace the last step in the method, namely the superposition of the threshold sets \(\{v\} \times \psi \left( \textsf{X}_v(F)\right) \), cf. (3), by a summation of the characteristic functions of these thresholds \(\psi \left( \textsf{X}_v(F)\right) \).

For a set \(X\in \mathcal {P}(E)\), write \(\chi X\) for the characteristic function of X: for \(p\in E\), \(\chi X(p) = 1\) if \(p\in X\) and \(\chi X(p) = 0\) if \(p\notin X\). Then for an operator \(\psi : \mathcal {P}(E) \rightarrow \mathcal {P}(E)\), let \(\chi \psi :\mathcal {P}(E) \rightarrow \{0,1\}^E\) be the composition of \(\psi : \mathcal {P}(E) \rightarrow \mathcal {P}(E)\) followed by \(\chi : \mathcal {P}(E) \rightarrow \{0,1\}^E\); thus, for any \(X\in \mathcal {P}(E)\) we write \(\chi \psi (X)\) for the characteristic function of \(\psi (X)\). Then, when \(V\subseteq \mathbb {R}^m\), the flat extension of an increasing binary operator \(\psi \) satisfies

$$\begin{aligned} \psi ^V(F)(p) = \bot + \mathcal {S}\bigl (\chi \psi (\textsf{X}_v(F))(p) \bigm \vert v\in V\bigr ) , \end{aligned}$$

where \(\bot \) is the least element of V and \(\mathcal {S}\) is a summation operator that we introduced in [6] and studied further in [1]; here we sum the binary values \(\chi \psi (\textsf{X}_v(F))(p)\) for v ranging in V. This formula is valid when the operator \(\psi \) is increasing. We proposed to extend it to any operator \(\psi \) on binary images; in some cases, for instance in the morphological gradient, the base value \(\bot \) can be omitted in it. We obtained then non-increasing flat operators that conform to intuition, in particular the morphological gradient and Laplacian, the top-hat and the hit-or-miss transform get flat extensions that agree with the forms empirically given in the literature.

Because of the summation \(\mathcal {S}\), this new approach requires some restrictions that were not necessary in the previous theory of [2] for increasing operators. First, \(\mathcal {S}\) is defined only for functions with bounded numerical or vector values (we recall in Sect. 2.3 the definition and properties of \(\mathcal {S}\), and the form that it takes for discrete or continuous values and vectors). Thus, the complete lattice V takes here the form \(V = V_1 \times \cdots \times V_m\), where each \(V_i = [\bot _i,\top _i]\), a bounded closed interval of \(\mathbb {R}\) or of \(u_i \mathbb {Z}\) for some real \(u_i >0\) (usually \(u_i=1\)); we also allow a complete sublattice of \(V_1 \times \cdots \times V_m\). Second, the summation \(\mathcal {S}\) requires the summed function to be of bounded variation, see Sect. 2.2; in practice, this condition is satisfied in many situations (see Subsection 5.2 of [1] for more details):

  • when V has finite height, in particular if V is finite;

  • when the operator \(\psi \) is local, that is, for any \(p\in E\), there is a finite \(W(p)\in \mathcal {P}(E)\) such that for any \(Z\in \mathcal {P}(E)\), \(p\in \psi (Z) \;\Leftrightarrow \;p\in \psi \bigl (Z\cap W(p)\bigr )\), for instance if \(\psi \) is a morphological operator with a finite structuring element;

  • when \(\psi \) is obtained as a linear combination of increasing binary operators, for instance the morphological gradient and Laplacian, the top-hat and the hit-or-miss transform.

Subsection 5.3 of [1] studied some elementary properties of this generalised form of flat extension, for instance the componentwise decomposition of a flat operator on vector images into grey-level flat operators for the vector components, and conditions for the preservation of an interval of values. Then its Subsection 5.4 showed that connected binary operators extend to connected flat operators, and we linked our method to the max-tree approach to anti-extensive connected operators.

In this paper, we will continue the analysis of the properties of our generalised flat extension. We first give a mathematical reminder in Sect. 2. In Sect. 3, after recalling our definition of flat extension, we consider some further properties: the flat extension of a supremum and infimum of binary operators (Sect. 3.1), the flat extension of a composition of binary operators (Sect. 3.2), and finally the commutation of flat operators with contrast mappings (Sect. 3.3).

Duality under inversion of values is a complex problem, to which we devote Sect. 4. We first consider the dual form of summation (Sect. 4.1), then the relation between duality and flat extension (Sect. 4.2).

Section 5 introduces the study of flat linear operators. We will show that a linear convolution by a finite mask is a flat operator.

Finally, the conclusion summarises our work and suggests possible generalisations.

2 Mathematical Background

We summarise here the mathematical basis of our theory: posets and lattices (Sect. 2.1), bounded variation (Sect. 2.2) and function summation (Sect. 2.3).

2.1 Posets and Lattices

Concerning posets and lattices, we follow the theory given in [3, 7, 8]; the basic terminology was given in Subsection 1.3 of [1], we refer the reader to it. The following concepts are thus assumed to be known: a poset, a chain and its length, the height of a poset, a closed interval, a closure operator, a closure range, a bounded poset, a lattice, a complete lattice, a conditionally complete lattice, an inf-closed (resp., sup-closed) subset of a complete lattice. By empty/non-empty supremum or infimum, we mean supremum or infimum of an empty/non-empty subset of the lattice. We write h(P) for the height of a poset P.

Let L be a complete lattice. We say that L is infinitely supremum distributive if it satisfies the identity \(a\wedge \bigl (\bigvee _{i\in I} b_i\bigr ) \) \(= \bigvee _{i\in I} (a\wedge b_i)\) for any \(a\in L\) and any subset \(\{ b_i \mid i\in I\} \subseteq L\). In Subsection 2.1 of [2], we also considered complete distributivity, which is usually defined as extended supremum distributivity (equations (10,12) there) or as extended infimum distributivity (equations (11,13) there). We will use here an equivalent form given there. Define the relation \(\triangleleft \) on L as follows (see equation (14) in [2]): for \(w,x\in L\),

$$\begin{aligned}&w \triangleleft x \quad \iff \quad \bigl [\, \forall Y\subseteq L , \nonumber \\&x \le \bigvee Y \;\Rightarrow \;\exists y\in Y, ~ w\le y \,\bigr ] . \end{aligned}$$
(5)

Note that we do not exclude the case where \(Y=\emptyset \); it shows that one can never have \(w \triangleleft \bot \). Moreover [2]: \(w\triangleleft x \;\Rightarrow \;w\le x\), \(v\le w\triangleleft x\le y \;\Rightarrow \;v\triangleleft y\), and \(\bot \triangleleft x \;\Leftrightarrow \;\bot <x\).

By Lemma 2 of [2], L is completely distributive iff:

$$\begin{aligned} \forall \, x\in L, \quad x = \bigvee \{ w\in L \mid \bot < w \triangleleft x \} . \end{aligned}$$
(6)

A complete chain and a direct product of complete chains (with componentwise order) are completely distributive complete lattices. A complete sublattice of a completely distributive complete lattice is completely distributive.

Given a non-empty subset Q of \(\overline{\mathbb {R}}= \mathbb {R}\cup \{-\infty ,+\infty \}\), we write \(\sup Q\) and \(\inf Q\) for the numerical supremum and infimum of Q; similarly, for a subset Q of \(\overline{\mathbb {R}}^m\) (\(m>1)\)), we write \(\sup Q\) and \(\inf Q\) for the componentwise numerical supremum and infimum of Q, namely:

$$\begin{aligned}&\sup _{i \in I} (x^i_1, \ldots , x^i_m) = \bigl ( \sup _{i \in I} x^i_1, \ldots , \sup _{i \in I} x^i_m\bigr ) \quad \text{ and } \nonumber \\&\inf _{i \in I} (x^i_1, \ldots , x^i_m) = \bigl ( \inf _{i \in I} x^i_1, \ldots , \inf _{i \in I} x^i_m\bigr ) . \end{aligned}$$
(7)

Given \(a,b\in \overline{\mathbb {R}}\) such that \(a<b\), the closed interval [ab] is a complete lattice for the numerical order, where the non-empty supremum and infimum operations are the numerical \(\sup \) and \(\inf \), while the empty supremum and infimum give the bounds a and b. Similarly, for \(a,b\in \overline{\mathbb {R}}^m\), with the componentwise order (1) and the componentwise \(\sup \) and \(\inf \) (7). The same holds for a closed interval in \(\overline{\mathbb {Z}}= \mathbb {Z}\cup \{-\infty ,+\infty \}\) and in \(\overline{\mathbb {Z}}^m\). Note that such a closed interval in \(\overline{\mathbb {R}}\), \(\overline{\mathbb {R}}^m\), \(\overline{\mathbb {Z}}\) or \(\overline{\mathbb {Z}}^m\) is a completely distributive complete lattice.

On the other hand, a subset of \(\overline{\mathbb {R}}^m\) or \(\overline{\mathbb {Z}}^m\) can be a complete lattice where the supremum and infimum operations are not the componentwise \(\sup \) and \(\inf \). For instance, let \(m = 2\) and \(X = \{ (0,0), (1,2), (2,1), (3,3) \}\); then X is a finite lattice, thus a complete lattice; here the supremum and infimum in X of the pair \(\{ (1,2), (2,1) \}\) are (3, 3) and (0, 0), while \(\sup \{ (1,2), (2,1) \} = (2,2)\notin X\) and \(\inf \{ (1,2), (2,1) \} = (1,1)\notin X\). In such a lattice, we will write \(\bigvee \) and \(\bigwedge \) for the supremum and infimum operations. This distinction is important, because the traditional approach of [2] applies the lattice-theoretical supremum \(\bigvee \) to image values, while our new approach [1] uses the numerical or componentwise \(\sup \). We showed indeed in Example 21 of [1] that with such a lattice of values, a dilation will give different image values with the traditional approach and with the new one. In fact, our new approach implicitly assumes that the lattice of values is an interval in \(\mathbb {R}^m\) or \(\mathbb {Z}^m\); for instance, in the above example, X is embedded in the interval \(X' = \{0,1,2,3\}^2\), which constitutes then the effective lattice of image values.

2.2 Bounded Variation

We summarise here Sect. 2 of [1], where some furthers results, examples and counterexamples are given.

For \(x\in \mathbb {R}\), let \([x]^+ = \max (x,0)\) be the positive part of x, and let \([x]^- = [-x]^+ = \max (-x,0)\) be the negative part of x. Then \(x=[x]^+-[x]^-\) and \(\vert x\vert =[x]^++[x]^-\).

Let P be a poset not reduced to a singleton. A strictly increasing sequence in P is a \((n+1)\)-tuple \((s_0,\ldots ,s_n)\), where \(n\in \mathbb {N}\), \(s_0, \ldots , s_n \in P\) and \(s_0< \cdots < s_n\). Let \(f:P\rightarrow \mathbb {R}\); for any strictly increasing sequence \((s_0,\ldots ,s_n)\) in P, we define the positive, negative and total variation of f on it:

$$\begin{aligned} PV_{(s_0,\ldots ,s_n)}(f){} & {} = \sum _{i=1}^n \bigl [f(s_i)-f(s_{i-1})\bigr ]^+ , \\ NV_{(s_0,\ldots ,s_n)}(f){} & {} = \sum _{i=1}^n \bigl [f(s_i)-f(s_{i-1})\bigr ]^- , \\ TV_{(s_0,\ldots ,s_n)}(f) ={} & {} PV_{(s_0,\ldots ,s_n)}(f) + NV_{(s_0,\ldots ,s_n)}(f) \\{} & {} = \sum _{i=1}^n \bigl \vert f(s_i)-f(s_{i-1})\bigr \vert . \end{aligned}$$

These three numbers are non-negative. Now, for \(a,b\in P\) with \(a\le b\), let S(ab) be the set of strictly increasing sequences in P that start in a and end in b:

$$\begin{aligned} S(a,b) =&\{ (s_0,\ldots ,s_n) \mid n\in \mathbb {N}, \nonumber \\&a=s_0< \cdots < s_n=b \} . \end{aligned}$$
(8)

One obtains then the positive, negative and total variation of f on the interval [ab]:

$$\begin{aligned}{} & {} PV_{[a,b]}(f) = \sup \{ PV_{(s_0,\ldots ,s_n)}(f) \mid \\{} & {} \quad (s_0,\ldots ,s_n) \in S(a,b) \} , \\{} & {} NV_{[a,b]}(f) = \sup \{ NV_{(s_0,\ldots ,s_n)}(f) \mid \\{} & {} \quad (s_0,\ldots ,s_n) \in S(a,b) \} , \\{} & {} TV_{[a,b]}(f) = \sup \{ TV_{(s_0,\ldots ,s_n)}(f) \mid \\{} & {} \quad (s_0,\ldots ,s_n) \in S(a,b) \} . \end{aligned}$$

These three variations are non-negative, but they can be infinite, they are thus in the interval \([0,+\infty ]\). Now we have

$$\begin{aligned} PV_{[a,b]}(f) + f(a) = NV_{[a,b]}(f) + f(b) \end{aligned}$$
(9)

and

$$\begin{aligned} TV_{[a,b]}(f) = PV_{[a,b]}(f) + NV_{[a,b]}(f) . \end{aligned}$$
(10)

By (9), \(PV_{[a,b]}(f)\) and \(NV_{[a,b]}(f)\) are either both finite or both infinite. We say that f is of bounded variation on [ab], or briefly, f is BV[ab], if \(TV_{[a,b]}(f)\) is finite; equivalently, \(PV_{[a,b]}(f)\) and \(NV_{[a,b]}(f)\) are both finite. Thus:

$$\begin{aligned}{} & {} \text{ for } f ~ BV[a,b]: \\{} & {} \quad PV_{[a,b]}(f) - NV_{[a,b]}(f) = f(b) - f(a) . \end{aligned}$$

Note that the three variations increase when the interval [ab] increases, in other words, for \(a'\le a\le b\le b'\) we have \(PV_{[a,b]}(f) \le PV_{[a',b']}(f)\), and similarly for NV and TV. In the limit case where \(a=b\), S(ab) consists of the unique sequence (a), and then \(PV_{[a,a]}(f) = NV_{[a,a]}(f) = TV_{[a,a]}(f) =0\); the above three equalities are trivially valid in this case.

We will say that f is of bounded variation on P, or briefly, f is BV, if \(\sup \{ TV_{[a,b]}(f) \mid a,b\in P, ~ a<b \} < \infty \); in other words, there is a real M such that \(PV_{[a,b]}(f)\le M\) and \(NV_{[a,b]}(f)\le M\) for all \(a,b\in P\) such that \(a<b\).

When P is bounded by \(\bot , \top \), we will write PV(f), NV(f) and TV(f) for \(PV_{[\bot ,\top ]}(f)\), \(NV_{[\bot ,\top ]}(f)\) and \(TV_{[\bot ,\top ]}(f)\) respectively. Then f is of bounded variation on P iff \(TV(f) < \infty \), equivalently, both PV(f) and NV(f) are finite.

Assume now that P has a least element \(\bot \). We define the positive and negative variation functions \(pv[f],nv[f]:P\rightarrow [0,\infty ]\) as follows:

$$\begin{aligned}{} & {} \forall \, x\in P, \quad pv[f](x) = PV_{[\bot ,x]}(f) \\{} & {} \quad \text{ and }\quad nv[f](x) = NV_{[\bot ,x]}(f) . \end{aligned}$$

Note that \(pv[f](\bot ) = nv[f](\bot ) = 0\). Next, we define \(f_P\) and \(f_N\), the positive and negative increments of f, by

$$\begin{aligned} \forall \, x\in P, \quad&f_P(x) = \bigl [f(\bot )\bigr ]^+ + pv[f](x) \nonumber \\ \text{ and }\quad&f_N(x) = \bigl [f(\bot )\bigr ]^- + nv[f](x) . \end{aligned}$$
(11)

The two functions pv[f] and nv[f] are non-negative and increasing. Now, f is BV iff both pv[f] and nv[f] are bounded, and then for all \(x\in P\) we have \(f(x) = f_P(x) - f_N(x)\). Moreover, a bounded, non-negative and increasing function f satisfies \(f = f_P\) and is BV.

Consider now the dual poset with the inverse order relation \(\ge \) and with the bounds \(\bot \) and \(\top \) exchanged; then positive and negative variation will be exchanged, that is, \(PV_{[a,b]}(f)\) corresponds to \(NV_{[b,a]}(f)\) in the dual poset. If P has a greatest element \(\top \), we obtain the dual positive and negative variation functions \(pv^*[f],nv^*[f]:P\rightarrow [0,\infty ]\) given by

$$\begin{aligned}{} & {} \forall \, x\in P, \quad pv^*[f](x) = NV_{[x,\top ]}(f) \\{} & {} \quad \text{ and }\quad nv^*[f](x) = PV_{[x,\top ]}(f) . \end{aligned}$$

Note that \(pv^*[f](\top ) = nv^*[f](\top ) = 0\). We have then the dual positive and negative increments of f,

$$\begin{aligned} \forall \, x\in P, \quad&f_P^*(x) = \bigl [f(\top )\bigr ]^+ + pv^*[f](x) \nonumber \\ \text{ and }\quad&f_N^*(x) = \bigl [f(\top )\bigr ]^- + nv^*[f](x) . \end{aligned}$$
(12)

The two functions \(pv^*[f]\) and \(nv^*[f]\) are non-negative and decreasing. Now, f is BV iff both \(pv^*[f]\) and \(nv^*[f]\) are bounded, and then for all \(x\in P\) we have \(f(x) = f_P^*(x) - f_N^*(x)\). See Fig. 1. Moreover, a bounded, non-negative and decreasing function f satisfies \(f = f_P^*\) and is BV.

Fig. 1
figure 1

Let \(P = [\bot ,\top ] \subset \mathbb {R}\). Left: a BV function \(f: P\rightarrow \mathbb {R}\). We have \(f=g-h\) for \(g = f_P^*\) and \(h = f_N^*\), cf. (12). Right: we show g and \(-h\). When f decreases, g decreases while h remains constant; when f increases, \(-h\) increases (so h decreases) while g remains constant

We deduce from the above discussion of variation functions and dual variation functions:

Proposition 1

Let P be poset, and let \(f:P\rightarrow \mathbb {R}\).

  1. 1.

    If P has least element \(\bot \), then f is of bounded variation iff there exist two bounded, non-negative and increasing functions \(g,h:P\rightarrow \mathbb {R}\) such that \(f=g-h\).

  2. 2.

    If P has greatest element \(\top \), then f is of bounded variation iff there exist two bounded, non-negative and decreasing functions \(g,h:P\rightarrow \mathbb {R}\) such that \(f=g-h\).

Note that when P is bounded by \(\bot , \top \), every increasing or decreasing function f is bounded: for f increasing, \(f(\bot ) \le f(x) \le f(\top )\), while for f decreasing, \(f(\top ) \le f(x) \le f(\bot )\).

By taking for a BV function f the thresholdings of \(f_P\) and \(f_N\) at positive integer levels, we obtain the following, see Proposition 17 of [1]:

Proposition 2

Let P be a poset with least element \(\bot \), and let \(f:P\rightarrow \mathbb {Z}\) be of bounded variation. Let \(m = \max _{x\in P} f_P(x)\) and \(n= \max _{x\in P} f_N(x)\). Then there are \(m+n\) increasing functions \(g_1,\ldots ,g_m,h_1,\ldots ,h_n: P\rightarrow \{0,1\}\) such that \(g_1 \ge \cdots \ge g_m\), \(h_1 \ge \cdots \ge h_n\) and \(f = \sum _{i=1}^m g_i - \sum _{j=1}^n h_j\).

2.3 Function Summation

We consider a poset \(P \subset \mathbb {R}^m\) (\(m\ge 1\)), and we suppose that P is bounded by \(\bot ,\top \in \mathbb {R}^m\): \(\forall \, x\in P\), \(\bot \le x \le \top \). We will define a summation on functions \(P\rightarrow \mathbb {R}\).

Consider first a function \(f:P\rightarrow \mathbb {R}\) that is bounded, non-negative and decreasing. For a strictly increasing sequence \((s_0,\ldots ,s_n)\) in P, define the summation

$$\begin{aligned} \mathcal {S}_{(s_0,\ldots ,s_n)}(f) = \sum _{i=1}^n f(s_i) (s_i-s_{i-1}) . \end{aligned}$$
(13)

For \(P\subset \mathbb {R}\), this represents an approximation from below of the integral of f on the interval \([s_0,s_n]\), see Fig. 2. For \(P \subset \mathbb {R}^m\), we have \(\mathcal {S}_{(s_0,\ldots ,s_n)}(f) \in \mathbb {R}^m\).

Fig. 2
figure 2

For a bounded, non-negative and decreasing function f, the hatched area represents \(\mathcal {S}_{(s_0,\ldots ,s_6)}(f)\) for a strictly increasing sequence \((s_0,\ldots ,s_6)\)

Given \(a,b\in P\) with \(a<b\), recall from (8) the set S(ab) of strictly increasing sequences in P starting in a and ending in b. For \(f:P\rightarrow \mathbb {R}\) bounded, non-negative and decreasing, we define the summation of f over the interval [ab]:

$$\begin{aligned} \mathcal {S}_{[a,b]}(f) =&\sup \bigl \{ \mathcal {S}_{(s_0,\ldots ,s_n)}(f) \bigm \vert \nonumber \\&(s_0,\ldots ,s_n) \in S(a,b) \bigr \} . \end{aligned}$$
(14)

Note that, given \(P \subset \mathbb {R}^m\), \(\mathcal {S}_{[a,b]}(f) \in \mathbb {R}^m\) and here \(\sup \) is the numerical supremum for \(m=1\), and the componentwise numerical supremum for \(m>1\).

For \(a=b\), S(ab) consists of the unique sequence (a), and \(\mathcal {S}_{[a,a]}(f) = 0\). Now, P is bounded by \(\bot , \top \), and we will write \(\mathcal {S}(f)\) for \(\mathcal {S}_{[\bot ,\top ]}(f)\), the summation of f over P. The summation \(\mathcal {S}_{[a,b]}(f)\) is non-negative and bounded: given \(M>0\) such that all \(x\in P\) satisfy \(0\le f(x)\le M\), we have \(0 \le \mathcal {S}_{[a,b]}(f) \le M (b-a)\). It is also increasing on the function f: if \(f(x)\le g(x)\) for all \(x\in P\), then \(\mathcal {S}_{[a,b]}(f) \le \mathcal {S}_{[a,b]}(g)\). Given a scalar \(\lambda \ge 0\), \(\lambda f\) is bounded, non-negative and decreasing, and then \(\mathcal {S}_{[a,b]}(\lambda f) = \lambda \mathcal {S}_{[a,b]}(f)\).

Now, given \(f,g:P\rightarrow \mathbb {R}\) bounded, non-negative and decreasing, \(f+g\) is also bounded, non-negative and decreasing, but we generally obtain only the inequality \(\mathcal {S}_{[a,b]}(f+g) \le \mathcal {S}_{[a,b]}(f) + \mathcal {S}_{[a,b]}(g)\). We say that \(\mathcal {S}\) is additive on P if for all bounded, non-negative and decreasing functions \(f,g:P\rightarrow \mathbb {R}\), and all \(a,b\in P\) with \(a<b\), we have \(\mathcal {S}_{[a,b]}(f+g) = \mathcal {S}_{[a,b]}(f) + \mathcal {S}_{[a,b]}(g)\).

Recall Proposition 1: a function \(f:P\rightarrow \mathbb {R}\) is of bounded variation iff there are two bounded, non-negative and decreasing functions \(g,h:P\rightarrow \mathbb {R}\) such that \(f=g-h\). When the summation is additive, we can then define the summation of f as \(\mathcal {S}_{[a,b]}(f)= \mathcal {S}_{[a,b]}(g)-\mathcal {S}_{[a,b]}(h)\), and this definition will not depend on the choice of g and h:

Theorem 3

Let P be a bounded poset. Suppose that \(\mathcal {S}\) is additive on P. For any \(f:P\rightarrow \mathbb {R}\) of bounded variation, given a decomposition \(f=g-h\) for \(g,h:P\rightarrow \mathbb {R}\) bounded, non-negative and decreasing, define \(\mathcal {S}_{[a,b]}(f)= \mathcal {S}_{[a,b]}(g)-\mathcal {S}_{[a,b]}(h)\). Then \(\mathcal {S}_{[a,b]}(f)\) does not depend on the choice of g and h in the decomposition, and \(\mathcal {S}_{[a,b]}\) is a linear operator on the module of functions with bounded variation: for \(f_1,f_2:P\rightarrow \mathbb {R}\) of bounded variation and \(\lambda _1,\lambda _2\in \mathbb {R}\),

$$\begin{aligned} \mathcal {S}_{[a,b]}(\lambda _1 f_1 + \lambda _2 f_2) = \lambda _1 \mathcal {S}_{[a,b]}(f_1) + \lambda _2 \mathcal {S}_{[a,b]}(f_2) . \end{aligned}$$

The additivity of \(\mathcal {S}\) depends on the poset P. We give three types of posets on which \(\mathcal {S}\) is additive, and then describe the summation of a function of bounded variation.

First, if P is a bounded chain, then \(\mathcal {S}\) is additive on P. In the case of a finite chain P, that is, \(P= \{t_0, \ldots , t_n\}\) with \(t_0< \cdots < t_n\), for \(0\le u < v \le n\) we have \(\mathcal {S}_{[t_u,t_v]}(f) = \sum _{i=u+1}^v f(t_i) (t_i-t_{i-1})\). In the continuous case where \(P=[\bot ,\top ] \subset \mathbb {R}\), for \(a,b\in P\) with \(a<b\), we have \(\mathcal {S}_{[a,b]}(f) = \int _a^b f(t) \, dt\); this is a Riemann integral (any real function of bounded variation is continuous almost everywhere, hence Riemann integrable).

Second, let \(P= P_1 \times \cdots \times P_m\), the Cartesian product of bounded posets \(P_1, \ldots , P_m\), with componentwise ordering; now, each \(P_i\) is bounded by \(\bot _i,\top _i\), so P will be bounded by \(\bot , \top \), where \(\bot = (\bot _1,\ldots ,\bot _m)\) and \(\top = (\top _1,\ldots ,\top _m)\). If \(\mathcal {S}\) is additive on each \(P_i\) (\(i=1,\ldots ,m\)), then \(\mathcal {S}\) is additive on P. In particular, since \(\mathcal {S}\) is additive on a bounded chain, if follows that it is additive on a Cartesian product of bounded chains.

Let us now describe the form taken by the summation in P in terms of summations in all \(P_i\). For each \(i=1,\ldots ,m\), there is some \(k_i\ge 1\) such that \(P_i\subset \mathbb {R}^{k_i}\); let \(Q_i = \mathbb {R}^{k_i}\) and \(Q = Q_1 \times \cdots \times Q_m\), thus \(P\subset Q\). Now, summations of the form \(\mathcal {S}_{(s_0,\ldots ,s_n)}(f)\) and \(\mathcal {S}_{[a,b]}(f)\) will belong to Q for \(f:P\rightarrow \mathbb {R}\), but to \(Q_i\) for \(f:P_i\rightarrow \mathbb {R}\). For each \(i=1,\ldots ,m\) we define the i-th projection

$$\begin{aligned} \pi _i&: Q = Q_1 \times \cdots \times Q_m \rightarrow Q_i \nonumber \\&: (x_1,\ldots ,x_m) \mapsto x_i . \end{aligned}$$
(15)

Given \(a=(a_1,\ldots ,a_m)\in P\), we define the i-th embedding through a

$$\begin{aligned} \eta ^a_i&: Q_i \rightarrow Q = Q_1 \times \cdots \times Q_m \nonumber \\&: x \mapsto (a_1,\ldots ,a_{i-1},x,a_{i+1},\ldots ,a_m) , \end{aligned}$$
(16)

and for \(f: P\rightarrow \mathbb {R}\), we write \(f\eta ^a_i\) for the composition of \(\eta ^a_i\) followed by f:

$$\begin{aligned} f\eta ^a_i&:&P_i\rightarrow \mathbb {R}: x \mapsto f(\eta ^a_i(x)) \\= & {} f(a_1,\ldots ,a_{i-1},x,a_{i+1},\ldots ,a_m) . \end{aligned}$$

Then, for \(a=(a_1,\ldots ,a_m), b=(b_1,\ldots ,b_m)\in P\) with \(a<b\), and \(f:P\rightarrow \mathbb {R}\) of bounded variation, we have

$$\begin{aligned} \pi _i(\mathcal {S}_{[a,b]}(f)) = \mathcal {S}_{[a_i,b_i]}(f\eta ^a_i)&\nonumber \\ \text{ for } ~ i=1,\ldots ,m .&\end{aligned}$$
(17)

In geometrical terms, each projection \(\pi _i(\mathcal {S}_{[a,b]}(f))\) is obtained by summing f along the line segment parallel to the i-th axis of P, joining \(a = (a_1,\ldots ,a_m)\) to \((a_1,\ldots ,a_{i-1},b_i,a_{i+1},\ldots ,a_m)\). In particular \(\mathcal {S}_{[a,b]}(f)\) is completely determined by the restriction of f to the m lines through a parallel to the axes.

If \(P_i\) is a finite chain, \(P_i= \{t_0, \ldots , t_n\}\) with \(t_0< \cdots < t_n\), given \(a_i=t_u\) and \(b_i=t_v\) (\(0\le u \le v \le n\)), we have \(\pi _i(\mathcal {S}_{[a,b]}(f))= \sum _{h=u+1}^v f\eta ^a_i(t_h) (t_h-t_{h-1})\). If \(P_i\) is a real interval, \(P_i=[\bot _i,\top _i] \subset \mathbb {R}\), then \(\pi _i(\mathcal {S}_{[a,b]}(f))= \int _{a_i}^{b_i} f\eta ^a_i(t) \, \text {d}t\).

Let us illustrate this in the cases of \(\mathbb {Z}^3\) and \(\mathbb {R}^3\), with componentwise ordering. Let \(a=(a_1,a_2,a_3)\) and \(b=(b_1,b_2,b_3)\), with \(a_1 < b_1\), \(a_2 < b_2\) and \(a_3 < b_3\). In \(\mathbb {Z}^3\) we get for a BV function f:

$$\begin{aligned}&\mathcal {S}_{[a,b]}(f) = \Bigl ( \sum _{t=a_1+1}^{b_1} f(t,a_2,a_3) \; , \nonumber \\&\sum _{t=a_2+1}^{b_2} f(a_1,t,a_3) \; , \; \sum _{t=a_3+1}^{b_3} f(a_1,a_2,t) \Bigr ) . \end{aligned}$$
(18)

In \(\mathbb {R}^3\) we get:

$$\begin{aligned}&\mathcal {S}_{[a,b]}(f) = \Bigl ( \int _{a_1}^{b_1} f(t,a_2,a_3) \, \text {d}t \; , \nonumber \\&\int _{a_2}^{b_2} f(a_1,t,a_3) \, dt \; , \; \int _{a_3}^{b_3} f(a_1,a_2,t) \, \text {d}t \Bigr ) . \end{aligned}$$
(19)

We now give the third type of poset on which the summation is additive. Let P be a poset bounded by \(\bot , \top \). Let \(\varphi \) be a closure map on P such that \(\varphi (\bot ) = \bot \), and let \(M = \{ \varphi (x) \mid x \in P \}\) be the corresponding closure range; we have then \(\bot , \top \in M\). For any \(f:M\rightarrow \mathbb {R}\), define \(f_\varphi :P\rightarrow \mathbb {R}\) by \(f_\varphi (x)= f(\varphi (x))\); for \(x\in M\), we have \(f_\varphi (x)= f(x)\). If \(\mathcal {S}\) is additive on P, then it is additive on M: for \(f:M\rightarrow \mathbb {R}\) of bounded variation and for any \(a,b\in M\) such that \(a<b\), we have \(PV_{[a,b]}(f_\varphi ) = PV_{[a,b]}(f)\) and \(NV_{[a,b]}(f_\varphi ) = NV_{[a,b]}(f)\), so \(f_\varphi \) is of bounded variation, and \(\mathcal {S}_{[a,b]}(f)= \mathcal {S}_{[a,b]}(f_\varphi )\).

For instance, if P is a complete lattice and M is a complete sublattice of P, then P is a closure range, the corresponding closure map \(\varphi \) is defined by \(\varphi (x) = \bigwedge \{ y \in M \mid x \le y \}\). Thus, if \(\mathcal {S}\) is additive on P, it will be additive on M. From the above two cases, it follows that \(\mathcal {S}\) is additive on any complete sublattice of a direct product of complete chains.

We end this section with a few properties that will be used in the sequel. The following result (Proposition 14 of [1]) was fundamental in the analysis of the flat extension of increasing operators on binary images in [1]; we will apply it here to functions of bounded variation:

Proposition 4

Let P be bounded by \(\bot , \top \). For any decreasing function \(f:P\rightarrow \{0,1\}\),

$$\begin{aligned} \bot + \mathcal {S}(f) = \sup \{ x \in P \mid f(x)=1 \} , \end{aligned}$$
(20)

where we set \(\sup \emptyset = \bot \) on the right side of the equation.

The following “isomorphism lemma” will be used in Sect. 3.3:

Lemma 5

Let PQ be bounded posets and let \(\theta : P\rightarrow Q\) be a bijection such that for a real \(a>0\), for all \(x,y\in P\) we have \(\theta (y)-\theta (x) = a(y-x)\). Then \(\mathcal {S}\) is additive on P iff it is additive on Q. For any \(f: Q\rightarrow \mathbb {R}\), let \(f\theta : P\rightarrow \mathbb {R}: x\mapsto f(\theta (x))\); then f is BV iff \(f\theta \) is BV, and for any \(a,b\in P\) with \(a\le b\), we have \(\mathcal {S}_{[\theta (a),\theta (b)]}(f) = a \mathcal {S}_{[a,b]}(f\theta )\).

Proof

For \(x,y\in P\), \(\theta (x)< \theta (y) \;\Leftrightarrow \;x < y\), so \(\theta \) is a poset isomorphism between P and Q. Thus, for \(f: Q\rightarrow \mathbb {R}\), f is decreasing iff \(f\theta \) is decreasing; now, f and \(f\theta \) have the same sign and the same bounds. Let f be bounded, non-negative and decreasing. For a strictly increasing sequence \((s_0,\ldots ,s_n)\) in P, we have

$$\begin{aligned}{} & {} \mathcal {S}_{(\theta (s_0),\ldots ,\theta (s_n))}(f) = \sum _{i=1}^n f(\theta (s_i)) (\theta (s_i)-\theta (s_{i-1})) \\{} & {} \quad = a \sum _{i=1}^n f(\theta (s_i)) (s_i-s_{i-1}) = a \mathcal {S}_{(s_0,\ldots ,s_n)}(f\theta ) . \end{aligned}$$

For \(a,b\in P\) with \(a\le b\) \(S(\theta (a),\theta (b))\) is the set of all \((\theta (s_0),\ldots ,\theta (s_n))\) for \((s_0,\ldots ,s_n) \in S(a,b)\), hence

$$\begin{aligned}{} & {} \mathcal {S}_{[\theta (a),\theta (b)]}(f) = \sup \bigl \{ \mathcal {S}_{(\theta (s_0),\ldots ,\theta (s_n))}(f) \bigm \vert \\{} & {} \quad (\theta (s_0),\ldots ,\theta (s_n)) \in S(\theta (a),\theta (b)) \bigr \} \\{} & {} \quad = \sup \bigl \{ a \mathcal {S}_{(s_0,\ldots ,s_n)}(f\theta ) \bigm \vert (s_0,\ldots ,s_n) \in S(a,b) \bigr \} \\{} & {} \quad = a \mathcal {S}_{[a,b]}(f\theta ) . \end{aligned}$$

For \(g,h: Q\rightarrow \mathbb {R}\) bounded, non-negative and decreasing, \(\mathcal {S}_{[\theta (a),\theta (b)]}(g+h) = a \mathcal {S}_{[a,b]}((g+h)\theta ) = a \mathcal {S}_{[a,b]}(g\theta +h\theta )\), while \(\mathcal {S}_{[\theta (a),\theta (b)]}(g) = a \mathcal {S}_{[a,b]}(g\theta )\) and \(\mathcal {S}_{[\theta (a),\theta (b)]}(h) = a \mathcal {S}_{[a,b]}(h\theta )\); hence \(\mathcal {S}_{[\theta (a),\theta (b)]}(g+h) = \mathcal {S}_{[\theta (a),\theta (b)]}(g) + \mathcal {S}_{[\theta (a),\theta (b)]}(h)\) iff \(\mathcal {S}_{[a,b]}(g\theta +h\theta ) = \mathcal {S}_{[a,b]}(g\theta ) + \mathcal {S}_{[a,b]}(h\theta )\); in other words, \(\mathcal {S}\) is additive on P iff it is additive on Q. Now \(f: Q\rightarrow \mathbb {R}\) is BV iff \(f=g-h\) for \(g,h: Q\rightarrow \mathbb {R}\) bounded, non-negative and decreasing, iff \(f\theta = g\theta - h\theta \) with \(g\theta ,h\theta : P\rightarrow \mathbb {R}\) bounded, non-negative and decreasing, iff \(f\theta \) is BV. We have then \(\mathcal {S}_{[\theta (a),\theta (b)]}(f) = \mathcal {S}_{[\theta (a),\theta (b)]}(g) - \mathcal {S}_{[\theta (a),\theta (b)]}(h) = a \mathcal {S}_{[a,b]}(g\theta ) - a \mathcal {S}_{[a,b]}(h\theta ) = a \mathcal {S}_{[a,b]}(f\theta )\). \(\square \)

The following will be used in Sect. 5:

Lemma 6

Let P be a bounded subset, and let \(\mathcal {S}\) is additive on P. Let \(f_1,f_2: P\rightarrow \mathbb {R}\) such that \(f_1(x) = f_2(x)\) for all \(x>\bot \). If \(f_1\) is BV, then \(f_2\) is BV, and \(\mathcal {S}(f_1) = \mathcal {S}(f_2)\).

Proof

By Proposition 1, there are two bounded, non-negative and decreasing functions \(g_1,h_1:P\rightarrow \mathbb {R}\) such that \(f_1=g_1-h_1\). Define \(g_2,h_2:P\rightarrow \mathbb {R}\) as follows. For \(x>\bot \), let \(g_2(x) = g_1(x)\) and \(h_2(x) = h_1(x)\). If \(f_1(\bot ) \ge f_2(\bot )\), we set \(g_2(\bot ) = g_1(\bot )\) and \(h_2(\bot ) = h_1(\bot ) + f_1(\bot ) - f_2(\bot )\), while if \(f_1(\bot ) < f_2(\bot )\), we set \(g_2(\bot ) = g_1(\bot ) + f_2(\bot ) - f_1(\bot )\) and \(h_2(\bot ) = h_1(\bot )\); then in both cases \(g_2(\bot ) - h_2(\bot ) = g_1(\bot ) - h_1(\bot ) + f_2(\bot ) - f_1(\bot ) = f_2(\bot )\), \(g_2(\bot ) \ge g_1(\bot )\) and \(h_2(\bot ) \ge h_1(\bot )\). It follows that \(f_2 = g_2-h_2\), and that \(g_2,h_2\) are bounded, non-negative and decreasing functions. Hence \(f_2\) is BV. By (13), for a strictly increasing sequence \((s_0,\ldots ,s_n)\) in P, the summation involves only the values of the function at \(s_1,\ldots ,s_n\), all \(>\bot \), so \(\mathcal {S}_{(s_0,\ldots ,s_n)}(g_1) = \mathcal {S}_{(s_0,\ldots ,s_n)}(g_2)\). It follows by (14) that \(\mathcal {S}(g_1) = \mathcal {S}(g_2)\); similarly \(\mathcal {S}(h_1) = \mathcal {S}(h_2)\). Therefore \(\mathcal {S}(f_1) = \mathcal {S}(g_1) -\mathcal {S}(h_1) = \mathcal {S}(g_2) - \mathcal {S}(h_2) = \mathcal {S}(f_2)\). \(\square \)

3 Generalised Flat Morphological Operators

In this section we recall our new definition of flat extension; then we consider its properties with respect to the join and meet of operators (Sect. 3.1) and then the composition of operators (Sect. 3.2); finally, we consider the commutation of flat operators with contrast mappings (Sect. 3.3).

Let E be the space of points. We take a set of image values \(U = C_1 \times \cdots \times C_m\), where \(m\ge 1\) and for \(i= 1,\ldots ,m\), either \(C_i = \mathbb {R}\) or \(C_i = u_i \mathbb {Z}\) for some real \(u_i >0\) (usually \(u_i=1\)). All images, those given as input to flat operators, as well as those obtained as output of these operators, will have their values in U, they will be maps \(E\rightarrow U\).

For \(m=1\), U is ordered numerically, while for \(m>1\) it has the componentwise or marginal ordering (1). The set U has two important properties. First, it is a conditionally complete lattice, in particular, every closed interval \([a,b] \subset U\) will be a complete lattice where the non-empty supremum and infimum operations are the componentwise numerical \(\sup \) and \(\inf \) operations. Second, it is a module for the operations of addition and subtraction, with neutral \(\textbf{0}= (0,\ldots ,0)\), and the scalar multiplication with scalars in \(\mathbb {Z}\). It follows from these two properties that for any interval \([a,b] \subset U\) (\(a\le b\)) and any bounded, non-negative and decreasing function \(f: [a,b] \rightarrow \mathbb {Z}\), for any strictly increasing sequence \((s_0,\ldots ,s_n)\) in [ab], the summation \(\mathcal {S}_{(s_0,\ldots ,s_n)}(f)\) will belong to U; thus, the summation \(\mathcal {S}_{[a,b]}(f)\) will also belong to U.

We choose two bounds \(\bot ,\top \in U\), with \(\bot <\top \), and consider the interval \([\bot ,\top ] = \{ v \in U \mid \bot \le v \le \top \}\). Now \(\bot = (\bot _1, \ldots , \bot _m)\) and \(\top = (\top _1, \ldots , \top _m)\), so

$$\begin{aligned}{}[\bot ,\top ] = [\bot _1,\top _1] \times \cdots \times [\bot _m,\top _m] , \end{aligned}$$

where \([\bot _i,\top _i] = \{ v \in C_i \mid \bot _i \le v \le \top _i \}\) (\(i= 1,\ldots ,m\)). Let either \(V = [\bot ,\top ]\) (what we call the standard case), or V be a complete sublattice of \([\bot ,\top ]\) (what we call the sub-standard case).

All input images must have bounded values, so they will be \(E \rightarrow V\). Thus, we will apply flat operators to input images \(E \rightarrow V\), and the resulting output images will be \(E\rightarrow U\). Since V is the direct product of the complete chains \([\bot _i,\top _i]\), or a complete sublattice of that product, the summation \(\mathcal {S}\) will be additive on V; this allows us to define the flat extension as the summation of a function defined on V. Moreover, V is a completely distributive complete lattice, a property that guarantees some good properties of flat extension, as we saw in [2] and will see again in the rest of the paper.

Recall from Sects. 2.2 and 2.3 that for a function f defined on V, \(PV_{[\bot ,\top ]}(f)\), \(NV_{[\bot ,\top ]}(f)\), \(TV_{[\bot ,\top ]}(f)\) and \(\mathcal {S}_{[\bot ,\top ]}(f)\) can be abbreviated into PV(f), NV(f), TV(f) and \(\mathcal {S}(f)\).

In Sects. 2.2 and 2.3, we analysed the variation and summation of a function in a single variable. Here we will consider the variation and summation of an expression in several variables, and we need to specify over which variable we take the variation or summation. Given an expression W in several variables, a variable x appearing in W, and a poset P, we will write “\(W\mid x\in P\)” to specify that the variation or summation of W is over the variable x ranging over P; in other words, \(TV_{[a,b]}(W\mid x\in P)\) and \(\mathcal {S}_{[a,b]}(W\mid x\in P)\) designate the total variation \(TV_{[a,b]}(f)\) and summation \(\mathcal {S}_{[a,b]}(f)\) of the function \(f: P\cap [a,b] \rightarrow \mathbb {R}: x\mapsto W\).

Recall that for a set \(X\in \mathcal {P}(E)\), we write \(\chi X\) for the characteristic function of X. Then for \(\psi : \mathcal {P}(E) \rightarrow \mathcal {P}(E)\), let \(\chi \psi :\mathcal {P}(E) \rightarrow \{0,1\}^E\) be the composition of \(\psi \) followed by \(\chi \), in other words, we write \(\chi \psi (X)\) for the characteristic function of \(\psi (X)\); thus, \(\chi \psi (X)(p) = 1\) for \(p \in \psi (X)\) and \(\chi \psi (X)(p) = 0\) for \(p \notin \psi (X)\).

A binary image transformation is a map \(\mathcal {P}(E) \rightarrow \mathcal {P}(E)\), for instance, the dilation, erosion, opening and closing by a structuring element. A binary image measurement is a map \(\mathcal {P}(E) \rightarrow K^E\) for a finite interval \(K \subset \mathbb {Z}\), for instance the morphological Laplacian

$$\begin{aligned} \chi \delta + \chi \varepsilon -2\chi \textbf{id}: \mathcal {P}(E) \rightarrow \{-1,0,1\}^E :&\nonumber \\ X \mapsto \chi \delta (X) + \chi \varepsilon (X) - 2 \chi X ,&\end{aligned}$$
(20)

where \(\textbf{id}\) is the identity operator on \(\mathcal {P}(E)\), while \(\delta \) and \(\varepsilon \) are the dilation and erosion by a point neighbourhood. Obviously, to every binary image transformation \(\psi \) corresponds the binary image measurement \(\chi \psi \), with \(K=\{0,1\}\).

The distinction between the two may seem to be purely formal, but we see a concrete meaning in it. The flat extension (to grey-level or vector images) of a binary image transformation will be a flat operator preserving the general contrast, such as a dilation, erosion, opening, closing or median filter; thus, if the input image values are translated, the same translation will be applied to output image values. On the other hand, the flat extension of a binary image measurement will be a flat operator whose output does not necessarily change when the input image has its values translated, for instance the gradient or Laplacian. This distinction manifests itself in the two formulas below, with the translation by \(\bot \) appearing only for a binary image transformation. We will see another difference between the two in the interpretation of duality, see Sect. 4.

Let us introduce some further terminology. A stack on V [2] is a decreasing map \(\textsf{Y}: V\rightarrow \mathcal {P}(E)\), i.e., to every \(v\in V\) it associates \(\textsf{Y}(v) \subseteq E\), and for \(v,w\in V\) with \(v\le w\) we have \(\textsf{Y}(w)\subseteq \textsf{Y}(v)\). For instance, given \(F:E\rightarrow V\), the map \(V\rightarrow \mathcal {P}(E): v\mapsto \textsf{X}_v(F)\) is a stack, and for an increasing binary image transformation \(\psi \), the map \(V\rightarrow \mathcal {P}(E): v\mapsto \psi (\textsf{X}_v(F))\) is also a stack. We say that a binary image measurement \(\mu \):

  • has stack-pointwise bounded variation if for every stack \(\textsf{Y}\) and every point \(p\in E\), \(TV\bigl (\mu (\textsf{Y}(v))(p) \bigm \vert v\in V\bigr ) < \infty \);

  • has pointwise bounded variation if for every point \(p\in E\), \(TV\bigl (\mu (Z)(p) \bigm \vert Z\in \mathcal {P}(E)\bigr ) < \infty \);

  • is local [1] if for any \(p\in E\), there exists a finite \(W(p) \in \mathcal {P}(E)\) such that for any \(Z\in \mathcal {P}(E)\), \(\mu (Z)(p) = \mu \bigl (Z\cap W(p)\bigr )(p)\).

By extension, a binary image transformation \(\psi \) has stack-pointwise bounded variation or pointwise bounded variation, or is local, when the binary image measurement \(\chi \psi \) has that property.

For instance, an increasing binary image transformation \(\psi \) has pointwise bounded variation: as Z increases, \(\chi \psi (Z)(p)\) will change once from 0 to 1, so \(PV\bigl (\mu (Z)(p) \bigm \vert Z\in \mathcal {P}(E)\bigr ) = 1\) and \(NV\bigl (\mu (Z)(p) \bigm \vert Z\in \mathcal {P}(E)\bigr ) = 0\).

These three properties are related: being local implies having pointwise bounded variation, which implies having stack-pointwise bounded variation. Indeed, we first recall Proposition 23 of [1]:

Proposition 7

Let \(\mu : \mathcal {P}(E) \rightarrow K^E\) be a binary image measurement, for a finite interval \(K\subset \mathbb {Z}\). If \(\mu \) is local with the finite \(W(p) \in \mathcal {P}(E)\) associated to each \(p\in E\), then for any \(p\in E\), \(TV\bigl (\mu (Z)(p) \bigm \vert Z\in \mathcal {P}(E)\bigr ) = TV\bigl (\mu (X)(p) \bigm \vert X\in \mathcal {P}(W(p))\bigr ) \le h(K) \vert W(p)\vert \). Thus, if \(\mu \) is local, then \(\mu \) has pointwise bounded variation.

Now, the following result is adapted from Proposition 23 of [1], in which we just replace \(\textsf{X}_v(F)\) (for \(F:E\rightarrow V\)) by \(\textsf{Y}(v)\) for an arbitrary stack:

Proposition 8

Let \(\mu : \mathcal {P}(E) \rightarrow K^E\) be a binary image measurement, for a finite interval \(K\subset \mathbb {Z}\). Then for any stack \(\textsf{Y}\) and point \(p\in E\), \(TV\bigl (\mu (\textsf{Y}(v))(p) \bigm \vert v\in V\bigr ) \le \min \Bigl (h(K)h(V),TV\bigl (\mu (Z)(p) \bigm \vert Z\in \mathcal {P}(E)\bigr )\Bigr )\). Thus, if V has finite height or if \(\mu \) has pointwise bounded variation, then \(\mu \) has stack-pointwise bounded variation.

Recall that the summation \(\mathcal {S}\) is additive on V. Given a binary image measurement \(\mu : \mathcal {P}(E) \rightarrow K^E\), we define the no-shift flat extension \(\mu ^{-V}\) of \(\mu \) by setting for any image \(F:E\rightarrow V\) and point \(p\in E\):

$$\begin{aligned} \mu ^{-V}(F)(p) = \mathcal {S}\bigl (\mu (\textsf{X}_v(F))(p) \bigm \vert v\in V\bigr ) , \end{aligned}$$
(21)

provided that the summation is well-defined, that is, the summed function \(v\mapsto \mu (\textsf{X}_v(F))(p)\) is of bounded variation; for instance this is guaranteed when \(\mu \) has stack-pointwise bounded variation.

By the linearity of the summation, see Theorem 3, the no-shift flat extension is linear: for two binary image measurements \(\mu _1,\mu _2\) and two scalars \(\lambda _1,\lambda _2 \in \mathbb {Z}\), we have \(\bigl (\lambda _1\mu _1 + \lambda _2\mu _2\bigr )^{-V} = \lambda _1\mu _1^{-V} + \lambda _2\mu _2^{-V}\).

Given a binary image transformation \(\psi : \mathcal {P}(E) \rightarrow \mathcal {P}(E)\), we define the shifted flat extension \(\psi ^{+V}\) of \(\psi \) by setting for any image \(F:E\rightarrow V\) and point \(p\in E\):

$$\begin{aligned}&\psi ^{+V}(F)(p) = \bot + (\chi \psi )^{-V}(F)(p) \nonumber \\&\quad = \bot + \mathcal {S}\bigl (\chi \psi (\textsf{X}_v(F))(p) \bigm \vert v\in V\bigr ) , \end{aligned}$$
(22)

again provided that the summation is well-defined, that is, the function \(v\mapsto \chi \psi (\textsf{X}_v(F))(p)\) is of bounded variation, for instance if \(\psi \) has stack-pointwise bounded variation. We always have \(\psi ^{+V}(F)(p) \in [\bot ,\top ]\), see equation (43) of [1]. Note however that in the non-standard case, that is, when \(V \ne [\bot ,\top ]\), if \(\psi \) is not increasing, then we do not necessarily have \(\psi ^{+V}(F)(p) \in V\), see Example 22 of [1].

In Proposition 20 of [1], we showed that for an increasing binary image transformation \(\psi \), the shifted flat extension coincides with the usual flat extension according to [2]: \(\psi ^{+V} = \psi ^V\). Indeed, in (4) the condition \(p\in \psi (\textsf{X}_v(F))\) can be written \(\chi \psi (\textsf{X}_v(F))(p) =1\), and in V the supremum \(\bigvee \) becomes the componentwise numerical \(\sup \); applying (20) to the resulting formula, we get (23). In particular, we have then \(\psi ^{+V}(F)(p) \in V\).

3.1 The Lattice-Ordered Group of Flat Operators

The set of all binary image transformations is ordered as follows: \(\psi _1 \le \psi _2\) iff for all \(X\in \mathcal {P}(E)\), \(\psi _1(X) \subseteq \psi _2(X)\). It constitutes then a complete lattice, with supremum \(\bigvee _{i\in I} \psi _i: X \mapsto \bigcup _{i\in I} \psi _i(X)\) and infimum \(\bigwedge _{i\in I} \psi _i: X \mapsto \bigcap _{i\in I} \psi _i(X)\). Note that in [2], we wrote \(\subseteq \), \(\bigcup \) and \(\bigcap \) for the order, the supremum and infimum on increasing binary image transformations. Binary image measurements are also ordered, with \(\mu _1 \le \mu _2\) iff for all \(X\in \mathcal {P}(E)\), \(\mu _1(X) \le \mu _2(X)\).

We saw in [2] (Proposition 15 and Corollary 29) that the map \(\psi \rightarrow \psi ^V\) is an isomorphism between the poset of increasing binary operators and the one of increasing flat operators. Our generalisation of flat extension has also that property, by Corollary 33 of [1]:

Lemma 9

For any two binary image measurements \(\mu _1, \mu _2\) we have \(\mu _1 \le \mu _2 \;\Leftrightarrow \;\mu _1^{-V} \le \mu _2^{-V}\). For any two binary image transformation \(\psi _1, \psi _2\) we have \(\psi _1 \le \psi _2 \;\Leftrightarrow \;\psi _1^{+V} \le \psi _2^{+V}\). In particular, the two maps \(\mu \mapsto \mu ^{-V}\) and \(\psi \mapsto \psi ^{+V}\) are injective.

We saw then in [2] that for increasing binary image transformations, this isomorphism is generally compatible with the supremum and infimum operations. More precisely, for any complete lattice V,

  • the flat extension of a supremum of increasing binary image transformations is the supremum of their flat extensions: \(\bigl (\bigvee _{i\in I} \psi _i\bigr )^V = \bigvee _{i\in I} \psi _i^V\) (see Proposition 28 of [2]);

  • when V is infinite supremum distributive, the flat extension of the infimum of two increasing binary image transformations is the infimum of their flat extensions: \(\bigl (\psi _1 \wedge \psi _2\bigr )^V = \psi _1^V \wedge \psi _2^V\) (see Proposition 30 of [2]);

  • when V is completely distributive, the flat extension of an infimum of increasing binary image transformations is the infimum of their flat extensions: \(\bigl (\bigwedge _{i\in I} \psi _i\bigr )^V = \bigwedge _{i\in I} \psi _i^V\) (see Proposition 30 of [2]).

In our framework, V is a complete sublattice of \([\bot ,\top ]\), it is thus a completely distributive complete lattice, and the above properties hold for increasing binary image transformations, with the shifted flat extension \(\psi ^{+V}\), which coincides with the classical flat extension \(\psi ^V\). Since the shifted flat extension (23) of \(\psi _i\) differs from the no-shift one (22) applied to \(\chi \psi _i\) only by the translation by \(\bot \), which is compatible with the supremum and infimum, we obtain similar identities for the no-shift flat extension of their characteristic functions:

$$\begin{aligned}{} & {} \bigl (\sup _{i\in I} \chi \psi _i\bigr )^{-V} = \bigvee _{i\in I} (\chi \psi _i)^{-V} \\{} & {} \quad \text{ and }\quad \bigl (\inf _{i\in I} \chi \psi _i\bigr )^{-V} = \bigwedge _{i\in I} (\chi \psi _i)^{-V} , \end{aligned}$$

where \(\sup \) and \(\inf \) are the componentwise numerical supremum and infimum.

However, these identities do not extend to the general case, as we will see in Example 10 for non-increasing binary image transformations, and Example 11 for binary image measurements with non-binary values (\(K \ne \{0,1\}\)). We will thus analyse in more detail the maps \(\mu \mapsto \mu ^{-V}\) and \(\psi \mapsto \psi ^{+V}\).

We consider the family \(\mathcal {M}(E)\) of all binary image measurements on \(\mathcal {P}(E)\), in other words, of all maps \(\mu : \mathcal {P}(E) \rightarrow \mathbb {Z}^E\) with bounded values \(\mu (X)(p)\) (\(X \in \mathcal {P}(E)\), \(p \in E\)). For any \(\mu \in \mathcal {M}(E)\), let \(K[\mu ] = \{ \mu (X)(p) \mid X \in \mathcal {P}(E), ~ p \in E \}\); thus, \(\mu \) is a map \(\mathcal {P}(E) \rightarrow K[\mu ]^E\), where \(K[\mu ]\) is included in a finite interval in \(\mathbb {Z}\).

Then \(\mathcal {M}(E)\) is closed under the operations of addition and subtraction of functions, as we have

$$\begin{aligned}{} & {} K[-\mu ] = {\check{K}}[\mu ] = \bigl \{ -k \bigm \vert k \in K[\mu ] \bigr \} \\{} & {} \quad \text{ and } \quad K[\mu _1+\mu _2] \subseteq K[\mu _1] \oplus K[\mu _2] \\{} & {} \quad = \bigl \{ k_1 + k_2 \bigm \vert k_1 \in K[\mu _1], ~ k_2 \in K[\mu _2] \bigr \} . \end{aligned}$$

In other words, \(\mathcal {M}(E)\) is a commutative group for the operation of addition. It is also ordered by \(\le \). Write \(\vee \) and \(\wedge \) for the binary operations on functions applying pointwise numerical maximum and minimum:

$$\begin{aligned}{} & {} (\mu _1\vee \mu _2)(X)(p) = \max \bigl \{ \mu _1(X)(p), \mu _2(X)(p) \bigr \} \\{} & {} \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \text{ and } \\{} & {} \quad (\mu _1\wedge \mu _2)(X)(p) = \min \bigl \{ \mu _1(X)(p), \mu _2(X)(p) \bigr \} ; \end{aligned}$$

then \(K[\mu _1\vee \mu _2], K[\mu _1\wedge \mu _2] \subseteq K[\mu _1] \cup K[\mu _2]\); thus, \(\mathcal {M}(E)\) is a lattice. Now, the addition is compatible for the order, \(\mu _1 \le \mu _2 \;\Rightarrow \;\mu _1+\mu \le \mu _2+\mu \). Thus, \(\mathcal {M}(E)\) is a lattice-ordered group, or l-group, see [3], Chapter XIII.

The lattice \(\mathcal {M}(E)\) is not complete. For instance, for all \(n\in \mathbb {N}\) and \(X\in \mathcal {P}(E)\), let \(\mu _n(X)=0\) if \(\vert X\vert <n\) and \(\mu _n(X)=n\) if \(\vert X\vert \ge n\), so \(K[\mu _n] = \{0,n\}\); then \(\mu = \sup _{n\in \mathbb {N}}\mu _n\) satisfies \(\mu (X)=\vert X\vert \) for X finite, and \(\mu (X)= \infty \) for X infinite, so \(K[\mu ] = \mathbb {N}\cup \{\infty \}\) is infinite and not contained in \(\mathbb {Z}\). However, this lattice is conditionally complete. Given a family \(\mu _i \in \mathcal {M}(E)\) (\(i\in I\)) and \(\mu \in \mathcal {M}(E)\) such that \(\mu _i \le \mu \) for all \(i\in I\), we have \(\sup _{i\in I} \mu _i \le \mu \), then \(\sup _{i\in I} \mu _i\) takes values bounded above by \(\max K[\mu ]\), and bounded below by \(\min K[\mu _j]\) for any \(j\in I\); thus, \(\sup _{i\in I} \mu _i \in \mathcal {M}(E)\). We have then the dual property for the infimum: if \(\mu _i \ge \mu \) for all \(i\in I\), then \(\inf _{i\in I} \mu _i \in \mathcal {M}(E)\).

Let \(\mathcal {M}^V(E)\) be the set of no-shift flat extensions of binary image measurements: \(\mathcal {M}^V(E) = \{ \mu ^{-V} \mid \mu \in \mathcal {M}(E) \}\). By Lemma 9, the no-shift flat extension \(\mu \mapsto \mu ^{-V}\) is an isomorphism between the two posets \(\mathcal {M}(E)\) and \(\mathcal {M}^V(E)\): \(\mu _1 \le \mu _2 \;\Leftrightarrow \;\mu _1^{-V} \le \mu _2^{-V}\). Hence \(\mathcal {M}^V(E)\) inherits the lattice structure of \(\mathcal {M}(E)\); write \(\sqcup \) and \(\sqcap \) for the join and meet operations on \(\mathcal {M}^V(E)\); thus,

$$\begin{aligned}&\mu _1^{-V} \sqcup \mu _2^{-V} = (\mu _1\vee \mu _2)^{-V} \nonumber \\ \text{ and }\quad&\mu _1^{-V} \sqcap \mu _2^{-V} = (\mu _1\wedge \mu _2)^{-V} . \end{aligned}$$
(23)

Now, the no-shift flat extension is linear, it is in particular an isomorphism between the additive groups \(\mathcal {M}(E)\) and \(\mathcal {M}^V(E)\): \((\mu _1+\mu _2)^{-V} = \mu _1^{-V} + \mu _2^{-V}\). Therefore \(\mathcal {M}(E)\) and \(\mathcal {M}^V(E)\) are isomorphic l-groups.

As the sum of two integers equals the sum of their minimum and maximum, given two binary image measurements \(\mu _1,\mu _2\), we have

$$\begin{aligned} (\mu _1\vee \mu _2) + (\mu _1\wedge \mu _2) = \mu _1 + \mu _2 . \end{aligned}$$

The additivity of the no-shift flat extension gives then

$$\begin{aligned}&\bigl (\mu _1^{-V} \sqcup \mu _2^{-V}\bigr ) + \bigl (\mu _1^{-V} \sqcap \mu _2^{-V}\bigr ) \nonumber \\&\quad = (\mu _1\vee \mu _2)^{-V} + (\mu _1\wedge \mu _2)^{-V} \nonumber \\&\quad = \mu _1^{-V} + \mu _2^{-V} . \end{aligned}$$
(24)

Let \(\mathcal {T}(E)\) be the set of all binary image transformations. We have \(\psi _1 \le \psi _2 \;\Leftrightarrow \;\chi \psi _1 \le \chi \psi _2\), then

$$\begin{aligned}{} & {} \chi \Bigl ( \bigvee _{i\in I} \psi _i \Bigr ) = \sup _{i\in I} \chi \psi _i \\{} & {} \quad \text{ and }\quad \chi \Bigl ( \bigwedge _{i\in I} \psi _i \Bigr ) = \inf _{i\in I} \chi \psi _i , \end{aligned}$$

where \(\sup \) and \(\inf \) apply the pointwise numerical infimum and supremum. Thus, the characteristic function \(\chi \) gives an isomorphism between \(\mathcal {T}(E)\) and a sublattice of \(\mathcal {M}(E)\), which is complete. By Lemma 9, for \(\psi _1,\psi _2 \in \mathcal {T}(E)\), we have \(\psi _1 \le \psi _2 \;\Leftrightarrow \;\psi _1^{+V} \le \psi _2^{+V}\). From (23,25) we derive for any \(\psi _1,\psi _2 \in \mathcal {T}(E)\):

$$\begin{aligned} (\psi _1\vee \psi _2)^{+V} + (\psi _1\wedge \psi _2)^{+V} = \psi _1^{+V} + \psi _2^{+V} . \end{aligned}$$
(25)

Note that the equalities (25, 26) are particular cases of the identity \((a\vee b) + (a\wedge b) = a+b\) satisfied in any commutative l-group, see [3], Chapter XIII, Sect. 3.

We will now see that the form taken by the join \(\sqcup \) and meet \(\sqcap \) in \(\mathcal {M}^V(E)\) does not necessarily coincide with the pointwise numerical maximum and minimum for functions in \(U^E\).

First, for two binary image transformations \(\psi _1,\psi _2\) that are not increasing, we can have \((\psi _1\vee \psi _2)^{+V}(F) \ne \psi _1^{+V}(F) \vee \psi _2^{+V}(F)\) and \((\psi _1\wedge \psi _2)^{+V}(F) \ne \psi _1^{+V}(F) \wedge \psi _2^{+V}(F)\).

Fig. 3
figure 3

Top left: the function F, the dashed horizontal lines show the sets \(\textsf{X}_t(F)\) at level t. Top right: the sets \(\psi _1(\textsf{X}_t(F))\) at level t. Bottom left: the sets \(\psi _2(\textsf{X}_t(F))\) at level t. Bottom right: \(\psi _1^{+V}(F) = \psi _2^{+V}(F)\) (constant 4 function), \((\psi _1\vee \psi _2)^{+V}(F)\) (constant 8 function), and \((\psi _1\wedge \psi _2)^{+V}(F)\) (constant 0 function)

Example 10

See Fig. 3. Let \(E = \mathbb {Z}\) and \(V = \{ 0, \ldots , 8 \} \subset \mathbb {Z}\). Let \(F: V^E \rightarrow V^E\) be given by

$$\begin{aligned} F(x) = {\left\{ \begin{array}{ll} 0 &{} \text{ if } x<0 \text{ or } x > 7 , \\ 8-x &{} \text{ if } 0 \le x \le 7 . \\ \end{array}\right. } \end{aligned}$$

Define \(\psi _1,\psi _2: \mathcal {P}(E) \rightarrow \mathcal {P}(E)\) as follows:

$$\begin{aligned}{} & {} \psi _1(X) = {\left\{ \begin{array}{ll} \emptyset &{} \text{ if } \vert X\vert \in \{0, 1, 3, 5, 7\} , \\ E &{} \text{ otherwise } ; \\ \end{array}\right. } \\{} & {} \quad \psi _2(X) = {\left\{ \begin{array}{ll} \emptyset &{} \text{ if } \vert X\vert \in \{0, 2, 4, 6, 8\} , \\ E &{} \text{ otherwise } . \\ \end{array}\right. } \end{aligned}$$

Then \(\psi _1(\textsf{X}_t(F))= E\) for \(t = 0, 1, 3, 5, 7\) and \(\psi _1(\textsf{X}_t(F))\) \( = \emptyset \) for all other values of t, while \(\psi _2(\textsf{X}_t(F)) = E\) for \(t = 0, 2, 4, 6, 8\) and \(\psi _2(\textsf{X}_t(F)) = \emptyset \) for all other values of t. Since \(\bot =0\), \(\psi _i^{+V} = (\chi \psi _i)^{-V}\) (\(i=1,2\)). It follows that \(\psi _1^{+V}(F) = \psi _2^{+V}(F)\) is the constant 4 function, \((\psi _1\vee \psi _2)^{+V}(F)\) is the constant 8 function, and \((\psi _1\wedge \psi _2)^{+V}(F)\) is the constant 0 function. Therefore \((\psi _1\vee \psi _2)^{+V}(F) \ne \psi _1^{+V}(F) \vee \psi _2^{+V}(F)\) and \((\psi _1\wedge \psi _2)^{+V}(F) \ne \psi _1^{+V}(F) \wedge \psi _2^{+V}(F)\). Note that (26) holds.

For \(\mu _1= \chi \psi _1\) and \(\mu _2= \chi \psi _2\), we get \(\mu _1^{-V}(F) = \mu _2^{-V}(F)\), \((\mu _1\vee \mu _2)^{-V}(F) \ne \mu _1^{-V}(F) \vee \mu _2^{-V}(F)\) and \((\mu _1\wedge \mu _2)^{-V}(F) \ne \mu _1^{-V}(F) \wedge \mu _2^{-V}(F)\), but (25) holds.

Next, for two increasing binary image measurements \(\mu _1,\mu _2\) that do not have binary values, that is, which are not of the form \(\mu _1= \chi \psi _1\) and \(\mu _2= \chi \psi _2\) for two increasing binary image transformations \(\psi _1,\psi _2\), we can have \((\mu _1\vee \mu _2)^{-V}(F) \ne \mu _1^{-V}(F) \vee \mu _2^{-V}(F)\) and \((\mu _1\wedge \mu _2)^{-V}(F) \ne \mu _1^{-V}(F) \wedge \mu _2^{-V}(F)\).

Example 11

See Fig. 4. Let \(E = \mathbb {Z}^2\) and \(V = \{ 0, 1, 2 \} \subset \mathbb {Z}\). We take the function \(F: V^E \rightarrow V^E\) shown in (d), with \(\textsf{X}_1(F)\) and \(\textsf{X}_2(F)\) shown in (e) and (f) respectively. Let \(\varepsilon _A, \varepsilon _B, \varepsilon _C\) be the erosions by the three structuring elements ABC shown in (a,b,c). Let P be the singleton made of the pixel at the centre of \(\textsf{X}_1(F)\) and \(\textsf{X}_2(F)\), and let \(G = \chi P\), cf. (g,h). We have \(\varepsilon _A(\textsf{X}_1(F)) = \varepsilon _B(\textsf{X}_1(F)) = \varepsilon _C(\textsf{X}_1(F)) = P\), \(\varepsilon _A(\textsf{X}_2(F)) = P\), and \(\varepsilon _B(\textsf{X}_2(F)) = \varepsilon _C(\textsf{X}_2(F)) = \emptyset \). Let \(\mu _1 = \chi \varepsilon _A\) and \(\mu _2 = \chi \varepsilon _B + \chi \varepsilon _C\). Then \(\mu _1(\textsf{X}_1(F)) = G\), \(\mu _1(\textsf{X}_2(F)) = G\), \(\mu _2(\textsf{X}_1(F)) = G+G = 2\,G\), and \(\mu _2(\textsf{X}_2(F)) = 0+0 = 0\). Hence \((\mu _1 \vee \mu _2)(\textsf{X}_1(F)) = G \vee 2\,G = 2\,G\), \((\mu _1 \vee \mu _2)(\textsf{X}_2(F)) = G \vee 0 = G\), \((\mu _1 \wedge \mu _2)(\textsf{X}_1(F)) = G \wedge 2\,G = G\), \((\mu _1 \wedge \mu _2)(\textsf{X}_2(F)) = G \wedge 0 = 0\). From (22) we get:

$$\begin{aligned}{} & {} \mu _1^{{-}V}(F) {=} \mu _1(\textsf{X}_1(F)) {+} \mu _1(\textsf{X}_2(F)) {=} G{+}G {=} 2G , \\{} & {} \mu _2^{{-}V}(F) {=} \mu _2(\textsf{X}_1(F)) {+} \mu _2(\textsf{X}_2(F)) {=} 2G{+}0 {=} 2G , \\{} & {} (\mu _1 \vee \mu _2)^{{-}V}(F) {=} (\mu _1 \vee \mu _2)(\textsf{X}_1(F)) {+} (\mu _1 \vee \mu _2)(\textsf{X}_2(F)) \\{} & {} \quad {=} 2G{+}G {=} 3G , \\{} & {} (\mu _1 \wedge \mu _2)^{-V}(F) {=} (\mu _1 \wedge \mu _2)(\textsf{X}_1(F)) {+} (\mu _1 \wedge \mu _2)(\textsf{X}_2(F)) \\{} & {} \quad {=} G{+}0 {=} G , \end{aligned}$$

which means that \((\mu _1 \vee \mu _2)^{-V}(F) \ne \mu _1^{-V}(F) \vee \mu _2^{-V}(F)\) and \((\mu _1 \wedge \mu _2)^{-V}(F) \ne \mu _1^{-V}(F) \wedge \mu _2^{-V}(F)\). Note that (25) holds.

Fig. 4
figure 4

Here \(E = \mathbb {Z}^2\). ac The three structuring elements A, B and C; the cross + indicates the position of the origin. d The function F; it has value 0 outside the portion shown here. e \(\textsf{X}_1(F)\). f \(\textsf{X}_2(F)\). g \(P = \varepsilon _A(\textsf{X}_1(F)) = \varepsilon _B(\textsf{X}_1(F)) = \varepsilon _C(\textsf{X}_1(F)) = \varepsilon _A(\textsf{X}_2(F))\); on the other hand, \(\varepsilon _B(\textsf{X}_2(F)) = \varepsilon _C(\textsf{X}_2(F)) = \emptyset \). h \(G = \chi P\)

3.2 Composition of Operators

In Proposition 32 of [2], we showed that for any complete lattice V, the flat extension of the composition of two increasing binary image transformations is the composition of their flat extensions, \((\psi _1\psi _2)^V = \psi _1^V\psi _2^V\), provided that one of the following conditions hold:

  • the operator on the left, \(\psi _1\), is a dilation;

  • the operator on the right, \(\psi _2\), is an erosion;

  • V is completely distributive.

As we saw above, in our framework V is necessarily a completely distributive complete lattice. However, our next counterexample shows that the above property does not extend to the case where the right operator \(\psi _2\) is a non-increasing binary image transformation, even if the left operator \(\psi _1\) is a dilation.

Fig. 5
figure 5

Top left: the function F, the dashed horizontal lines show the sets \(\textsf{X}_t(F)\) at level t; we also show the structuring element A. Top middle: the sets \((\delta {\setminus }\varepsilon )(\textsf{X}_t(F))\) at level t, where \(\delta \) and \(\varepsilon \) are the dilation and erosion by A. Top right: the sets \(\delta (\delta {\setminus }\varepsilon )(\textsf{X}_t(F))\) at level t. Bottom left: \((\delta {\setminus }\varepsilon )^{+V}(F)\). Bottom middle: \([\delta (\delta {\setminus }\varepsilon )]^{+V}(F)\). Bottom right: \(\delta ^{+V}(\delta {\setminus }\varepsilon )^{+V}(F)\)

Example 12

See Fig. 5. Let \(E = \mathbb {Z}\) and \(V = \{ 0, \ldots , 8 \} \subset \mathbb {Z}\). Since \(\bot =0\), the shifted flat extension coincides with the no-shift one. We take the structuring element \(A = \{-1,0,+1\}\), and let \(\delta \) and \(\varepsilon \) be the dilation and erosion by A. We take a function F forming a ramp decreasing between \(x=1\) and \(x=7\), and constant for \(x\le 1\) and \(x\ge 7\). We get \((\delta {\setminus }\varepsilon )^{+V}(F)\) and \([\delta (\delta {\setminus }\varepsilon )]^{+V}(F)\) by summing the stacks \((\delta {\setminus }\varepsilon )(\textsf{X}_v(F))\) and \(\delta (\delta {\setminus }\varepsilon )(\textsf{X}_v(F))\) for \(v \in V\). Finally, \(\delta ^{+V}(\delta {\setminus }\varepsilon )^{+V}(F)\) results from the standard flat dilation applied to \((\delta {\setminus }\varepsilon )^{+V}(F)\), and we see that \(\delta ^{+V}(\delta {\setminus }\varepsilon )^{+V}(F) \ne [\delta (\delta {\setminus }\varepsilon )]^{+V}(F)\).

On the other hand, the above result from [2] remains valid when \(\psi _2\) is increasing and \(\psi _1\) has pointwise bounded variation. We will show this by using an argument similar to the one used in the proof of Lemma 31 of [2]. Recall that V is completely distributive, in the sense given by (5,6).

Lemma 13

Let \(\psi \) be an increasing binary image transformation. For any \(F: E \rightarrow V\) and \(x\in V\), we have \(\psi (\textsf{X}_x(F)) \subseteq \textsf{X}_x(\psi ^V(F))\), and \(\textsf{X}_x(\psi ^V(F)) \subseteq \psi (\textsf{X}_w(F))\) for any \(w \triangleleft x\). For any increasing map \(f: \mathcal {P}(E)\rightarrow \{0,1\}\), we have

$$\begin{aligned}&\mathcal {S}\bigl (f(\psi (\textsf{X}_v(F))) \bigm \vert v\in V\bigr ) \nonumber \\&\quad =\mathcal {S}\bigl (f(\textsf{X}_v(\psi ^V(F))) \bigm \vert v\in V\bigr ) . \end{aligned}$$
(26)

Proof

Here \(\psi ^V\) is the usual flat operator given by (4). As \(\textsf{X}_v(F)\) and \(\textsf{X}_v(\psi ^V(F))\) are decreasing in v, while \(\psi \) and f are increasing, the two maps \(V\rightarrow R: v \mapsto f(\textsf{X}_v(\psi ^V(F)))\) and \( v \mapsto f(\psi (\textsf{X}_v(F)))\) are decreasing; hence, the two summations in (27) are well-defined.

Take any \(x\in V\). For \(p \in \psi (\textsf{X}_x(F))\), x intervenes in the supremum \(\sup \bigl \{ v\in V \bigm \vert p\in \psi (\textsf{X}_v(F)) \bigr \}\), so by (4), \(\psi ^V(F)(p) \ge x\), that is, \(p \in \textsf{X}_x(\psi ^V(F))\). Hence \(\psi (\textsf{X}_x(F)) \subseteq \textsf{X}_x(\psi ^V(F))\). As f is increasing, \(f(\psi (\textsf{X}_x(F))) \le f(\textsf{X}_x(\psi ^V(F)))\). The summation on \(x \in V\) gives then

$$\begin{aligned}&\mathcal {S}\bigl (f(\psi (\textsf{X}_x(F))) \bigm \vert x\in V\bigr ) \nonumber \\&\quad \le \mathcal {S}\bigl (f(\textsf{X}_x(\psi ^V(F))) \bigm \vert x\in V\bigr ) . \end{aligned}$$
(27)

Let \(w \triangleleft x\). For any \(p \in \textsf{X}_x(\psi ^V(F))\), (4) gives \(x \le \psi ^V(F)(p) = \sup \bigl \{ v\in V \bigm \vert p\in \psi (\textsf{X}_v(F)) \bigr \}\), and (5) gives \(w \le u\) for some \(u\in V\) such that \(p\in \psi (\textsf{X}_u(F))\); then \(\textsf{X}_u(F) \subseteq \textsf{X}_w(F)\), and as \(\psi \) is increasing, \(\psi (\textsf{X}_u(F)) \subseteq \psi (\textsf{X}_w(F))\), so \(p \in \psi (\textsf{X}_w(F))\). Hence \(\textsf{X}_x(\psi ^V(F)) \subseteq \psi (\textsf{X}_w(F))\). As f is increasing, \(f(\textsf{X}_x(\psi ^V\) \((F))) \le f(\psi (\textsf{X}_w(F)))\). Thus, given \(x\in V\) such that \(f(\textsf{X}_x(\psi ^V(F))) =1\), every \(w \triangleleft x\) satisfies \(f(\psi (\textsf{X}_w(F))) = 1\), so (6) gives:

$$\begin{aligned}{} & {} x = \sup \{ w \in V \mid \bot < w \triangleleft x \} \\{} & {} \quad \le \sup \bigl \{ w \in V \bigm \vert f(\psi (\textsf{X}_w(F))) =1 \bigr \} . \end{aligned}$$

Taking the supremum of all such x, we get

$$\begin{aligned}&\sup \bigl \{ x \in V \bigm \vert f(\textsf{X}_x(\psi ^V(F))) =1 \bigr \} \nonumber \\&\le \sup \bigl \{ w \in V \bigm \vert f(\psi (\textsf{X}_w(F))) =1 \bigr \} . \end{aligned}$$
(28)

Applying Proposition 4 to the two decreasing maps \(V\rightarrow R: x \mapsto f(\textsf{X}_x(\psi ^V(F)))\) and \( x \mapsto f(\psi (\textsf{X}_x(F)))\), we get:

$$\begin{aligned}{} & {} \sup \bigl \{ x \in V \bigm \vert f(\textsf{X}_x(\psi ^V(F))) =1 \bigr \} \\{} & {} \quad = \bot + \mathcal {S}\bigl (f(\textsf{X}_x(\psi ^V(F))) \bigm \vert x\in V\bigr ) \\{} & {} \text{ and }\quad \sup \bigl \{ w \in V \bigm \vert f(\psi (\textsf{X}_w(F))) =1 \bigr \} \\{} & {} \quad = \bot + \mathcal {S}\bigl (f(\psi (\textsf{X}_w(F))) \bigm \vert w\in V\bigr ) . \end{aligned}$$

Combining this with the inequality (29), we get

$$\begin{aligned}{} & {} \mathcal {S}\bigl (f(\textsf{X}_x(\psi ^V(F))) \bigm \vert x\in V\bigr ) \\{} & {} \quad \le \mathcal {S}\bigl (f(\psi (\textsf{X}_w(F))) \bigm \vert w\in V\bigr ) . \end{aligned}$$

The two bound variables x on the left side and w on the right side can both be renamed v, so we obtain the converse of inequality (28), and we derive thus the equality (27). \(\square \)

Proposition 14

Let \(\psi \) be an increasing binary image transformation. For any binary image measurement \(\mu \) having pointwise bounded variation, \((\mu \psi )^{-V} = \mu ^{-V}\psi ^{+V}\). For any binary image transformation \(\xi \) having pointwise bounded variation, \((\xi \psi )^{+V} = \xi ^{+V}\psi ^{+V}\).

Proof

Let \(p\in E\). As \(\mu \) has pointwise bounded variation, for any \(p \in E\) we apply Proposition 2: there are \(m+n\) increasing functions \(f_1,\ldots ,f_{m+n}: \mathcal {P}(E) \rightarrow \{0,1\}\) (\(m,n\ge 0\)), such that for any \(Z\in \mathcal {P}(E)\), \(\mu (Z)(p) = \sum _{i=1}^m f_i(Z) - \sum _{j=m+1}^{m+n} f_j(Z)\). As \(\psi \) is increasing, \(\psi ^{+V}\) coincides with \(\psi ^V\). Thus, for any \(F: E \rightarrow V\), the above lemma gives for each \(i=1, \ldots , m+n\):

$$\begin{aligned}{} & {} \mathcal {S}\bigl (f_i(\psi (\textsf{X}_v(F))) \bigm \vert v\in V\bigr )\\{} & {} \quad = \mathcal {S}\bigl (f_i(\textsf{X}_v(\psi ^{+V}(F))) \bigm \vert v\in V\bigr ) . \end{aligned}$$

By linearity of summation, we get then

$$\begin{aligned}{} & {} \mathcal {S}\bigl (\mu (\psi (\textsf{X}_v(F)))(p) \bigm \vert v\in V\bigr ) \\{} & {} \quad = \mathcal {S}\Bigl ( \sum _{i=1}^m f_i(\psi (\textsf{X}_v(F))) \qquad \qquad \\{} & {} \qquad - \sum _{j=m+1}^{m+n} f_j(\psi (\textsf{X}_v(F))) \Bigm \vert v\in V \Bigr ) \\{} & {} \quad = \sum _{i=1}^m \mathcal {S}\bigl (f_i(\psi (\textsf{X}_v(F))) \bigm \vert v\in V\bigr ) \qquad \\{} & {} \qquad - \sum _{j=m+1}^{m+n} \mathcal {S}\bigl (f_j(\psi (\textsf{X}_v(F))) \bigm \vert v\in V\bigr ) \\{} & {} \quad = \sum _{i=1}^m \mathcal {S}\bigl (f_i(\textsf{X}_v(\psi ^{+V}(F))) \bigm \vert v\in V\bigr ) \qquad \\{} & {} \qquad - \sum _{j=m+1}^{m+n} \mathcal {S}\bigl (f_j(\textsf{X}_v(\psi ^{+V}(F))) \bigm \vert v\in V\bigr ) \\{} & {} \quad = \mathcal {S}\Bigl ( \sum _{i=1}^m f_i(\textsf{X}_v(\psi ^{+V}(F))) \qquad \qquad \\{} & {} \qquad \qquad - \sum _{j=m+1}^{m+n} f_j(\textsf{X}_v(\psi ^{+V}(F))) \Bigm \vert v\in V \Bigr ) \\{} & {} \quad = \mathcal {S}\bigl (\mu (\textsf{X}_v(\psi ^{+V}(F)))(p) \bigm \vert v\in V\bigr ) . \end{aligned}$$

By (22), this means that \((\mu \psi )^{-V}(F)(p) = \mu ^{-V}(\psi ^{+V}(F))\) (p).

For \(\mu = \chi \xi \), we get then \(\bot + (\chi \xi \psi )^{-V}(F)(p) = \bot + (\chi \xi )^{-V}(\psi ^{+V})(p)\), which means by (23) that \((\xi \psi )^{+V}(F)(p)\) \( = \xi ^{+V}(\psi ^{+V}(F))(p)\). \(\square \)

3.3 Commutation with Contrast Mappings and with Thresholding

We will consider here two classical properties of flat increasing operators: commutation with contrast mappings or anamorphoses [9, 10] and commutation with thresholding. We will see that non-increasing flat operators commute only with linear contrast mappings. In order to ease of the discussion, we restrict ourselves to the standard case: \(V = [\bot ,\top ]\).

Let us first deal with contrast mappings. For any map \(\theta : V\rightarrow V\), let \(\theta _E: V^E\rightarrow V^E\) be the extension of \(\theta \) to functions \(E \rightarrow V\) obtained by pointwise application of \(\theta \), that is, for any \(F:E\rightarrow V\) and \(p\in E\) we have \(\theta _E(F)(p) = \theta (F(p))\). In the case of grey-level images, that is, when V is a complete chain included in \(\overline{\mathbb {R}}\) (say, \(V = \overline{\mathbb {R}}\), \(\overline{\mathbb {Z}}\), a closed interval \([a,b] \subset \mathbb {R}\), or an interval in \(\mathbb {Z}\)), one calls a contrast mapping or anamorphosis [9, 10] a map \(\theta _E\) for \(\theta : V\rightarrow V\) that is both increasing and continuous. When V is a finite chain, the continuity requirement on \(\theta \) can be dropped, and when \(V = \overline{\mathbb {Z}}\), it applies only at \(\pm \infty \). Then, the flat extension \(\psi ^V\) of an increasing binary image transformation \(\psi \) will commute with any contrast mapping \(\theta _E\): for any \(F\in V^E\), \(\theta _E(\psi ^V(F)) = \psi ^V(\theta _E(F))\).

A complete characterisation of such a commutation in the case of an arbitrary complete lattice V was made in [11], see Theorem 8 there. In particular, given an increasing binary image transformation \(\psi \) and an increasing map \(\theta : V\rightarrow V\), the following three conditions taken together are sufficient for the commutation of \(\psi ^V\) with \(\theta _E\), that is \(\theta _E(\psi ^V(F)) = \psi ^V(\theta _E(F))\):

  1. 1.

    \(\theta (\bot ) = \bot \) or \(\psi (E) = E\);

  2. 2.

    \(\theta (\top ) = \top \) or \(\psi (\emptyset ) = \emptyset \);

  3. 3.

    \(\theta \) commutes with non-empty suprema and non-empty infima in V.

When \(V = \overline{\mathbb {R}}\) or \(V = [a,b] \subset \mathbb {R}\), condition 3 is equivalent to the continuity of the map \(\theta \). When V is a product of chains, condition 3 becomes very restrictive.

Now, if we consider bounded functions \(E\rightarrow \mathbb {R}^m\), an increasing linear map \(\theta \) satisfies condition 3, so \(\theta _E\) will commute with increasing flat operators. The same should then hold for non-increasing flat operators obtained as linear combinations of increasing ones.

In practice, linearity will be necessary, as we can see with our usual example of the set difference between an extensive dilation \(\delta \) and an anti-extensive erosion \(\varepsilon \). Assume \(\bot =0\), and define the binary image transformation \(\psi \) by \(\psi (X) = \delta (X){\setminus }\varepsilon (X)\) for all \(X\in \mathcal {P}(E)\). We have \(\psi ^{+V} = \delta ^{+V} - \varepsilon ^{+V}\). Consider an increasing map \(\theta : V\rightarrow V\) such that \(\theta _E\) commutes with the increasing flat operators \(\delta ^{+V}\) and \(\varepsilon ^{+V}\). Then

$$\begin{aligned} \psi ^{+V} \theta _E= & {} \bigl [ \delta ^{+V} - \varepsilon ^{+V} \bigr ] \theta _E \\= & {} \delta ^{+V} \theta _E - \varepsilon ^{+V} \theta _E = \theta _E \delta ^{+V} - \theta _E \varepsilon ^{+V} , \end{aligned}$$

while \(\theta _E \psi ^{+V} = \theta _E \bigl [ \delta ^{+V} - \varepsilon ^{+V} \bigr ]\). The equality \(\psi ^{+V} \theta _E = \theta _E \psi ^{+V}\) requires that for all functions F we have \(\theta _E(\delta ^{+V}(F))\) \( - \theta _E(\varepsilon ^{+V}(F)) = \theta _E \bigl (\delta ^{+V}(F) - \varepsilon ^{+V}(F) \bigr )\), that is, for every \(p\in E\) we have

$$\begin{aligned}{} & {} \theta \bigl (\delta ^{+V}(F)(p)\bigr ) -\theta \bigl (\varepsilon ^{+V}(F)(p)\bigr ) \\{} & {} \quad = \theta \bigl (\delta ^{+V}(F)(p) - \varepsilon ^{+V}(F)(p)\bigr ) . \end{aligned}$$

A sufficient and probably necessary condition for this general equality is that \(\theta \) is additive, that is \(\theta (x+y) = \theta (x)+\theta (y)\). As \(\theta \) is continuous, it will then be linear. Our next example confirms the necessity of the additivity condition on \(\theta \).

Fig. 6
figure 6

Let \(E=\mathbb {Z}\) and \(V = [0,\top ]\), and let \(\delta \) and \(\varepsilon \) be the dilation and erosion by the structuring element \(\{-1,0,+1\}\), and let \(\psi \) be their set difference. (a) From top to bottom, the two successive interval A and B in E, then their dilations \(\delta (A),\delta (B)\) and erosions \(\varepsilon (A),\varepsilon (B)\), and finally the three boundary sets \(X = \delta (A) {\setminus } \bigl [ \varepsilon (A)\cup \delta (B) \bigr ]\), \(Y = \delta (A)\cap \delta (B)\) and \(Z = \delta (B) {\setminus } \bigl [ \varepsilon (B)\cup \delta (A) \bigr ]\). (b) Let \(F_{r,s} = r\chi A + s\chi B\), for \(s \ge r \ge 0\). (c) The vertical lines are made of the union of all cross-sections \(\{v\} \times \psi (\textsf{X}_v(F_{r,s}))\), for \(v\in V\). (d) Then \(\psi ^+(F_{r,s}) = r\chi X + (s-r)\chi Y + s\chi Z = G_{r,s-r,s}\)

Example 15

See Fig. 6. Let \(E = \mathbb {Z}\) and \(V = [0,\top ] \subset \mathbb {R}\) for \(\top >0\). For \(x,y\in \mathbb {Z}\) with \(x<y\), let \([x\ldots y] = \{ z\in \mathbb {Z}\mid x\le z\le y \}\) be the discrete interval between x and y. Let \(\delta \) and \(\varepsilon \) be the dilation and erosion by the structuring element \(\{-1,0,+1\}\), and let \(\psi \) be their set difference, \(\psi (X) = \delta (X) {\setminus } \varepsilon (X)\). Given \(a,b,c\in \mathbb {Z}\) such that \(a+3\le b\le c-3\), let \(A= [a\ldots b-1]\) and \(B= [b\ldots c-1]\). Define \(X = \delta (A) {\setminus } \bigl [ \varepsilon (A)\cup \delta (B) \bigr ] = \{a-1,a\}\) (the left boundary of A), \(Y = \delta (A)\cap \delta (B) = \{b-1,b\}\) (the common boundary of A and B), and \(Z = \delta (B) {\setminus } \bigl [ \varepsilon (B)\cup \delta (A) \bigr ] = \{c-1,c\}\) (the right boundary of B). We have then \(\psi (A) = X\cup Y\), \(\psi (B) = Y\cup Z\), and \(\psi (A\cup B) = X\cup Z\). For \(u,v,w \in V\), define \(F_{u,v} = u\chi A + v\chi B\) and \(G_{u,v,w} = u\chi X + v\chi Y + w\chi Z\). Let \(s \ge r \ge 0\); we have: for \(0<v\le r\), \(\textsf{X}_v(F_{r,s}) = A\cup B\) and \(\psi (\textsf{X}_v(F_{r,s})) = X\cup Z\); for \(r<v\le s\), \(\textsf{X}_v(F_{r,s}) = B\) and \(\psi (\textsf{X}_v(F_{r,s})) = Y\cup Z\); for \(v>s\), \(\textsf{X}_v(F_{r,s}) =\psi (\textsf{X}_v(F_{r,s})) = \emptyset \). It follows then that \(\psi ^+(F_{r,s}) = G_{r,s-r,s}\).

Given a contrast mapping \(\theta _E\), we have \(\theta _E(F_{r,s}) = F_{\theta (r),\theta (s)}\), so \(\psi ^+(\theta _E(F_{r,s})) = \psi ^+(F_{\theta (r),\theta (s)}) = G_{\theta (r),\theta (s)}\) \({_{\theta (r),\theta (s)}}\); on the other hand, \(\theta _E(\psi ^+(F_{r,s})) {=} \theta _E(G_{r,s{-}r,s})\) \( = G_{\theta (r),\theta (s-r),\theta (s)}\). The commutation \(\psi ^+(\theta _E(F_{r,s})) = \theta _E(\psi ^+(F_{r,s}))\) requires thus that \(\theta (s-r) = \theta (s)-\theta (r)\), in other words, the additivity of \(\theta \).

Now, the commutation with contrast mappings raises a theoretical problem in our framework: we consider images with bounded values, and the contrast mapping will modify the bounds, for an image \(F: E \rightarrow [\bot ,\top ]\), \(\eta _E(F)\) will be \(E \rightarrow [\eta (\bot ),\eta (\top )]\). This problem could be avoided in the classical framework for increasing operators [2] by taking image values in \({{\overline{R}}}^m\). Our solution is to consider images with values ranging in an interval that can be modified: for \(\bot _1 \le \bot _0 < \top _0 \le \top _1\), an image \(F: E\rightarrow [\bot _0,\top _0]\) can be considered as \(F: E\rightarrow [\bot _1,\top _1]\), and we can choose the interval \([\bot _1,\top _1]\) wide enough to have \(\bot _1 \le \eta (\bot _0) < \eta (\top _0) \le \top _1\), that is, \(\eta _E(F): E \rightarrow [\bot _1,\top _1]\). But then it raises a new problem, the two formulas (22) and (23) depend on the chosen interval \([\bot ,\top ]\), changing that interval can change the result.

In Proposition 34 of [1], we showed that given \(\bot _1 \le \bot _0 < \top _0 \le \top _1\), \(V_0 =[\bot _0,\top _0]\), and \(V_1 =[\bot _1,\top _1]\), for any \(F: E\rightarrow V_0\) and for any binary image measurement \(\mu \), we have

$$\begin{aligned} \mu ^{-V_1}(F)&= (\bot ^0-\bot _1) \mu (E) + \mu ^{-V_0}(F)&\nonumber \\&\quad + (\top _1-\top _0) \mu (\emptyset )&. \end{aligned}$$
(29)

From (23), we deduce that for any binary image transformation \(\psi \),

$$\begin{aligned} \psi ^{+V_1}(F)&= (\bot ^0-\bot _1) \bigl ( \chi \psi (E)-1 \bigr ) \nonumber \\&\quad + \psi ^{+V_0}(F) + (\top _1-\top _0) \chi \psi (\emptyset ) . \end{aligned}$$
(30)

When \(E = \mathbb {R}^n\) or \(\mathbb {Z}^n\), a morphological operator based on structuring elements commutes with translations of E; it follows then that \(\mu (E)\) and \(\mu (\emptyset )\) must be constant, and both \(\psi (E)\) and \(\psi (\emptyset )\) must be equal to either E or \(\emptyset \). We make this requirement in the general case, and so extending the interval from \([\bot _0,\top _0]\) to \([\bot _1,\top _1]\) leads only to a vertical translation of the result of the flat operator, which can be corrected. In some particular cases, we can make stricter requirements.

Most known morphological operators on sets (dilation, erosion, hit or miss transform, gradient, ...) satisfy \(\mu (\emptyset )=0\) and \(\psi (\emptyset )= \emptyset \), so the last term \((\top _1-\top _0) \mu (\emptyset )\) in (30) and \((\top _1-\top _0) \chi \psi (\emptyset )\) in (31) is equal to 0. When this is not the case, the operator involves a set complementation. Specifically, if \(\mu (\emptyset )= k\ne 0\), then we have \(\mu = k - \mu _0\), where \(\mu _0(\emptyset )= \emptyset \); then by linearity we get \(\mu ^{-V_i}(F) = k(\top _i-\bot _i) - \mu _0^{-V_i}(F)\) (\(i=0,1\)). Similarly, if \(\psi (\emptyset )= E\), then \(\psi (X)= \rho (X)^c\), where \(\rho (\emptyset )= \emptyset \); then for \(i=0,1\), \((\chi \psi )^{-V_i}(F) = \top _i-\bot _i - (\chi \rho )^{-V_i}(F)\), hence \(\psi ^{+V_i}(F) = \top _i+\bot _i - \rho ^{+V_i}(F)\) by (23). Thus, the flat operator involves an inversion in \(V_i\), whose specific form depends on its bounds \(\bot _i\) and\(\top _i\).

For the value of \(\mu (E)\) and \(\psi (E)\), the situation is variable. Given an extensive dilation \(\delta \) and an anti-extensive erosion \(\varepsilon \), we have \(\delta (E) = \varepsilon (E) =E\), but \((\delta {\setminus }\varepsilon )(E)= \emptyset \). For the no-shift flat extension, we can require that \(\mu (E)=0\), so that left term \((\bot ^0-\bot _1) \mu (E)\) in (30) is equal to 0. Now for the shifted flat extension, we can require instead that \(\psi (E)=E\), so that left term \((\bot ^0-\bot _1) \bigl ( \chi \psi (E)-1 \bigr )\) in (31) is equal to 0. Otherwise, since we consider linear contrast mappings of the form \(\theta : v\mapsto a v\) for \(a>0\), we can restrict ourselves to the case where \(\bot _0 = \bot _1 = 0\), in other words, to positive image values; this also cancels the left term in \((\bot ^0-\bot _1)\).

Consider thus scaling by a positive scalar: \(\theta : v\mapsto av\), where \(a>0\). In the case of continuous image intensities, that is, \(U = \mathbb {R}^m\), we have \(a\in \mathbb {R}^+\); on the other hand, for discrete image intensities, that is, \(U = u_1\mathbb {Z}\times \cdots \times u_m\mathbb {Z}\), we take \(a\in \mathbb {N}\). Let \(V_0 =[\bot _0,\top _0]\), \(aV_0 =\{ av \mid a \in V_0 \}\) and \(V_0^a =[a\bot _0,a\top _0]\). In the continuous case \(U = \mathbb {R}^m\), \(aV_0 = V_0^a\), while in the discrete case, \(aV_0\) is the complete sublattice of \(V_0^a\) made of all vectors whose coordinates are multiple of a (relatively to \(u_1,\ldots ,u_m\)).

Let \(F:E\rightarrow V_0\); then aF is \(E\rightarrow aV_0\), and for \(v\in V_0\) we have \(\textsf{X}_{av}(aF) = \textsf{X}_v(F)\). Define \(\theta : V_0\rightarrow aV_0: v\mapsto av\) and \(f: aV_0\rightarrow \mathbb {Z}: w\mapsto \mu (\textsf{X}_w(aF))(p)\); then \(f\theta : V_0\rightarrow \mathbb {Z}\) satisfies \(f\theta (v) = f(av) = \mu (\textsf{X}_{av}(aF))(p) = \mu (\textsf{X}_{v}(F))(p)\). We apply Lemma 5 with (22):

$$\begin{aligned}{} & {} \mu ^{-aV_0}(aF)(p) = \mathcal {S}_{[a\bot _0,a\top _0]}(f) \\{} & {} \quad = a \mathcal {S}_{[\bot _0,\top _0]}(f\theta ) = a \mu ^{-V_0}(F)(p) . \end{aligned}$$

Then (23) gives

$$\begin{aligned}{} & {} \psi ^{+aV_0}(aF)(p) = a\bot _0 + (\chi \psi )^{-aV_0}(aF)(p) \\{} & {} \quad = a \bot _0 + a (\chi \psi )^{-V_0}(F)(p) = a\psi ^{+V_0}(F)(p) . \end{aligned}$$

As aF is \(E\rightarrow aV_0\) and \(aV_0\) is a complete sublattice of \(V_0^a\), Proposition 31 of [1] gives \(\mu ^{-aV_0}(aF) = \mu ^{-V_0^a}(aF)\) and \(\psi ^{+aV_0}(aF) = \psi ^{+V_0^a}(aF)\). Hence

$$\begin{aligned}&\mu ^{-V_0^a}(aF) = \mu ^{-aV_0}(aF) = a \mu ^{-V_0}(F) \quad \text{ and } \nonumber \\&\psi ^{+V_0^a}(aF) = \psi ^{+aV_0}(aF) = a \psi ^{+V_0}(F) . \end{aligned}$$
(31)

Take now an interval \(V_1 = [\bot _1,\top _1]\) wide enough to include both \(V_0\) and \(V_0^a\), that is, \(\bot _1 \le \bot _0\), \(\bot _1 \le a\bot _0\), \(\top _1 \ge \top _0\), and \(\top _1 \ge a\top _0\). Then (30) gives

$$\begin{aligned}{} & {} a\mu ^{-V_1}(F) = a(\bot ^0-\bot _1) \mu (E) + a\mu ^{-V_0}(F) \\{} & {} \quad + a(\top _1-\top _0) \mu (\emptyset ) \end{aligned}$$

and

$$\begin{aligned} \mu ^{-V_1}(aF)= & {} (a\bot ^0-\bot _1) \mu (E) + \mu ^{-V_0^a}(aF) \\{} & {} + (\top _1-a\top _0) \mu (\emptyset ) \\= & {} (a\bot ^0-\bot _1) \mu (E) + a\mu ^{-V_0}(F) \\{} & {} + (\top _1-a\top _0) \mu (\emptyset ) . \end{aligned}$$

The equality \(a\mu ^{-V_1}(F) = \mu ^{-V_1}(aF)\) is equivalent to \((a-1)\bot _1 \mu (E) - (a-1)\top _1 \mu (\emptyset ) =0\). Allowing the interval \([\bot _1,\top _1]\) to vary, this condition will be satisfied in the following three cases: (a) \(\mu (E) = \mu (\emptyset ) =0\); (b) \(\bot _1 =0\) (we consider positive image values) and \(\mu (\emptyset ) =0\); (c) \(\mu (E) =0\) and \(\top _1 =0\) (we consider negative image values).

Similarly, (31) gives

$$\begin{aligned} a\psi ^{+V_1}(F)= & {} a(\bot ^0-\bot _1) \bigl ( \chi \psi (E)-1 \bigr ) \\{} & {} + a\psi ^{+V_0}(F) + a(\top _1-\top _0) \chi \psi (\emptyset ) \end{aligned}$$

and

$$\begin{aligned} \psi ^{+V_1}(aF)= & {} (a\bot ^0-\bot _1) \bigl ( \chi \psi (E)-1 \bigr ) \\{} & {} + \psi ^{+V_0^a}(aF) + (\top _1-a\top _0) \chi \psi (\emptyset ) \\= & {} (a\bot ^0-\bot _1) \bigl ( \chi \psi (E)-1 \bigr ) \\{} & {} + a\psi ^{+V_0}(F) + (\top _1-a\top _0) \chi \psi (\emptyset ) . \end{aligned}$$

The equality \(a\psi ^{+V_1}(F) = \psi ^{+V_1}(aF)\) is equivalent to \((a-1)\bot _1 \bigl ( \chi \psi (E)-1 \bigr ) - (a-1)\top _1 \chi \psi (\emptyset ) =0\). Allowing the interval \([\bot _1,\top _1]\) to vary, this condition will be satisfied in the following three cases: (a) \(\psi (E) = E\) and \(\psi (\emptyset ) = \emptyset \); (b) \(\bot _1 =0\) (we consider positive image values) and \(\psi (\emptyset ) = \emptyset \); (c) \(\psi (E) = E\) and \(\top _1 =0\) (we consider negative image values).

The most sensible choice is to take images with positives values, \(\bot _1 = \bot _0 =0\), with the further conditions \(\mu (\emptyset ) =0\) and \(\psi (\emptyset ) = \emptyset \), giving \(a\mu ^{-V_1}(F) = \mu ^{-V_1}(aF)\) and \(a\psi ^{+V_1}(F) = \psi ^{+V_1}(aF)\) respectively.

We will now give the conditions under which a flat operator commutes with vertical translation \(v\mapsto v+b\). Recall \(V_0 =[\bot _0,\top _0]\). Let \(b\in U\) and \(V_0+b = \{ v + b \mid v \in V_0 \}\); as U is a module, \(V_0+b =[\bot _0+b,\top _0+b] \subseteq U\). For \(F:E\rightarrow V_0\), \(F+b\) is \(E\rightarrow V_0+b\), and for \(v\in V_0\) we have \(\textsf{X}_{v+b}(F+b) = \textsf{X}_v(F)\). Define \(\theta : V_0\rightarrow V_0+b: v\mapsto v+b\) and \(f: V_0+b\rightarrow \mathbb {Z}: w\mapsto \mu (\textsf{X}_w(F+b))(p)\); then \(f\theta : V_0\rightarrow \mathbb {Z}\) satisfies \(f\theta (v) = f(v+b) = \mu (\textsf{X}_{v+b}(F+b))(p) = \mu (\textsf{X}_{v}(F))(p)\). We apply Lemma 5 with (22):

$$\begin{aligned} \mu ^{-V_0+b}(F+b)(p)= & {} \mathcal {S}_{[\bot _0+b,\top _0+b]}(f) \\= & {} \mathcal {S}_{[\bot _0,\top _0]}(f\theta ) = \mu ^{-V_0}(F)(p) . \end{aligned}$$

For a binary image transformation \(\psi \), (23) gives then

$$\begin{aligned}{} & {} \psi ^{+V_0+b}(F+b)(p) = \bot _0 +b + (\chi \psi )^{-V_0+b}(F+b)(p) \\{} & {} \quad = \bot _0 + (\chi \psi )^{-V_0}(F)(p) + b = \psi ^{+V_0}(F)(p) + b . \end{aligned}$$

Hence

$$\begin{aligned}&\mu ^{-V_0+b}(F+b) = \mu ^{-V_0}(F) \quad \text{ and } \nonumber \\&\psi ^{+V_0+b}(F+b) = \psi ^{+V_0}(F) +b . \end{aligned}$$
(32)

Take now an interval \(V_1 = [\bot _1,\top _1]\) wide enough to include both \(V_0\) and \(V_0+b\), that is, \(\bot _1 \le \bot _0\), \(\bot _1 \le \bot _0+b\), \(\top _1 \ge \top _0\), and \(\top _1 \ge \top _0+b\). Then (30) gives

$$\begin{aligned} \mu ^{-V_1}(F+b)= & {} (\bot ^0+b-\bot _1) \mu (E) \\{} & {} + \mu ^{-V_0+b}(F+b) + (\top _1-\top _0-b) \mu (\emptyset ) \\= & {} b \mu (E) + (\bot ^0-\bot _1) \mu (E) + \mu ^{-V_0}(F) \\{} & {} + (\top _1-\top _0) \mu (\emptyset ) - b \mu (\emptyset ) \\= & {} \mu ^{-V_1}(F) +b \bigl ( \mu (E)-\mu (\emptyset ) \bigr ) . \end{aligned}$$

From (23), we deduce

$$\begin{aligned} \psi ^{+V_1}(F+b) = \psi ^{+V_1}(F) + b \bigl ( \chi \psi (E)-\chi \psi (\emptyset ) \bigr ) . \end{aligned}$$

When \(\mu (E) = 1\) and \(\mu (\emptyset ) = 0\), we get \(\mu ^{-V_1}(F+b) = \mu ^{-V_1}(F) +b\); similarly, when \(\psi (E) = E\) and \(\psi (\emptyset ) = \emptyset \), we get \(\psi ^{+V_1}(F+b) = \psi ^{+V_1}(F) + b\). This is for instance the case for usual increasing morphological operators (dilation, erosion, opening, closing, ...).

On the other, when \(\mu (E) = \mu (\emptyset ) = 0 \), we get \(\mu ^{-V_1}(F+b) = \mu ^{-V_1}(F)\); similarly, when \(\psi (E) = \psi (\emptyset ) = \emptyset \), we get \(\psi ^{+V_1}(F+b) = \psi ^{+V_1}(F)\) This is for instance the case for the difference between two increasing morphological operators, for instance a Beucher gradient or a top-hat.

Let us next consider commutation with thresholding. Here \(V = [\bot ,\top ]\). It has been shown that given an increasing binary image transformation \(\psi \), under some conditions on either \(\psi \) or V, for any \(F:E\rightarrow V\) and \(v\in V\), we get \(\textsf{X}_v(\psi ^{+V}(F)) = \psi (\textsf{X}_v(F))\).

Let us first remark that commutation with thresholding can be expressed under the form \(\xi _v(\psi ^{+V}(F)) = \psi ^{+V}(\xi _v(F))\) for a map \(\xi _v: V^E\rightarrow V^E\). For any \(A\in \mathcal {P}(E)\), define \(\beta (A): E\rightarrow V\) by \(\beta (A) = \bot + (\top -\bot ) \chi A\), in other words, for all \( p\in E\), \(\beta (A)(p) = \top \) when \(p\in A\) and \(\beta (A)(p) = \bot \) when \(p\notin A\) (in [1] we wrote it \(B_\bot ^\top [A]\)). It is thus the binary image \(E\rightarrow \{\bot ,\top \}\) corresponding to A. For any binary image transformation \(\psi \), we showed in Corollary 32 of [1] that for any \(A\in \mathcal {P}(E)\):

$$\begin{aligned} \psi ^{+V}(\beta (A)) = \beta (\psi (A)) . \end{aligned}$$

Now, define \(\xi _v: V^E\rightarrow \{\bot ,\top \}^E\) by \(\xi _v(F)= \beta (\textsf{X}_v(F))\). The above equality with \(A = \textsf{X}_v(F)\) gives \(\psi ^{+V}(\xi _v(F)) = \psi ^{+V}(\beta (\textsf{X}_v(F))) = \beta (\psi (\textsf{X}_v(F)))\), while \(\xi _v(\psi ^{+V}(F)) = \beta (\textsf{X}_v(\psi ^{+V}(F)))\). Thus, \(\xi _v(\psi ^{+V}(F)) = \psi ^{+V}(\xi _v(F))\) iff \(\beta (\textsf{X}_v(\psi ^{+V}(F))) = \beta (\psi (\textsf{X}_v(F)))\), and as \(\beta \) is a bijection \(\mathcal {P}(E)\rightarrow \{\bot ,\top \}^E\), this is equivalent to \(\textsf{X}_v(\psi ^{+V}(F)) = \psi (\textsf{X}_v(F))\). Therefore,

$$\begin{aligned}{} & {} \xi _v(\psi ^{+V}(F)) = \psi ^{+V}(\xi _v(F)) \\{} & {} \quad \iff \textsf{X}_v(\psi ^{+V}(F)) = \psi (\textsf{X}_v(F)) . \end{aligned}$$

In [11] we expressed commutation with thresholding in the form \(\xi _v\psi ^V = \psi ^V\xi _v\) for an increasing \(\psi \).

As \(\xi _v\) is not linear, from the above discussion around Example 15, it appears that commutation with thresholding will fail for the difference between a dilation and an erosion. See for instance Fig. 5, where we have \(\textsf{X}_4([\delta {\setminus } \varepsilon ]^{+V}(F)) = \emptyset \) (see bottom left), while \([\delta {\setminus } \varepsilon ](\textsf{X}_4(F)) \ne \emptyset \) (see top middle). It is indeed easily shown that, unless \(V=\{\bot ,\top \}\), commutation with thresholding requires \(\psi \) to be increasing:

Proposition 16

Let \(\psi \) be a binary image transformation, let \(a,b\in V\) such that \(\bot< a < b\) and for any \(F:E\rightarrow V\), the equality \(\textsf{X}_v(\psi ^{+V}(F)) = \psi (\textsf{X}_v(F))\) holds for \(v=a\) and for \(v=b\). Then \(\psi \) is increasing.

Proof

Let \(X,Y\in \mathcal {P}(E)\) such that \(X\subseteq Y\). Define \(F:E\rightarrow V\) by setting for \(p\in E\):

$$\begin{aligned} F(p) = {\left\{ \begin{array}{ll} b &{} \text{ if }~ p\in X , \\ a &{} \text{ if }~ p\in Y{\setminus } X , \\ \bot &{} \text{ if }~ p\in E{\setminus } Y . \end{array}\right. } \end{aligned}$$

Then \(\textsf{X}_a(F)=Y\) and \(\textsf{X}_b(F)=X\). As the threshold set \(\textsf{X}_v(F)\) is decreasing in the threshold v, from \(a<b\) we derive \(\textsf{X}_b(\psi ^{+V}(F)) \subseteq \textsf{X}_a(\psi ^{+V}(F))\). Hence

$$\begin{aligned}{} & {} \psi (X) = \psi (\textsf{X}_b(F)) = \textsf{X}_b(\psi ^{+V}(F)) \\{} & {} \quad \subseteq \textsf{X}_a(\psi ^{+V}(F)) = \psi (\textsf{X}_a(F)) = \psi (Y) , \end{aligned}$$

so \(\psi \) is increasing. \(\square \)

Let thus \(\psi \) be an increasing binary image transformation. So \(\psi ^{+V}\) is the classical flat extension \(\psi ^V\). For \(v = \bot \), the equality \(\textsf{X}_\bot (\psi ^V(F)) = \psi (\textsf{X}_\bot (F))\) holds iff \(\psi (E) = E\). For \(v>\bot \), the condition varies according to the lattice V. When V is a finite chain, the equality \(\textsf{X}_v(\psi ^V(F)) = \psi (\textsf{X}_v(F))\) always holds for all \(v>\bot \). When \(V = \overline{\mathbb {Z}}\), it holds for any finite v. When \(V = \overline{\mathbb {Z}}\) and \(v=+\infty \), or when V is continuous (\(V = \overline{\mathbb {R}}\) or \(V = [a,b] \subset \mathbb {R}\)) and we take any \(v>\bot \), the equality holds if \(\psi \) is upper semi-continuous [9]: given a decreasing sequence of subsets of E, \(X_0 \supseteq X_1 \supseteq \ldots \supseteq X_n \supseteq \ldots \), we have \(\psi \bigl (\bigcap _{n\in \mathbb {N}} X_n\bigr ) = \bigcap _{n\in \mathbb {N}} \psi (X_n)\).

Consider next an arbitrary complete lattice V. By Theorem 10 of [11], the increasing binary image transformation \(\psi \) satisfies \(\textsf{X}_v(\psi ^V(F)) = \psi (\textsf{X}_v(F))\) for any \(F:E\rightarrow V\) and for all \(v>\bot \), iff \(\psi \) is V-\(\downarrow \)-continuous (see Definition 5 there): for every non-void lower set S in V and for every function \(G: E\rightarrow V\), we have

$$\begin{aligned} \psi \Bigl (\bigcap _{v\in S} \textsf{X}_v(G)\Bigr ) = \bigcap _{v\in S} \psi \bigl (\textsf{X}_v(G)\bigr ) . \end{aligned}$$

When \(V = \overline{\mathbb {Z}}\), \(V = \overline{\mathbb {R}}\) or \(V = [a,b] \subset \mathbb {R}\), \(\psi \) is V-\(\downarrow \)-continuous iff it is upper semi-continuous (see Proposition 27 there).

4 Duality

In image processing, duality exchanges the roles of foreground and background, of dark and bright regions. Thus, the dual of an operator \(\psi \) is the operator \(\psi ^*\) that is applied to the background or negative when \(\psi \) is applied to the foreground or positive. For \(\psi : \mathcal {P}(E)\rightarrow \mathcal {P}(E)\), \(\psi ^*(X) = \psi (X^c)^c\) (recall that the superscript c denotes the complementation in E). For \(\psi : V^E\rightarrow V^E\) with V bounded by \(\bot \) and \(\top \), \(\psi ^*(F) = \nu _E(\psi (\nu _E(F)))\), where \(\nu : V\rightarrow V: v\mapsto \bot +\top -v\) is the inversion of V, and \(\nu _E\) its extension to functions \(E \rightarrow V\), cf. Sect. 3.3. Note that \((\psi ^*)^* = \psi \), the duality relation is symmetric. For instance, dilation and erosion are dual, as well as opening and closing. Duality is compatible with the composition of operators and exchanges join and meet: \((\xi \psi )^* = \xi ^*\psi ^*\), \((\xi \vee \psi )^* = \xi ^*\wedge \psi ^*\), and \((\xi \wedge \psi )^* = \xi ^*\vee \psi ^*\).

In [2] we showed that for an increasing binary image operator \(\psi \) and a completely distributive lattice V, we have \((\psi ^*)^V = (\psi ^V)^*\). In this section, we will see how this result can be extended to a binary image operator that is not increasing, or to a binary image measurement.

Here with operators involving complementation, the relation of duality with foreground and background becomes subtler. For instance, let \(\delta \) be an extensive dilation on \(\mathcal {P}(E)\), let \(\varepsilon \) be the anti-extensive dual erosion, and let \(\psi \) be their set difference: \(\psi (X) = \delta (X){\setminus }\varepsilon (X)\). When \(\delta \) and \(\varepsilon \) are the dilation and erosion by a symmetric point neighbourhood, \(\psi (X)\) is the boundary of X, the union of its outer boundary \(\delta (X){\setminus } X\) and of its inner boundary \(X{\setminus }\varepsilon (X)\). Now, the boundary of \(X^c\) is \(\psi (X^c)=\psi (X)\), the union of \(\delta (X^c){\setminus } X^c = X{\setminus }\varepsilon (X)\) and \(X^c{\setminus }\varepsilon (X^c) = \delta (X){\setminus } X\); so, X and \(X^c\) have the same boundary, the outer and inner boundaries of \(X^c\) are those of X exchanged. On the other hand, the dual \(\psi ^*\) of \(\psi \) gives \(\psi ^*(X) = \psi ^*(X^c) = \varepsilon (X)\cup \varepsilon (X^c)\), the complement of the boundary. We see thus that a notion like boundary should not be seen as an image transformation (like dilation, erosion, opening and closing), but rather as a feature extraction. For an image transformation \(\psi \), we consider the dual \(\psi ^*: X \mapsto \psi (X^c)^c\), while for a feature extraction we simply apply \(\psi \) to \(X^c\). This distinction is somewhat analogous to the one between a binary image transformation (with shifted flat extension) and a binary image measurement (with no-shift flat extension).

In [2] we considered the dual flat extension \(\psi ^{V*}\), defined as the flat extension for the dual lattice of V; we will here consider the dual summation in Sect. 4.1. Then in Sect. 4.2 the results will be applied to the relation of flat extension with duality.

4.1 Dual Summation

Given a function \(f:P\rightarrow \mathbb {R}\) and a fixed real number \(M>0\), we will write BND(fM) if f is bounded by M, non-negative, and decreasing, that is: for all \(x\in P\), \(0\le f(x)\le M\), and for all \(x,y\in P\), \(x<y \;\Rightarrow \;f(x)\ge f(y)\).

We assume that the poset P is bounded by \(\bot , \top \). Consider first a bounded, non-negative and decreasing function \(f:P\rightarrow \mathbb {R}\), in other words, BND(fM) for some \(M>0\). In the definition (13) of \(\mathcal {S}_{(s_0,\ldots ,s_n)}(f)\) for a strictly increasing sequence \((s_0,\ldots ,s_n)\), we associated to the interval \([s_{i-1},s_i]\) the term \(f(s_i) (s_i-s_{i-1})\). When P is a real interval, this term is an approximation from below of the integral of f on that interval, see Fig. 2. Hence in the definition (14) of \(\mathcal {S}_{[a,b]}(f)\), we took the supremum of all \(\mathcal {S}_{(s_0,\ldots ,s_n)}(f)\) for \((s_0,\ldots ,s_n) \in S(a,b)\). We can instead approximate this integral from above, associating to the interval \([s_{i-1},s_i]\) the term \(f(s_{i-1}) (s_i-s_{i-1})\), leading thus to the dual summation

$$\begin{aligned} \mathcal {S}^*_{(s_0,\ldots ,s_n)}(f)&= \sum _{i=1}^n f(s_{i-1}) (s_i-s_{i-1}) \nonumber \\&= \sum _{i=0}^{n-1} f(s_i) (s_{i+1}-s_i) , \end{aligned}$$
(33)

see Fig. 7a. Then we obtain the dual summation of f over the interval [ab] by taking the infimum of such dual summations for all \((s_0,\ldots ,s_n) \in S(a,b)\):

$$\begin{aligned} \mathcal {S}^*_{[a,b]}(f)&= \inf \bigl \{ \mathcal {S}^*_{(s_0,\ldots ,s_n)}(f) \bigm \vert (s_0,\ldots ,s_n) \in S(a,b) \bigr \} . \end{aligned}$$
(34)
Fig. 7
figure 7

(a) The function \(f:P\rightarrow \mathbb {R}\) is bounded, non-negative and decreasing: BND(fM). We consider a strictly increasing sequence \((s_0,\ldots ,s_6)\) in P. The grey area represents \(\mathcal {S}^*_{(s_0,\ldots ,s_6)}(f)\). (b) Let \(\nu : x \mapsto \bot + \top - x\) be the inversion between P and \(P^\nu \), and let \(t_i = s_{6-i}\) for \(i= 0,\ldots ,6\). Then \((t_0,\ldots ,t_6)\) is a strictly increasing sequence in \(P^\nu \). The function \(f\nu : P^\nu \rightarrow \mathbb {R}: x\mapsto f(\nu (x))\) is increasing. The grey area represents the complement of \(\mathcal {S}^*_{(s_0,\ldots ,s_6)}(f)\) in the rectangle \([t_0,t_6] \times [0,M]\). (c) The function \(M-f\nu \) is bounded, non-negative and decreasing: \(BND(M-f\nu ,M)\). The grey area of (b), after inversion of the interval [0, M], represents \(\mathcal {S}_{(t_0,\ldots ,t_6)}(M-f\nu )\). Thus, \(\mathcal {S}_{(t_0,\ldots ,t_6)}(M-f\nu ) = (s_6-s_0)M - \mathcal {S}^*_{(s_0,\ldots ,s_6)}(f)\)

We will relate the original summation \(\mathcal {S}\) and the dual one \(\mathcal {S}^*\) by combining the function f with an inversion of both its domain P and its range included in \(\mathbb {R}\). Since \(P \subseteq \mathbb {R}^m\) for some \(m\ge 1\), we define the inversion \(\nu : \mathbb {R}^m\rightarrow \mathbb {R}^m: x \mapsto \bot +\top -x\); it is an involution (dual isomorphism that is its own inverse), and it exchanges \(\bot \) and \(\top \). Let \(P^\nu = \{ \nu (x) \mid x \in P \}\); then the poset \(P^\nu \) has the same least and greatest elements \(\bot \) and \(\top \) as P, and \(\nu \) is a dual isomorphism between P and \(P^\nu \). For \(a,b \in P\) with \(a\le b\), the map \((s_0,\ldots ,s_n) \mapsto (\nu (s_n),\ldots ,\nu (s_0))\) is a bijection between S(ab) in P and \(S(\nu (b),\nu (a))\) in \(P^\nu \). Note that when P is the whole interval \([\bot ,\top ]\) in \(\mathbb {R}^m\), or its trace in \(\mathbb {Z}^m\), then \(P^\nu = P\).

Consider a function \(f:P\rightarrow \mathbb {R}\) such that BND(fM). As f is decreasing, the function \(f\nu : P^\nu \rightarrow \mathbb {R}: x\mapsto f(\nu (x))\) is increasing. Inverting \(f\nu \) w.r.t. M, we get \(M-f\nu : P^\nu \rightarrow \mathbb {R}: x\mapsto M-f(\nu (x))\), such that \(BND(M-f\nu ,M)\). Let \((s_0,\ldots ,s_n)\) be an increasing sequence in P, and let \((t_0,\ldots ,t_n) = (\nu (s_n),\ldots ,\nu (s_0))\) be the inverted sequence in \(P^\nu \); let \(L = t_n-t_0 = s_n-s_0\). We have

$$\begin{aligned}{} & {} \mathcal {S}_{(t_0,\ldots ,t_n)}(M-f\nu ) = \sum _{i=1}^n \bigl (M-f(\nu (t_i))\bigr ) (t_i-t_{i-1}) \\{} & {} \quad = \sum _{i=1}^n M (t_i-t_{i-1}) - \sum _{i=1}^n f(\nu (t_i)) (t_i-t_{i-1}) \\{} & {} \qquad {[}\text{ apply } t_i = \nu (s_{n-i})] \\{} & {} \quad = LM - \sum _{i=1}^n f(s_{n-i}) (\nu (s_{n-i}) - \nu (s_{n-i+1})) \\{} & {} \qquad {[}\text{ apply } \nu (x)-\nu (y) = y-x] \\{} & {} \quad = LM - \sum _{i=1}^n f(s_{n-i}) (s_{n-i+1} - s_{n-i}) \\{} & {} \qquad {[}\text{ change } \text{ variable: } j=n-i+1] \\{} & {} \quad = LM - \sum _{j=n}^1 f(s_{j-1}) (s_j-s_{j-1}) \\{} & {} \quad = LM - \mathcal {S}^*_{(s_0,\ldots ,s_n)}(f) . \end{aligned}$$

The above argument is illustrated in Fig. 7. Then for \(a,b \in P\) such that \(a\le b\), we get (with \(L=b-a\)):

$$\begin{aligned}{} & {} \mathcal {S}_{[\nu (b),\nu (a)]}(M-f\nu ) = \sup \bigl \{ \mathcal {S}_{(t_0,\ldots ,t_n)}(M-f\nu ) \bigm \vert \\{} & {} \qquad (t_0,\ldots ,t_n) \in S(\nu (b),\nu (a)) \bigr \} \\{} & {} \quad = \sup \bigl \{ (b-a)M - \mathcal {S}^*_{(s_0,\ldots ,s_n)}(f) \bigm \vert \\{} & {} \qquad (s_0,\ldots ,s_n) \in S(a,b) \bigr \} \\{} & {} \quad = (b-a)M - \inf \bigl \{ \mathcal {S}^*_{(s_0,\ldots ,s_n)}(f) \bigm \vert \\{} & {} \qquad (s_0,\ldots ,s_n) \in S(a,b) \bigr \} = (b-a)M - \mathcal {S}^*_{[a,b]}(f) . \end{aligned}$$

We summarise: for \(f:P\rightarrow \mathbb {R}\), we have \(M-f\nu : P^\nu \rightarrow \mathbb {R}\), \(BND(f,M) \;\Rightarrow \;BND(M-f\nu ,M)\), and

$$\begin{aligned} \mathcal {S}_{[\nu (b),\nu (a)]}(M-f\nu ) = (b-a)M - \mathcal {S}^*_{[a,b]}(f) . \end{aligned}$$
(35)

Note that for \(g= M-f\nu \) we get \(f= M-g\nu \). Indeed, for \(x\in P\), we have

$$\begin{aligned}{} & {} (M-g\nu )(x) = M - g(\nu (x)) = M - (M-f\nu )(\nu (x)) \\{} & {} \quad = M - \bigl ( M - f\nu (\nu (x)) \bigr ) = f(\nu (\nu (x))) = f(x) . \end{aligned}$$

Conversely, for \(g: P^\nu \rightarrow \mathbb {R}\), we have \(M-g\nu : P\rightarrow \mathbb {R}\), \(BND(g,M) \;\Rightarrow \;BND(M-g\nu ,M)\), and for \(f= M-g\nu \) we get \(g= M-f\nu \). Then (36) gives

$$\begin{aligned} \mathcal {S}_{[\nu (b),\nu (a)]}(g) = (b-a)M - \mathcal {S}^*_{[a,b]}(M-g\nu ) , \end{aligned}$$

hence the dual form of (36) for \(g: P^\nu \rightarrow \mathbb {R}\) such that BND(gM):

$$\begin{aligned} \mathcal {S}^*_{[a,b]}(M-g\nu ) = (b-a)M - \mathcal {S}_{[\nu (b),\nu (a)]}(g) . \end{aligned}$$
(36)

We show now that \(\mathcal {S}\) is additive on \(P^\nu \) if and only if \(\mathcal {S}^*\) is additive on P. Suppose \(\mathcal {S}\) additive on \(P^\nu \), and let \(f_1,f_2:P\rightarrow \mathbb {R}\) such that \(BND(f_1,M_1)\) and \(BND(f_2,M_2)\). Then \(f_1+f_2:P\rightarrow \mathbb {R}\) satisfies \(BND(f_1+f_2,M_1+M_2)\), and \((f_1+f_2)\nu = f_1\nu + f_2\nu \). Applying (36) to \(f_1\), \(f_2\) and \(f_1+f_2\), together with the additivity of \(\mathcal {S}\) on \(P^\nu \), we get for \(a,b \in P^\nu \) such that \(a\le b\):

$$\begin{aligned}{} & {} (b-a)(M_1+M_2) - \mathcal {S}^*_{[a,b]}(f_1+f_2) \\{} & {} \quad = \mathcal {S}_{[\nu (b),\nu (a)]} \bigl ( M_1+M_2-(f_1+f_2)\nu \bigr ) \\{} & {} \quad = \mathcal {S}_{[\nu (b),\nu (a)]}(M_1-f_1\nu +M_2-f_2\nu ) = \\{} & {} \mathcal {S}_{[\nu (b),\nu (a)]}(M_1-f_1\nu ) + \mathcal {S}_{[\nu (b),\nu (a)]}(M_2-f_2\nu ) \\{} & {} \quad = (b-a)M_1 - \mathcal {S}^*_{[a,b]}(f_1) + (b-a)M_2 - \mathcal {S}^*_{[a,b]}(f_2) , \end{aligned}$$

from which we obtain \(\mathcal {S}^*_{[a,b]}(f_1+f_2) = \mathcal {S}^*_{[a,b]}(f_1) + \mathcal {S}^*_{[a,b]}(f_2)\), that is, \(\mathcal {S}^*\) is additive on P. Conversely, if \(\mathcal {S}^*\) is additive on P, we show that \(\mathcal {S}\) additive on \(P^\nu \) by the same argument with \(g_1,g_2:P^\nu \rightarrow \mathbb {R}\) in place of \(f_1,f_2:P\rightarrow \mathbb {R}\), inverting the roles of \(\mathcal {S}\) and \(\mathcal {S}^*\), and using (37) instead of (36).

Let now \(f:P\rightarrow \mathbb {R}\) be of bounded variation, We have \(f=g-h\) for two functions \(g,h:P\rightarrow \mathbb {R}\) such that BND(gM) and BND(hM) for some \(M>0\); as for the original summation \(\mathcal {S}\), we can define \(\mathcal {S}^*_{[a,b]}(f) = \mathcal {S}^*_{[a,b]}(g) - \mathcal {S}^*_{[a,b]}(h)\), and by the additivity of \(\mathcal {S}^*\) on P, this definition of \(\mathcal {S}^*_{[a,b]}(f)\) does not depend on the choice of g and h. Now we have \(f\nu = (g-h)\nu = g\nu -h\nu = (M-h\nu ) - (M-g\nu )\), where \(M-h\nu \) and \(M-g\nu \) are two functions \(P^\nu \rightarrow \mathbb {R}\), \(BND(M-g\nu ,M)\) and \(BND(M-h\nu ,M)\). We get then:

$$\begin{aligned}{} & {} \mathcal {S}_{[\nu (b),\nu (a)]}(f\nu ) \\{} & {} \quad = \mathcal {S}_{[\nu (b),\nu (a)]}(M-h\nu ) -\mathcal {S}_{[\nu (b),\nu (a)]}(M-g\nu ) \\{} & {} \quad = \bigl [ (b-a)M - \mathcal {S}^*_{[a,b]}(h) \bigr ] - \bigl [ (b-a)M - \mathcal {S}^*_{[a,b]}(g) \bigr ] \\{} & {} \quad = \mathcal {S}^*_{[a,b]}(g) - \mathcal {S}^*_{[a,b]}(h) = \mathcal {S}^*_{[a,b]}(f) . \end{aligned}$$

We can summarise our results:

Theorem 17

Let P be a poset bounded by \(\bot ,\top \). Let \(\nu : x \mapsto \bot + \top - x\) be the inversion between P and \(P^\nu \). The dual summation \(\mathcal {S}^*\) is additive on P iff \(\mathcal {S}\) is additive on \(P^\nu \). Under this additivity condition, for any \(f:P\rightarrow \mathbb {R}\) of bounded variation, given a decomposition \(f=g-h\) for \(g,h:P\rightarrow \mathbb {R}\) bounded, non-negative and decreasing, we define \(\mathcal {S}^*_{[a,b]}(f)= \mathcal {S}^*_{[a,b]}(g) - \mathcal {S}^*_{[a,b]}(h)\), then \(\mathcal {S}^*_{[a,b]}(f)\) does not depend on the choice of g and h in the decomposition, and we have \(\mathcal {S}^*_{[a,b]}(f) = \mathcal {S}_{[\nu (b),\nu (a)]}(f\nu )\) for all \(a,b \in P\) with \(a\le b\). The additive dual summation \(\mathcal {S}^*\) will be a linear operator on the module of functions of bounded variation.

Let us now describe the form taken by the dual summation \(\mathcal {S}^*\) for some particular posets. Throughout, let \(f:P\rightarrow \mathbb {R}\) be of bounded variation.

We consider first the case where P is a bounded chain; then \(P^\nu \) is a bounded chain. From the discussion in Sect. 2.3, \(\mathcal {S}\) is additive on \(P^\nu \); hence by Theorem 17, \(\mathcal {S}^*\) is additive on P, and we obtain the dual form of the formulas given there:

  • If P is a finite chain, that is, \(P= \{t_0, \ldots , t_n\}\) with \(t_0< \cdots < t_n\), then for \(0\le u < v \le n\) we have:

    $$\begin{aligned} \mathcal {S}^*_{[t_u,t_v]}(f)= & {} \sum _{i=u}^{v-1} f(t_i) (t_{i+1}-t_i) \\{} & {} = \sum _{i=u+1}^v f(t_{i-1})(t_i-t_{i-1}) . \end{aligned}$$

    Recall that we had \(\mathcal {S}_{[t_u,t_v]}(f) = \sum _{i=u+1}^v f(t_i) (t_i-t_{i-1})\).

  • If P is a real interval, \(P=[\bot ,\top ] \subset \mathbb {R}\), then for \(a,b\in P\) with \(a<b\),

    $$\begin{aligned} \mathcal {S}^*_{[a,b]}(f) = \mathcal {S}_{[a,b]}(f) = \int _a^b f(t) \, \textrm{d}t . \end{aligned}$$

Consider now a Cartesian product \(P= P_1 \times \cdots \times P_m\) of posets, with componentwise order, see (1). We assume that each \(P_i\) is bounded by \(\bot _i, \top _i\), so P will be bounded by \(\bot , \top \), where \(\bot = (\bot _1,\ldots ,\bot _m)\) and \(\top = (\top _1,\ldots ,\top _m)\). Each \(P_i\) has the inversion \(\nu _i: P_i \rightarrow P_i^{\nu _i}: x \mapsto \bot _i + \top _i -x\). Define the inversion \(\nu : P\rightarrow P^\nu : x \mapsto \bot +\top -x\); we have then \(\nu (x_1,\ldots ,x_m) = \bigl (\nu _1(x_1),\ldots ,\nu _m(x_m)\bigr )\) and \(P^\nu = P_1^{\nu _1} \times \cdots \times P_m^{\nu _m}\).

From the discussion in Sect. 2.3, if \(\mathcal {S}\) is additive on each \(P_i^{\nu _i}\) (\(i=1,\ldots ,m\)), then \(\mathcal {S}\) is additive on \(P^\nu = P_1^{\nu _1} \times \cdots \times P_m^{\nu _m}\). Hence, by Theorem 17: if \(\mathcal {S}^*\) is additive on each \(P_i\) (\(i=1,\ldots ,m\)), then \(\mathcal {S}^*\) is additive on P. We can now describe the form taken by the dual summation in P in terms of dual summations in all \(P_i\). As said in Sect. 2.3, for each \(i=1,\ldots ,m\) we have some \(k_i\ge 1\) such that \(P_i\subset \mathbb {R}^{k_i}\); let \(Q_i = \mathbb {R}^{k_i}\) and \(Q = Q_1 \times \cdots \times Q_m = \mathbb {R}^{k_1+ \cdots +k_m}\), so \(P\subset Q\). For \(i=1,\ldots ,m\), recall

  • from (15) the i-th projection \(\pi _i: Q = Q_1 \times \cdots \times Q_m \rightarrow Q_i: (x_1,\ldots ,x_m)\mapsto x_i\),

  • and from (16) the i-th embedding through a for \(a =(a_1,\ldots ,a_m)\in P\):

    $$\begin{aligned} \eta ^a_i&:&Q_i \rightarrow Q = Q_1 \times \cdots \times Q_m \qquad \\&:&x \mapsto (a_1,\ldots ,a_{i-1},x,a_{i+1},\ldots ,a_m) . \end{aligned}$$

Now let \(a=(a_1,\ldots ,a_m)\) and \(b=(b_1,\ldots ,b_m)\in P\) with \(a\le b\). By Theorem 17 applied to P, \(\mathcal {S}^*_{[a,b]}(f) = \mathcal {S}_{[\nu (b),\nu (a)]}(f\nu )\); for \(i=1,\ldots ,m\), \(\pi _i(\mathcal {S}^*_{[a,b]}(f)) {=} \pi _i(\mathcal {S}_{[\nu (b),}\) \(_{\nu (a)]}(f\nu ))\). Applying (17) with \(f\nu : P^\nu \rightarrow \mathbb {R}\), \(\nu (b)\) and \(\nu (a)\) in place of \(f:P\rightarrow \mathbb {R}\), a and b, we get \(\pi _i(\mathcal {S}_{[\nu (b),\nu (a)]}(f\nu )) = \mathcal {S}_{[\nu _i(b_i),\nu _i(a_i)]}(f\nu \eta ^{\nu (b)}_i)\). Now for \(x\in P_i\), (16) gives

$$\begin{aligned} \nu \eta ^{\nu (b)}_i(x)&{=}&\nu \bigl ( \nu _1(b_1), \ldots , \qquad \nu _{i{-}1}(b_{i{-}1}),x, \\{} & {} \nu _{i{+}1}(b_{i{+}1}), \ldots , \nu _m(b_m) \bigr ) \\&{=}&(b_1,\ldots ,b_{i{-}1},\nu _i(x),b_{i{+}1},\ldots ,b_m) {=} \eta ^b_i(\nu _i(x)) , \end{aligned}$$

so \(\nu \eta ^{\nu (b)}_i = \eta ^b_i\nu _i\). Thus, \(\mathcal {S}_{[\nu _i(b_i),\nu _i(a_i)]}(f\nu \eta ^{\nu (b)}_i) = \mathcal {S}_{[\nu _i(b_i),}\) \(_{\nu _i(a_i)]}(f\eta ^b_i\nu _i)\). Applying again Theorem 17 to \(P_i\), we get \(\mathcal {S}_{[\nu _i(b_i),\nu _i(a_i)]}(f\eta ^b_i\nu _i) = \mathcal {S}^*_{[a_i,b_i]}(f\eta ^b_i)\). Combining all above equalities, we get the dual form of (17):

$$\begin{aligned} \pi _i(\mathcal {S}^*_{[a,b]}(f)) = \mathcal {S}^*_{[a_i,b_i]}(f\eta ^b_i) . \end{aligned}$$
(37)

Note that we have here \(\eta ^b_i\) instead of \(\eta ^a_i\). Geometrically speaking, this means that each projection \(\pi _i(\mathcal {S}^*_{[a,b]}(f))\) is obtained by the dual summation of f along the line segment parallel to the i-th axis of P, joining \((b_1,\ldots ,b_{i-1},a_i,b_{i+1},\) \(\ldots ,b_m)\) to \(b = (b_1,\ldots ,b_m)\). In particular \(\mathcal {S}_{[a,b]}^*(f)\) is completely determined by the restriction of f to the m lines through b parallel to the axes.

Now if P is a product of bounded chains, that is, if each \(P_i\) is a chain, then \(\mathcal {S}^*\) is additive on \(P_i\) (see above), hence \(\mathcal {S}^*\) will be additive on P. In particular:

  • If \(P_i\) is a finite chain, \(P_i= \{t_0, \ldots , t_n\}\) with \(t_0< \cdots < t_n\), then for \(a_i=t_u\) and \(b_i=t_v\) (\(0\le u \le v \le n\)),

    $$\begin{aligned} \pi _i(\mathcal {S}^*_{[a,b]}(f))= & {} \sum _{j=u}^{v-1} f\eta ^b_i(t_j) (t_{j+1}-t_j) \\= & {} \sum _{j=u+1}^v f\eta ^b_i(t_{j-1})(t_j-t_{j-1}) . \end{aligned}$$
  • If \(P_i\) is a real interval, \(P_i=[\bot _i,\top _i] \subset \mathbb {R}\), then \(\pi _i(\mathcal {S}^*_{[a,b]}(f)) = \int _{a_i}^{b_i} f\eta ^b_i(t) \, \text {d}t\).

We illustrate this in the cases of \(\mathbb {Z}^3\) and \(\mathbb {R}^3\), with componentwise ordering. Let \(a=(a_1,a_2,a_3)\) and \(b=(b_1,b_2,b_3)\), with \(a_1 < b_1\), \(a_2 < b_2\) and \(a_3 < b_3\). In \(\mathbb {Z}^3\) we get the dual of (18):

$$\begin{aligned}&\mathcal {S}^*_{[a,b]}(f) = \Bigl ( \sum _{t=a_1}^{b_1-1} f(t,b_2,b_3) \; , \nonumber \\&\quad \sum _{t=a_2}^{b_2-1} f(b_1,t,b_3) \; , \; \sum _{t=a_3}^{b_3-1} f(b_1,b_2,t) \Bigr ) . \end{aligned}$$
(38)

In \(\mathbb {R}^3\) we get the dual of (19):

$$\begin{aligned} \mathcal {S}^*_{[a,b]}(f)&= \Bigl ( \int _{a_1}^{b_1} f(t,b_2,b_3) \, \textrm{d}t \; , \nonumber \\&\quad \int _{a_2}^{b_2} f(b_1,t,b_3) \, \textrm{d}t \; , \; \int _{a_3}^{b_3} f(b_1,b_2,t) \, \textrm{d}t \Bigr ) . \end{aligned}$$
(39)

We give now the dual of Proposition 4, which will be used in Sect. 4.2:

Proposition 18

Let P be bounded by \(\bot , \top \). For any decreasing function \(f:P\rightarrow \{0,1\}\),

$$\begin{aligned} \bot + \mathcal {S}^*(f) = \inf \{ y \in P \mid f(y)=0 \} , \end{aligned}$$
(40)

where we set \(\inf \emptyset = \top \) on the right side of the equation.

Proof

Here BND(f, 1). With the inversion \(\nu : x \mapsto \bot +\top -x\) between P and \(P^\nu \), \(1-f\nu \) is a function \(P^\nu \rightarrow \{0,1\}\) and \(BND(1-f\nu ,1)\). By (36), \(\mathcal {S}(1-f\nu ) = \top -\bot - \mathcal {S}^*(f)\), so \(\mathcal {S}^*(f) = \top - \bigl (\bot + \mathcal {S}(1-f\nu )\bigr )\). Applying (20) to \(1-f\nu \), we get:

$$\begin{aligned}{} & {} \bot + \mathcal {S}^*(f) = \bot +\top - \bigl (\bot + \mathcal {S}(1-f\nu )\bigr ) \\{} & {} \quad =\bot +\top - \sup \{ x \in P^\nu \mid (1-f\nu )(x)=1 \} \\{} & {} \quad = \bot +\top - \sup \{ x \in P^\nu \mid f\nu (x)=0 \} \\{} & {} \quad = \inf \{ \bot +\top - x \mid x \in P^\nu , ~ f\nu (x)=0 \} \\{} & {} \quad = \inf \{ \nu (x) \mid x \in P^\nu , ~ f\nu (x)=0 \} \\{} & {} \quad = \inf \{ y \in P \mid f(y) = 0 \} . \end{aligned}$$

The empty infimum on the right side of (41) corresponds to the case where \(f(y)=1\) for all \(y\in P\); then for every \((s_0,\ldots ,s_n) \in S(\bot ,\top )\), (34) gives \(\mathcal {S}^*_{(s_0,\ldots ,s_n)}(f) = \sum _{i=1}^n (s_i-s_{i-1}) = \top -\bot \), hence by (35) we get \(\mathcal {S}^*(f) = \top -\bot \), so \(\bot + \mathcal {S}^*(f) = \top = \inf \emptyset \). \(\square \)

4.2 Duality in Flat Operators

Let us now analyse duality under inversion of flat operators. We will relate it to the dual flat extension, which will rely on the dual summation \(\mathcal {S}^*\).

We define for any image \(F:E\rightarrow V\) and \(v\in V\) the dual threshold set:

$$\begin{aligned} \textsf{X}^*_v(F) = \{ p\in E \mid F(p)\le v \} . \end{aligned}$$
(41)

We consider also the complement of the threshold set,

$$\begin{aligned} \textsf{X}_v(F)^c = \{ p\in E \mid F(p)\not \ge v \} . \end{aligned}$$

Both sets \(\textsf{X}^*_v(F)\) and \(\textsf{X}_v(F)^c\) are increasing in v: for \(v<w\), we have \(\textsf{X}^*_v(F) \subseteq \textsf{X}^*_w(F)\) and \(\textsf{X}_v(F)^c \subseteq \textsf{X}_w(F)^c\).

In [2], for any increasing binary image transformation \(\psi \), we defined \(\psi ^{V^*}\), the dual flat extension of \(\psi \), as the flat extension of \(\psi \) w.r.t. the dual of V (with the order inverted), given by the dual of (4):

$$\begin{aligned} \psi ^{V^*}(F)(p) = \bigwedge \bigl \{ v\in V \bigm \vert p\in \psi (\textsf{X}^*_v(F)) \bigr \} . \end{aligned}$$
(41)

We showed that for any dual automorphism \(\beta \) of V, \(\beta _E \psi ^V \beta _E^{-1} = \psi ^{V^*}\). We also showed that when V is completely distributive, \(\psi ^{V^*} = (\psi ^*)^V\), where \(\psi ^*\) is the dual of \(\psi \) defined by \(\psi ^*(X) = \psi (X^c)^c\).

Recall the inversion \(\nu : U \rightarrow U: x \mapsto \bot + \top - x\) of Sect. 4.1, and write \(V^\nu = \{ \nu (v) \mid v \in V \}\). Since V is a complete sublattice of \([\bot ,\top ]\), \(V^\nu \) will also be a complete sublattice of \([\bot ,\top ]\), so \(\mathcal {S}\) will be additive on it; thus, by Theorem 17, \(\mathcal {S}^*\) will be additive on V and on \(V^\nu \).

We say that V is symmetrical if \(V=V^\nu \), in other words, for any \(v\in V\), \(\bot +\top -v \in V\). For instance, in the standard case \(V = [\bot ,\top ]\), V is symmetrical. There is a linear dual automorphism of V if and only if V is symmetrical, and then the only one is \(\nu \).

The following result, the dual of Proposition 20 of [1], relates (43) to summation:

Proposition 19

Given an increasing operator \(\psi : \mathcal {P}(E) \rightarrow \mathcal {P}(E)\), an image \(F:E\rightarrow V\) and a point \(p\in E\),

$$\begin{aligned}{} & {} \top - \mathcal {S}^*\bigl (\chi \psi (\textsf{X}^*_v(F))(p) \bigm \vert v\in V\bigr ) \\{} & {} \quad = \inf \bigl \{ v\in V \bigm \vert p\in \psi (\textsf{X}^*_v(F)) \bigr \} , \end{aligned}$$

where we set \(\inf \emptyset = \top \) on the right side of the equation. If V is closed under componentwise numerical infimum, we get

$$\begin{aligned} \psi ^{V^*}(F)(p) = \top - \mathcal {S}^*\bigl (\chi \psi (\textsf{X}^*_v(F))(p) \bigm \vert v\in V\bigr ) , \end{aligned}$$

where \(\psi ^{V^*}\) is the dual flat extension of \(\psi \) to \(V^E\).

Proof

As \(\psi \), \(\chi \) and the map \(v\mapsto \textsf{X}^*_v(F)\) are increasing, the map \(V\rightarrow \{0,1\}: v\mapsto \chi \psi (\textsf{X}^*_v(F))(p)\) is increasing, so the map \(v\mapsto 1-\chi \psi (\textsf{X}^*_v(F))(p)\) is a decreasing map \(V\rightarrow \{0,1\}\). We apply Proposition 18 to it, so (41) gives

$$\begin{aligned}{} & {} \bot + \mathcal {S}^*\bigl (1-\chi \psi (\textsf{X}^*_v(F))(p) \bigm \vert v\in V\bigr ) \\{} & {} \quad = \inf \bigl \{ v\in V \bigm \vert 1-\chi \psi (\textsf{X}^*_v(F))(p) =0 \bigr \} . \end{aligned}$$

The additivity of \(\mathcal {S}^*\) gives

$$\begin{aligned}{} & {} \bot + \mathcal {S}^*\bigl (1-\chi \psi (\textsf{X}^*_v(F))(p) \bigm \vert v\in V\bigr ) \\{} & {} \quad = \bot + \mathcal {S}^*(1) - \mathcal {S}^*\bigl (\chi \psi (\textsf{X}^*_v(F))(p) \bigm \vert v\in V\bigr ) \\{} & {} \quad = \bot + (\top -\bot ) - \mathcal {S}^*\bigl (\chi \psi (\textsf{X}^*_v(F))(p) \bigm \vert v\in V\bigr ) \\{} & {} \quad = \top - \mathcal {S}^*\bigl (\chi \psi (\textsf{X}^*_v(F))(p) \bigm \vert v\in V\bigr ) . \end{aligned}$$

Now, \(1-\chi \psi (\textsf{X}^*_v(F))(p) =0 \;\Leftrightarrow \;\chi \psi (\textsf{X}^*_v(F))(p) =1 \;\Leftrightarrow \;p\in \psi (\textsf{X}^*_v(F))\). Combining this equivalence with the above two equalities, we get indeed

$$\begin{aligned}{} & {} \top - \mathcal {S}^*\bigl (\chi \psi (\textsf{X}^*_v(F))(p) \bigm \vert v\in V\bigr ) \\{} & {} \quad = \inf \bigl \{ v\in V \bigm \vert p\in \psi (\textsf{X}^*_v(F)) \bigr \} . \end{aligned}$$

The empty infimum on the right side corresponds to the case where \(p\notin \psi (\textsf{X}^*_v(F))\) for all \(v\in V\), so on the left side we have \(\mathcal {S}^*\bigl (\chi \psi (\textsf{X}^*_v(F))(p) \bigm \vert v\in V\bigr ) = 0\), giving thus \(\top \) as result.

If V is closed under componentwise numerical infimum, the latter coincides with the lattice-theoretical infimum operation in V, so

$$\begin{aligned}{} & {} \top - \mathcal {S}^*\bigl (\chi \psi (\textsf{X}^*_v(F))(p) \bigm \vert v\in V\bigr ) \\{} & {} \quad = \bigwedge \bigl \{ v\in V \bigm \vert p\in \psi (\textsf{X}^*_v(F)) \bigr \} , \end{aligned}$$

which gives \(\psi ^{V^*}(F)(p)\) by (43). \(\square \)

This result leads us to our definition of dual flat extension by summation. Given a binary image measurement \(\mu : \mathcal {P}(E) \rightarrow K^E\), we define the no-shift dual flat extension \(\mu ^{-V^*}\) of \(\mu \) by setting for any image \(F:E\rightarrow V\) and point \(p\in E\):

$$\begin{aligned} \mu ^{-V^*}(F)(p) = - \mathcal {S}^*\bigl (\mu (\textsf{X}^*_v(F))(p) \bigm \vert v\in V\bigr ) , \end{aligned}$$
(42)

provided that the summation is well-defined, that is, the summed function \(v\mapsto \mu (\textsf {X}^*_v(F))(p)\) is of bounded variation. Given a binary image transformation \(\psi : \mathcal {P}(E) \rightarrow \mathcal {P}(E)\), we define the shifted dual flat extension \(\psi ^{+V^*}\) of \(\psi \) by setting for any image \(F:E\rightarrow V\) and point \(p\in E\):

$$\begin{aligned}&\psi ^{+V^*}(F)(p) = \top + (\chi \psi )^{-V^*}(F)(p) \nonumber \\&\qquad = \top - \mathcal {S}^*\bigl (\chi \psi (\textsf{X}^*_v(F))(p) \bigm \vert v\in V\bigr ) , \end{aligned}$$
(43)

again provided that the summation is well-defined, that is, the function \(v\mapsto \chi \psi (\textsf {X}^*v(F))(p)\) is of bounded variation

Recall \(\nu _E: V^E\rightarrow V^E\), the extension of \(\nu \) to functions \(E \rightarrow V\), given by pointwise application of \(\nu \), that is, \(\nu _E(F)(p) = \nu (F(p))\). Then the dual flat extension is the dual by inversion \(\nu _E\) of the flat extension:

Proposition 20

Let V be symmetrical. Given a binary image measurement \(\mu \) and a binary image transformation \(\psi \), for any image \(F:E\rightarrow V\), we have \(\mu ^{-V^*}(F) = -\mu ^{-V}(\nu _E(F))\) and \(\psi ^{+V^*}(F) = \nu _E(\psi ^{+V}(\nu _E(F)))\).

Proof

Apply Theorem 17 to (44):

$$\begin{aligned}{} & {} \mu ^{-V^*}(F)(p) = - \mathcal {S}^*\bigl (\mu (\textsf{X}^*_v(F))(p) \bigm \vert v\in V\bigr ) \\{} & {} \quad = - \mathcal {S}\bigl (\mu (\textsf{X}^*_{\nu (v)}(F))(p) \bigm \vert v\in V\bigr ) . \end{aligned}$$

Now for \(q\in E\),

$$\begin{aligned}{} & {} q\in \textsf{X}^*_{\nu (v)}(F) \;\Leftrightarrow \;F(q) \le \nu (v) \;\Leftrightarrow \;\nu (F(q)) \ge v \\{} & {} \quad \;\Leftrightarrow \;\nu _E(F)(q) \ge v \;\Leftrightarrow \;q\in \textsf{X}_v(\nu _E(F)) . \end{aligned}$$

So \(\textsf{X}^*_{\nu (v)}(F) = \textsf{X}_v(\nu _E(F))\). Thus, with (22) we get:

$$\begin{aligned}{} & {} \mu ^{-V^*}(F)(p) = - \mathcal {S}\bigl (\mu (\textsf{X}_v(\nu _E(F)))(p) \bigm \vert v\in V\bigr ) \\{} & {} \quad = - \mu ^{-V}(\nu _E(F)) . \end{aligned}$$

Then (45), combined with the above and (23), gives:

$$\begin{aligned}{} & {} \psi ^{+V^*}(F)(p) = \top + (\chi \psi )^{-V^*}(F)(p) \\{} & {} \quad = \top - (\chi \psi )^{-V}(\nu _E(F)) \\{} & {} \quad = (\top +\bot ) - \bigl ( \bot + (\chi \psi )^{-V}(\nu _E(F)) \bigr ) \\{} & {} \quad = \nu _E(\psi ^{+V}(\nu _E(F))) . \end{aligned}$$

\(\square \)

We will now relate the dual flat extension of a binary image operator to the flat extension of the dual by complementation of that operator. Recall that V is completely distributive, in the sense given by (5,6). The following preliminary result is adapted from Proposition 36 of [2], and its proof is similar:

Lemma 21

For any decreasing function \(f:\mathcal {P}(E)\rightarrow \{0,1\}\) and image \(F:E\rightarrow V\),

$$\begin{aligned}{} & {} \sup \{ v \in V \mid f(\textsf{X}_v(F)^c) = 1 \} \\{} & {} \quad = \inf \{ v \in V \mid f(\textsf{X}^*_v(F)) = 0 \} . \end{aligned}$$

Here the empty supremum and infimum are \(\bot \) and \(\top \) respectively. Furthermore,

$$\begin{aligned} \mathcal {S}\bigl (f(\textsf{X}_v(F)^c) \bigm \vert v\in V\bigr ) = \mathcal {S}^*\bigl (f(\textsf{X}^*_v(F)) \bigm \vert v\in V\bigr ) . \end{aligned}$$

The latter equality also holds if f is increasing.

Proof

Let \(A = \{ v \in V \mid f(\textsf{X}_v(F)^c) = 1 \}\) and \(B = \{ v \in V \mid f(\textsf{X}^*_v(F)) = 0 \}\). If A is empty, then \(f(\emptyset ) = f(\textsf{X}_\bot (F)^c) = 0\), and as f is decreasing, f must be constant 0, so \(B=V\), and \(\sup A = \inf B = \bot \). If B is empty, then \(f(V) = f(\textsf{X}^*_\top (F)) = 1\), and as f is decreasing, f must be constant 1, so \(A=V\), and \(\sup A = \inf B = \top \). We can thus assume A and B to be non-empty.

For any \(v \in A\) and \(w \in B\), \(f(\textsf{X}_v(F)^c) = 1\) and \(f(\textsf{X}^*_w(F)) = 0\), that is, \(f(\textsf{X}_v(F)^c) \not \le f(\textsf{X}^*_w(F))\); as f is decreasing, this implies that \(\textsf{X}^*_w(F) \not \subseteq \textsf{X}_v(F)^c\), so there is some \(q\in \textsf{X}^*_w(F) \cap \textsf{X}_v(F)\); then \(F(q) \le w\) and \(F(q) \ge v\), hence \(v \le w\). It follows that \(\sup A \le \inf B\).

Write \(b = \inf B\). Let \(g \in V\) such that \(g \triangleleft b\), cf. (5), and let \(h = \sup \{ F(q) \mid q \in \textsf{X}_g(F)^c \}\); then for any \(q \in \textsf{X}_g(F)^c\), \(F(q) \le h\), so \(q\in \textsf{X}^*_h(F)\), hence \(\textsf{X}_g(F)^c \subseteq \textsf{X}^*_h(F)\); as f is decreasing, \(f(\textsf{X}_g(F)^c) \ge f(\textsf{X}^*_h(F))\). Suppose that \(g \notin A\): then \(f(\textsf{X}_g(F)^c) = 0\), hence \(f(\textsf{X}^*_h(F)) = 0\), so \(h \in B\), thus \(b \le h\), that is, \(b \le \sup \{ F(q) \mid q \in \textsf{X}_g(F)^c \}\); by (5), we deduce that there is some \(q \in \textsf{X}_g(F)^c\) such that \(g \le F(q)\), that is, \(q \in \textsf{X}_g(F)\), a contradiction. Therefore, for every \(g \in V\) such that \(g \triangleleft b\), we must have \(g \in A\). As V is completely distributive, by (6) we have \(b = \sup \{ g\in V \mid \bot < g \triangleleft x \} \le \sup A\), so \(\inf B \le \sup A\). From the double inequality, we deduce the equality \(\sup A = \inf B\).

Applying Proposition 4, (20) gives

$$\begin{aligned}{} & {} \sup \{ v \in V \mid f(\textsf{X}_v(F)^c) = 1 \} \\{} & {} \quad = \bot + \mathcal {S}\bigl (f(\textsf{X}_v(F)^c) \bigm \vert v\in V\bigr ) . \end{aligned}$$

Applying Proposition 18, (41) gives

$$\begin{aligned}{} & {} \inf \{ v \in V \mid f(\textsf{X}^*_v(F)) = 0 \} \\{} & {} \quad = \bot + \mathcal {S}^*\bigl (f(\textsf{X}^*_v(F)) \bigm \vert v\in V\bigr ) . \end{aligned}$$

We conclude that \(\mathcal {S}\bigl (f(\textsf{X}_v(F)^c) \bigm \vert v\in V\bigr ) = \mathcal {S}^*\bigl (f(\textsf{X}^*_v(F)) \bigm \vert v\in V\bigr )\).

Let now f be increasing. Then \(1-f: \mathcal {P}(E)\rightarrow \{0,1\}\) is decreasing, so we apply to it the above result, and the additivity of both \(\mathcal {S}\) and \(\mathcal {S}^*\) gives

$$\begin{aligned}{} & {} {[}\top -\bot ] - \mathcal {S}\bigl (f(\textsf{X}_v(F)^c) \bigm \vert v\in V\bigr ) \\{} & {} \quad = \mathcal {S}(1 \mid v\in V) - \mathcal {S}\bigl (f(\textsf{X}_v(F)^c) \bigm \vert v\in V\bigr ) \\{} & {} \quad = \mathcal {S}\bigl ([1-f](\textsf{X}_v(F)^c) \bigm \vert v\in V\bigr ) \\{} & {} \quad = \mathcal {S}^*\bigl ([1-f](\textsf{X}^*_v(F)) \bigm \vert v\in V\bigr ) \\{} & {} \quad = \mathcal {S}^*(1 \mid v\in V) - \mathcal {S}^*\bigl (f(\textsf{X}^*_v(F)) \bigm \vert v\in V\bigr ) \\{} & {} \quad = {[}\top -\bot ] - \mathcal {S}^*\bigl (f(\textsf{X}^*_v(F)) \bigm \vert v\in V\bigr ) , \end{aligned}$$

hence \(\mathcal {S}\bigl (f(\textsf{X}_v(F)^c) \bigm \vert v\in V\bigr ) = \mathcal {S}^*\bigl (f(\textsf{X}^*_v(F)) \bigm \vert v\in V\bigr )\) again. \(\square \)

Given a binary image measurement \(\mu \), define the binary image measurement \(\mu ^\ddag \) by \(\mu ^\ddag (Z) = \mu (Z^c)\). For any strictly increasing sequence \((Z_0,\ldots ,Z_n)\) in \(\mathcal {P}(E)\), \((Z_n^c,\ldots ,Z_0^c)\) is a strictly increasing sequence, and

$$\begin{aligned}{} & {} TV_{(Z_0,\ldots ,Z_n)} \bigl (\mu ^\ddag (Z)(p) \bigm \vert Z\in \mathcal {P}(E)\bigr ) \\{} & {} \quad = \sum _{i=1}^n \bigl \vert \mu ^\ddag (Z_i)(p) - \mu ^\ddag (Z_{i-1})(p) \bigr \vert \\{} & {} \quad = \sum _{i=1}^n \bigl \vert \mu (Z_i^c)(p) - \mu (Z_{i-1}^c)(p) \bigr \vert \\{} & {} \quad = \sum _{i=n}^1 \bigl \vert \mu (Z_{i-1}^c)(p) - \mu (Z_i^c)(p) \bigr \vert \\{} & {} \quad = TV_{(Z_n^c,\ldots ,Z_0^c)} \bigl (\mu (Z)(p) \mid Z\in \mathcal {P}(E)\bigr ) . \end{aligned}$$

Hence \(TV\bigl (\mu ^\ddag (Z)(p) \bigm \vert Z\in \mathcal {P}(E)\bigr ) = TV\bigl (\mu (Z)(p) \bigm \vert Z\in \mathcal {P}(E)\bigr )\), so: \(\mu \) has pointwise bounded variation iff \(\mu ^\ddag \) has pointwise bounded variation.

Proposition 22

Given a binary image measurement \(\mu \) having pointwise bounded variation, \(\mu ^{-V^*} = - (\mu ^\ddag )^{-V}\).

Proof

Let \(p\in E\). As \(\mu \) has pointwise bounded variation, for any \(p \in E\) we apply Proposition 2: there are \(m+n\) increasing functions \(f_1,\ldots ,f_{m+n}: \mathcal {P}(E) \rightarrow \{0,1\}\) (\(m,n\ge 0\)), such that for any \(Z\in \mathcal {P}(E)\), \(\mu (Z)(p) = \sum _{i=1}^m f_i(Z) - \sum _{j=m+1}^{m+n} f_j(Z)\). For any \(F: E \rightarrow V\), the above lemma gives for each \(i=1, \ldots , m+n\):

$$\begin{aligned} \mathcal {S}\bigl (f_i(\textsf{X}_v(F)^c) \bigm \vert v\in V\bigr ) = \mathcal {S}^*\bigl (f_i(\textsf{X}^*_v(F)) \bigm \vert v\in V\bigr ) . \end{aligned}$$

By linearity of \(\mathcal {S}\) and \(\mathcal {S}^*\), we get then

$$\begin{aligned}{} & {} \mathcal {S}\bigl (\mu (\textsf{X}_v(F)^c)(p) \bigm \vert v\in V \bigr ) \\{} & {} \quad = \mathcal {S}\Bigl ( \sum _{i=1}^m f_i(\textsf{X}_v(F)^c) - \sum _{j=m+1}^{m+n} f_j(\textsf{X}_v(F)^c) \Bigm \vert v\in V \Bigr ) \\{} & {} \quad = \sum _{i=1}^m \mathcal {S}\bigl ( f_i(\textsf{X}_v(F)^c) \bigm \vert v\in V \bigr ) \qquad \\{} & {} \qquad - \sum _{j=m+1}^{m+n}\mathcal {S}\bigl ( f_j(\textsf{X}_v(F)^c) \bigm \vert v\in V \bigr ) \\{} & {} \quad = \sum _{i=1}^m \mathcal {S}^*\bigl ( f_i(\textsf{X}^*_v(F)) \bigm \vert v\in V \bigr ) \qquad \\{} & {} \qquad - \sum _{j=m+1}^{m+n}\mathcal {S}^*\bigl ( f_j(\textsf{X}^*_v(F)) \bigm \vert v\in V \bigr ) \\{} & {} \quad = \mathcal {S}^*\Bigl ( \sum _{i=1}^m f_i(\textsf{X}^*_v(F)) - \sum _{j=m+1}^{m+n} f_j(\textsf{X}^*_v(F)) \Bigm \vert v\in V \Bigr ) \\{} & {} \quad = \mathcal {S}^*\bigl (\mu (\textsf{X}^*_v(F))(p) \bigm \vert v\in V \bigr ) . \end{aligned}$$

Now (22) gives \(\mathcal {S}\bigl (\mu (\textsf{X}_v(F)^c)(p) \bigm \vert v\in V \bigr ) = \mathcal {S}\bigl ((\mu ^\ddag )(\textsf{X}_v\) \((F))(p) \bigm \vert v\in V\bigr ) = (\mu ^\ddag )^{-V}(F)(p)\), while (44) gives \(\mathcal {S}^*\bigl (\mu (\textsf{X}^*_v(F))(p) \bigm \vert v\in V\bigr ) = - \mu ^{-V^*}(F)(p)\). Therefore \((\mu ^\ddag )^{-V}(F)(p) = - \mu ^{-V^*}(F)(p)\), so \(\mu ^{-V^*}(F) = - (\mu ^\ddag )^{-V}(F)\). \(\square \)

Given a binary image operator \(\psi \), define the dual binary image operator \(\psi ^*\) by \(\psi ^*(Z) = \psi (Z^c)^c\). We have

$$\begin{aligned} \chi \psi ^*(Z)&= \chi (\psi (Z^c)^c) = 1 - \chi (\psi (Z^c)) \nonumber \\&= 1 - [\chi \psi ]^\ddag (Z) . \end{aligned}$$
(44)

Thus, for \(p\in E\) and successive \(Z_{i-1},Z_i\in \mathcal {P}(E)\),

$$\begin{aligned}{} & {} \bigl \vert \chi \psi ^*(Z_i)(p) - \chi \psi ^*(Z_{i-1})(p) \bigr \vert \\{} & {} \quad = \bigl \vert \bigl [ 1 - [\chi \psi ]^\ddag (Z_i)(p) \bigr ] - \bigl [ 1 - [\chi \psi ]^\ddag (Z_{i-1})(p) \bigr ] \bigr \vert \\{} & {} \quad = \bigl \vert [\chi \psi ]^\ddag (Z_{i-1})(p) - [\chi \psi ]^\ddag (Z_i)(p) \bigr \vert \\{} & {} \quad = \bigl \vert [\chi \psi ]^\ddag (Z_i)(p) - [\chi \psi ]^\ddag (Z_{i-1})(p) \bigr \vert . \end{aligned}$$

It follows that \(TV\bigl (\chi \psi ^*(Z)(p) \bigm \vert Z\in \mathcal {P}(E)\bigr ) = TV\bigl ([\chi \psi ]^\ddag \) \((Z)(p) \bigm \vert Z\in \mathcal {P}(E)\bigr )\), which from the above discussion on \(\mu \) is equal to \(TV\bigl (\chi \psi (Z)(p) \bigm \vert Z\in \mathcal {P}(E)\bigr )\). Hence, \(\psi \) has pointwise bounded variation iff \(\psi ^*\) has pointwise bounded variation.

Corollary 23

Given a binary image operator \(\psi \) having pointwise bounded variation, \(\psi ^{+V^*} = (\psi ^*)^{+V}\).

Proof

Let \(F:E\rightarrow V\) and \(p\in E\). By (22,46) we have:

$$\begin{aligned}{} & {} (\chi \psi ^*)^{-V}(F)(p) = \mathcal {S}\bigl ( \chi \psi ^*(\textsf{X}_v(F))(p) \bigm \vert v\in V \bigr ) \\{} & {} \quad = \mathcal {S}\bigl ( 1 - [\chi \psi ]^\ddag (\textsf{X}_v(F))(p) \bigm \vert v\in V \bigr ) \\{} & {} \quad = \mathcal {S}(1) - \mathcal {S}\bigl ( [\chi \psi ]^\ddag (\textsf{X}_v(F))(p) \bigm \vert v\in V \bigr ) \\{} & {} \quad = (\top -\bot ) - ([\chi \psi ]^\ddag )^{-V}(F)(p) . \end{aligned}$$

Thus, \((\chi \psi ^*)^{-V}(F) = (\top -\bot ) - ([\chi \psi ]^\ddag )^{-V}(F)\). Applying successively (45), Proposition 22, the above equality, and (23), we obtain:

$$\begin{aligned}{} & {} \psi ^{+V^*}(F) = \top + [\chi \psi ]^{-V^*}(F) = \top - ([\chi \psi ]^\ddag )^{-V}(F) \\{} & {} \quad = \bot + (\top -\bot ) - ([\chi \psi ]^\ddag )^{-V}(F) \\{} & {} \quad = \bot + (\chi \psi ^*)^{-V}(F) = (\psi ^*)^{+V}(F) . \end{aligned}$$

\(\square \)

Assume that V is symmetrical. Combining Proposition 20 with Proposition 22 and Corollary 23, for any binary image measurement \(\mu \), any binary image transformation \(\psi \), and any image \(F:E\rightarrow V\), we obtain:

$$\begin{aligned}&\mu ^{-V}(\nu _E(F)) = -\mu ^{-V^*}(F) = (\mu ^\ddag )^{-V}(F) \quad \text{ and } \nonumber \\&\nu _E(\psi ^{+V}(\nu _E(F))) = \psi ^{+V^*}(F) = (\psi ^*)^{+V}(F) . \end{aligned}$$
(45)

Let us illustrate this in the case of the difference between a dilation and erosion. Let \(\delta \) be an extensive dilation on \(\mathcal {P}(E)\), and let \(\varepsilon = \delta ^*\) be its dual by complementation; thus, \(\varepsilon \) is an anti-extensive erosion. As \(\delta (X) {\setminus } \varepsilon (X) = \delta (X) \cap \varepsilon (X)^c = \delta (X) \cap \delta (X^c)\), we have \(\delta (X^c) {\setminus } \varepsilon (X^c) = \delta (X) {\setminus } \varepsilon (X)\). Consider the binary image measurement \(\mu = \chi (\delta {\setminus }\varepsilon ): X \mapsto \chi \bigl ( \delta (X){\setminus }\varepsilon (X) \bigr ) = \chi \delta (X) - \chi \varepsilon (X)\); then \(\mu ^\ddag = \mu \). Now, \(\mu ^{-V} = (\chi \delta )^{-V} - (\chi \varepsilon )^{-V} = \delta ^{+V} - \varepsilon ^{+V}\). Then (47) gives \(\mu ^{-V}(\nu _E(F)) = (\mu ^\ddag )^{-V}(F) = \mu ^{-V}(F)\). Indeed, applying (47) to \(\delta \) and \(\varepsilon \), \(\varepsilon ^{+V}\) is the dual by inversion \(\nu _E\) of \(\delta ^{+V}\), so we have:

$$\begin{aligned}{} & {} \mu ^{-V}(\nu _E(F)) = \delta ^{+V}(\nu _E(F)) - \varepsilon ^{+V}(\nu _E(F)) \\{} & {} \quad = \nu _E(\varepsilon ^{+V}(F)) - \nu _E(\delta ^{+V}(F)) \\{} & {} \quad = [\top +\bot - \varepsilon ^{+V}(F)] -[\top +\bot - \delta ^{+V}(F)] \\{} & {} \quad = \delta ^{+V}(F) - \varepsilon ^{+V}(F) = \mu ^{-V}(F) . \end{aligned}$$

Consider next the binary image transformation \(\psi =\delta {\setminus }\varepsilon \). We have thus \(\chi \psi = \mu \) and \(\psi ^{+V} = \bot + \mu ^{-V} = \bot + \delta ^{+V} - \varepsilon ^{+V}\). The previous equality gives \((\chi \psi )^{-V}(\nu _E(F)) = (\chi \psi )^{-V}(F)\), hence \(\psi ^{+V}(\nu _E(F)) = \psi ^{+V}(F)\). As seen above, we have \(\psi (X^c) = \psi (X)\), so \(\psi ^*(X) = \psi (X^c)^c = \psi (X)^c = \varepsilon (X) \cup \varepsilon (X^c)\). Then (47) gives \((\psi ^*)^{+V}(F) = \nu _E(\psi ^{+V}(\nu _E(F))) = \nu _E(\psi ^{+V}(F))\). Indeed, as \(\chi \psi ^*(X) = \chi [\psi (X)^c] = 1 - \chi \psi (X)\), we get

$$\begin{aligned}{} & {} (\psi ^*)^{+V}(F) = \bot + (\chi \psi ^*)^{-V}(F) \\{} & {} \quad = \bot + \mathcal {S}(1) - (\chi \psi )^{-V}(F) \\{} & {} \quad = \bot + (\top -\bot ) - [\delta ^{+V}(F) - \varepsilon ^{+V}(F)] \\{} & {} \quad = \bot + \top - [\bot + \delta ^{+V}(F) - \varepsilon ^{+V}(F)] \\{} & {} \quad = \bot + \top - \psi ^{+V}(F) = \nu _E(\psi ^{+V}(F)) . \end{aligned}$$

Concerning duality, we have thus obtained in our new approach the same results as in the classical theory [2]. First, the dual flat extension of an operator coincides with the dual by inversion of the flat extension of that operator, see Proposition 20. Next, the dual flat extension of an operator coincides also with the flat extension of the dual by complementation of that operator, see Proposition 22 and Corollary 23. All this is summarised in (47).

5 Flat Linear Operators and Hybrid Morphology

As we mentioned in Sect. 3, after (22), the no-shift flat extension is linear: \(\bigl (\lambda _1\mu _1 + \lambda _2\mu _2\bigr )^{-V} = \lambda _1\mu _1^{-V} + \lambda _2\mu _2^{-V}\). We stated that equality for scalars \(\lambda _1,\lambda _2 \in \mathbb {Z}\), but if we relax our framework by considering binary image measurements with non-integer output values, the equality will remain valid for \(\lambda _1,\lambda _2 \in \mathbb {R}\).

As we suggested in the conclusion of [1], it follows that some linear operators on grey-level or multivalued images will be flat. Assume \(\bot = 0\). A translation \(\tau \) of the space E, acting on \(\mathcal {P}(E)\), is an increasing binary image operator, and its flat extension \(\tau ^V\) is the same translation acting on \(V^E\) [2]; we have \(\tau ^V = \tau ^{+V} = (\chi \tau )^{-V}\). Then, for k translations \(\tau _1, \ldots , \tau _k\) and k scalars \(\lambda _1, \ldots , \lambda _k \in \mathbb {R}\), we get

$$\begin{aligned}{} & {} \bigl ( \lambda _1 \chi \tau _1 + \cdots + \lambda _k \chi \tau _k \bigr )^{-V} \\{} & {} \quad = \lambda _1 (\chi \tau _1)^{-V} + \cdots + \lambda _k (\chi \tau _k)^{-V} \\{} & {} \quad = \lambda _1 \tau _1^V + \cdots + \lambda _k\tau _k^V . \end{aligned}$$

Here \(\lambda _1 \chi \tau _1 + \cdots + \lambda _k \chi \tau _k\) is a discrete convolution operator acting on binary images, associated to the mask with values \(\lambda _1, \ldots , \lambda _k\), positioned at \(\tau _1(o), \ldots , \tau _k(o)\), where o is the origin in E; then \(\lambda _1 \tau _1^V + \cdots + \lambda _k\tau _k^V\) is the same convolution operator for grey-level or multivalued images, and it is obtained as the flat extension of the one on binary images.

We will present here the first elements of a general theory of flat linear operators. But we need beforehand to introduce some constraints on the lattice V of image values. Given a flat linear operator \(\mu ^{-V}\) applied to two functions \(F,G:E\rightarrow V\), the linearity gives the equality \(\mu ^{-V}(F+G) = \mu ^{-V}(F)+\mu ^{-V}(G)\), where \(\mu ^{-V}\) is applied to the function \(F+G\), which is not necessarily \(E\rightarrow V\); we are thus in the same situation as in Sect. 3.3, where the interval of values is bounded, but may vary. In view of (30), as we will always have \(\mu (\emptyset ) =0\), we can restrict ourselves to functions with non-negative values, in other words, the lattice V has its lower bound \(\bot =0\). Then for \(\bot _1 = \bot _0 =0 < \top _0 \le \top _1\), \(V_0 =[0,\top _0]\), and \(V_1 =[0,\top _1]\), for any \(F: E\rightarrow V_0\), (30) with the condition \(\mu (\emptyset ) =0\) will give \(\mu ^{-V_1}(F) = \mu ^{-V_0}(F)\). In other words, \(\mu ^{-[0,\top ]}(F)\) does not vary when the upper bound \(\top \) increases.

From now on, we assume that the lower bound \(\bot \) will always be 0, but the upper bound \(\top \) can vary. We consider thus bounded positive functions, that is, any function F for which there exists \(\top >0\) with \(0\le F(p) \le \top \) for all \(p\in E\). The set of such functions is closed under addition and multiplication by a positive scalar. Here linearity means that \(\mu ^{-V}(F+G) = \mu ^{-V}(F)+\mu ^{-V}(G)\) and \(\mu ^{-V}(aF) = a \mu ^{-V}(F)\) for \(a>0\), where \(V=[0,\top ]\) with \(\top \) large enough to guarantee that \(F,G,F+G,aF\) are all \(E\rightarrow V\). The case of functions that are not positive and of negative scalars will be dealt with later.

Given a bounded positive function F and a positive scalar \(a>0\), taking \(\top >0\) large enough to have both F and aF with values in the interval \(V= [0,\top ]\), assuming \(\mu (\emptyset ) =0\), then (32) will give \(\mu ^{-V}(aF) = a \mu ^{-V}(F)\). There remains to guarantee that \(\mu ^{-V}(F+G) = \mu ^{-V}(F)+\mu ^{-V}(G)\) for \(F,G,F+G: E\rightarrow V\).

For a binary image measurement \(\mu \) let us say that \(\mu \) is additive if for any \(X,Y\in \mathcal {P}(E)\), \(X\cap Y =\emptyset \) implies that \(\mu (X\cup Y) = \mu (X) + \mu (Y)\). We can give an equivalent formulation of that property:

Lemma 24

A binary image measurement \(\mu \) is additive if and only if \(\mu (\emptyset ) =0\) and for any \(X,Y\in \mathcal {P}(E)\), \(\mu (X\cup Y) + \mu (X\cap Y) = \mu (X) + \mu (Y)\).

Proof

Let \(\mu \) be additive. As \(X\cap \emptyset =\emptyset \), we obtain \(\mu (X) = \mu (X\cup \emptyset ) = \mu (X) + \mu (\emptyset )\), hence \(\mu (\emptyset ) =0\). For any \(X,Y\in \mathcal {P}(E)\), we have \(X\cap [Y{\setminus } X] =\emptyset \) and \(X\cup Y = X\cup [Y{\setminus } X]\), so \(\mu (X\cup Y) = \mu (X\cup [Y{\setminus } X]) = \mu (X) + \mu (Y{\setminus } X)\); now \([X\cap Y] \cap [Y{\setminus } X] =\emptyset \) and \([X\cap Y] \cup [Y{\setminus } X] = Y\), so \(\mu (Y) = \mu ([X\cap Y] \cup [Y{\setminus } X]) = \mu (X\cap Y) + \mu (Y{\setminus } X)\). Subtracting the equalities \(\mu (X\cup Y) = \mu (X) + \mu (Y{\setminus } X)\) and \(\mu (Y) = \mu (X\cap Y) + \mu (Y{\setminus } X)\), we get \(\mu (X\cup Y) - \mu (Y) = \mu (X) - \mu (X\cap Y)\), that is, \(\mu (X\cup Y) + \mu (X\cap Y) = \mu (X) + \mu (Y)\).

Conversely, if \(\mu (\emptyset ) =0\) and for any \(X,Y\in \mathcal {P}(E)\), \(\mu (X\cup Y) + \mu (X\cap Y) = \mu (X) + \mu (Y)\), then for \(X\cap Y =\emptyset \) we get \(\mu (X\cup Y) = \mu (X\cup Y) + 0 = \mu (X\cup Y) + \mu (X\cap Y) = \mu (X) + \mu (Y)\); hence, \(\mu \) is additive; \(\square \)

Note that the condition \(\mu (\emptyset ) =0\) cannot be omitted, it is not a consequence of the identity \(\mu (X\cup Y) + \mu (X\cap Y) = \mu (X) + \mu (Y)\). For instance, if \(\mu \) is the constant 1 function, then \(\mu (X\cup Y) + \mu (X\cap Y) = \mu (X) + \mu (Y) = 2\), but \(\mu \) is not additive, since \(\mu (\emptyset ) \ne 0\).

Given an additive binary image measurement \(\mu \), one can easily show by induction on \(n\in \mathbb {N}\) that for n mutually disjoint subsets \(X_1,\ldots ,X_n\) of E, \(\mu \bigl (X_1\cup \cdots \cup X_n\bigr ) = \mu (X_1) + \cdots + \mu (X_n)\).

Recall from the Introduction the cylinder of base B and level v for \(B\subseteq E\) and \(v\in V\): the function \(C_{B,v}\) given by \(C_{B,v}(p) = v\) if \(p\in B\), and \(C_{B,v}(p) = \bot =0\) if \(p\notin B\).

Lemma 25

Let the binary image measurement \(\mu \) satisfy \(\mu (\emptyset ) =0\). For any \(B\subseteq E\) and \(v\in V\), \(\mu ^{-V}(C_{B,v}) = v \mu (B)\).

Proof

\(C_{B,v}\) has its values in the finite chain \(W= \{0,v,\top \}\), which is a complete sublattice of V. By Proposition 31 of [1], \(\mu ^{-V}(C_{B,v}) = \mu ^{-W}(C_{B,v})\). The summation of a function \(f:W\rightarrow \mathbb {R}\) takes the form \(\mathcal {S}(f)= f(v)(v-0) + f(\top )(\top -v)\). Thus, for any \(p\in E\), (22) gives

$$\begin{aligned}{} & {} \mu ^{-W}(C_{B,v})(p) \\{} & {} \quad = \mu (\textsf{X}_v(C_{B,v}))(p)(v-0) + \mu (\textsf{X}_\top (C_{B,v}))(p)(\top -v) . \end{aligned}$$

We have \(\textsf{X}_v(C_{B,v}) =B\) and when \(v<\top \) we have \(\textsf{X}_\top (C_{B,v}) =\emptyset \). Thus, \(\mu (\textsf{X}_v(C_{B,v})) = \mu (B)\) and either \(\top -v =0\) or \(\mu (\textsf{X}_\top (C_{B,v})) = \mu (\emptyset ) =0\). The above equality gives then \(\mu ^{-W}(C_{B,v})(p) = v\mu (B)(p)\). Hence \(\mu ^{-V}(C_{B,v}) = \mu ^{-W}(C_{B,v}) = v\mu (B)\). \(\square \)

Now, we say that \(\mu ^{-V}\) is additive if \(\mu ^{-V}(F+G) = \mu ^{-V}(F)+\mu ^{-V}(G)\) for any \(F,G,F+G: E\rightarrow V\). We obtain then the following:

Corollary 26

Given a binary image measurement \(\mu \), if \(\mu ^{-V}\) is additive, then \(\mu \) is additive.

Proof

By additivity, \(\mu ^{-V}(0) =0\), while Corollary 32 of [1] give \(\mu ^{-V}(0) = (\top -0) \mu (\emptyset )\). Hence \(\mu (\emptyset ) =0\). Let \(X,Y\in \mathcal {P}(E)\) such that \(X\cap Y =\emptyset \). For \(v\in V {\setminus }\{0\}\), \(C_{X\cup Y,v} = C_{X,v} + C_{Y,v}\). Lemma 25 gives then

$$\begin{aligned}{} & {} v \mu (X) + v \mu (Y) = \mu ^{-V}(C_{X,v}) + \mu ^{-V}(C_{Y,v}) \\{} & {} \quad = \mu ^{-V}(C_{X,v} + C_{Y,v}) = \mu ^{-V}(C_{X\cup Y,v}) = v \mu (X\cup Y) , \end{aligned}$$

so \(\mu (X\cup Y) = \mu (X) + \mu (Y)\). \(\square \)

The following question arises: given an additive binary image measurement, is \(\mu ^{-V}\) additive? We do not have a general answer. First, we know that \(\mu ^{-V}\) will be well-defined, because \(\mu \) has pointwise bounded variation, hence stack-pointwise bounded variation (see Proposition 8):

Lemma 27

Let \(\mu : \mathcal {P}(E) \rightarrow K^E\) be an additive binary image measurement, for a bounded \(K\subset \mathbb {R}\). Then for any \(p\in E\),

$$\begin{aligned}&PV\bigl (\mu (Z)(p) \bigm \vert Z\in \mathcal {P}(E)\bigr ) \le \sup K \quad \text{ and } \nonumber \\&NV\bigl (\mu (Z)(p) \bigm \vert Z\in \mathcal {P}(E)\bigr ) \le -\inf K . \end{aligned}$$
(46)

Thus, \(\mu \) has pointwise bounded variation.

Proof

Let \((Z_0,\ldots ,Z_n)\) be a strictly increasing sequence in \(\mathcal {P}(E)\), and let \(p\in E\). By the additivity of \(\mu \), for each \(i=1,\ldots ,n\), \(\mu (Z_i)(p) - \mu (Z_{i-1})(p) = \mu (Z_i{\setminus } Z_{i-1})(p)\). The sets \(Z_i{\setminus } Z_{i-1}\) for \(i=1,\ldots ,n\) are mutually disjoint. Let P be the set of all \(i=1,\ldots ,n\) such that \(\mu (Z_i)(p) - \mu (Z_{i-1})(p) >0\). We have

$$\begin{aligned}{} & {} PV_{(Z_0,\ldots ,Z_n)} \bigl (\mu (Z)(p) \bigm \vert Z\in \mathcal {P}(E)\bigr ) \\{} & {} \quad =\sum _{i\in P} \bigl ( \mu (Z_i)(p) - \mu (Z_{i-1})(p) \bigr ) = \sum _{i\in P} \mu (Z_i{\setminus } Z_{i-1})(p) \\{} & {} \quad = \mu \Bigl ( \bigcup _{i\in P}(Z_i{\setminus } Z_{i-1}) \Bigr )(p) \le \sup K . \end{aligned}$$

The equality at the beginning of the second line follows from the additivity of \(\mu \), since the \(Z_i{\setminus } Z_{i-1}\) are mutually disjoint. Let N be the set of all \(i=1,\ldots ,n\) such that \(\mu (Z_i)(p) - \mu (Z_{i-1})(p) <0\). We have similarly

$$\begin{aligned}{} & {} -NV_{(Z_0,\ldots ,Z_n)} \bigl (\mu (Z)(p) \mid Z\in \mathcal {P}(E)\bigr ) \\{} & {} \quad = \sum _{i\in N} \bigl ( \mu (Z_i)(p) - \mu (Z_{i-1})(p) \bigr ) = \sum _{i\in N} \mu (Z_i{\setminus } Z_{i-1})(p) \\{} & {} \quad = \mu \Bigl ( \bigcup _{i\in N}(Z_i{\setminus } Z_{i-1}) \Bigr )(p) \ge \inf K , \end{aligned}$$

that is, \(NV_{(Z_0,\ldots ,Z_n)} \bigl (\mu (Z)(p) \bigm \vert Z\in \mathcal {P}(E)\bigr ) \le -\inf K\). Taking the supremum of positive and negative variations for all strictly increasing sequences \((Z_0,\ldots ,Z_n)\), having the same bounds \(\sup K\) and \(-\inf K\), (48) follows. \(\square \)

Next, our question receives a positive answer when \(\mu \) is local.

Theorem 28

Let \(\mu \) be an additive binary image measurement, and let \(\mu \) be local with the finite \(W(p) \in \mathcal {P}(E)\) associated to each \(p\in E\). For any \(p\in E\) and \(q \in W(p)\), let \(M_{q,p} = \mu (\{q\})(p)\). Then for any \(F: E\rightarrow V\) and \(p\in E\),

$$\begin{aligned} \mu ^{-V}(F)(p) = \sum _{q\in W(p)} F(q) M_{q,p} . \end{aligned}$$
(47)

In particular, \(\mu ^{-V}\) is additive.

Proof

Let \(F: E\rightarrow V\) and let \(v\in V\) such that \(v>0\). For any \(q\in E\), define \(F_{/q}: E\rightarrow V\) by \(F_{/q}(q) = F(q)\) and \(F_{/q}(p) = 0\) for \(p\ne q\); in other words, \(F_{/q} = C_{\{q\},F(q)}\). If \(F(q) \ge v\), then \(q\in \textsf{X}_v(F)\) and \(\textsf{X}_v(F_{/q}) = \{q\}\), while if \(F(q) \not \ge v\), then \(q\notin \textsf{X}_v(F)\) and \(\textsf{X}_v(F_{/q}) = \emptyset \); thus, \(\textsf{X}_v(F_{/q}) = \textsf{X}_v(F) \cap \{q\}\). Now take \(p\in E\). We have

$$\begin{aligned}{} & {} \textsf{X}_v(F) \cap W(p) = \textsf{X}_v(F) \cap \Bigl ( \bigcup _{q\in W(p)} \{q\} \Bigr ) \\{} & {} \quad = \bigcup _{q\in W(p)} (\textsf{X}_v(F) \cap \{q\}) = \bigcup _{q\in W(p)} \textsf{X}_v(F_{/q}) . \end{aligned}$$

Since \(\mu \) is local with W(p) associated to p, the \(\textsf{X}_v(F_{/q})\) for \(q\in W(p)\) are mutually disjoint, and \(\mu \) is additive, we have

$$\begin{aligned}{} & {} \mu (\textsf{X}_v(F))(p) = \mu (\textsf{X}_v(F) \cap W(p))(p) \\{} & {} \quad = \mu \Bigl ( \bigcup _{q\in W(p)} \textsf{X}_v(F_{/q}) \Bigr )(p) = \sum _{q\in W(p)} \mu (\textsf{X}_v(F_{/q}))(p) . \end{aligned}$$

This equality holds for any \(v>0\); so, by Lemma 6, the summation of the two functions for \(v\in V\) are equal, hence (22) and the additivity of summation give:

$$\begin{aligned}{} & {} \mu ^{-V}(F)(p) = \mathcal {S}\bigl (\mu (\textsf{X}_v(F))(p) \bigm \vert v\in V\bigr ) \\{} & {} \quad = \mathcal {S}\Bigl (\sum _{q\in W(p)} \mu (\textsf{X}_v(F_{/q}))(p) \Bigm \vert v\in V\Bigr ) \\{} & {} \quad = \sum _{q\in W(p)} \mathcal {S}\bigl (\mu (\textsf{X}_v(F_{/q}))(p) \bigm \vert v\in V\bigr ) \\{} & {} \quad = \sum _{q\in W(p)} \mu ^{-V}(F_{/q})(p) . \end{aligned}$$

By Lemma 25, \(\mu ^{{-}V}(F_{/q}) {=} \mu ^{{-}V}(C_{\{q\},F(q)}) {=} F(q) \mu (\{q\})\), so \(\mu ^{{-}V}(F_{/q})(p) {=} F(q) \mu (\{q\})(p) {=} F(q) M_{q,p}\). Hence (49) follows. As this formula is that of a convolution, \(\mu ^{-V}\) is additive. \(\square \)

We did not find any general result on the additivity of \(\mu ^{-V}\) when \(\mu \) is not local. However, we get some preliminary results in the case where \(\mu \) has binary values, that is, \(\mu \) is \(\mathcal {P}(E) \rightarrow \{0,1\}^E\).

We have considered flat linear operators on bounded positive functions, that is, functions \(F: V^E\rightarrow U^E\) such that for some \(\top \in U\) with \(\top >0\), F is \(V^E\rightarrow [0,\top ]^E\). We will now extend our framework to bounded functions, that is, functions \(F: V^E\rightarrow U^E\) such that for some \(\top \in U\) with \(\top >0\), F is \(V^E\rightarrow [-\top ,\top ]^E\), in other words, \(-\top \le F(p) \le \top \) for all \(p\in E\). We will use the same method as in Theorem 3, where we extended the additive summation \(\mathcal {S}\) from bounded, non-negative and decreasing functions to functions of bounded variation.

Every bounded function F is the difference of two bounded positive functions, for instance its positive and negative parts \(F^+\) and \(F^-\). We define the flat extension \(\mu ^{*V}\) of \(\mu \) as follows: given a decomposition \(F=G-H\), where GH are bounded positive functions, we set \(\mu ^{*V}(F) = \mu ^{-V}(G) - \mu ^{-V}(H)\), and when \(\mu ^{-V}\) is additive, this definition does not depend on the decomposition. The following result has its proof similar to that of Theorem 3, given in Theorem 12 of [6].

Theorem 29

Let \(\mathcal {A} = \bigcup _{\top >0} [0,\top ]^E\) be the set of bounded positive functions, and let \(\mathcal {B}= \bigcup _{\top >0} [-\top ,\top ]^E\) be the set of bounded functions. Let \(\Psi : \mathcal {A}\rightarrow U^E\) be additive: for \(F,G\in A\), \(\Psi (F+G) = \Psi (F) + \Psi (G)\). Define \({\widehat{\Psi }}: \mathcal {B}\rightarrow U^E\) as follows: given a decomposition of \(F\in \mathcal {B}\) as \(F=G-H\) for \(G,H\in \mathcal {A}\), we set \({\widehat{\Psi }}(F) = \Psi (G) - \Psi (H)\). Then

  1. 1.

    \({\widehat{\Psi }}(F)\) does not depend on the choice of the decomposition: for \(F = G_1-H_1 = G_2-H_2\), where \(G_1,G_2,H_1,H_2\in \mathcal {A}\), we have \(\Psi (G_1) - \Psi (H_1) = \Psi (G_2) - \Psi (H_2)\).

  2. 2.

    \({\widehat{\Psi }}\) extends \(\Psi \): for \(F\in \mathcal {A}\), we have \({\widehat{\Psi }}(F) = \Psi (F)\).

  3. 3.

    \({\widehat{\Psi }}\) is additive: for \(F_1,F_2 \in \mathcal {B}\), \({\widehat{\Psi }}(F_1+F_2) = {\widehat{\Psi }}(F_1) + {\widehat{\Psi }}(F_2)\).

  4. 4.

    If \(\Psi (aG) = a\Psi (G)\) for all \(G\in \mathcal {A}\) and \(a>0\), then \({\widehat{\Psi }}(aF) = a{\widehat{\Psi }}(F)\) for all \(F\in \mathcal {B}\) and \(a\in \mathbb {R}\).

Proof

  1. 1.

    Let \(F = G_1-H_1 = G_2-H_2\); then \(G_1+H_2 = G_2+H_1\), and the additivity of \(\Psi \) gives \(\Psi (G_1)+\Psi (H_2) = \Psi (G_1+H_2) = \Psi (G_2+H_1) = \Psi (G_2)+\Psi (H_1)\), hence \(\Psi (G_1) - \Psi (H_1) = \Psi (G_2) - \Psi (H_2)\).

  2. 2.

    For \(F\in \mathcal {A}\), we have \(F = F - 0\), where 0 is the zero function in \(\mathcal {A}\). By additivity, \(\Psi (0)=0\), so \({\widehat{\Psi }}(F) = \Psi (F) - \Psi (0) = \Psi (F)\).

  3. 3.

    Let \(F_1,F_2 \in \mathcal {B}\), with the decompositions \(F_1 = G_1-H_1\) and \(F_2 = G_2-H_2\) for \(G_1,G_2,H_1,H_2\in \mathcal {A}\). We have \(F_1+F_2 = G_1-H_1+G_2-H_2 = (G_1+G_2)-(H_1+H_2)\), so the definition of \({\widehat{\Psi }}\) and the additivity of \(\Psi \) give

    $$\begin{aligned}{} & {} {\widehat{\Psi }}(F_1+F_2) = \Psi (G_1+G_2) - \Psi (H_1+H_2) \\{} & {} \quad = \Psi (G_1) + \Psi (G_2) - \Psi (H_1) - \Psi (H_2) \\{} & {} \quad = \bigl (\Psi (G_1) - \Psi (H_1)\bigr ) + \bigl (\Psi (G_2) - \Psi (H_2)\bigr ) \\{} & {} \quad = {\widehat{\Psi }}(F_1) + {\widehat{\Psi }}(F_2) . \end{aligned}$$
  4. 4.

    Let \(F\in \mathcal {B}\) with \(F=G-H\) for \(G,H\in \mathcal {A}\). For \(a=0\), \({\widehat{\Psi }}(aF) = {\widehat{\Psi }}(0) = \Psi (0) = 0 = 0 {\widehat{\Psi }}(F)\). For \(a>0\), \(aF = aG-aH\), so

    $$\begin{aligned}{} & {} {\widehat{\Psi }}(aF) = \Psi (aG) - \Psi (aH) = a\Psi (G) - a\Psi (H) \\{} & {} \quad = a \bigl (\Psi (G) -\Psi (H)\bigr ) = a{\widehat{\Psi }}(F) . \end{aligned}$$

    For \(a<0\), \(aF = aG-aH = \vert a\vert H-\vert a\vert G\), so

    $$\begin{aligned}{} & {} {\widehat{\Psi }}(aF) = \Psi (\vert a\vert H) - \Psi (\vert a\vert G) = \vert a\vert \Psi (H) - \vert a\vert \Psi (G) \\{} & {} \quad = -\vert a\vert \bigl (\Psi (G)-\Psi (H)\bigr ) = -\vert a\vert {\widehat{\Psi }}(F) = a{\widehat{\Psi }}(F) . \end{aligned}$$

\(\square \)

Here \(\mu ^{*V} = {\widehat{\Psi }}\) for \(\Psi = \mu ^{-V}\). Assuming that \(\mu ^{-V}\) is additive, \(\mu ^{*V}\) will be well-defined and additive. Now we saw above that for \(a>0\) and \(G\in \mathcal {A}\), \(\mu ^{-V}(aG) = a \mu ^{-V}(G)\). Hence \(\mu ^{*V}\) will be linear on \(\mathcal {B}\).

In image processing, one has considered hybrid filters, which combine linear and morphological operators, see for instance [12,13,14]. A simple example is a smoothing filter applying locally a weighted average of medians. As morphological operators are not additive, we cannot use the construction \(\mu ^{*V}\) when \(\mu \) is not linear, so our theory of flat extension can be applied only in the case of bounded positive functions.

By Proposition 14, given an increasing binary image transformation \(\psi \) and a local additive binary image measurement \(\mu \), we will have \((\mu \psi )^{-V} = \mu ^{-V}\psi ^{+V}\), where \(\psi ^{+V} = \psi ^V\) is the classical flat extension of \(\psi \), and \(\mu ^{-V}\) is the linear operator corresponding to \(\mu \), as in equation (49) of Theorem 28. See Example 30.

Fig. 8
figure 8

In \(\mathbb {Z}^2\), the 8 neighbours of a point p are labelled \(p_n, p_{nw}, p_w, p_{sw}, p_s, p_{se}, p_e, p_{ne}\) according to their geographical position. We show the three windows W(p), \(W_0(p)\) and \(W_1(p)\) associated to a point p

Example 30

Let \(E=\mathbb {Z}^2\). We consider bounded positive functions \(E\rightarrow \mathbb {R}^+\). We refer to Fig. 8 for the three windows W(p), \(W_0(p)\) and \(W_1(p)\) associated to a point p. Let \(\psi \) be the binary image transformation defined, for \(X\in \mathcal {P}(E)\), by \(p\in \psi (X) \;\Leftrightarrow \;\vert X\cap W_0(p)\vert \ge 2\). Then \(\psi ^{+V} = \psi ^V\) is the rank filter given by setting, for a bounded positive function F, \(\psi ^{+V}(F)(p)\) equal to the second greatest value among the F(q), \(q \in W_0(p)\). Let \(\mu \) be the binary image measurement defined, for \(X\in \mathcal {P}(E)\), by \(\mu (X)(p) = \frac{1}{4} \sum _{q\in W_1(p)} \chi X(q)\). Then \(\mu ^{-V}\) is the averaging filter with window \(W_1\), that is, for a bounded positive function F we have \(\mu ^{-V}(F)(p) = \frac{1}{4} \sum _{q\in W_1(p)} F(q)\). Now, \((\mu \psi )^{-V} = \mu ^{-V}\psi ^{+V}\); this operator associates to a point p the average of the second greatest image values in the four \(2\times 2\) quadrants in W(p).

6 Conclusion

This second paper concludes our presentation of a new approach to flat morphological operators, where lattice-theoretical threshold superposition is replaced by numerical threshold summation. The advantage of this new framework is that the flat extension is not restricted to increasing binary image transformations, that is, increasing operators on binary images giving binary images as output; indeed, it applies to non-increasing binary image transformations, and also to what we call binary image measurements, that is, operators on binary images with output images that are not necessarily binary, for instance the morphological Laplacian (21), or a linear convolution by a mask of coefficients. A minor drawback of this new approach is that the flat extension applies only to grey-level or multivalued images with numerical or componentwise (marginal) ordering of image values, while the classical approach [2] applied to images with values in an arbitrary complete lattices, for instance label images.

Our first paper [1] was mainly devoted to the mathematical basis of our approach, namely bounded variation and the summation operation \(\mathcal {S}\), extending preliminary results of [6]. Then it gave the definition of flat extension by threshold summation, in its two forms of the no-shift flat extension \(\mu ^{-V}\) of a binary image measurement \(\mu \) and the shifted flat extension \(\psi ^{+V}\) of a binary image transformation \(\psi \). Finally, it studied the elementary properties of this flat extension, and also showed how connected binary image transformations extend to connected flat operators. These last results were rather straightforward; they generalised the same results given in [2] for the classical flat extension of increasing binary image transformations.

The new approach is compatible with the old one, in the sense that for increasing binary image transformations, our shifted flat extension coincides with the classical flat extension: \(\psi ^{+V} = \psi ^V\).

In this second paper, we have considered further properties of the flat extension, which were given in [2] within the classical framework for increasing binary image transformations. They are more complex, indeed, they generally rely on the complete distributivity of the lattice V of image values. We now see that most of these properties are valid only for increasing binary image transformations, they generally fail for non-increasing binary image transformations and for binary image measurements with non-binary output values (i.e., which do not correspond to binary image transformations). However, we could obtain some weaker properties that remain valid in our general framework.

In [2] we showed that when the lattice V of image values is completely distributive, the flat extension of a supremum or infimum of increasing binary image transformations is respectively the supremum or infimum of their flat extensions. This is no more true in the general case, see Sect. 3.1. However, since the no-shift flat extension is both linear and an isomorphism between the poset of binary image measurements and the poset of their no-shift flat extensions, it follows that flat operators constitute a lattice-ordered group, but here the join and meet operations take a different form than the usual ones for image operators, see Examples 10 and 11. Moreover, the lattice of shifted flat extensions of binary image transformations is complete.

Similarly, in [2] we showed that when the lattice V of image values is completely distributive, the flat extension of a composition of increasing binary image transformations is the composition of their flat extensions. This property fails in the general case, see Sect. 3.2, in particular Example 12. However, it remains valid in the case of the composition of an increasing binary image transformation followed by a binary image measurement having pointwise bounded variation, see Proposition 14.

It is known that under some continuity conditions, the flat extension of an increasing binary image transformation commutes with anamorphoses (increasing contrast mappings) and with thresholding [9,10,11]. As we saw in Sect. 3.3, in general, the shifted flat extension of a non-increasing binary image transformation commutes only with linear contrast mappings.

Section 4 studied duality, following the same plan as in [2]. First we considered the dual flat extension; in [2] it was defined through superposition in the dual lattice of dual threshold sets, here it is defined through the dual summation of dual threshold sets, see Sect. 4.1. Then in Sect. 4.2 we showed that the dual flat extension of a binary image transformation corresponds to both the dual by inversion of the flat extension of that transformation, and to the flat extension of the dual by complementation of that transformation. We obtained something very similar for binary image measurements.

Section 5 considered flat linear operators. Here we had to restrict our framework to bounded positive functions, that is, images with bounded positive values. When the no-shift flat extension \(\mu ^{-V}\) of a binary image measurement \(\mu \) is linear, \(\mu \) must be additive. We could not obtain the reciprocal result, that the no-shift flat extension of any additive binary image measurement is linear; it seems that a general analysis of additive binary image measurements is extremely difficult. However, we proved that the no-shift flat extension of a local additive binary image measurement is linear, it takes the form of a convolution by a mask of values, see equation (49) in Theorem 28.

We can extend flat linear operators to bounded functions, that is, images with bounded values that are not necessarily positive, by decomposing them as the difference between two bounded positive functions.

In the case of bounded positive functions, one can consider hybrid operators obtained as the composition of a flat morphological operator followed by a linear convolution. They can then be considered as flat operators, thanks to Proposition 14.

In our work, we considered binary image measurements having integer output values. This allowed us, in the case of a binary image measurement \(\mu \) having pointwise bounded variation, to use Proposition 2 to decompose \(\mu (Z)(p)\) into a linear combination of binary-valued functions, see Propositions 14 and 22. Now, in Sect. 5 we suggested that our framework can be extended to binary image measurements with non-integer output values. Here \(\mu \) will be \(\mathcal {P}(E) \rightarrow K^E\) for a finite \(K \subset \mathbb {R}\). Then we need to generalise Proposition 2 to functions with non-integer values. This seems straightforward by using in its proof (see Proposition 17 of [1]) the following generalisation of Lemma 6 of [6]: for \(f: P \rightarrow \{v_0, \ldots , v_n\}\), where \(0\le v_0< \cdots < v_n\), we have \(f = v_0 + \sum _{i=1}^n (v_i-v_{i-1}) f_i\), where \(f_i(x) =1\) if \(f(x)\ge v_i\) and \(f(x) = 0\) if \(f(x) < v_i\).

Many more problems can be studied in the theory and applications of these generalised flat operators. We do not intend to investigate them further.