Martin Eller and Massimo Fornasier

4Rotation invariance in exemplar-based image inpainting

This work is respectfully dedicated to the Memory of Vicent Caselles who showed kindness to one of us.

Martin Eller, Graduate School for Computational Engineering, Technische Universität Darmstadt, Dolivostrasse 15, 64293 Darmstadt, Germany, e-mail: 13

Massimo Fornasier, Faculty of Mathematics, Technische Universität München, Boltzmannstrasse 3, 85748 Garching (Munich), Germany, e-mail: [email protected]

Abstract: Because of their good performance on textured images, exemplar-based methods for image recovery have been the subject of research in recent years. In this work, the variational framework of exemplar-based inpainting is reviewed and enriched by rotation invariance as an additional degree of freedom in patch searching. For an efficient rotation invariant comparison of image patches we present methods based on sampled Circular Harmonics (CH) expansions, in particular, we also elaborate a method for gradient-based comparisons thanks to the property of CH of being eigenfunctions of the Laplacian. These new pattern matching methods allow for an extremely efficient implementation of the alternating optimization scheme of exemplar-based inpainting, also when rotation invariant patch matching is considered. The patch non-local means algorithm and its performance in the recovery of image structures and textures are described in detail and we demonstrate by numerical examples the significant improvement in recovering smooth edges, which is due to the additional rotation invariance.

Keywords: Exemplar-based inpainting, rotation invariance, circular harmonics, fast Fourier transform, variational methods, alternating minimization algorithms

Mathematics Subject Classification 2010: 68U10, 94A08, 42C10, 65T50, 49J40, 65K10

4.1Introduction to inpainting

4.1.1The inpainting problem

An important task in image processing is the process of filling in missing parts of damaged images or object removal. Usually the information is obtained from the surrounding parts of the image. This problem, which basically can be seen as an interpolation task, is called image inpainting. The inpainting problem treats the question of how to construct an image u on the image domain Ω 2, when image data is not available inside some (damaged) domain O Ω, called the inpainting domain or hole, and one only possesses image information û outside the hole, that is in Oc = Ω O (Figure 1). Usually one considers the case where u = û in Oc.

Fig. 1: The inpainting problem. The task is to find a reconstructed image u which is supported on the image domain Ω 2, lacking the image information in the inpainting domain O. The image data û is only available in Oc. Typically, one considers the restriction constraint u|Oc = û.
4.1.1.0.1 Applications

Among a wide range of applications, digital image inpainting is used for the restoration of ancient paintings [10], an automated scratch removal in old photographs and films, and for text (subtitles, date stamps, etc.) or object removal in photo and video editing [13, 19, 21, 42]. More special applications are concerned with zooming or superresolution of images [19], removal of laser glares in video-sequences [20], and even CT raw data inpainting in X-ray imaging [35].

4.1.1.0.2 Different approaches

Lately, image inpainting has become an active field of research in the mathematical image processing community. In the past years, several different approaches have been used and a large variety of methods have been proposed. These methods can roughly be divided into two groups: geometry-oriented and texture-oriented or exemplar-based methods. We shall give a brief overview on different methods which have been developed.

4.1.1.1Geometry-oriented methods

Geometry-oriented methods are often based on modeling the reconstructed image as the solution of a partial differential equation (PDE). Pioneering works include the work by [17], where an approach on image interpolation was introduced, a level lines-based method presented by [45], and the work by [13]. Inspired by these early papers, the geometry-based methods have been extended to different applications and, inspired by physical processes [15] or variational techniques, other models have been introduced. [19] proposed a regularization term, taking into account the total variation. Later this idea was extended by [53] who presented a framework for arbitrary vectorvalued regularization techniques. The PDE-basedmethods have been extended for application to video-sequences [20], for application on ancient frescoes, cf. [10], and to encounter higher order PDEs [49].

Geometry-oriented methods are local in the sense that in their discretization the value of each pixel is only dependent on values of the neighboring pixels. As a consequence, among all the data available throughout the image domain these methods only use the data obtained from the boundary of the inpainting domain to accomplish the inpainting task.

In general, these methods show good performance in the propagation of gradients or smooth level lines. However, they fail in the presence of texture and are therefore also often referred to as cartoon inpainting, cf. [24].

4.1.1.2Exemplar-based inpainting

In his 1948 article on A Mathematical Theory of Communication Claude Shannon introduced an interesting way of producing English-sounding written texts using n-grams (a sequence of n characters from a given sequence of text), cf. [50]. The English language is modeled as a Markov chain: an n-gram is assumed to completely determine the probability distribution of the next letter. Using a large sample of the language (e.g., a book) one can build up a library of probability tables for each n-gram.

In their work, which received much consideration afterwards, [27] generalized this idea to images by interpreting image texture as a statistical model, where the value of each pixel is statistically determined by its neighborhood. This concept was picked up and further analyzed by [55] and justified in terms of probability theory by [44]. [21] applied the concept to inpainting problems like object removal. Although we focus on inpainting it is worth mentioning the groundbreaking paper by [16], which introduces the non-local means method for image denoising, and has been followed by other relevant contributions, cf. [40, 47, 58]. Non-local means can also be re-interpreted as a diffusion process over the high-dimensional graph of the exemplar patches [52].

Differently from geometry-based inpainting, the texture-based methods are allowed to scan the whole image and, therefore, are non-local methods. They are often referred to as exemplar-based approaches, since exemplars from outside of the inpainting region are used for the inpainting task.

As was pointed out by [22] the exemplar-based inpainting task can be interpreted as the process of finding a correspondence map Γ : O Oc, which for each point x in the inpainting domain O assigns a position Γ(x) Oc where the image is known. The inpainted image is then given by copying the image information from Oc into O according to the correspondence map Γ (Figure 2). The algorithms by [27, 55] are greedy methods for the computation of a suitable correspondence map, since each pixel in

Fig. 2: The image displays the setting of exemplar-based inpainting. The region O ̃ Ω is considered to be the set of all centers whose patches intersect with O. (The size of the set thus depends on the choice of the patch radius.) Also a correspondence map is displayed: For a good inpainting image the patch around x O ̃ should look similar to the one around y = Γ(x) Õ c.

the inpainting domain is visited only once. As was shown by [21] the quality of the result heavily depends on the order in which the pixels are processed.

In order to realize the computation of a suitable correspondence map Γ, [22] propose the minimization of the following functional

where Ωp 2 denotes the patch domain, a bounded set centered in (0, 0). The diameter of the patch domain is a parameter which should be chosen such that it matches the size of the textures in the image; we will discuss this issue in Section 4.3.3. The solution u to the inpainting problem is then given by u(x) = û(Γ(x)), for x O.

The functional in (1.1) has been further analyzed by [8] and extended to piecewise roto-translation maps. The authors state that the energy functional (1.1) is highly non-convex and no efficient way is known to compute its minimizer(s).

In order to compute at least surrogate minimizers, a relaxation of (1.1) was introduced by [38, 56]. The relaxed functional then reads as

where Õ := O+Ωp is the set of all centers of patches which intersect with O (Figure 2). The authors propose an alternating optimization scheme as an iterative approach to compute minimizers and as a consequence, the unknown image is then determined in the course of the optimization process and not limited to the constraint u(x) = û(Γ(x)), for x O, see also Section 4.3.1.1. The minimization of (1.2)with respect to Γ, whenever u is fixed coincides with the computation of the best-matching patch in the L2-norm.

This model has been the subject of further analysis by [4, 5], where existence of minimizers and convergence of the alternating optimization scheme to critical points of the functional in (1.2) was proven. Furthermore, other error functions apart from the L2-normhave been introduced, whichmeasure differently the distance of the patterns on two patches and also interfere with the image synthesis. We will gain further insight into this matter in Section 4.3.

The non-local exemplar-based approach of [27, 55]; has also found applications in other fields of mathematical image processing. In [9, 39, 41]; the concept has been applied to image denoising and [34] used it for the regularization of inverse problems in imaging. In contrary to the image inpainting task, one explicitly wants the contribution of multiple patches from different locations in the image. Hence, the appropriate correspondence maps are not one-to-one, but one-tomany (or fuzzy), and usually represented by a weight function w: Ω × Ω , where Ω is the image domain and for each x, w(x, ) represents the weight of the contribution of each image location to the point x.

Picking up this idea, [4, 5] also present an analysis for the variational framework for exemplar-based inpainting with fuzzy correspondence maps, which can be seen as an inpainting task with a certain denoising effect, depending on a regularization parameter T (see Section 4.3 for details).

Exemplar-based inpainting methods yield impressive results in recovering textures and repetitive structures. Unfortunately, their ability to create nice geometry without an example is limited and not well understood (Section 4.3.3). Combination of geometry-oriented and texture-oriented methods has been tried, but most results require human intervention or lead to a split in the image between structure/ cartoon and texture components 0 (see, e.g., [24]).

4.1.2Aims of this work

In the summary of the previous section, we concluded that exemplar-based inpaintingmethodsmay have difficulties in reproducing geometry whenever there is a lack of suitable exemplars. In this work we want to enrich the capability of exemplar-based inpainting methods presented by [4, 5] with an additional degree of freedom, by allowing the algorithm to rotate the available patches by arbitrary rotation angles. As a consequence the variety of available patches is heavily increased and thereby the potential of the algorithm to recreate geometry and structure is enhanced. For instance, whenever the edge of a round object is presented as damaged and there are no other similar portions around, the ability to rotate patches is of utmost importance for a successful reconstruction of the image, as we can see in the following example in Figure 3, where an algorithm without rotations (NR) is compared to a rotation invariant one (R).

For this purpose, we will introduce in Section 4.2 new error functions, measuring how the patterns of two patches coincide, which additionally incorporate rotation invariance. Thereafter, we shall present an efficient method for fast computation of these error functions based on the Circular Harmonics expansion (see Section 4.2.2.3). These methods are inspired by the work of [32], where a mathematical approach is presented to reorganize fragments of famous Italian frescoes by A. Mantegna, which were destroyed during World War II.

Fig. 3: First row, from left to right: (a) Inpainting problem. The inpainting domain is indicated by the gray box. (b) Zoom on the initialization of the inpainting domain. The initialization is already close to the original image shown in (c). Second row: Inpainting results, without rotations (d) and under consideration of rotation (e).

In Section 4.3, issues related to the practical implementation of rotation invariant exemplar-based inpainting algorithms will be discussed and results of numerical experiments will be presented.

We shall conclude our work with a thorough analysis of the different variational models and their associated functionals. We shall prove the existence of minimizers to functionals similar to (1.2), but additionally incorporating the rotation invariant error functions from Section 4.2, and examine the properties of these minimizers in Theorem 4.6 and Propositions 4.1, 4.7, and 4.13. Furthermore, the alternated optimization of these functionals will be the subject of investigation and we will show convergence to critical points of the respective energies in Propositions 4.10, 4.12, and 4.18. To round up Section 4.4, we give some concluding remarks and discuss future work.

Let us briefly go through some of the relevant original results which are developed in this work.

Although in the literature rotation invariance in non-local image recovery has already been considered, for instance by [41], in their work, because of the computational costs, the authors used only a discrete set of rotation angles. In the numerical experiments, for instance, they used rotations of 0, 90, 180, and 270, because they can be quickly computed on rectangular image grids. Their results in non-local denoising are nevertheless dissatisfactory [41, Section 3.2, in particular Figure 9], precisely because of the use of discrete sets of angles, which are really way too coarse to be considered an effective additional degree of freedom. In this work not only do we allow for arbitrary angles, but our procedure also has a computational cost in practice, which is comparable with the one of considering only four discrete angles, see Section 4.3, in particular Subsection 4.3.1.3 for the details. Let us additionally stress that our method is FFT based in the patch search and it has complexity ?(r2Mlog(M)), where r > 0 is the radius of the circular patch and M is the number of pixels in the searched image, see 32, pag. 2081, for the detailed computation of the complexity. This is precisely the same complexity as the PatchMatch algorithm by [11, 12] without implementation of any rotation invariance! Moreover, the library we implemented is fully parallelizable on clusters of computers, since the program is based on a client/ server architecture. The client sends individual patches to an available server for the patch to be compared to all possible patches in an image, considering arbitrary mutual rotations. Our numerical results show dramatic improvements in geometry recovery thanks to the use of arbitrary angles (Figure 3 and further examples in Section 4.3.3).

A further original result is the extension of the analysis in [4, 5], where rotations were not yet incorporated. In this work, the analysis is developed very carefully and in detail for the case of arbitrary rotation angles. In particular, following the tracks of the proof of the fundamental lemma [4, Lemma 1], we not only extend the proof to rotation invariance but, for the sake of providing an easy-to-read review, we take the liberty of developing the details of the proof, which was given in a slightly more sketchy way in [4, 5].

The implementation of the rotation invariant matching is built upon the library written by M. Fornasier for the Mantegna project, cf. [18, 32]. However, the application to exemplar-based inpainting required many different improvements and modifications, which are elaborated in detail in Section 4.2. In particular, we introduce an efficientmethod for the comparison of two patches in a weighted L2-norm,whose weight function is rotation invariant. The computation of the matching coefficient in [32] is extended by the Circular Harmonic moments, whose angular frequency index m = 0, and without much further computational cost the precise L2-scalar product between the two patches is computed for the best rotation angle. This allows for an approach to the so-called patch non-local means scheme of exemplar-based inpainting (cf. (2.2), Section 4.2).

Finally, we elaborate an efficient and precise approach for the treatment of gradient-based patch comparison exploiting the property of the Circular Harmonics of being eigenfunctions, not only of rotation operators, but also of the Laplacian. In Section 4.2.5 we present a novel approach for the comparison of the gradients of two patches in a weighted L2-norm, whenever the weight functions are suitably chosen. For the application to exemplar-based inpainting, this permits an efficient approach in the rotation invariance setting for the so-called patch non-local Poisson scheme, which was introduced in [5] without considering rotations. Because of the diagonalization of the Laplacian provided by the Circular Harmonics, our gradientbased patch comparison method has a similar computational cost as the weighted L2-norm approach from above. In particular, thanks again to the eigenfunction properties, the gradient of the patches is evaluated analytically and no finite difference approximations are needed.

4.1.3Notation

Gray-scale images are denoted as functions u, û : Ω [0, 1] , where Ω denotes the image domain, usually a rectangle in 2. Pixel positions are denoted by x, y, z or h, the latter for positions inside the patch. A patch of u centered at x is denoted by pu(x) := pu(x, ) : Ωp , where Ωp is a disk of radius r centered at the origin, that is Ωp = Br(0). The patch is formally defined by pu(x, h) := u(x + h), where h Ωp. Sometimes we will abbreviate px := pu(x) and rotations by an angle θ of a patch px will sometimes be denoted as px,θ. As shown in Figure 1, O Ω is the hole or inpainting domain, and Oc := Ω O. Usually we will denote by u the part of the image inside the hole, while û is the part of the image in Oc. Furthermore, we define Õ , the extended inpainting domain, as the set of centers of patches that intersect the hole, that is Õ := O+Ωp = {x Ω: (x+Ωp)O ≠ 0} and Õ c := ΩÕ . Then patches pû (y), centered in y Õ c, are entirely outside of O (Figure 2). Additional notation will be introduced in the text. We assume for the reader a certain level of familiarity with Fourier analysis, function spaces (Lebesgue spaces Lp, Sobolev spaces Wp,k, the space BV of functions of bounded variation ...), partial differential equations (Poisson equation ...), variational methods (compactness arguments, such as the direct method of calculus of variations, weak convergences ...). Nevertheless, for the more advanced results, we provide specific references to ensure a fully conscious reading also to non-experts.

4.2Rotation invariant image pattern recognition

As we have seen in the previous section, an important task in mathematical image processing, particularly in exemplar-based image inpainting, is the comparison of image patterns. In this section we want to discuss ways to find the best-matching patch to a given patch, out of a pool of possible patches with a certain image pattern. In Section 4.2.1 we will introduce different patch error functions that penalize deviations of the patterns of two patches. In the subsequent subsections we will present an efficient method to compare patches in the L2-norm. The methods described here use the rotation invariance properties of the Circular Harmonics basis for an efficient and robust computation of the similarity of two patches.

4.2.1Patch error functions

The underlying idea of exemplar-based image inpainting is that the value of a pixel is statistically dependent on a set of pixels around it, cf. [27, 44, 55]. Thus, the comparison of patches plays a crucial role. This intrinsically leads to the question: By which error function should the similarity of patches be measured?

Patches are functions defined on Ωp 2 and that live on a suitable space X which suits the error function to which it is associated. In our setting Ωp should be chosen to be the open disk of radius r with center in the origin, Br(0), as the natural choice for a rotation symmetric patch domain. We shall now discuss some possible choices for error functions ϵ : X + {0}. Furthermore, we add additional degrees of freedom by admitting the choice of an intra-patchweight function g : Ωp +. The intra-patch weight function g should also be radially symmetric, that is g(h) = g(|h|). As an example, we may think of

the bivariate Gaussian probability density function with zero mean and isotropic standard deviation σ.

Let us define the rotation operator, acting on a function f(ρ, θ) in polar coordinates (ρ, θ) for an arbitrary angle α as Rαf(ρ, θ) = f(ρ, θ + α) and, for later use, the rotation map of angle α around the origin rα(x) : 2 2, (r, θ) (r, θ+α), such that Rαf(x) = f (rα(x)).

Here are some examples of patch error functions which include rotations:

4.2.1.1Patch non-local means

A square penalization term is used for the pixel-wise error. As a result the patch error function becomes a weighted squared L2-norm.We write:

In this case we set X = L2(Ωp). For g 1 the patch non-local means error function reduces to the usual squared L2-norm. The scalar product associated to this Hilbert normed space will be denoted as ⟨, g and is equal to or ⟨g, ⟩ whenwritten in terms of the usual L2-scalar product. The g-weighted L2-norm will also be denoted as g.

4.2.1.2Patch non-local medians

The penalization term for the pixel-wise error is taken to be the absolute value | |. As a result the patch error function becomes a weighted L1-norm. We write:

In this case we set X = L1(Ωp). For g 1 the patch non-local means error function reduces to the standard L1-norm.

Furthermore, one can use gradient-based error functions. These error functions are able to find matching patterns even if they differ by additive brightness.

4.2.1.3Patch non-local Poisson

A square penalization term is used for the pixel-wise gradient error. As a result the patch error function becomes

In this case the natural choice for X is W1,2(Ωp). The g-weighted L2-norm of the gradient will also be denoted as g,.

4.2.1.4Patch non-local gradient medians

If we choose X = W1,1(Ωp), the corresponding patch error function is

In principle the above error functions can also be linearly combined or carried to Lp, p 1.

In the variational framework of exemplar-based inpainting the patch error function is not only used as a criterion for the similarity of patches but also determines the image synthesis. It therefore plays a crucial role which we will further investigate in the subsequent sections.

Since, for a given patch px, we want to compute the best-matching patch py,θ, where the best rotation angle θ is not known a priori, an efficient algorithm should not be based on a pixel-by-pixel comparison but rather employ an expansion in a suitable basis. In this work we restrict the further analysis to the case of error functions derived from the L2-normsince they can be calculated efficiently using the Circular Harmonics basis. For general results with error functions based on the L1-norm the interested reader is referred to [5]. Another approach for the computation of best-matching patches is the PatchMatch correspondence algorithm by [11, 12].

4.2.2Circular harmonics basis

4.2.2.1Definition and basic properties

For a thorough introduction of the Circular Harmonics, we consider the Laplace eigenvalue problem on a disk of radius r with Dirichlet boundary conditions

From (2.4) we obtain a sequence of eigenfunctions (ψi)i with eigenvalues λi which, when normalized, form an orthonormal basis for L2(Br(0)).

The system of eigenfunctions to the above problem can be identified with the compactly supported Circular Harmonics functions on Br(0), which,whenwritten in polar coordinates (ρ, θ), read as

where Jm denotes the Bessel-functions of first kind and order m, (jm,n)n denotes the (increasing) sequence of the positive roots of Jm, see [54] for details, and cm,n the normalization constant. Furthermore, the eigenvalues associated to em,n,r are well known, and explicitly given by

A crucial observation is that the Laplace operator commutes with the rotations Rα. As a consequence the em,n,r are simultaneously eigenfunctions of both operators. In particular, for (m, n) ×we have

This property (referred to as self-steerability in [6]) will be of utmost importance for the detection of the mutual rotation when comparing the image pattern on two given patches.

As we can see in Figure 4 the Circular Harmonics possess a certain structure with respect to radial and angular frequencies. With increasing m the term eimθ in (2.5) causes increasing oscillatory behavior in θ, whereas with increasing n the radial frequency increases. Also, the Fourier transform of a compactly supported Circular Harmonic function em,n,r L1 has a fast decay in its radial direction (em,n,r(ρ, θ) ρ5/2) and has its predominant frequencies at radial distance jm,n/r [29, 57], see also Figure 5. We will now discuss why these properties are important once the Circular Harmonics are sampled and applied to discrete signals.

4.2.2.2Sampling of circular harmonics

For our purpose, the application to digital images, the Circular Harmonics will not be used in the continuous setting, but in the discrete one. An important and classical result in the theory of digital-to-analog signal conversion, which guarantees an errorfree passage from continuous to discrete signals, is Shannons sampling theorem. It gives a relation of the sampling rate necessary to obtain the full information of a signal f after discrete sampling to its band-width, that is the localization of its Fouriertransform (f). We recall that the one-dimensional Fourier-transform of a signal f is given by

Fig. 4: [32]. Real part of some compactly supported Circular Harmonics, ordered by angular (abscissa) and radial (ordinate) frequencies, depending, respectively, on the parameters m and n .

If the Fourier-transform of f is such that F (f)(ω) = 0 for all |ω| B, B > 0, then the sampling theorem states that f is completely determined by giving its ordinates at a series of points spaced one from the other [51]. Functions, whose Fourier-transform fulfills the above condition, are also called bandlimited functions. The theorem easily extends to higher dimensions, simply by tensor product. As a corollary of the sampling theorem, the scalar product of bandlimited functions f, g, is preserved under sampling, that is , see [31, Theorem 3.4].

If functions are not suitably bandlimited, that is the sampling process violates the above bound established by [51], signals, which were different before the sampling, become indistinguishable (or aliases of one another) when sampled. In signal processing this ambiguity is referred to as aliasing. For a more thorough introduction to aliasing we refer to [46].

In Section 4.2.2.1 we have seen that the Circular Harmonics are not bandlimited, but their Fourier-transforms have a fast decay in radial direction. Choosing suitable norms to measure the tails of the Fourier-transforms we can estimate the aliasing error, the distortion of a signal under sampling, details in [29, Sections 2, 3], and [31, Thm. 3.4]. As a consequence for any desired precision ε > 0 and any radius r there exists a sampling rate τ > 0, that is a sampling grid τ2, and a frequency set Φr,ε containing frequency pairs (m, n) such that the corresponding em,n,r have an aliasing error which can be controlled by ε. Here, on purpose and for the sake of a more concise presentation, we do not wish to discuss the details of the sampling theory applied to Circular Harmonics, but limit ourselves to just stating the fundamental facts. We will denote these sampled functions with s for sampled whenever it is important to stress the difference to their corresponding analog versions. Analogously denotes the sampled disk

Fig. 5: [32]. Absolute value of the Fourier transform of the compactly supported Circular Harmonics function e3,2,10. The predominant frequencies are at radial distance j3,2/10 fromthe origin. The fast decay in radial direction is visualized.

For an adequate choice of ε > 0 (and thus of sampling rate τ > 0 small enough so that is affected by small aliasing errors) we have that

and thus forms a near-orthonormal system, which implies that thesampled functions remain linearly independent. If we choose (note: this is not possible for arbitrary ε) the system Φr,ε is a frame for (see, e.g., [30] for the definition of a frame and some of their properties). Examples for admissible frequency sets of Circular Harmonics functions can be seen in Figures 4 and 6.

Fig. 6: Example of a frequency set Φr,ε defined as the set of couples (m, n) such that for m 0, ε = 0.1, τ = 1, and r = 15. The points with m = 0 (white) are not needed for the detection of the best rotation angle, for negative ms the set is the mirror image of the positive branch with respect to the line m = 0.
4.2.2.3Self-steerability of sampled circular harmonics

Again as a consequence of [31, Theorem 3.4], the self-steerability can be carried over to the case of discrete compactly supported Circular Harmonics in an approximate way: For any rotation operator Rα and suitably bandlimited function f we have that

holds for all (m, n) Φr,ε. As announced before, this property will be used to detect mutual angles when checking for similarities in the patterns of two patches.

Since image data, in gray levels or the separated color RGB channels, can be interpreted as a function with real values, we shall only be using the positive moments.Indeed, for real signals we have

and thus no additional information is obtained from the moments m < 0. Furthermore, the moments for m = 0 are rotation-invariant and thus redundant for detection of mutual angles. To calculate mutual angles it hence suffices to include pairs of (m, n) in Φr,ε which have m > 0.

We are now ready to discuss algorithms that detect mutual angles for matching patterns.

4.2.3Mutual angle detection algorithms

In this section we will get to know algorithms which detect mutual angles between image patterns on disk patches. We shall start with an ideal method to better grasp the rotation invariance properties of Circular Harmonics. Thereafter we shall describe a method for mutual angle detection based on CH-moments which was introduced by [32].

For the remainder of this section we will without loss of generality assume the sampling grid size τ = 1. Furthermore, we have seen above, that the finite dimensional system is almost orthonormal and spans a #Φr,ε-dimensional subspace of which we will denote as ?Φ. Increasing the dimension of ?Φ by adding more (m, n)s to Φr,ε yields a larger space which spans more signals f, in particular those with very high oscillatory components, however this deteriorates as well the precision ε > 0 and in particular the faithfulness of the approximations in (2.9), due to larger aliasing errors. A suitable choice of Φr,ε spans well a broad variety of bandlimited functions and at the same time guarantees practically negligible aliasing errors. We will use the approximation symbol in this view. Equation (2.9) hence ensures an (almost) error free passage in angle resolution from the continuous to the discrete setting for any function in ?Φ.

4.2.3.1Idealized matching coefficient

An ideal matching coefficient comparing two patches should fulfill the following properties: It should detect the mutual rotation angle between the patches independently of the original mutual rotation. Hence, we do not want to restrict to any discrete set of angles. Additionally, it should provide a measure of how similar the patterns of the two patches are to each other. Of course, robustness to noise is also a requirement, since we have to deal with the aliasing errors which are due to the discretization of the Circular Harmonics, and noise can also be assumed a priori on the image. Of course, an efficient calculation is desired. Its plenty to ask, but we shall show now that all of these wishes are indeed realizable.

A possible definition for a matching coefficient comparing two functions px L2(Br(0)), py L2(Br(0)) considering a rotation angle θ is given by

It fulfills the following properties which show the independence of the rotations of the patches at the start:

where the second property is due to (2.9). Furthermore, the matching coefficient is independent of multiplicative brightness, that is for λ , λ > 0, M(λpx , py , θ) = M (px , py , θ).Moreover, since both p x and py are non-negative functions, we have that 0 M(px , py , θ) 1 (by CauchySchwarz inequality and Rθpx2 = px2), where M(px , py , θ) = 1 if and only if λRθpx = py for some λ > 0.

We have mentioned after (2.10) that we can exclude the moments m 0 from the detection of the best-matching angle. In fact, the contribution of moments for m < 0 are precisely the same as the ones for m > 0 when considering M (px , py , θ) and thus yield no further information. Excluding the moments with m = 0 makes the matching coefficient independent of constant additive brightness, and even of additive radially symmetric functions ϕ, that is ϕ(r, θ) = ϕ(r), since they are only spanned by the (e0,n,r)n.

As a consequence px and py must not be in ?Φ to obtain information about their mutual angles. The information obtained from their orthogonal projection to ?Φ yields as much information as including the corresponding moments m < 0 and the moments m = 0.

Therefore, let us assume without loss of generality that px , py ?Φ for px , py real valued signals. From (2.9) we deduce that

where denotes the (discrete) CH-moment of the corresponding Circular Harmonics function em,n,r and Re[c] the real part of a complex number c. In view of this equation

For a practical computation of the best-matching coefficient, when one wants to find the angle which maximizes it, one needs a relatively fine angle resolution and to apply a maximization search over (2.13). In the subsequent section we will investigate an even more efficient way to detect mutual angles.

4.2.3.2Matching coefficient via circular sum

Let and be defined as above. Furthermore, let

and likewise

Again, we want to find θ [0, 2π] such that the scalar product ⟨Rθpx , py2 is maximal. For real valued patches, the scalar product can be rewritten as the sum ofthe scalar products Thus, for every m we would like to find the rotation angle θ = θ(m) such that the real part of the scalar product is maximized. We have the following result:

Assume that

then a rotation angle of α applied on is the one which maximizes the real part of over θ [0, 2π], since

and for all θ [0, 2π].

In this way, the scalar products for different m > 0 each suggest a possible good rotation angle. Iteratively considering all contributions of different ms (suitably weighted with their respective norms) we expect to compute a successive approximation and correction of the best-matching rotation angle θ. Let us formalize this idea and introduce the circular sum operation to rigorously define the procedure.

Let us first consider the operator k:

For an integer m > 0 we define the circular sum operation on υ1, . . . , υm {0} by:

For m {0} and a sequence υ1 = ρ1eiα, . . . , υm = ρmeimα, with ρk > 0 for all k = 1, . . . , m and α [0, 2π], the circular sum detects α in the following way:

This motivates the following definition [32]:

We note that due to the (almost) orthonormality in (2.8). The factor which multiplies the scalar product leads to a suitable weighting of the different proposed angles and thus to a more robust angle detection,since for small values of one might not want to trust the detected angle as much as the one of more prominent terms, cf. [32].

Motivated by (2.17) the mutual angle is then given by θ = arg(M(px , py)). The circular sum and the process of rotating back by the angle calculated so far guarantee that the calculated matching coefficient |M(px , py)| and rotation angle arg(M(px , py)) are independent of the mutual rotation as follows:

Furthermore, we have that 0 |M(px , py)| 1 (by CauchySchwarz inequality) and|M(px , py)| 1 if and only if there exists λ > 0 such that for all k = 1, . . . , m. The circular sum has additionally an intrinsic auto-correction property: The error on the angle αk at some k step of the circular sum is compensated by the next term k + 1. To illustrate this, we consider the following example, where υk = eikα, k = 1, . . . , m 2, m, and υm1 = ei((m1)α)+δα. Then

If 0 < δα 1 and m large enough, a small-angle approximation yields

and in any case one obtains

for some λ [0, 1]. Thus, the correction term eiλδα always has the opposite phase sign to the error eiδα done in the step before. This property ensures a certain stability to noise and robustness of the procedure, since especially for larger k when the aliasing errors become larger the auto-correction property ensures a rigid result. The detected angles of small ks tend to be very accurate due to the particular circular oscillation behavior of the Circular Harmonics (see (2.5)).

We will now use the quantities here introduced by means of the Circular Harmonics to measure the error between two patches in error functions which are interesting for the inpainting task.

4.2.4Rotation invariant L2-error using the circular harmonics basis

In this subsection we will discuss the calculation of L2-norm errors between two image patches for any mutual rotation using the Circular Harmonics basis. Here we may assume that the best-matching angle θ has already been computed as described in the previous section. We will first work with the standard L2-norm and thereafter we consider weighted L2-norms.

4.2.4.1Constant weight

The term can fruitfully be rewritten as

Since the only term depending on the angle of rotation θ is the scalar product. Let us define

where denotes the CH-moment associated to the corresponding basis function em,n,r. Analogously we define Then we have

Because of the orthonormality of the Circular Harmonics and the linearity of the rotation operator Rθ we can rewrite the scalar product as follows

Using the self-steerability property (2.6) we have

If px and py are real-valued functions, we can use (2.10) to calculate the real part of the scalar product for m < 0 with the corresponding scalar product of the positive m = |m|. Let m > 0 and θ [0, 2π], then

and therefore Re so that

As mentioned above, for p x, py we can restrict the above computations, up to negligible aliasing errors, to finite-dimensional spaces spanned by em,n,r with (m, n) Φr,ε to calculate Re⟨px , Rθpy⟩. When the computation is run after the calculation of M (px , py), see (2.18), to detect the best-matching angle θ, an approximate calculation of (2.24) can be done reasonably fast, since are already calculated for a suitable frequency set Φr,ε,which includes only em,n,rswhose m 0. The formula then is

where are defined as

4.2.4.2Intra-patch weight function g

In the variational framework of exemplar-based inpainting the error norm is closely linked to the image synthesis process. It can be useful to choose an intra-patchweight function g that describes the importance of the information gathered from different points in the patch. As an example, one may think of a Gaussian weight. We will gain further insight into this matter in later sections.

Let us therefore consider the Patch Non-local Means error function as in (2.2) which incorporates an intra-patch weight function g. We recall that for our purpose g : Ωp + should be radially symmetric, that is g(h) = g(|h|).

Since

the only dependence on θ is again due to the scalar product.

If we assume the rotation angle θ to be known, we could compute the scalar product as follows:

where the second equality is due to the fact that g = g(|h|) is a function solely depending on the radial part of the argument and to the orthogonality of eimθ for m ≠ m. Furthermore, we have that

and since only the real part is of interest, this reduces again to

In the discrete case for suitable px, py it is again possible to work on a finite-dimensional subspace spanned by em,n,r where (m, n) Φr,ε and one would obtain a formula similar to (2.25) which has summands of the form

For the detection of the optimal rotation angle θ we will use a slightly different circular sum procedure than described before. It will be based on subspace scalar products of the form to compliment the calculation of the g-weighted scalar product. For that we define the following matching procedure

It is easily seen that this matching coefficient fulfills similar properties as the matching coefficient defined in (2.18), which are 0 |M(px , py)| 1 and |M(px , py)| 1 if and only if exists λ > 0 such that where θ̄ = arg(M(px , py)), for all k = 1, . . . , m. Furthermore, M g(px , py) possesses the same stability properties as M (px , py), since they are due to the circular sum procedure.

4.2.5Rotation invariant gradient-based L2-errors and the CH-basis

In general, gradient-based error functions are expected to have better performance, when the brightness of structures in an image is not constant, for instance in the case of a graduated shading. Let us now discuss possibilities to calculate gradient-based error functions using the expansion in CH-moments of the patches px and py. Again we shall at first discuss this for the usual L2-norm and thereafter treat the case of g-weighted norms.

4.2.5.1Constant weight

We rewrite the patch non-local Poisson error function from (2.3):

Let us examine the rotation angle dependent term ⟨px , Rθpy⟩. Using integration by parts we have

where BI denotes the boundary integral term, which can be non-zero and dependent on θ.

Using the notation previously introduced for the Laplace eigenvalue problem, we see that

where the last equality is due to the fact that the em,n,rs are eigenfunctions of the Laplacian with eigenvalues λm,n. We define

From the definition we immediately see that if m ≠ m. We deduce that

Assuming for a moment that the boundary integral term BI were zero, the desired error function value could be calculated once the scalar products and the optimal rotation angle θ are known.

These are computed when executing the mutual angle detection algorithm with suitably sampled functions as follows

where

Thanks to the fact that the Circular Harmonics are eigenfunctions of the Laplace operator we have just found, we can use the introduced framework also for the comparison of gradient-based error functions by simply weighting its respective moments by their eigenvalues, whenever the boundary integral BI is assumed to be zero.

We will now see that a suitably chosen intra-patch weight function helps us to force the boundary integral term BI to be zero.

4.2.5.2Intra-patch weight function g

Trying to incorporate a weight function g interferes with the integration by parts. However, it ensures that the boundary integral BI is zero, if we choose g to be zero at the boundary. For such a function g we have:

The second term on the right-hand side can be rewritten as ⟨gpx,λ , Rθpy⟩ and thus can be treated as discussed in the previous subsections. The first term requires a closer look. We write and examine We have:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.164.39