Flat morphological operators from non-increasing set operators, I: general theory

: Flat morphology is a general method for obtaining increasing operators on grey-level or multivalued imagesfromincreasingoperatorsonbinaryimages(orsets).Itreliesonthresholdstackingandsuperposition; equivalently, Boolean max and min operations are replaced by lattice-theoretical sup and inf operations. In this paper we consider the construction a flat operator on grey-level or colour images from an operator on binary images that is not increasing. Here grey-level and colour images are functions from a space to an interval in R m or Z m ( m ≥ 1). Two approaches are proposed. First, we can replace threshold superposition by threshold summation. Next, we can decompose the non-increasing operator on binary images into a linear combination of increasing operators, then apply this linear combination to their flat extensions. Both meth-ods require the operator to have bounded variation, and then both give the same result, which conforms to intuition. Our approach is very general, it can be applied to linear combinations of flat operators, or to linear convolution filters. Our work is based on a mathematical theory of summation of real-valued functions of one variable ranging in a poset. In a second paper, we will study some particular properties of non-increasing flat operators.


Introduction
Mathematical morphology [10,[20][21][22] is a branch of image processing, that relies on lattice-theoretical and geometrical operations. It is used for processing binary, grey-level and multivalued images, as well as many other imaging structures.
It was initially developed in the framework of binary images, and later generalised to grey-level and multivalued images. The mostly used morphological operators on grey-level (or multivalued) images are the socalled flat operators, for instance those using flat structuring elements. They are obtained from operators on binary images through the method of flat extension [16]. For instance a grey-level flat dilation (resp., erosion) applies at each point a local supremum (resp., infimum) of grey-levels. Another flat operator is the median filter. A fundamental limitation of this method is that 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, or the hit-or-miss transform, although many authors have given grey-level versions of these operators in an ad hoc manner.
The purpose of this paper is to generalise the flat extension to non-increasing operators. Subsection 1.1 recalls the classical theory of the flat extension of binary operators, then the simple example of the difference between a dilation and an erosion shows how this method fails for non-increasing operators. Subsection 1.2 introduces two equivalent approaches for obtaining the flat extension of a non-increasing operator: first, replace threshold superposition by threshold summation; second, decompose the non-increasing operator into a linear combination of increasing operators, and take this linear combination with their flat extensions.
The paper requires a substantial mathematical background, which was initiated in [18]. The two proposed approaches require the operator to be of bounded variation: this condition is studied in Section 2. Section 3 introduces a theory of summation on posets, which gives a kind of Riemann integral. Section 4 studies the decompositions of functions into linear combinations of increasing functions.
Then Section 5 applies this theory to the flat extension of operators on binary images, not only operators P(E) → P(E), but also P(E) → K E for a finite interval K ⊂ Z. Section 6 concludes and introduces some perspectives, some of which will be dealt with in a second paper.

Flat extension by threshold superposition
We use the standard lattice-theoretical terminology of [16]. See Subsection 1.3 for more details.
Consider a space of points E, which can be the Euclidean (E = R n ) or digital (E = Z n ) space, or a subset of such a space. Image intensities are numerical values, they range in a closed subset T of R = R ∪ {−∞, +∞}; for example in the digital case, one can take T to be an interval in Z = Z∪ {−∞, +∞}. Then one models binary images as subsets of E, grey-level images as numerical functions E → T, and multivalued images (e.g., colour, multispectral, or multimodal images) as functions E → T m for some integer m > 1. Write P(E) for the set of all subsets of E (i.e., binary images), T E and (T m ) E for the set of maps E → T and E → T m respectively.
An operator is a map transforming an image into an image. There are for instance operators on binary, grey-level images or multivalued images, that is, maps P(E) → P(E), T E → T E or (T m ) E → (T m ) E . There can also be operators between different families of images, for instance thresholding is an operator T E → P(E).
An operator ψ : P(E) → P(E) on binary images is said to be increasing (or isotone) if it preserves the inclusion order: for X, Y ∈ P(E), X ⊆ Y ⇒ ψ(X) ⊆ ψ(Y). There is a systematic method for constructing an operator on grey-level or multivalued images from an increasing operator on binary images: the flat extension. Let us briefly recall from [16] how this is done.
Let us write V for the set of image values; we assume that V = T (for grey-level images) or V = T m (for multivalued images), where T is a closed interval in Z or R. Then V is partially ordered, numerically for T, and componentwise for T m : (x 1 , . . . , xm) ≤ (y 1 , . . . , ym) ⇐⇒ x i ≤ y i for i = 1, . . . , m . ( Note that there are other possible orders on T m , but the componentwise order is mathematically easier, with it we could obtain results for multivalued images, see Theorem 10 and Proposition 30. Now, V constitutes a complete lattice [1] (every subset of V has a supremum and an infimum for the order). Write ⊥ and ⊤ for the least and greatest elements of V, and ⋁︀ for the supremum operation in V; when V = T, ⋁︀ is the numerical supremum, and when V = T m , it is the componentwise numerical supremum. Thus, V E will be a complete lattice, whose order, supremum and infimum are obtained by applying those of V pointwise: F ≤ G iff F(p) ≤ G(p) for all p ∈ E, and for F i ∈ V E , i ∈ I, ⋁︀ i∈I F i is the function E → V : p ↦ → ⋁︀ i∈I F i (p). For an image F : E → V and v ∈ V, the threshold set [10] is The set Xv(F) is decreasing in v: w > v ⇒ Xw(F) ⊆ Xv(F), in other words threshold sets form a stack [15,16]. We illustrate such a stack in Figure 1 for E = R and V = T = [a, b], a bounded interval in R: the sets {t} × X t (F) for t ∈ T pile up. For B ⊆ E and v ∈ V, the cylinder of base B and level v is the function C B,v given by Then every function F : E → V is the upper envelope of the sets {v} × Xv(F), in other words the supremum of cylinders Consider now an increasing operator ψ : P(E) → P(E) on binary images, so X ⊆ Y ⇒ ψ(X) ⊆ ψ(Y). Then for any F : E → V, the sets ψ (︀ Xv(F) )︀ decrease with v, thus they form a stack. We can take the upper envelope of the sets {v} × ψ (︀ Xv(F) )︀ , that is: For every point p ∈ E we have: Then ψ V : V E → V E : F ↦ → ψ V (F) is the flat operator corresponding to ψ, or the flat extension of ψ [15,16]. We illustrate this construction in Figure 2 for the example of Figure 1, where the operator ψ is first the dilation δ B , then the erosion ε B by a structuring element B ∈ P(E) [10,20]: for any X ∈ P(E), here Now if we take a non-increasing operator, this approach does not work correctly. The sets ψ (︀ Xv(F) )︀ do not anymore form a stack, since they do not decrease with v. Consider the example of Figure 1, and let the operator ψ be the set difference between the dilation δ and erosion ε of Figure 2. As shown in Figure 3, the stacking approach of (3,4) gives for F the same result as the flat extension of the dilation: [δ \ ε] T (F) = δ T (F). More generally, for a function G, we will have δ T (G) ≥ [δ \ ε] T (G) ≥ δ T (G) − ε T (G), see Figure 4.
However intuition tells us that since here the erosion is included in the dilation, the flat extension of their set-theoretical difference should be the arithmetical difference of their flat extensions: [δ \ ε] T (F) = δ T (F) − ε T (F). This accords with common practice, as indeed the Beucher gradient [20] of an image is defined as δ(X) \ ε(X) for a binary image X and δ T (F) − ε T (F) for a grey-level image F, where δ and ε are the dilation and erosion by a point neighbourhood.

Threshold summation and linear combination of increasing operators
The solution to our problem was hinted at in Section V.2 of [14]; in fact, it proposed two equivalent methods for obtaining the flat extension of a non-increasing binary operator. Although the point of view of that paper was strictly finitary (with only finite structuring elements or filter windows, and finitely many images intensities), and restricted to grey-level images (V = T), the approach can be extended to our general framework. This paper proposed two different ideas that will finally lead to the same result. Let us (temporarily) restrict ourselves to grey-level images (V = T). The first idea is that the sets ψ (︀ X t (F) )︀ (t ∈ T) should not be superposed by a supremum of cylinders, but numerically summed or integrated over t ∈ T, following the threshold decomposition method introduced by [5] for median filters, and extended in [24] to arbitrary flat operators. In order to avoid long or imbricated subscripts, for any X ∈ P(E), we will write χX, rather than the usual χ X , for the characteristic function of X: Then, given an operator ψ : P(E) → P(E), for any X ∈ P(E) we write χψ(X) for the characteristic function of ψ(X); in other words, we have the map χψ : P(E) → {0, 1} E , which is the composition of ψ : P(E) → P(E) followed by χ : P(E) → {0, 1} E . Given an increasing operator ψ : P(E) → P(E), we have for any F ∈ T E and p ∈ E: dilation \ erosion by ψ = Figure 4: The same operator ψ as in Figure 3, but with another function G. Here δ T (G) − ε T (G) would give the height of the union of all sets {t} × ψ (︀ X t (F) )︀ .
The two equations (7,8) should be extended to multivalued images (V = T m ) and unified into a single equation valid for both discrete and continuous numerical values. Indeed, our contributed article [18] at the Kiselmanfest of 2006 is devoted to such a generalisation: we introduced an analogue of the Riemann integral for functions defined on a poset (partially ordered set) included in R m or Z m (m ≥ 1), we called it function summation; it relies on the order and the compatibility of the operations of addition, subtraction and scalar multiplication (in R m or Z m ) with that order. Its application to thresholded grey-level images gives (7) for discrete grey-levels and (8) for continuous grey-levels; moreover, in the case of an increasing operator, for image values in an interval in R m or Z m , the result is equivalent to flat extension, in other words threshold summation (7,8) is equivalent to threshold stacking (4). Now this function summation was defined only for functions that are linear combinations of bounded, non-negative and decreasing (or increasing) functions, in other words functions with bounded variation; thus we analysed this property in [18]. We do not exclude the possibility of extending our function summation to functions defined on a poset, which do not have bounded variation; this could possibly be achieved by using measure theory and the methodology of the Lebesgue integral, but that is beyond the scope of our study.
The second idea of [14] is that a function with binary values should be expressed as a linear combination of increasing binary-valued functions. We proposed there to decompose a function f : {0, 1} n → {0, 1} into an alternating sum and difference of a decreasing sequence of increasing binary functions, that is, into f 1 − f 2 + f 3 − · · · + (−1) r−1 fr, where r is an integer > 0, each function f i : {0, 1} n → {0, 1} is increasing, and f 1 > · · · > fr. This was stated without justification, the details were announced to appear in a manuscript in preparation, which was never written ... until the result was proven in a more general form in [18], see Section 4, in particular Theorem 18. Now for ψ : P(E) → P(E), we would like to have a similar decomposition where the ψ i (i = 1, . . . , r) form a decreasing sequence of increasing operators P(E) → P(E); then we would deduce from it the same decomposition for the flat extension (assuming ⊥ = 0): However, in an infinite space E, such a decomposition is not guaranteed. Indeed, as ψ 1 , . . . , ψr are increasing, given an increasing sequence (Xn) n∈N in P(E), for any p ∈ E and i = 1, . . . , r, the sequence χψ i (Xn)(p) can change at most once, from 0 to 1, hence for the decomposition (10), the sequence χψ(Xn)(p) should change at most r times, alternating between 0 and 1. However, for an infinite space E, it is easy to find an operator ψ such that the sequence χψ(Xn)(p) will endlessly alternate between 0 and 1.
We will indeed see that the necessary and sufficient condition for a decomposition of the form (10) is that the functions P(E) → {0, 1} : X ↦ → χψ(X)(p) for p ∈ E are of uniform bounded variation, in other words the same bound holds for their total variation for all p ∈ E. This will imply in particular that for every F : E → V and p ∈ E, the function v ↦ → χψ (︀ Xv(F) )︀ (p) will have its summation well-defined, in other words the formula generalising (7,8) will be valid. In fact, assuming ⊥ = 0, we will then have the corresponding decomposition (11).
We see thus that bounded variation is at the core of the theory of the flat extension of non-increasing set operators, and it was the main theme of [18]. This work constitutes the mathematical basis for our study, and the next three sections will mostly summarise the main concepts and results of that paper, although we present a few new results. Section 2 studies bounded variation of functions defined on an arbitrary poset (partially ordered set) and with real or integer values. Then Section 3 defines a summation for real-valued functions defined on a poset included in R m or Z m , m ≥ 1. For m = 1, this summation gives the integral in the continuous case, and a sum similar to (7) in the discrete case. For m > 1, there will be a summation along each coordinate; for instance, in R 3 , given a i ≤ b i for i = 1, 2, 3, the summation of f from (a 1 , a 2 , a 3 ) to Next, Section 4 studies the decomposition of integer-valued functions into a linear combination of increasing binary functions; in the case where the function to be decomposed has binary values, we get an alternating sum and difference of a decreasing sequence of increasing binary functions, cf. (10). Section 5 applies the mathematical results of the three preceding sections to the theory of the flat extension of operators on binary images, that is, operators P(E) → P(E), or more generally P(E) → K E for a finite interval K ⊂ Z, such as for instance the morphological Laplacian: where id is the identity operator on P(E), while δ and ε are the dilation and erosion by a point neighbourhood.
Our approach relies on threshold summation, and in the case of increasing operators P(E) → P(E), it gives the same result as the original threshold stacking method. We will see that several examples of non-increasing flat operators for grey-level images informally given in the literature belong to our framework: the external, internal and Beucher gradient, the morphological Laplacian, the white, black, and self-complementary tophat, and finally Soille's unconstrained hit-or-miss transform. We will also give some general properties of flat operators, which are rather similar to those given in [16] in the case of increasing operators. Finally the conclusion summarises our findings and proposes some possible extensions of our theory.
Note that our approach combines linear operations (summation, linear combination) with non-linear ones (thresholding); thus the resulting flat operators are generally non-linear (for instance, the usual operators of mathematical morphology). However, we can also obtain flat operators that are linear; for instance, the identity and spatial translations are linear flat operators, so the convolution by a finite mask, which is a linear combination of translations, will be a linear flat operator, which will be increasing only when the mask coefficients are all non-negative.
Given the length of our study, we have split our work into two parts. In a second paper, we will consider duality and study some properties of flat operators, where the non-increasing case differs from the increasing one, for instance the flat extension of a supremum, infimum or composition of operators.

Mathematical preliminaries
We recall here some basic notions from the theory of posets and lattices [1,4,7]. A poset is a set P with a partial order relation ≤ (reflexive, antisymmetric and transitive); write < for the corresponding strict partial order, that is, x < y ⇔ (x ≤ y and x ≠ y). Two elements x and y of P are said to be comparable if either x < y or x = y or x > y. We say that the order ≤ is total if x and y are comparable for all x, y ∈ P; then P is called a chain. A finite chain v 0 < · · · < vn in a poset P has length n; the height of P, written h(P), is the supremum of the lengths of all chains included in P; if there is no upper bound on chain lengths in P, we get h(P) = ∞. For a, c ∈ P, we say that c covers a if a < c and there is no A bounded poset is one having a least element and a greatest element; a poset is bounded by a, b if its least element is a and its greatest element is b.
Given two posets P and Q (equal or different), a map ψ : A closure map on P [4,7] is a map φ : P → P that is increasing, extensive, and idempotent. Equivalently, for all x, y ∈ P, x ≤ φ(y) ⇔ φ(x) ≤ φ(y). A closure range on P [4] is a subset M of P such that for every x ∈ P, the set of all y ∈ M such that y ≥ x is non-empty and has a least element. There is a bijection between closure maps and closure ranges on P, where a closure map φ and a closure range M correspond by two reciprocal relations: M = {φ(x) | x ∈ P}, and for every x ∈ P, φ(x) is the least y ∈ M such that y ≥ x. Note that when P has a greatest element ⊤, we always have ⊤ ∈ M and φ(⊤) = ⊤.
For Q ⊆ P, a lower bound (resp., upper bound) of Q is any x ∈ P such that for all y ∈ Q, x ≤ y (resp., x ≥ y). The greatest lower bound of Q is a lower bound of Q greater than any other lower bound; if it exists, it is unique. One defines similarly the least upper bound of Q. Then P is a lattice if every pair {x, y} in P has a least upper bound, called the join of x, y and written x ∨ y, and a greatest lower bound, called the meet of x, y and written x ∧ y. Now P is a complete lattice if every subset Q of P has a least upper bound, called the supremum of Q and written ⋁︀ Q, and a greatest lower bound, called the infimum of Q and written ⋀︀ Q; in particular it has a least element ⊥ = ⋀︀ P = ⋁︀ ∅ and a greatest element ⊤ = ⋁︀ P = ⋀︀

∅.
Of particular interest are lattices of numbers and of vectors. Every interval in Z, every closed interval [a, b] in R, the completions Z = Z ∪ {−∞, +∞} and R = R ∪ {−∞, +∞} are complete lattices for the numerical order; all of them have the same non-empty supremum and infimum operations, which coincide with the usual numerical supremum and infimum; we will thus write sup Q and inf Q rather than ⋁︀ Q and ⋀︀ Q for a non-empty Q ⊆ R. The empty numerical supremum and infimum, sup ∅ and inf ∅, have no a priori values, they are generally defined as the least and greatest elements of the interval under consideration. For m > 1, Z m and R m , as well as any closed interval in Z m or R m , are complete lattices for the componentwise order (1); their non-empty supremum and infimum, again written sup and inf, correspond to taking the numerical supremum and infimum componentwise: writing x i for the i-th coordinate of x ∈ R (i = 1, . . . , n), for any non-empty Q ⊆ R m we have (︀ sup Q )︀ i = sup{x i | x ∈ Q} and similarly for the infimum. A conditionally complete lattice is a lattice where every subset having an upper bound has a least upper bound (supremum), and every subset having a lower bound has a greatest lower bound (infimum). For in-stance, Z and R are conditionally complete lattices for the numerical order, while for m > 1, Z m and R m are conditionally complete lattices for the componentwise order.
In a complete lattice P, one calls an inf-closed subset of P a subset M of P such that for any subset Q of M, ⋀︀ Q ∈ M; in particular, it contains the empty infimum, that is, the greatest element: ⊤ = ⋀︀ ∅ ∈ M. In fact, M is inf-closed if and only if it is a closure range; it is then a complete lattice, with the same infimum operation as in P, but with the supremum of Q ⊆ M given by φ (︀⋁︀ Q )︀ , where φ is the closure map corresponding to M. One defines similarly a sup-closed subset of P: Q ⊆ M ⇒ ⋁︀ Q ∈ M; then ⊥ ∈ M and M is a complete lattice. A complete sublattice of P is a subset Q of P which is a complete lattice with the same supremum and infimum operations as in P, in other words, Q is both inf-closed and sup-closed; it contains in particular the empty supremum and infimum, that is, the least and greatest elements: ⊥, ⊤ ∈ Q.

Bounded variation in a poset
Bounded variation is a classical topic in functions R → R, see for example Section 3.5 of [6]. We summarise here Section 2 of [18], with minor corrections and improvements, and we add some examples. The most important results of this section are Proposition 4 and Corollary 5, together with the discussion of duality following them.
Let P be a poset. In practice, P can be P(E), the set of parts of a space E (ordered by inclusion), or a closed interval T in R, or P = T m (ordered componentwise). We will consider functions P → R.
Every function P → R has its positive, negative and total variation, and when the latter is bounded, we say that the function has bounded variation. The bounded variation of functions P → R has been studied in [8,9] in the restricted case where the order ≤ is total.
Let f : P → R. For any strictly increasing sequence, we define the positive, negative and total variation of f on it: These three numbers are non-negative. Then concatenating strictly increasing sequences adds their variations, in other words, a strictly increasing sequence (s 0 , . . . , sm+n) (where m, n ≥ 0) satisfies: It follows (see Lemma 1 of [18]) that taking a sub-sequence of a strictly increasing sequence decreases its variations: if (r 0 , . . . , rm) ⊆ (s 0 , . . . , sn) then PV (r0,...,rm) (f ) ≤ PV (s0,...,sn) (f ) , NV (r0,...,rm) (f ) ≤ NV (s0,...,sn) (f ) , and TV (r0,...,rm) (f ) ≤ TV (s0,...,sn) (f ) . S(a, b) be the set of strictly increasing sequences in P that start in a and end in b: Taking the supremum over all (s 0 , . . . , sn) ∈ S(a, b), we get for a < b : Now Then (18) gives TV (s0,...,sn) (f ) = 2NV (s0,...,sn) (f ) + f (b) − f (a), so by taking the supremum over all (s 0 , . . . , sn) ∈ S(a, b), we get TV [a,b] , and by (19) we get: NB. In [18] we incorrectly derived (21) from (20) by taking the suprema over all (s 0 , . . . , sn) ∈ S(a, b), but a supremum of sums does not necessarily coincide with the sum of suprema. By (19), PV [a,b] (f ) and NV [a,b] (f ) are either both finite or both infinite. We say that f is of bounded variation Then the terms of (19) are finite, so for a < b and f BV [a, b] : The following (Lemma 2 of [18]) generalises a remark in Section 3. If P is a chain, then for every b ∈ P such that a < b < c, we have When P is not a chain, the second statement in the lemma is generally false. We will say that f is of bounded variation on P (or briefly, f is BV) if sup{TV [a,b] (f ) | a, b ∈ P, a < b} < ∞; in other words, all PV [a,b] (f ) and NV [a,b] (f ) (a, b ∈ P, a < b) are all bounded by some real M.
When P is bounded by ⊥, ⊤, we will write PV(f ), NV(f ) and TV(f ) for PV [⊥,⊤] (f ), NV [⊥,⊤] (f ) and TV [⊥,⊤] (f ) respectively. Then f is of bounded variation on P iff TV(f ) < ∞, that is, both PV(f ) and NV(f ) are finite. If P has finite height and f is bounded (in particular, if P is finite), then f will be of bounded variation; when one of these two conditions is not satisfied, f can have unbounded variation: Next, we define f P and f N , the positive and negative increments of f , by We have then the following (see Proposition 4 of [18]): Proposition 4. Let P be poset with least element ⊥, and let f : P → R. Then:

f is increasing iff nv
5. If f = g − h for g, h : P → R non-negative and increasing, then for all x ∈ P we have pv

NB.
In [18], the equation (24) was given under the condition that f is BV (on P) instead of now BV [⊥, x], and the second "iff" in items 3 and 4 was given under the condition that f is BV, which is now removed. Indeed, the proof only requires that f has bounded variation on the interval [0, x] (not on P); now for x ∈ P, each of the four equalities nv

) given in items 3 and 4 implies that pv[f ](x) and nv[f ](x) cannot be both infinite, and then from (19) we deduce that pv[f ](x)
and , which is sufficient for the proof. Combining items 1, 2 and 5, we deduce (Corollary 5 of [18]): Corollary 5. Let P be poset with least element ⊥, and let f : P → R. Then f is of bounded variation iff there exist g, h : P → R bounded, non-negative and increasing, such that f = g − h, and then the least such g and h are f P and f N .
A similar result was given in [8] when P is a chain. The principle of duality states that for a set P with a partial order relation ≤, the inverse relation ≥ is also a partial order, so every statement has a dual where one exchanges ≤ with ≥, least element ⊥ with greatest element ⊤, etc. Here positive and negative variation are exchanged, that is, a] (f ) in the dual poset. Now, if P has a greatest element ⊤, we obtain the dual positive and negative variation functions They are decreasing, and pv * [f ](⊤) = nv * [f ](⊤) = 0. We have then the dual positive and negative increments of f , Now, for f BV we have the dual of (24): The dual of Corollary 5 is: let P have greatest element ⊤; then f : P → R is BV iff f is the difference of two bounded, non-negative and decreasing functions P → R. We illustrate such a decomposition in Figure 5.
In fact, given two bounded non-negative functions g, h : P → R, for some M > 0 we have 0 ≤ g, h ≤ M, then the two functions g ′ = M − h and h ′ = M − g are bounded and non-negative, they satisfy 0 ≤ g ′ , h ′ ≤ M; moreover, g ′ − h ′ = g − h; now g and h are increasing iff g ′ and h ′ are decreasing. Thus we can consider either Note that when P is bounded by ⊥, ⊤, every increasing or decreasing function f is bounded: Let us briefly mention an application of bounded variation to signal processing. Rohwer and Wild [13] considered functions Z → R and flat morphological operators on such functions, in particular those built from the closing Un and opening Ln by a segment of length n + 1 (for n > 0); they showed that for any function f : Z → R and any operator ψ obtained by composing in any order some Un and Ln for n > 0, we

Function summation in numerical and multivalued posets
Here we summarise Section 4 of [18], but we also add some new material: first, counterexamples ( Figure 7 and Example 12), then an important property, Proposition 13, and finally, some technical results (Proposition 14 and Lemma 15). The most important results of this section are Theorem 8, Theorem 10, Corollary 11 and Proposition 13. We will define a summation of real-valued functions defined on a poset of real numbers or vectors with real coordinates. This leads to a sum as in (7) when the poset is a discrete chain in R, and to an integral as in (8) when the poset is an interval in R. When the poset is a product of chains, the summation will be made along each coordinate of the vectors. Our results will be used in our new definition of flat morphological operators and the analysis of their properties.
We assume that the poset P is a subset of R m (m ≥ 1), with componentwise ordering, cf. (1). The standard case (assumed in most studies) is the one where we choose in R m (resp., in Z m ) a bottom value ⊥ and a top value ⊤, with ⊥ < ⊤, and take for P the interval [⊥, ⊤] (resp., the discrete interval [⊥, ⊤] ∩ Z m ). Choosing ⊥ = 0 = (0, . . . , 0) makes formulas simpler, but we will not restrict ourselves to that choice. Then we consider functions P → R.
In our theory, a central role is played by bounded, non-negative and decreasing functions. Note that if P has a least element ⊥, then a decreasing function f : P → R is bounded by f (⊥).
Consider a function f : P → R that is bounded, non-negative and decreasing. For a strictly increasing sequence (s 0 , . . . , sn) in P, define the summation We illustrate in Figure 6 this construction for P being an interval in R.  Then, as we had for variations, see (14), concatenating strictly increasing sequences adds their summations, in other words, a strictly increasing sequence (s 0 , . . . , sm+n) (where m, n ≥ 0) satisfies: And as we had for variations, see (15), taking a sub-sequence of a strictly increasing sequence leads to a smaller summation (see Lemma 9 of [18]): Recall from (16) the set S(a, b) of strictly increasing sequences in P starting in a and ending in b (where a, b ∈ P and a < b). Again, let f : P → R be bounded, non-negative and decreasing. In the definition (26) of ; when P is a real interval, this term is an approximation from below of the integral of f on that interval, so S (s0,...,sn) (f ) approximates the integral of f from below, see Figure 6. Thus, for a, b ∈ P with a < b, we define the summation of f over the interval [a, b] as the supremum of summations over all sequences in S(a, b): Note that this supremum sup is taken in R m (or Z m ), in other words, by taking componentwise the numerical supremum. That is why we write sup instead of ⋁︀ for the supremum. It is easily seen that this summation is non-negative and bounded: given , the summation of f over P. The following result (Proposition 10 of [18]) is the analogue of Lemma 1 for summation instead of variation: Proposition 6. Let f : P → R be bounded, non-negative and decreasing, and let a, c ∈ P, where a < c but c does not cover a. Then If P is a chain, then for every b ∈ P such that a < b < c, we have The second equality is specific to chains, for instance it does not hold in R m and Z m for m > 1, see Corollary 11 and the example in R 3 following it.

Additive summation
In order to extend summation to functions that are not necessarily non-negative and decreasing, we will consider the summation of a linear combination of bounded, non-negative and decreasing functions. This will lead to the condition that S is additive on P. We first have the following general property (Lemma 11 of [18]): Lemma 7. Let f , g : P → R be bounded, non-negative and decreasing, let a, b ∈ P with a < b, and take a scalar λ ≥ 0. Then: 1. λf is bounded, non-negative and decreasing and S [a,b] (λf ) = λS [a,b] (f ).

f + g is bounded, non-negative and decreasing and S
We say that S is additive on P if for all bounded, non-negative and decreasing functions f , g : P → R, and all . This property is fundamental, as it allows to extend the definition of the summation S [a,b] to functions of bounded variation. Indeed, we saw after Corollary 5 that, assuming that P is bounded, a function f : P → R is of bounded variation iff there are two bounded, non-negative and decreasing functions g, h : We can then define the summation of f as S [a,b] . But this definition should not depend on the choice of g and h. Suppose two decompositions f = g 1 − h 1 = g 2 − h 2 ; then we have g 1 + h 2 = g 2 + h 1 , and the additivity gives . Then this extension of S [a,b] to functions of bounded variation will be a linear operator (Theorem 12 of [18]): Theorem 8. Let P be a bounded poset. Suppose that S is additive on P. For any f : P → R of bounded variation, given a decomposition f = g − h for g, h : P → R bounded, non-negative and decreasing, define

) does not depend on the choice of g and h in the decomposition, and S [a,b] is a linear operator on the module of functions with bounded variation
A consequence of this result is that summation is increasing on functions of bounded variation. Let f and g be two BV functions such that f ≥ g.
In view of Theorem 8 and Corollary 5, we will require the poset P to be bounded, and the summation S to be additive on P. We will describe later (see Figure 7 and Example 12) a family of posets included in Z 2 , for which the summation is not additive. However, we have shown that summation is additive for a chain (a totally ordered set) or a direct product of chains, for instance for the usual posets of real values or real-valued vectors in an interval. We consider first a chain (see Proposition 13 and Corollary 14 of [18]): Proposition 9. If P is a bounded chain, then S is additive on P. Given f : P → R of bounded variation: 1. If P is a finite chain, P = {t 0 , . . . , tn} with t 0 < · · · < tn, then for In the case of real functions, our definition of the summation of a function is very similar to that of the Riemann integral. Now a real function is Riemann integrable iff it is continuous almost everywhere, that is, the set of its discontinuities has Lebesgue measure zero. As a decreasing real function is continuous almost everywhere (see Section 3.5 of [6]), it follows that any real function of bounded variation is continuous almost everywhere, hence Riemann integrable. Note that the sum in item 1 can be considered as a discrete analogue of the integral in item 2.
We will now consider the case where P is a product of chains, and we will see below that S does not resemble the classical multi-dimensional real integral, nor the complex integral.
Let P = P 1 × · · · × Pm, the cartesian product of posets P 1 , . . . , Pm, with componentwise ordering, see (1). If each P i is bounded by ⊥ i , ⊤ i , then P will be bounded by ⊥, ⊤, where ⊥ = (⊥ 1 , . . . , ⊥m) and ⊤ = (⊤ 1 , . . . , ⊤m). For each i = 1, . . . , m we define the i-th projection Since each P i is included in R k for some k ≥ 1, we can extend this definition of the projection π i to linear combinations of elements of P, hence to the summation of a function on a chain, cf. (26), and finally to the summation over an interval, cf. (29). Given a = (a 1 , . . . , am) ∈ P, define the i-th embedding through a: in other words π i (η a i (x)) = x and π j (η a i (x)) = a j for j ≠ i. Now for f : P → R, we write fη a i rather than f ∘ η a i for their composition, in other words: We obtain then the following important result (see Proposition 15 and Corollary 16 of [18]): , with the componentwise order on P. Let f : P → R be bounded, non-negative and decreasing, and let a = (a 1 , , with fη a i given by (32). Moreover, if each P i is bounded and S is additive on each P i (i = 1, . . . , m), then S is additive on P, and the Geometrically speaking, this result means that each projection π i (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 , More generally, if each P i is a chain, from Proposition 9 we derive the following (Corollary 17 of [18]): Corollary 11. Let P = P 1 × · · · × Pm, where each P i is a bounded chain (i = 1, . . . , m), with the componentwise order on P. Then S is additive on P. Let f : P → R be of bounded variation, and take a = (a 1 , Then: Let us illustrate this in the case where m = 3. Let P = R 3 , with componentwise ordering. Let a = (a 1 , a 2 , a 3 ) Then for a BV function f , and similarly for π 2 and π 3 . We see thus that in Proposition 6, the second equality is specific to chains. We have a similar result for P = Z 3 , here We give now a family of bounded posets included in Z 2 , with componentwise ordering, on which S is not additive; it includes several non-distributive lattices, which are not sublattices of Z 2 .
For any such poset P, define the two bounded, non-negative and decreasing functions f , g : P → R as follows, see Figure 7 (c,d): for any x ∈ P, For a strictly increasing chain starting in ⊥ = (0, 0) and ending in ⊤ = (2,2), the summation of f on this chain according to (26) either is equal to 0, or has an element x > (0, 0) with f (x) > 0, namely x = (2, 0) or (0, 2), and it is then the unique non-zero contribution to the sum. Thus .
Given a product V of bounded chains, S is additive on V, but S will not necessarily be additive on a sup-closed subset of V, as we saw with the above example P 1 . However, S will be additive on an inf-closed subset of V.
Recall from Subsection 1.3 the two corresponding notions of a closure map and a closure range. When P is a complete lattice (for instance, a product of complete chains), a closure range is an inf-closed set.
Proposition 13. Let P be a poset bounded by ⊥, ⊤, let M be a closure range on P such that ⊥ ∈ M, and let φ be the corresponding closure map on P. For any f : ). Then f is the restriction of fφ to M, and for any a, b ∈ M such that a < b we have PV [a,b] In particular, if f is of bounded variation, then fφ is of bounded variation. If S is additive on P, then it is additive on M, and for f : We consider the set S(a, b) of strictly increasing sequences in P that start in a and end in b, that is, For the summation, we suppose first that f is bounded, non-negative and decreasing. For x, y ∈ P with Then (26) gives S (s0,...,sn) (fφ) = S (s0,...,s k−1 ,s k+1 ,...,sn) (fφ): we remove s k from the sequence, keeping the summation equal. Second case: if φ(s k ) ≠ s k+1 , then s k < φ(s k ) < s k+1 and as f is decreasing, fφ(φ(s k )) = fφ( Then (26) gives S (s0,...,sn) (fφ) ≤ S (s0,...,s k−1 ,φ(s k ),s k+1 ,...,sn) (fφ): in the sequence, we replace s k by φ(s k ), which increases the summation. In both cases we have reduced the number of terms of the sequence which do not belong to M, with the summation getting greater or equal. We repeat this modification until we get a reduced sequence (t 0 , . . . , tm) ∈ S(a, b) M such that S (s0,...,sn) (fφ) ≤ S (t0,...,tm) (fφ) = S (t0,...,tm) (f ). We deduce then from (29) by the dual form of Corollary 5, fφ is of bounded variation (but this follows also from the equality of the positive and negative variations, see above).
A particular case arises when P is a complete lattice and M is both sup-closed and inf-closed, in other words it is a complete sublattice of P. This implies that the summation is additive on any complete sublattice of a closed interval in R m or Z m .
We illustrate this result with a simple example. Let ⊥, ⊤ ∈ R with ⊥ < ⊤, and let P = [⊥, ⊤], ordered numerically. Let M be a finite chain in P, bounded by ⊥, ⊤, M = {⊥ = t 0 , . . . , t k = ⊤}; then M is a closure range on P, the corresponding closure map φ is defined by φ(t 0 ) = t 0 and φ(x) = t i for t i−1 < x ≤ t i , i = 1, . . . , k. For a map f : M → R, fφ will be the step function with fφ( . The integral of a step function reduces to the sum of products of the width and height of steps.
The above result will be useful in our study of flat operators, when we will consider the restriction of images values to a complete sublattice of the original lattice of values: then the definitions of such an operator for both lattices will coincide.

Further properties
We end with two technical results that will be used in our analysis of the properties of flat operators.
The following proposition (implicit in [18]) will imply that for an increasing operator on binary images, given image intensities forming a complete sublattice of the interval [⊥, ⊤] in R m or Z m , flat extension by threshold summation leads to the same result as flat extension by threshold stacking.
where we set sup ∅ = ⊥ on the right side of the equation.
Finally, we will need the following slight generalisation of Lemma 1 and Proposition 6:

Decomposition of integer-valued functions
We will now consider the decomposition of an integer-valued function of bounded variation into a sum and difference of increasing binary functions. In other words, for f : P → Z of bounded variation, we will obtain a decomposition f = ∑︀ n i=1 λ i f i , where for each i = 1, . . . , n, f i is an increasing function P → {0, 1} and λ i = ±1. Morever, when f is P → {0, 1}, we have f 1 > · · · > fn and λ i = (−1) i−1 , we get an alternating sum and difference of a decreasing sequence of increasing binary functions, cf. (10).
We will use such a decomposition to compute the flat extension of a non-increasing operator on binary images: a linear combination of increasing operators on binary images will extend to the same linear combination of their flat extensions. This will be possible when the operator is of uniform bounded variation.
We start by decomposing a function P → {0, . . . , n} (where n > 0) into a sum of binary functions, using the method of threshold summation of [5,24], as in (9). For f : P → N and t ∈ N, let ξ t (f ) = χX t (f ) be the characteristic function (6) of the threshold set (2) X t (f ): The following was obtained in Lemma 6 of [18] (except the "if" part of the last sentence, which is straightforward): n} (n ∈ N), and let f 1 , . . . , f N : P → {0, 1}. Then the following two statements are equivalent: Furthermore, f is increasing if and only if ξ i (f ) is increasing for each i = 1, . . . , n.
The first elements of the sequence (38) are: Then the first elements of the sequence (39) are: Intuitively, we take f 1 = I(f ) = ξ 1 (f T ), then f 1 − f has a smaller variation than f , and we get by recurrence the decomposition f 1 − f = f 2 − f 3 + · · · + (−1) v−2 fv, with each f i as in (39). Let us complement the last sentence of the above theorem (this result is new): ∑︀ v i=2 (−1) i f i ; by induction hypothesis, g is P → {0, 1} and g ≤ f 2 ; since f 2 < f 1 , we have g ≤ f 1 . Thus, for all x ∈ P, we have 0 ≤ g(x) ≤ f 1 (x) ≤ 1, from which we deduce that 0 ≤ f 1 (x) − g(x) ≤ f 1 (x) ≤ 1. As f = f 1 − g, we get thus 0 ≤ f (x) ≤ f 1 (x) ≤ 1, and the result follows for v. Now, f is BV by the last sentence of Theorem 18.

Generalised flat morphological operators
The three preceding sections provide a mathematical framework for our generalised theory of flat morphological operators. Our new definition of the flat extension of an operator on binary images deals correctly with the case where the operator is not increasing. Quite generally, we will consider not only operators P(E) → P(E) (transforming binary images), but also operators P(E) → K E for a finite interval K ⊆ Z; this occurs for instance when one makes measurements on binary images, see for example the morphological Laplacian (12).
In the case where image intensities are in a closed interval in R m or Z m , for any increasing operator P(E) → P(E), the new definition of its flat extension will coincide with the classical one [15,16]. For operators that are not increasing, the properties of the flat extension given in [15,16] for the increasing case will not always be satisfied.

Basic definitions and examples
We specify our framework for images. Let E be the space of points. Image values will be reals or integers (for grey-level images), or vectors with real or integer coordinates (for multivalued images). Formally, let m ≥ 1, and for i = 1, . . . , m, let either C i = R or C i = u i Z for some real u i > 0 (usually u i = 1); now let U = C 1 ×· · ·×Cm, with componentwise or marginal ordering (1). Note that there are other possible orders on U, including total orders (such as the lexicographic order), but the componentwise order is mathematically easier to deal with, it allowed us to obtain a componentwise decomposition of the summation, see Theorem 10, which will be applied to flat operators, see Proposition 30. Then all images, those given as input to flat operators, as well as those obtained as the output of operators, will have their values in U. The set U has two important properties: -It is a conditionally complete lattice for the componentwise order: every subset of U having an upper bound (resp., a lower bound) will have a supremum (resp., infimum). In particular, every closed interval [a, b] ⊂ U will be a complete lattice where the supremum and infimum operations are the componentwise numerical sup and inf operations.  1, 1, . . . , m). Note that we do not necessarily choose ⊥ = 0 = (0, . . . , 0); indeed, some modalities use a range of intensities that can include negative values, for instance, CT images have values in Hounsfield units, which correspond to the radiodensity of the objects. Since each [⊥ i , ⊤ i ] is a complete chain, [⊥, ⊤] is a completely distributive complete lattice [16].
We will apply flat operators to images E → V, where V is a subset of the interval [⊥, ⊤] having ⊥ and ⊤ as least and greatest elements: {⊥, ⊤} ⊆ V ⊆ [⊥, ⊤]. Then the output of flat operators will be images E → U (not necessarily E → V). We have some flexibility in the choice of the set V of image values. We make the following two requirements: A. The summation S must be additive on V (we saw in Example 12 that this does not hold for some bounded posets in Z m ). This is necessary in order to define the summation of any BV function, see Theorem 8. It also implies that given a decomposition of an operator on binary images as a linear combination of operators on binary images, we obtain the same decomposition with the flat extensions, see (10,11). B. The set V must be closed under non-empty componentwise numerical supremum. By Proposition 20 below, this will guarantee that for increasing operators on binary images, the new definition of the flat extension to images E → V will coincide with the classical one in [16].
We give here two cases where both requirements are satisfied: = 1, . . . , n). Hence V is a product of chains, so the summation will be additive on [⊥, ⊤] by Corollary 11. We introduce here a new convention. Throughout Sections 2 and 3, there was no ambiguity in the notation TV [a,b] (f ) and S [a,b] (f ) about the variable over which we measure the variation or make the summation, since we assumed that f is a function of a single variable. Similarly, for a real function of one variable, we can write ∫︀ b a f for ∫︀ b a f (x) dx. Now we will encounter functions of several variables, and we will have to specify over which variable we consider the variation or summation of the function. Similarly, for a real function of three variables, ∫︀ b a f (x, y, z) dy indicates that the integration is made on the second variable y. Given an expression W in several variables, a variable x appearing in W and a poset P, we will write "W | x ∈ 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 | x ∈ P) and S [a,b] (W | x ∈ P) designate the total variation TV [a,b] (f ) and summation S [a,b] (f ) for the function f : Recall from the Introduction the characteristic function χX of a set X ∈ P(E), cf. (6); then for an operator ψ : P(E) → P(E), we have the operator χψ : P(E) → {0, 1} E : X ↦ → χψ(X). Given a function F : E → V, for each v ∈ V we have the threshold set Xv(F), cf. (2); this set decreases when v increases. Now with our new convention, the three formulas (7,8,9) for the flat extension by threshold summation will unify into Here we summed over the variable t an expression depending also on the function F and the point p ∈ E. More generally, we can express the flat extension ψ V of an increasing binary image transformation ψ : P(E) → P(E), see (3,4), in terms of a summation. The following result generalises the threshold decomposition method (9) introduced in [5,24]: where we set sup ∅ = ⊥ on the right side of the equation. If V is closed under componentwise numerical supremum (it is then a complete lattice), we get where ψ V is the flat extension of ψ to V E .
Proof. The set Xv(F) decreases when v increases, and the operator ψ is increasing; hence the set ψ(Xv(F)) also decreases when v increases, so for any p ∈ E, the function V → {0, 1} : v ↦ → χψ(Xv(F))(p) is decreasing. We apply Proposition 14, so (33) gives: If V is closed under componentwise numerical supremum, then the latter coincides with the lattice-theoretical supremum operation in V, so which gives ψ V (F)(p) by (4).
This result can be taken as the basis for the definition of the flat extension of any operator on P(E). But our theory requires first to distinguish two types of operators in image processing. On the one hand there are operators such as the opening, closing, median filtering and Gaussian smoothing, which map an image in V E to another image in V E that is supposed to show the same objects; we call such an operator V E → V E an image transformation. On the other hand, there are operators like the gradient or the Laplacian, which are not intended to produce viewable images, and indeed do not necessarily preserve the interval V of values, for instance, they can generate negative values from positive grey-levels; we call such an operator an image measurement.
Let us formalise this distinction in the case of binary images. A binary image transformation is a map P(E) → P(E); for instance, the dilation, erosion, opening and closing by a structuring element. A binary image measurement is a map P(E) → K E for a finite interval K ⊂ Z; for instance, the morphological Laplacian (12). Obviously, every binary image transformation ψ corresponds to the binary image measurement χψ, with Given a binary image measurement µ : P(E) → K E , we define the no-shift flat extension µ −V of µ by setting for any image F : E → V and point p ∈ E: provided that the summation is well-defined, that is, the summed function v ↦ → µ(Xv(F))(p) is of bounded variation: This question will be analysed in the next subsection. Note that if V has finite height, in particular if V is finite, then this function will indeed be of bounded variation, see Proposition 23 below. On the other hand, when V is an interval in R m , this will not necessarily be the case, see Example 25 below.
Since the summation on V is additive (requirement A), the no-shift flat extension will be linear on the operator µ (see Theorem 8): for two scalars λ 1 , λ 2 and two binary image measurements µ 1 , µ 2 , Given a binary image transformation ψ : P(E) → P(E), we define the shifted flat extension ψ +V of ψ by setting for any image F : E → V and point p ∈ E: again provided that the summation is well-defined. Assuming V to be closed under componentwise numerical supremum (requirement B), for any increasing operator ψ, this definition (42) will by Proposition 20 be equivalent to the usual definition (3,4). Without requirement B, this is not true:  1). Let ∅ ⊂ A ⊂ E, and let F : E → V with F(p) = (1, 0) for p ∈ A and F(p) = (0, 1) for p ∈ E \ A. We have X (0,0) (F) = E, X (1,0) (F) = A, X (0,1) (F) = E \ A, and X (2,2) (F) = ∅. Take an extensive dilation δ on P(E), so δ(E) = E (we have δ(∅) = ∅ anyway). Then δ(X (0,0) (F)) = E, δ(X (1,0) (F)) = δ(A), δ(X (0,1) (F)) = δ(E \ A), and δ(X (2,2) 4). As V is a chain, it is closed under componentwise numerical supremum, and S is additive on V. Let ∅ ⊂ A ⊂ E, and let F : E → V with F(p) = (2, 3) for p ∈ A and F(p) = (2, 1) for p ∈ E \ A. We have X (0,0) (F) = X (2,1) (F) = E, X (2,3) (F) = A, and X (4,4)  We end this subsection by describing some well-known examples of non-increasing flat operators given in the literature. For the sake of simplicity, we can assume that E is the digital space Z n and that V is an interval [⊥, ⊤] in R m or Z m (m ≥ 1), thus we are in the standard case. Then V will be a completely distributive complete lattice, which is a necessary requirement for obtaining the usual properties of increasing flat operators [16]. Moreover, for any increasing operator ψ, Proposition 20 gives ψ +V = ψ V : the shifted flat extension of ψ coincides with the standard flat extension according to [16]. For X ∈ P(E), write X c = E \ X (the complement of X) andX = {−x | x ∈ X} (the symmetrical of X). Recall from (5) the dilation δ B and erosion ε B by a structuring element B ∈ P(E); we assume that B ≠ ∅. Write id for the identity operator on P(E).

(F) = ∅. Take an extensive dilation δ and an anti-extensive erosion ε on P(E), so δ(E) = E and ε(∅) = ∅ (we have δ(∅) = ∅ and ε(E) = E anyway). Consider the non-increasing operator on P(E) given by their difference
When B is the digital neighbourhood of the origin (origin included), δ B (X) \ X is the outer border of X (set of all points of X c neighbouring at least one point of X), while X \ ε B (X) is the inner border of X (set of all points of X neighbouring at least one point of X c ); their disjoint union δ B (X) \ ε B (X) is the border of X. We can generalise this to any symmetrical structuring element B containing the origin, and we get thus the three image transformations δ B \ id, id \ ε B and δ B \ ε B . Since B contains the origin, δ B is extensive and ε B is anti-extensive, that is, ε B (X) ⊆ X ⊆ δ B (X) for all X ∈ P(E), so we get: From (40,42) and the linearity of summation, we derive: Here id +V will be the identity operator on V E , while δ +V B and ε +V B will be the standard flat dilation and erosion δ V B and ε V B based on computing a local supremum and infimim respectively, see [16]. The three operators δ +V B −id +V , id +V − ε +V B and δ +V B − ε +V B are called the external gradient, internal gradient and Beucher gradient (or morphological gradient) respectively [22]; they are morphological variants of the traditional Roberts, Prewitt or Sobel gradients based on linear convolution.
The Laplacian on binary images (12) is the image measurement P(E) → {−1, 0, +1} E defined by Its no-shift flat extension is then the morphological Laplacian: Take now any non-empty structuring element B, and consider the opening and closing by B, Then φ B is extensive and B is anti-extensive, we have B (X) ⊆ X ⊆ φ B (X) for all X ∈ P(E). The set φ B (X) \ X shows all portions of X c that are too narrow to contain a translate ofB, while X \ B (X) shows all portions of X that are too narrow to contain a translate of B ; their disjoint union φ B (X) \ B (X) will show both. As with the gradient, we get: Then we obtain their no-shift flat extensions: , the flat opening and closing, are obtained by composing the flat erosion and dilation, see [16]. The three operators id +V − +V B , φ +V B − id +V and φ +V B − +V B are called the white top-hat, black top-hat and self-complementary top-hat respectively [22]; the same names can also be used for their binary counterparts id \ B , φ B \ id and φ B \ B . In the case of grey-level or colour images, the white top-hat shows narrow bright zones, the black top-hat shows narrow dark zones, and the self-complementary top-hat shows both.
The hit-or-miss transform uses a pair (A, B) of structuring elements, and looks for all positions where A can be fitted within a figure X, and B within the background X c [20], in other words it is the operator HMT (A,B) : P(E) → P(E) defined by One assumes that A ∩ B = ∅, otherwise we have always HMT (A,B) (X) = ∅. We can write HMT (A,B) )︀ , where we always have δB(X) ∩ ε A (X) ⊆ ε A (X). Thus where ∧ is the meet (binary infimum) operation. Now (δB ∩ ε A ) +V = δ +V B ∧ ε +V A [16], hence we obtain: Thus for any F : E → V and p ∈ E we have: In the case of images with discrete grey-levels (V = T = {t 0 , . . . , t 1 } ⊂ Z), Soille's unconstrained hit-or-miss transform [22] was defined, for an input grey-level image F, by computing at every point p ∈ E the length of the interval exactly Soille's unconstrained hit-or-miss transform. This operator was further analysed in [12], where it was extended to continuous grey-levels (T ⊂ R) and to grey-level structuring functions instead of structuring elements. This paper gave a general survey of the various types of hit-or-miss transforms for grey-level images. These examples of non-increasing flat grey-level operators, namely the external, internal and Beucher gradient, the morphological Laplacian, the white, black, and self-complementary top-hat, and Soille's unconstrained hit-or-miss transform, have previously been defined in an intuitive way as a grey-level extension of the corresponding set operators. No formal theory for their construction was given, except in [12] for the specific case of the hit-or-miss transform.
Note that their form given in the literature always coincides with the no-shift flat extension (χψ) −V of the corresponding binary image transformation ψ, rather than the shifted one ψ +V = ⊥ + (χψ) −V . Indeed, most authors implicitly assume image intensities to be between 0 and 255, in other words, ⊥ = 0, so the intensity shift by ⊥ does not matter.

Bounded variation of image measurements
We have now to analyse conditions for the summation S (︀ µ(Xv(F))(p) ⃒ ⃒ v ∈ V )︀ of (40) to be well-defined, in other words for the summed function to have bounded variation: Then the no-shift flat extension (40), and the shifted one (42) for µ = χψ, will be well-defined.
Recall from Subsection 1.3 h(V), the height of V, that is, the supremum of the lengths of all chains in P; for a finite interval K ⊂ Z we have similarly its height h(K) = max K − min K. Now the total variation of µ(Xv(F))(p) on v ∈ V can be bounded either by h(K)h(V), or by the total variation of µ(Z)(p) on Z ∈ P(E):

Proposition 23. Let µ : P(E) → K E be a binary image measurement, for a finite interval K ⊂ Z. Then for any F ∈ V E and p ∈ E, TV
Proof. Let F ∈ V E and consider a strictly increasing sequence (s 0 , . . . , sn) in V. Then for i = 1, . . . , n, Hence Since TV (s0,...,sn) (µ(Xv(F))(p) for every strictly increasing sequence (s 0 , . . . , sn) in V, by taking the supremum on such sequences, we deduce that TV(µ(Xv(F))(p) . Now Xs i (F) decreases when i increases from 1 to n. We eliminate in the sequence s 0 , . . . , sn all s i with Xs i (F) = Xs i−1 (F), we obtain thus a subsequence (t 0 , . . . , tm), where m ≤ n, such that X t0 (F) ⊃ · · · ⊃ X tm (F). For j = 0, . . . , m, let Z j = X t m−j (F), so Z 0 ⊂ · · · ⊂ Zm. Then (with the change of variable k = m − j + 1 at the end of the second line), By taking the supremum on all strictly increasing sequences (s 0 , . . . , sn), we obtain TV

(p) = µ(E)(p), then we replace Xu by E in the sequence, while if µ(Xu)(p) ≠ µ(E)(p), then we replace the sequence
For any v ∈ V, let φ(v) be the least t i (i = 0 . . . , u) such that t i ≥ v (since tu = ⊤, such a t i always exists); then Xv(F) = X φ(v) (F). As φ is a closure operator on V, Proposition 13 gives From Proposition 23 we see that when V has finite height, for instance if V is finite, then TV )︀ = ∞, so the function is not summable: Then for any p ∈ E, χψ(Xv(F))(p) = 1 if v ∈ A, and = 0 if v ∈ B. As A and B are dense in V, for any n > 0 there is a strictly increasing sequence

for i odd and v i ∈ B for i even, in other words the sequence alternates between A and B. Then χψ(Xv(F))(p) alternates between 1 and 0 on this sequence, that is, TV
We consider now a condition that puts a limit on the variation of the function P(E) → K : Z ↦ → µ(Z)(p). Let us say that µ is local if for any p ∈ E there exists a finite W(p) ∈ P(E) such that for any Z ∈ P(E), )︀ (p). For instance, the dilation, erosion, opening and closing by a finite structuring element, and the hit-or-miss transform by two finite structuring elements, are local.
Proposition 26. Let µ : P(E) → K E be a binary image measurement, for a finite interval K ⊂ Z. If µ is local, then for any p ∈ E, Proof. Let (Z 0 , . . . , Zn) be a strictly increasing sequence in P(E). If we remove from that sequence all Z i such that )︀ is strictly increasing. Since µ is local, Now P(W(p)), ordered by inclusion, has height |W(p)|, so the strictly increasing sequence Y j ∩ W(p) (j = 0, . . . , m) has length at most |W(p)|, thus m ≤ |W(p)|. Hence The result follows.
Therefore, when a binary image measurement µ is local, for any F ∈ V E and p ∈ E, Proposition 23 gives so the flat extension µ −V will be well-defined. Let us say that the binary image measurement µ is of uniform bounded variation if sup p∈E TV )︀ < ∞. This property is stronger than the having TV (︀ µ(Z)(p) ⃒ ⃒ Z ∈ P(E) )︀ finite for all p ∈ E (which is the sufficient condition we gave for the flat extension µ −V to be well-defined), as shown by the following example: Example 27. Let E = N, and define the binary image transformation ψ : P(E) → P(E) as follows: ∀ Z ∈ P(E), )︀ = m. Therefore χψ has bounded variation at every point, but is not of uniform bounded variation.
By Proposition 26, a local binary image measurement will be of uniform bounded variation if sup p∈E |W(p)| < ∞; this is for instance the case when E = R n or Z n and the local operator µ is translation-invariant, because here W(p) = Bp, the translate by p of a fixed finite structuring element B.
Now uniform bounded variation is precisely the necessary and sufficient condition for a binary image measurement µ to take the form of a sum and difference of characteristic functions of increasing binary image transformations: )︀ ≤ n.

Proposition 29. A binary image measurement µ : P(E) → K E (for a finite interval K ⊂ Z) has a decomposition of the form
if and only if µ is of uniform bounded variation and there is a binary image transformation ψ : P(E) → P(E) such that µ = χψ.
Proof. If µ is of uniform bounded variation and µ = χψ for ψ : P(E) → P(E), we apply the same argument as in Proposition 28, but using Theorem 18 instead of Proposition 17, which gives thus (45) in place of (44). Conversely, if (45) holds, we use Proposition 19 in the argument.

General properties
We will give some mathematical properties of flat extension, following Section 3 of [16]. We consider first the standard case, see Subsection 5.1: V = [⊥, ⊤], a closed interval in the module U = C 1 × · · · × Cm; thus . For instance, in multivalued images, V = T n (n > 1), for a closed interval T.
Recall from (30) the i-th projection π i : V → V i : (v 1 , . . . , vn) ↦ → v i for i = 1, . . . , n; it can naturally be extended to a projection Π i : For instance, if V consists of RGB colours and π 1 projects a colour on its red component, then Π 1 will associate to a coulour image its red layer. We obtain the same result as Proposition 12 of [16]: a flat operator is obtained by applying that flat operator on each projection. For instance, a RGB colour Laplacian is obtained by applying the intensity Laplacian to each R, G and B layer.

Proposition 30. Assume the standard case. Let F : E → V. For every binary image measurement µ we have
)︀ for all i = 1, . . . , n. For every binary image transformation ψ we have Π i We apply the definition of projection, then by Theorem 10 we get: , and the above with (40) again gives: As the equality holds for any p ∈ E, we deduce the identity . Now for a binary image transformation ψ, we apply (42), so In Let p ∈ E. We apply Proposition 13 with P = V, M = W and f : As the summation S is additive on V, it will be additive on W, f has the same bounded variation as fφ, and we get S(fφ) = S(f ), that is, A particular case is W = {⊥, ⊤}. Images E → {⊥, ⊤} are binary, they correspond to subsets of E. For any Then for every F : Corollary 33. For any two binary image measurements µ 1 , µ 2 we have µ 1 For any two binary image transformation ψ 1 , ψ 2 we have ψ 1 ≤ ψ 2 ⇔ ψ +V 1 ≤ ψ +V 2 . In particular, the two maps µ ↦ → µ −V and ψ ↦ → ψ +V are injective.
It is known that for images with values in a finite chain, usual flat operators (median filter, dilation, erosion, opening or closing by a non-empty structuring element) do not create new values in an image. This is not true for images with values in an infinite chain or a product of chains. The topic of image values generated by increasing flat operators was analysed precisely in [16], see its Proposition 13 and Theorem 19, then its Subsection 3.3 for more details. We summarise these results. Let ψ be an increasing binary image transformation; then for any F : E → V and p ∈ E: 2. If p ∈ ψ(∅), then in item 1 the empty infimum appears as an argument to the supremum, and ψ V (F)(p) = ⊤.
Thus, from item 1, ψ V (F)(p) belongs to the complete sublattice of V generated by {F(q) | q ∈ E}. More specifically, following item 4, when p ∈ ψ(E) \ ψ(∅), ψ V (F)(p) belongs to the least subset of V containing {F(q) | q ∈ E} and closed under non-empty supremum and infimum; this set is a complete lattice, however its least and greatest elements can differ from ⊥ and ⊤. For operators that are not increasing, the flat extension will involve not only lattice-theoretical operations, but also arithmetical ones, see for instance Example 22. We obtain the following result for binary image measurements: Proposition 34. Let W be a non-empty subset of V, closed under non-empty (numerical) supremum and infimum, with least element ⊥ 0 = inf W and greatest element ⊤ 0 = sup W. Then S is additive on W, and for any F : E → W and for any binary image measurement µ, we have Proof. Since W is a complete sublattice of [⊥ 0 , ⊤ 0 ], S is additive on W by Proposition 13. Let X = W ∪ {⊥, ⊤}. Then X is the complete sublattice of V generated by W, and by Proposition 31, µ −X = µ −V . Clearly ⊥ 0 is comparable to every other element of X: ⊥ ≤ ⊥ 0 ≤ ⊤ and ⊥ 0 ≤ x for any x ∈ W; similarly ⊤ 0 is comparable to every other element of X.
As we noticed in [16], when E = R n or Z n and the increasing binary image transformation ψ is translationinvariant, ψ(E) and ψ(∅) must be equal to E or ∅; thus either (a) ψ(E) = E and ψ(∅) = ∅, (b) ψ is the constant E map, or (c) ψ is the constant ∅ map. Hence the two joint conditions ψ(E) = E and ψ(∅) = ∅ appear as a standard requirement for increasing binary image transformations. Indeed, from item 4 above, they guarantee that each ψ V (F)(p) will be a non-empty supremum of non-empty infima of values F(q) (q ∈ E). In particular ψ V will preserve constant functions, and for a function F with values in an interval [a, b], ψ V (F) will have values in that interval.
Let us now consider the corresponding requirements for a binary image measurement µ, which is not necessarily increasing. We remark that when E = R n or Z n and µ is translation-invariant, µ(E) and µ(∅) will be constant, but there is a priori no ordering between them. In view of (47), we will require µ(∅) = ∅, so that values above ⊤ 0 will not influence the result. If we restrict ourselves to the no-shift flat extension, then we will require µ(E) = ∅, so that µ −V coincides with µ −W .
Extrapolating this discussion to the case where we do not have translation-invariance, for a binary image transformation ψ of uniform bounded variation, we will suppose that both ψ(E) and ψ(∅) are equal to either E or ∅. In the case where ψ(∅) = E, we have then ψ(X) = θ(X) c for all X ∈ P(E), with θ(∅) = ∅ (and again θ(E) will be either E or ∅); we get then (χψ) −V = (⊤ − ⊥) − (χθ) −V .

Flat zones and connected operators
In an image F : E → V, a flat zone is a connected subet of E on which F is constant, and which is maximal for the inclusion; in other words, it is a connected component of F −1 (v) for some v ∈ V. An operator Ψ transforming images is said to be connected if for every image F, each flat zone of F is included in a flat zone of Ψ(F); equivalently, given any connected subset C of E, if F is constant on C, then Ψ(F) will be constant on C. This definition depends on the definition of connectivity chosen for subsets of E: we call "connected set" one belonging to a given connection [17,21].
In Proposition 27 of [16], we showed that for an increasing binary image transformation ψ, if ψ is connected, then its flat extension ψ V is connected. We will generalise this result to non-increasing operators, but we will also analyse deeper the notion of flat zones and its relation to connections.
Recall [21] that a connection on P(E) is a a family C ⊆ P(E) that comprises the empty set and all singletons (∅ ∈ C and for all p ∈ E, {p} ∈ C), such that for any B ⊆ C such that ⋂︀ B ≠ ∅, we have ⋃︀ B ∈ C. Elements of C are said to be connected. For any X ∈ P(E), a connected component of X according to C is any non-empty connected subset of X, which is maximal for inclusion: C ∈ C, ∅ ≠ C ⊆ X, and ∀ C ′ ∈ C, C ⊆ C ′ ⊆ X ⇒ C ′ = C. Then the connected components of X form a partition of X [17]. When it is necessary to specify which connection is used (for instance, if we compare several connections), we will say a C-connected set and a C-connected component.
One can derive a connection from another. A well-known example is the connection by dilation [21]. Let C be a connection on P(E), and let δ be an extensive dilation on P(E) such that the dilation of a singleton is connected: ∀ p ∈ E, p ∈ δ({p}) ∈ C. For instance, when E = R n or E = Z n , δ is the dilation by a connected structuring element containing the origin: Then C δ is a connection and C ⊆ C δ . In practice, the elements of C δ are either C-connected sets, or clusters of Cconnected sets, see Figure 8. For any X ∈ P(E), each C δ -connected component A of X corresponds bijectively to a C-connected component B of δ(X) by the two reciprocal relations B = δ(A) and A = B ∩ X.
Given a function F : E → A and a set X ⊆ E, we say that F is flat on X, and write (F, X), if there is some a ∈ A such that for all x ∈ X we have F(x) = a. We extend this notion from functions E → A to subsets of E, thanks to the characteristic function: given F ∈ P(E), F is flat on X iff χF is flat on X, where χF is E → {0, 1} E ; in other words, either X ⊆ F, or X ⊆ E \ F.
Given two sets of image values A and B (not necessarily distinct), and a map Ψ : , the flatness preservation set of Ψ is the set FP(Ψ) of all X ⊆ E such that for any F : E → A, if F is flat on X, then Ψ(F) is flat on X: By the above identification of a set with its characteristic function, for a binary image measurement µ : is the inverse of the characteristic function, mapping a binary function onto its support, so µχ −1 is {0, 1} E → K E . Similarly, for a binary image transformation ψ : Now the usual notion that an operator Ψ is connected with respect to a given connection C on P(E), simply means that C ⊆ FP(Ψ). That such a notion has been put forward in relation to connections is justified by the following result: Proof. Let the set X be empty or a singleton. For any function G defined on E, trivially (G, X); thus for any F ∈ A E , (F, X) and (Ψ(F), X) both hold true; hence X ∈ FP(Ψ). Thus the empty set and all singletons belong to FP(Ψ).
Let B ⊆ FP(Ψ) such that ⋂︀ B ≠ ∅; if B is empty, then ⋃︀ B = ∅ ∈ FP(Ψ). We assume thus that B is nonempty; set C = ⋃︀ B and choose p ∈ ⋂︀ B. Suppose that for some F : E → A we have (F, C); then for any B ∈ B, we have B ⊆ C, so (F, B); as B ∈ FP(Ψ), we deduce that (Ψ(F), B). Now for any x ∈ C, there is some B ∈ B such that x ∈ B, and as p ∈ B and (Ψ(F), B), we get Ψ(F)(x) = Ψ(F)(p); thus Ψ(F) is flat on C. We have thus shown that (F, C) ⇒ (Ψ(F), C); therefore ⋃︀ B = C ∈ FP(Ψ).
This result also indicates that we are not bound to a particular choice of connection on sets: when one says that an operator Ψ is connected with respect to a given connection C, this simply means that C ⊆ FP(Ψ); however, the connection FP(ψ) can be greater than C, which means then that ψ can be connected with respect to a wider connectivity. We illustrate this with the connection by dilation: The set X, shown in black. (c) The dilation δ(X), shown in grey and surrounding X in black, has 3 C-connected components; thus, in (b) we delineate with dashed lines the 3 corresponding C δ -connected components of C; they are clusters of C-connected components. Next to each C-connected component of δ(X), we give the ration of its area to that of B. (d) We apply to δ(X) the area opening with threshold equal to 9 times the area of B, which eliminates one C-connected component of δ(X); the trace on X gives ψ(X), where one C δ -connected component has been eliminated.
Example 37. Take a connection C on P(E) and a dilation δ on P(E) such that ∀ p ∈ E, p ∈ δ({p}) ⊆ C. Let n be the area opening (w.r.t. C) with area threshold n: for any X ∈ P(E), n(X) is the union of all C-connected components of X whose measure (area or volume) is at least n. Given A ∈ C δ , let us say that A is large if δ(A) has measure at least n, and small otherwise. Consider the operator ψ on P(E) given by ψ(X) = X ∩ n(δ(X)). The behaviour of ψ is illustrated in Figure 8: it will remove all small C δ -connected components of a set. Then ψ is a connected operator for the connection C δ , but FP(ψ) is a larger connection. Let D be the set of all A ∈ P(E) such that either A ∈ C δ , or all C δ -connected components of A are large. Then D is a connection, and we have C δ ⊂ D ⊆ FP(ψ). We conjecture that for E = Z n , C the graph connectivity given by one of the usual translationinvariant adjacencies, and δ = δ B for o ∈ B ∈ C, we must have FP(ψ) = D.
Proof. Let C ∈ FP(µ); take any F : E → V such that (F, C); thus there is some a ∈ V such that F(x) = a for all x ∈ C. For any v ∈ V, from (2) we have either a ≥ v and C ⊆ Xv(F), or a ≱ v and C ⊆ E \ Xv(F); in other words Xv(F) is flat on C; as C ∈ FP(µ), (Xv(F), C) implies (µ(Xv(F)), C), so the value of µ(Xv(F))(p) is the same for all p ∈ C. Thus the summation S (︀ µ(Xv(F))(p) ⃒ ⃒ v ∈ V )︀ has the same value for all p ∈ C, and by (40), this means that µ −V (F) is flat on C. We have thus shown that (F, C) ⇒ (µ −V (F), C), so C ∈ FP(µ −V ). Therefore FP(µ) ⊆ FP(µ −V ).
An example of non-increasing connected flat operator is the white top-hat by reconstruction. Given a connected structuring element B, the opening r B by B by reconstruction associates to a set X the geodesical reconstruction from the marker B (X) in the mask X, in other words it will keep all connected components of X which contain a translate of B. The set difference id \ r B will select in X all connected components that are too narrow to contain a translate of B. Its flat extension [︀ χ(id \ r B ) ]︀ −V = id +V − ( r B ) +V extracts from a grey-level image its bright regions that are narrow relatively to B.
Anti-extensive connected operators have been analysed in the context of the max-tree [19]. We consider images with grey-level values in an integer interval: V = {h min , . . . , hmax} ⊂ Z. We assume that E ∈ C. Given an image F : E → V, we construct a directed tree whose nodes are all connected components of the thresholdings X h (F) for all h ∈ V; the root is E = X h min (F); given a connected component A of X h (F) (we say that A is at level h), the children nodes of A will be all connected components of X h+1 (F) (nodes at level h + 1) included in A. We associate to node A at level h the set of points of A having value h, those with higher values will be associated to its descendant nodes. If all points in A have value > h, then A is in fact a connected component of X h+1 (F), it coincides with its child node at level h + 1, so we remove the node A at level h, its parent node becomes thus the parent of A at level h + 1.
An anti-extensive connected operator on sets removes some connected components of a set. Applied to a thresholding X h (F), it will remove some of its connected components, in other words some nodes of the maxtree. There are then several methods to reconstruct the filtered image from the pruned tree. The direct method acts by threshold superposition; for an increasing operator on sets, it gives thus the usual flat extension. When the operator is not increasing, there are two variants trying to give it a behaviour similar to the increasing case: the min method will further remove all descendant nodes of a removed node, while the max method will counteract the removal of a node if one of its descendants is not removed.
In [23], a fourth method was introduced, the substractive one. It gives to a node the grey-level corresponding to the subtraction of its level and that of its parent, then sums all these grey-levels. This corresponds to our definition of the flat extension by threshold summation, and indeed equation (8) of [23] gives exactly the flat operator ψ + in the case where ψ is an attribute thinning, that is, an idempotent anti-extensive connected operator that acts independently on each connected component of a set and removes those that do not satisfy some criterion.
In [25], connected operators have been extended from the spatial domain to the domain of the max-tree.

Conclusion and perspectives
The classical theory of flat morphology [16] extends any increasing operator on sets (or binary images) to an increasing flat operator on grey-level or multi-valued images (more precisely, functions defined on sets and with values in a complete lattice). It relies on three steps: from a function F, build the stack of thresholdings, Xv(F) (v∈V) , then apply the increasing set operator ψ to all thresholdings Xv(F), and finally superpose the resulting stack ψ(Xv(F)) (v∈V) by using a lattice-theoretical supremum.
We have presented an alternative approach to flat morphology, which can be applied to a wider family of operators on sets, in particular to non-increasing ones, such as the hit-or-miss transform, the top-hat and the Beucher gradient. Here the last step of superposition is replaced by a summation, an idea first proposed in [5,24] in the case of bounded integer grey-levels. We have thus elaborated an extensive theory of function summation in a poset [18], which requires the functions to be of bounded variation. It can be applied to functions with values in a closed interval in R m or Z m , in other words to grey-level or multivalued images, with either discrete or analog values. In the case of increasing set operators, the new definition of flat extension gives the same result as the traditional one.
While classical flat morphology gives a flat extension of increasing operators P(E) → P(E) (or {0, 1} E → {0, 1} E ), our theory gives the flat extension of functions P(E) → K E (or {0, 1} E → K E ) for any finite interval K included in Z, so it can be applied to functions with non-binary values, such as the morphological Laplacian. Now, since the summation is a linear operation, given a function P(E) → K E which is a linear combination of increasing functions P(E) → {0, 1} E , its flat extension will be the same linear combination of the flat extensions of the latter functions. For instance, the flat extension of the set difference between an extensive dilation and an anti-extensive erosion on sets will be the arithmetical subtraction of the corresponding flat dilation and erosion on functions.
There should be no complication in relaxing the condition K ⊂ Z to K ⊂ ( 1 d )Z for some d > 1. We can thus apply our theory to linear combinations with rational coefficients of morphological operators on binary images. There have been several works on image filters built by combining linear and morphological operations, see for instance [2,3,11], and they could thus be integrated into our framework.
For instance, in the discrete space Z n , the convolution by a finite mask M is a linear combination of translations: F * M = sup p∈supp(M) M(p) · Tp(F), where supp(M) is the support of the mask M, and for p ∈ supp(M), M(p) is the mask value at p and Tp is the translation by p. Since the translation is an increasing operator on sets, so a flat operator on functions, convolution by the finite mask M is a linear combination of flat morphological operators, and it enters into our framework; in fact, the convolution by M for grey-level or multivalued functions is the flat extension of that same convolution for binary images.
We have analysed some general properties of flat operators, such as compatibility with projection on one value in the case of multivalued images, and preservation of intervals of values. We have also been able to show that the flat extension of a connected operator on sets is a connected operator on functions.
There are other properties that were established in [16] for the flat extension of increasing set operators, in particular its relation with combinations of operators (composition, union and intersection). These properties do not extend fully to the general case, but we can obtain weaker properties. Also the notion of duality becomes rather complex in the case of non-increasing operators. These problems can be analysed and solved through the use of complicated mathematical techniques, and they will be dealt with in our second paper, where we will also analyse linear operators and "hybrid filters" combining linear and morphological operators.