Exact solutions for the total variation denoising problem of piecewise constant images in dimension one

A method for obtaining the exact solution for the total variation denoising problem of piecewise constant images indimensionone is presented. Thevalidity of the algorithmrelies on some results concerning the behavior of the solution when the parameter λ in front of the fidelity term varies. Albeit some of them are well-known in the community, here they are proved with simple techniques based on qualitative geometrical properties of the solutions.


Introduction
When an image is acquired, it comes, unavoidably, with some distortion. Indeed, external conditions, other than defects or limitations of the instruments that are used to obtain them, affect the quality of the acquired data. Thus, in order to perform any task on the image, it is important to be able to recover the clean version in the best possible way, i.e., with optimal fidelity. If we denote it by u : Ω → ℝ and the acquired, corrupted image by f : Ω → ℝ, where Ω ⊂ ℝ N is an open set, it is usually assumed that the two are related via f = Au + n. (1.1) Here A is a bounded linear operator representing, for instance, the blurring effect and n is the instance of the random noise. One of the aims of image reconstruction is deblurring and denoising f in order to recover u (see [8,24]).
The seeking for an analytical method to find exact solutions to the minimization problem (1.3) (and some variants of it, both for piecewise constant and general initial data f ) has been the topic of many studies. For instance, the interested reader can consult [11,12,14,45,[48][49][50]53] and the references therein. The starting point of our investigation is the work of Strong and Chan (see [54]), where they consider the minimization problem (1.3) (essentially just in one dimension) where the initial data f is a piecewise constant function with noise. Under certain conditions on the amplitude of the noise, they are able to determine the solution of the minimization problem (1.3) in the case λ ≫ 1, namely when the solution has jumps where f has.
The aim of this paper is to carry on the previous analysis and to determine the solution of the minimization problem (1.3) for f being a piecewise constant function (without noise) for every value of the parameter λ.
To allow for more generality in the choice of the fidelity term, we generalize the L 2 norm to an L p one, with p ∈ (1, ∞). Some results are also presented in the case p = 1. To be precise, we consider the minimization problem min where Ω : for a given initial piecewise constant data f . Our aim is to provide a method for finding the solution to the minimization problem (1.4) in the case p > 1 for all values of λ > 0. The novelty of this paper relies on the fact that our approach is aimed at getting the solution u λ to the minimization problem (1.4) by considering the solution u λ for large values of λ and then obtaining the ones for small values of λ by decreasing the parameter λ, whereas all the above-mentioned papers used a fixed value of λ. In particular, the main result we obtain is Theorem 5.3 about the behavior of neighboring values of the solution u λ close to a jump point when the parameter λ is moving. Albeit some of the results could be proved by using the primal-dual optimality condition (see [14,51]) and the semigroup property of the total variation flow in dimension one (see [53]), here we prefer to employ more elementary techniques to study the problem.
We next explain the main idea behind the strategy we propose. The rigid structure of the initial data forces the solution to be piecewise constant itself, with jump set contained in the one of f (see Corollary 3.2). Moreover, a simple truncation argument shows that the solution takes values between the minimum and the maximum of f . Hence, the minimization problem (1.4) with f of the form is equivalent to the following minimization problem: where Q := [min f, max f] k and G : ℝ k → ℝ is the function defined by The function G is convex, but it lacks differentiability on the hyperplanes where {v i−1 = v i }. Thus, in principle, one should minimize the function G over several compact regions and then compare all the minimum values in order to find the global minimizer.
Our method aims at overcoming this difficulty. We will be able, for each λ, to predict a priori -that is, without knowing explicitly u λ (the minimizer of G corresponding to the parameter λ) -what the relative position of each u λ i with respect to u λ i−1 and f i will be. Knowing that, it is possible to look for the minimizer u λ only in a specific region of ℝ k , where the absolute values present in the expression of G can be written explicitly. Hence, u λ can be found by solving the appropriate Euler-Lagrange equation.
We give a more detailed description of our method: the function λ → u λ is continuous and u λ → f as λ → ∞ (see Lemma 5.1). Hence, for λ ≫ 1, we have that u λ i is very close to f i , and this allows us to predict the relative position of u λ i with respect to u λ i−1 . Moreover, thanks to the qualitative properties of the solutions we will prove in Lemma 5.2 and Proposition 5.5, we will also be able to tell the relative position of each u i with respect to f i . These information allows us to write explicitly the absolute values present in the expression of G, as well as to write explicitly the Euler-Lagrange equation, whose solution will give us the minimizer u λ . With this reasoning, we find the minimizers for λ large (how large λ has to be will be determined a posteriori).
The idea now is to let λ decrease. Since u λ is constant for small values of λ (see Lemma 3.6), by continuity of λ → u λ eventually two neighboring values u λ i and u λ i−1 will happen to be the same. The main technical result (Theorem 5.3) tells us that the same will be true for all smaller values of λ. As a result we now have to consider the function G restricted to the subspace {v i−1 = v i }, thus reducing the number of variables. By continuity of λ → u λ , it is then possible to predict the relative position of every u i with respect to u i−1 , while the qualitative properties of the solutions will give us the relative position of u i with respect to f i . As a consequence, also in this case, we are able to write explicitly the Euler-Lagrange equation.
We observe that the price to pay for applying this method is that, in order to determine the solution of the minimization problem (1.5) for a certain valueλ , we first need to know it for all λ >λ . This, in the end, boils down to solve some equations (linear if p = 2), whose number can be roughly bounded above by k(k + 1)/2.
Finally, we would like to comment on the case p = 1. The reason why the strategy described above fails for p = 1 is because we cannot use the continuity of the map λ → u λ . Indeed, even if for p = 1 there is no uniqueness for the solution of the minimization problem (1.5) (see an example in Proposition 4.1), there is always a solution taking only the values that f takes (see Corollary 3.3). But this jumping behavior of the solution prevents us to use continuity arguments, which are at the core of the strategy sketched above. Although it could be possible to obtain a solution of the minimization problem (1.5) in the case p = 1 by comparing the value of the functional G over all the vectors v ∈ ℝ k of the form v i = f σ(i) , where σ : {1, . . . , k} → {1, . . . , k} (see Corollary 3.3), we are currently investigating the possibility to obtain a more efficient analytic method to fulfill the task.
The paper is organized as follows. After a brief recalling of the main properties of one-dimensional functions of bounded variation in Section 2, we devote Section 3 to stating and proving basic results we will need in the sequel concerning the solutions of our minimization problem. In Section 4, we illustrate with a simple case the different behaviors of the solution in the cases p = 1 and p > 1. Section 5 contains the main technical results needed to justify the strategy to determine the solution of the minimization problem (1.5) we describe. In Section 6, we conclude with an explicit example.

Preliminaries
In this section, we review basic definitions of one-dimensional functions of bounded variation. For more details, see [5,40]. Here we assume a, b ∈ ℝ with a < b.

Definition 2.2.
For u ∈ L 1 ((a, b)), its total variation in (a, b) is given by If |Du|((a, b)) < ∞, we say that u belongs to the space BV((a, b)) of functions of bounded variation in (a, b).
In this case, Du is a finite Radon measure on (a, b). ((a, b)). We define the jump set of u by The relation between the total and the pointwise variation is given by the following result. In the following, L 1 will denote the one-dimensional Lebesgue measure on ℝ.
Theorem 2.4. Let u ∈ L 1 ((a, b)) and define the essential variation of u by The infimum defining eV(u; a, b) in (2.1) is achieved and it coincides with |Du|((a, b)).
Theorem 2.4 allows us to single out some well behaving representative of a BV function.
is called a good representative of u.

The general structure of the solutions
This section is devoted to stating and proving some basic results concerning the solution of the minimization problem (1.4). Albeit some of these properties may be known, we present here the proofs for the reader's convenience.
We start by stating a well-known result about the jump set of the solution (for a proof see, for instance, [14]).
In higher dimension, the inclusion J u ⊂ J f has been proved in [16,56] in the case p > 1, while it is known to be not always true if p = 1 (see [22,31]). The above result allows us to study an equivalent finite-dimensional minimization problem in the case in which f is a piecewise constant function.

Corollary 3.2. Let f be a piecewise constant function in
Then any solution u of the minimization problem (1.4) is of the form

2)
where G : ℝ k → ℝ is the function defined by Thus, we now concentrate on the study of the minimization problem (3.2). The cases p = 1 and p > 1 turn out to be quite different. Heuristically, the difference lies in the fact that, in the first case, the two terms of the energy are of the same order while, for p > 1, the fidelity term is of higher order than the total variation. This leads to very different behavior of the solutions in the two cases.
Because of the strict convexity of the functional G for p > 1, the solution of the minimization problem (3.2) is unique, while for p = 1 we have lack of uniqueness (see Proposition 4.1). Nevertheless, it is possible to identify a solution with a particular structure. Proof. For any given quadruple of functions The result then follows by noticing that G restricted to any A t 1 ,t 2 for some function σ : {1, . . . , k} → {1, . . . , k} and that as desired.
We conjecture that, in the case p = 1, non-uniqueness of the solution of the minimization problem (1.4) happens only for a finite number of critical values of λ, where a continuum of solutions is present.
Definition 3.4. We will denote by u λ a solution of the minimization problem (3.2) corresponding to the value λ. This will be the solution if p > 1, while, for p = 1, it will be understood as a solution whose structure is those given by the previous result.

Remark 3.5.
It is easy to see that u i ∈ [min f, max f] for every solution u and that, in the case where p > 1 and f is not constant, it holds that u λ ∈ (min f, max f) for all λ > 0. In particular, for p > 1, the solution u λ can never be equal to the initial data f .
In the rest of this section, we seek to understand the behavior of the solution u λ in the limiting cases for λ, i.e., when λ ≪ 1 and when λ ≫ 1. In the former case the predominant term of the energy is given by the total variation, thus we expect u λ to minimizes it. We first treat the case p > 1.
Then, for any Proof. Assume that u λ is not constant and let i ∈ {1, . . . , k} be such that u λ i = min{u λ j : j = 1, . . . , k}. Let By hypothesis, either r > 1 or t < k. Consider, for ε > 0, the vector u ε ∈ ℝ k defined by u ε j := u j + ε for j = r, . . . , t and u ε j := u λ j for all the other j's. Then, recalling that u j ∈ [m, M] for all j = 1, . . . , k, we have that . This means that u λ has to be constant for λ <λ . Moreover, it is easy to see that the function G restricted to the set {(u 1 , . . . , u k ) ∈ ℝ k : u 1 = ⋅ ⋅ ⋅ = u k } admits a unique minimizer that is independent of λ.
We now have to prove that uλ is constant. Assume that u λ i ≡ c for all λ ∈ (0,λ ) and all i = 1, . . . , k. Let c ∈ ℝ k be the vector given byc =c and all λ ∈ (0,λ ), where the subscript λ is to underline the dependence of G on λ. By letting λ ↗λ , we get Gλ (c) < Gλ (v) for all v ∈ ℝ k and thus uλ =c .
In the case p > 1, the only thing we can say about the case λ ≫ 1 is that We now consider the asymptotic behavior of the solution in the case p = 1.
Lemma 3.7. Let p = 1 and let f : Then, for all λ ∈ (0,λ 1 ], every solution u λ of the minimization problem (3.2) is constant, while for all λ ≥ λ 2 the solution u λ is unique and is given by f itself.
Proof. We prove this lemma in two steps.

On the other hand, for any function
Then, for λ <λ , the above estimates show that u λ must be constant. Finally, in order to prove that also uλ is constant, we reason as follows: we know that u λ =c λ for λ ∈ (0,λ ), for somec λ = (c λ , . . . , c λ ) ∈ ℝ k . Take λ n ↗λ . Since c λ n ∈ [min f, max f], up to a not relabeled subsequence, we have that c λ n → c. We conclude that Step 2: the case λ ≫ 1. Suppose that there exists a sequence λ j → ∞ for which u λ j i ̸ = f i for all j's (this is possible since k is finite). By recalling that u λ j i ∈ {f 1 , . . . , f k }, we have, for λ j >λ 2 , that , contradicting the minimality of u λ j . Remark 3.8. Note that, unlike the case p > 1, when p = 1 and λ ≪ 1, we cannot conclude that there exists a unique constant c ∈ ℝ such that u λ ≡ c for all λ ∈ (0,λ 1 ].

Explicit solutions in a simple case
Here we study the case where k = 2. This analysis, albeit its simplicity, is important to underline some features that distinguish the behavior of the solution of the minimization problem (1.4) in the cases p = 1 and p > 1.
It is easy to see that we must have f 1 ≤ u 1 ≤ u 2 ≤ f 2 . Thus, we consider the region and we rewrite the function G in T as When minimizing G in T, we can drop the term c λ . Note that v λ = 0 if and only if L 1 = L 2 and λ = 1/L 1 . In this case we have ). The minimizers of G over the triangle T are thus simply given by considering the intersection of with a line orthogonal to v λ . In the case L 1 < L 2 , the vector v λ |v λ | spans the two colored regions in Figure 1, for λ ∈ [0, ∞). When in the grey region, namely when λ < 1/L 1 , the minimizer is given by (f 2 , f 2 ), while for λ > 1/L 1 the minimizer is given by (f 1 , f 2 ). Note that the non-uniqueness happens only when the vector v λ is orthogonal to {x = y} ⊂ ℝ 2 .
In the case p > 1 the landscape of the solutions is quite different.
The solution u λ of the minimization problem (3.2) is the following: Proof. Recalling that f 1 ≤ u 1 ≤ u 2 ≤ f 2 , we just have to consider the region T defined in (4.1) and to rewrite the function G in that region as The critical point of G is given by and it belongs to the interior of T, i.e., u λ 1 < u λ 2 , only for λ > λ p T . Since G is strictly convex, this critical value turns out to be the global minimizer of G for λ > λ p T . In the case λ ≤ λ p T , the point of minimum has to be on ∂T.
Instead of performing all the computations for finding the minimum point in all of the three edges of ∂T and to compare them, we will use the following argument based on the continuity of the minimizer u λ with respect to λ (see Lemma 5.1), i.e., we invoke the fact that the function λ → u λ is continuous. Note that for λ ↘ λ p T we have u λ → (ū,ū ), is independent of λ. By using the continuity of the solution, we can conclude that, for λ = λ p T , the solution of the minimization problem is given by (ū,ū ). The conclusion for λ < λ p T follows from the result of Theorem 5.3.

Remark 4.3.
We remark a couple of facts: (i) We have that λ p T → λ 1 T as p → 1 + (in each of the cases for the definition of the second one). Indeed, suppose that L 1 < L 2 . Then Similar reasonings lead to the claimed result in the other two cases. In particular, note that λ p T > λ 1 T . (ii) The solutions converge to a solution for p = 1, as p ↘ 1. Indeed, suppose λ > λ 1 T . Then for p sufficiently close to 1, from the above bullet point, we have that λ > λ p T . Thus, the solution of the minimization problem for p is given by (4.3). In this case, it is easy to see that the solution converges to (f 1 , f 2 ), as p ↘ 1. In the case λ < λ 1 T , we can assume as above that p is so close to 1 that the solution of the minimization problem for p is given by (4.2). If L 1 > L 2 , then In the case L 1 = L 2 , both coefficients are equal to 1 2 . Finally, in the case λ = λ 1 T , since λ p T > λ 1 T , we have that the solution of the minimization problem is given by (4.2). The result follows by arguing as before.

The behavior of the solution for p > 1
This section contains the main result of this paper, namely Theorem 5.3, that is derived from the qualitative properties of the solutions proved in the following two lemmas and in Proposition 5.5. Although the same result can be deduced by using the semigroup property of the total variation in dimension one [53], we prefer to get it from more elementary observations of qualitative nature on the behavior of the solution u λ when the parameter λ varies. These observations allow to predict how the solution behaves when the parameter λ varies.
We start by proving the continuity (with respect to the Euclidean topology of ℝ k ) of the solution u λ with respect to λ. Proof. Fixλ > 0 and let λ n → λ. Then G(u λ n ) ≤ G(v) for all v ∈ ℝ k , where equality holds if and only if v = u λ n . Since |u λ n | ≤ √ k‖f‖ ∞ , up to a (not relabeled) subsequence, we have that u λ n →v . Using the continuity of G in both v and λ, we have that G(v ) ≤ G(v) for all v ∈ ℝ k . By the uniqueness of the solution, we deduce thatv = u λ , and that u λ n → u λ for all sequences λ n → λ.
To prove the second part of the lemma, we reason as follows. Assume that u λ does not converge to f as λ → ∞. Since u i ∈ [min f, max f], by compactness, we obtain (up to a not relabeled subsequence) u λ → v for some v ̸ = f . In particular, there exists an index i such that This is the desired contradiction.
We now prove several qualitative properties regarding the behavior of the solution u λ as λ varies. Some of the following results could be stated in a more inclusive way, but since they can be used to deduce qualitative properties of the solutions when no direct analysis can be performed, for clarity of exposition we opt to present each of them separately.
In particular, in the case r = 0, we have (v) Assume that, for λ ∈ (λ 1 , λ 2 ), there exists a function λ →ū λ such that, for some r ≥ 0, see Figure 6. Then λ →ū λ is decreasing. In particular, in the case r = 0, we have (vi) Assume that, for λ ∈ (λ 1 , λ 2 ), there exists a function λ →ū λ such that, for some r ≥ 0, Figure 7. Then λ →ū λ is decreasing. In particular, in the case r = 0, we have (vii) Assume that, for λ ∈ (λ 1 , λ 2 ), there exists a function λ →ū λ such that, for some r ≥ 0, see Figure 8. Then λ →ū λ is increasing. In particular, in the case r = 0, we have Proof. We start by proving property (i). Suppose that u λ i−1 <ū λ < u λ i+r+1 . In the other case we argue in a similar way. By hypothesis, the vector u λ minimizes the function G in the set and in this set the function G can be written as By keeping u 1 , . . . , u i−1 and u i+r+1 , . . . , u k fixed, the claim follows by minimizing the above quantity with respect toū .
Since all the other properties can be proved with an argument whose general lines are similar, we just prove property (ii), leaving the details of the others proofs to the reader.
In the hypothesis of (ii), it holds that u λ is a minimizer of G in the set {(u 1 , . . . , u k ) ∈ ℝ k : u i−1 , u i+r+1 < u i = ⋅ ⋅ ⋅ = u i+r }.       Restricted to this set, the function G can be written as So, for λ ∈ (λ 1 , λ 2 ) and u 1 . . . , u i−1 , u i+r+1 , . . . , u k fixed,ū λ is the minimizer of the strictly convex function To study the minimizer of H, we can assume without loss of generality that f i < f i+1 < ⋅ ⋅ ⋅ < f i+r . Indeed, we note that the order of the f j 's does not matter. Moreover, in the case in which f p = f q for some p ̸ = q, we can simply collect the two terms in a single one and use L p + L q as a corresponding factor in the above summation. We now want to prove that λ →ū is decreasing. Note that the function H can be written as Here H (c) = 0 has a solution only if the term in the parenthesis is negative and if so, then let λ → c λ be such a solution. It is easy to see that this function is regular in (f m , f m+1 ). By differentiating the expression H m (c λ ) with respect to λ, we obtain Thus, by recalling that the term in the first parenthesis is negative, we get dc λ dλ < 0, as desired. In the case in which the minimizer of the function H is reached at a point c = f m+1 , we simply consider the function H and we apply the argument above.
Finally, the same reasoning applies when c ∈ [f i+r , max f).
We are now in position to prove the fundamental result we will use to develop our strategy for finding the solution.
Proof. We prove this theorem in two steps.
If i > 1, we can focus, without loss of generality, only on the following two cases: u λ i−1 > u λ i and u λ i−1 < u λ i in (λ − ε,λ ).
In the first case, we get a contradiction since by property (iii) of Lemma 5.2 the map λ → u λ i is decreasing in (λ − ε,λ ) and thus, as above, we cannot have uλ i = uλ i+1 .
In the other case, we have u λ i−1 < u λ i < u λ i+1 in (λ − ε,λ ). By using property (i) of Lemma 5.2, we see that this is possible only if u λ i = f i for all λ ∈ (λ − ε,λ ). This yields the desired contradiction.
Step 1 and the continuity of λ → u λ ensure that λ i is well defined. Moreover, by Lemma 3.6, we also get that λ i > 0 for all i = i, . . . , k − 1. Finally, the fact that u λ → f as λ → ∞ tells us that λ i < ∞ for all i = 1, . . . , k − 1. This concludes the proof. Finally, we derive another consequence of Lemma 5.2 that will ensure that the solution is monotone where f is and with the same monotonicity.
In particular, u has the following structure: u i+r for j = j 2 , . . . , k, A similar statement holds in the case f i > f i+1 > ⋅ ⋅ ⋅ > f i+r .
Proof. We prove this proposition in two steps.
Step 1. We claim that u i ≤ u i+1 ≤ ⋅ ⋅ ⋅ ≤ u i+r . Suppose that u j−1 > u j for some j ∈ {i + 1, . . . , i + r}. We have to treat three cases: u j < f j , u j = f j and u j > f j .
In the first case, we get a contradiction with the minimality of u λ since it is easy to see that for ε > 0 small. Now, suppose u j > f j and that u j > u j+1 . Then, for ε > 0 small, yielding the desired contradiction. Finally, we can treat all the remaining cases (namely when u j = f j or the case where u j > f j and u j+1 > u j ) simultaneously as follows: let us denote by j m ∈ {i, . . . , j} the minimum index r such that u r > u r+1 . In both cases we have u j m > f j m , and thus for ε > 0 small.
Step 2. Using Step 1, we have that Since this value is invariant under modification of u λ j for j = i + 1, . . . , i + r − 1, if we keep u i and u i+r fixed, the minimality of u λ implies that This proves the second part of the statement of the proposition.

A method for finding the solution
In this section, we describe the method we propose in order to identify the solution of the minimization problem (3.2). The general idea is, for every λ > 0, to be able to tell a priori the relative position of each u λ i with respect to u λ i−1 and f i . Knowing that allows us to (i) know if the minimization of G has to take place in some subspace and hence if we have to reduce the number of variables G depends on; (ii) write explicitly the absolute values present in the expression of G. If we are able to do that, we can reduce the problem of minimizing the functional G to the problem of minimizing a strictly convex functional of class C 1 , and thus the minimizer can be found by solving the appropriate Euler-Lagrange equation. Let Step 0: initialization. For every i ∈ {2, . . . , k} set Finally, sets and, for every i ∈ {2, . . . , k − 1},s Step 1: Solving the Euler-Lagrange equations. Consider the functionalG : Find a solution u λ i of the i-th Euler-Lagrange equation of G. Note that in the case p = 2 this is a set of k − T linear equations. In the cases i = 0, set u λ i := f i . It can happen that sgn(f i − u λ i ) changes when varying λ. In that case we have to changes i .
Step Step 4: Cycle. Repeat Steps 1, 2 and 3 until T = k or λ ≤λ . The algorithm terminates after, at most, k iterations. Since at every step we have to solve k − T equations (linear in the case p = 2), the complexity of the algorithm is O(k 2 ).
Example. We illustrate the above strategy with a concrete example.