User:Matangavish/sandbox

In information theory and signal processing, the Discrete Universal Denoiser (DUDE) is a denoising scheme for recovering sequences over a finite alphabet, which have been corrupted by a discrete memoryless channel. The DUDE was proposed in 2005 by Tsachy Weissman, Erik Ordentlich, Gadiel Seroussi, Sergio Verdú and Marcelo J. Weinberger .

= Overview =

The Discrete Universal Denoiser (DUDE) is a denoising scheme that estimates an unknown signal $$x^n=\left( x_1 \ldots x_n \right)$$ over a finite alphabet from a noisy version $$z^n=\left( z_1 \ldots z_n \right)$$. While most denoising schemes in the signal processing and statistics literature deal with signals over an infinite alphabet (notably, real-valued signals), the DUDE addresses the finite alphabet case. The noisy version $$z^n$$ is assumed to be generated by transmitting $$x^n$$ through a known discrete memoryless channel.

For a fixed context length parameter $$k$$, the DUDE counts of the occurrences of all the strings of length $$2k+1$$ appearing in $$z^n$$. The estimated value $$\hat{x}_i$$ is determined based the two-sided length-$$k$$ context $$\left( z_{i-k}, \ldots, z_{i-1},z_{i+1}, \ldots,z_{i+k} \right) $$ of $$z_i$$, taking into account all the other tokens in $$z^n$$ with the same context, as well as the known channel matrix and the loss function being used.

The idea underlying the DUDE is best illustrated when $$x^n$$ is a realization of a random vector $$X^n$$. If the conditional distribution $$X_i | Z_{i-k}, \ldots, Z_{i-1}, Z_{i+1}, \ldots, Z_{i+k}$$, namely the distribution of the noiseless symbol $$X_i$$ conditional on its noisy context $$\left( Z_{i-k}, \ldots, Z_{i-1},Z_{i+1}, \ldots,Z_{i+k} \right) $$ was available, the optimal estimator $$\hat{X}_i$$ would be the Bayes Response to $$X_i | Z_{i-k}, \ldots, Z_{i-1}, Z_{i+1}, \ldots, Z_{i+k}$$. Fortunately, when the channel matrix is known and non-degenerate, this conditional distribution can be expressed in terms of the conditional distribution $$Z_i | Z_{i-k}, \ldots, Z_{i-1}, Z_{i+1}, \ldots, Z_{i+k}$$, namely the distribution of the noisy symbol $$Z_i$$ conditional on its noisy context. This conditional distribution, in turn, can be estimated from an individual observed noisy signal $$Z^n$$ by virtue of the Law of Large Numbers, provided $$n$$ is ``large enough''.

Applying the DUDE scheme with a context length $$k$$ to a sequence of length $$n$$ over a finite alphabet $$\mathcal{Z}$$ requires $$O(n)$$ operations and space $$O\left( \min( n, |\mathcal{Z}|^{2k} ) \right)$$.

Under certain assumptions, the DUDE is a universal scheme in the sense of asymptotically performing as well as an optimal denoiser, which has oracle access to the unknown sequence. More specifically, assume that the denoising performance is measured using a given single-character fidelity criterion, and consider the regime where the sequence length $$n$$ tends to infinity and the context length $$k=k_n$$ tends to infinity “not too fast”. In the stochastic setting, where a doubly-infinite sequence noiseless sequence $$\mathbf{x}$$ is a realization of a stationary process $$\mathbf{X}$$, the DUDE asymptotically performs, in expectation, as well as the best denoiser, which has oracle access to the source distribution $$\mathbf{X}$$. In the single-sequence, or “semi-stochastic” setting with a fixed doubly-infinite sequence $$\mathbf{x}$$, the DUDE asymptotically performs as well as the best “sliding window” denoiser, namely any denoiser that determines $$\hat{x}_i$$ from the window $$\left( z_{i-k},\ldots,z_{i+k} \right)$$, which has oracle access to $$\mathbf{x}$$.

=The discrete denoising problem=



Let $$\mathcal{X}$$ be the finite alphabet of a fixed but unknown original “noiseless” sequence $$x^n=\left( x_1, \ldots, x_n \right)\in \mathcal{X}^n$$. The sequence is fed into a discrete memoryless channel (DMC). The DMC operates on each symbol $$x_i$$ independently, producing a corresponding random symbol $$Z_i$$ in a finite alphabet $$\mathcal{Z}$$. The DMC is known and given as a $$\mathcal{X}$$-by-$$\mathcal{Z}$$ Markov matrix $$\Pi$$, whose entries are $$\pi(x,z)=\mathbb{P}\left( Z=z \,|\, X=x \right)$$. It is convenient to write $$\pi_z$$ for the $$z$$-column of $$\Pi$$. The DMC produces a random noisy sequence $$Z^n=\left( z_1,\ldots,z_n \right)\in\mathcal{Z}^n$$. A specific realization of this random vector will be denoted by $$z^n$$. A denoiser is a function $$\hat{X}^n: \mathcal{Z}^n \to \mathcal{X}^n$$ that attempts to recover the noiseless sequence $$x^n$$ from a distorted version $$z^n$$. A specific denoised sequence is denoted by $$\hat{x}^n=\hat{X}^n\left( z^n \right)=\left( \hat{X}_1 (z^n),\ldots, \hat{X}_n(z^n) \right)$$. The problem of choosing the denoiser $$\hat{X}^n$$ is known as signal estimation, filtering or smoothing. To compare candidate denoisers, we choose a single-symbol fidelity criterion $$\Lambda:\mathcal{X}\times \mathcal{X}\to [0,\infty)$$ (for example, the Hamming loss) and define the per-symbol loss of the denoiser $$\hat{X}^n$$ at $$(x^n,z^n)$$ by

$$ \begin{align} L_{\hat{X}^n}\left( x^n,z^n \right) = \frac{1}{n}\sum_{i=1}^n\Lambda\left( x_i \,, \, \hat{X}_i(z^n) \right) \,. \end{align} $$

Ordering the elements of the alphabet $$\mathcal{X}$$ by $$\mathcal{X}=\left( a_1, \ldots , a_{|\mathcal{X}|} \right)$$, the fidelity criterion can be given by a $$|\mathcal{X}|$$-by-$$|\mathcal{X}|$$ matrix, with columns of the form

$$ \begin{align} \lambda_{\hat{x}} = \left(  \begin{array}{c}    \Lambda(a_1,\hat{x}) \\    \vdots \\    \Lambda(a_{|\mathcal{X}|},\hat{x})  \end{array}  \right) \,. \end{align} $$

= The DUDE scheme =

Step 1: Calculating the empirical distribution in each context
The DUDE corrects symbols according to their context. The context length $$k$$ used is a tuning parameter of the scheme. For $$k+1\leq i\leq n-k$$, define the left context of the $$i$$-th symbol in $$z^n$$ by $$l^k(z^n,i)=\left( z_{i-k},\ldots,z_{i-1} \right)$$ and the corresponding right context as $$r^k(z^n,i)=\left( z_{i+1},\ldots,z_{i+k} \right)$$. A two-sided context is a combination $$(l^k,r^k)$$ of a left and a right context.

The first step of the DUDE scheme is to calculate the empirical distribution of symbols in each possible two-sided context along the noisy sequence $$z^n$$. Formally, a given two-sided context $$(l^k,r^k)\in\mathcal{Z}^k\times \mathcal{Z}^k$$ that appears once or more along $$z^n$$ determines an empirical probability distribution over $$\mathcal{Z}$$, whose value at the symbol $$z$$ is

$$ \begin{align} \mu \left( z^n,l^k,r^k \right)[z] = \frac{\Big| \left\{ k+1\leq i \leq n-k \,\,|\,\, ( z_{i-k},\ldots,z_{i+k})=l^k z r^k \right\} \Big|} {\Big| \left\{ k+1\leq i \leq n-k \,\,|\,\, l^k(z^n,i)=l^k \text{ and } r^k(z^n,i)=r^k\right\} \Big|} \,. \end{align} $$

Thus, the first step of the DUDE scheme with context length $$k$$ is to scan the input noisy sequence $$z^n$$ once, and store the length-$$|\mathcal{Z}|$$ empirical distribution vector $$ \mu \left( z^n,l^k,r^k \right) $$ (or its non-normalized version, the count vector) for each two-sided context found along $$z^n$$. Since there are at most $$N_{n,k}=\min\left( n,|\mathcal{Z}|^{2k} \right)$$ possible two-sided contexts along $$z^n$$, this step requires $$O(n)$$ operations and storage $$O(N_{n,k})$$.

Step 2: Calculating the Bayes response to each context
Denote the column of single-symbol fidelity criterion $$\Lambda$$, corresponding to the symbol $$\hat{x}\in\mathcal{X}$$, by $$\lambda_{\hat{x}}$$. We define the Bayes Response to any vector $$\mathbf{v}$$ of length $$|\mathcal{X}|$$ with non-negative entries as

$$ \begin{align} \hat{X}_{Bayes}(\mathbf{v}) = \text{argmin}_{\hat{x}\in\mathcal{X}}\lambda_{\hat{x}}^\top\mathbf{v}\,. \end{align} $$

This definition is motivated in the background below.

The second step of the DUDE scheme is to calculate, for each two-sided context $$(l^k,r^k)$$ observed in the previous step along $$z^n$$, and for each symbol $$z\in\mathcal{Z}$$ observed in each context (namely, any $$z$$ such that $$l^rzr^k$$ is a substring of $$z^n$$) the Bayes response to the vector $$\Pi^{-\top}\mu\left( z^n\,,\,l^k\,,\,r^k \right)\odot \pi_{z}$$, namely

$$ \begin{align} g(l^k,z,r^k) := \hat{X}_{Bayes} \left( \Pi^{-\top}\mu\left( z^n\,,\,l^k\,,\,r^k \right)\odot \pi_{z} \right)\,. \end{align} $$

Note that the sequence $$z^n$$ and the context length $$k$$ are implicit. Here, $$\pi_z$$ is the $$z$$-column of $$\Pi$$ and for vectors $$\mathbf{a}$$ and $$\mathbf{b}$$, $$\mathbf{a}\odot\mathbf{b}$$ denotes their Schur (entrywise) product, defined by $$\left( \mathbf{a}\odot\mathbf{b}\right)_i = a_i b_i$$. Matrix multiplication is evaluated before the Schur product, so that $$\Pi^{-\top}\mu\odot\pi_z$$ stands for $$(\Pi^{-\top}\mu)\odot\pi_z$$.

This formula assumed that the channel matrix $$\Pi$$ is square ($$|\mathcal{X}|=|\mathcal{Z}|$$) and invertible. When $$|\mathcal{X}|\leq|\mathcal{Z}|$$ and $$\Pi$$ is not invertible, under the reasonable assumption that it has full row rank, we replace $$(\Pi^\top)^{-1}$$ above with its Moore-Penrose pseudo-inverse $$\left( \Pi\Pi^\top \right)^{-1}\Pi$$ and calculate instead

$$ \begin{align} g(l^k,z,r^k):=\hat{X}_{Bayes}\left( (\Pi\Pi^\top)^{-1}\Pi \mu\left( z^n,l^k,r^k \right)\odot \pi_z \right)\,. \end{align} $$

By caching the inverse or pseudo-inverse $$\Pi^{-\top}$$, and the values $$\lambda_{\hat{x}}\odot \pi_z$$ for the relevant pairs $$(\hat{x},z)\in\mathcal{X}\times\mathcal{Z}$$, this step requires $$O(N_{k,n})$$ operations and $$O(N_{k,n})$$ storage.

Step 3: Estimating each symbol by the Bayes response to its context
The third and final step of the DUDE scheme is to scan $$z^n$$ again and compute the actual denoised sequence $$ \hat{X}^n(z^n)=\left( \hat{X}_1(z^n), \ldots, \hat{X}_n(z^n) \right) $$. The denoised symbol chosen to replace $$z_i$$ is the Bayes response to the two-sided context of the symbol, namely

$$ \begin{align} \hat{X}_i(z^n) := g\left( l^k(z^n,i) \,,\, z_i \,,\, r^k(z^n,i)\right)\,.\end{align} $$

This step requires $$O(n)$$ operations and used the data structure constructed in the previous step.

In summary, the entire DUDE requires $$O(n)$$ operations and $$O(N_{k,n})$$ storage.

= Asymptotic optimality properties =

The DUDE is designed to be universally optimal, namely optimal (is some sense, under some assumptions) regardless of the original sequence $$x^n$$.

Let $$\hat{X}^n_{DUDE}:\mathcal{Z}^n\to\mathcal{X}^n$$ denote a sequence of DUDE schemes, as described above, where $$\hat{X}^n_{DUDE}$$ uses a context length $$k_n$$ that is implicit in the notation. We only require that $$\lim_{n\to\infty}k_n=\infty$$ and that $$k_n |\mathcal{Z}|^{2K_n}=o\left( \frac{n}{\log n} \right)$$.

For a stationary source
Denote by $$\mathcal{D}_n$$ the set of all $$n$$-block denoisers, namely all maps $$\hat{X}^n:\mathcal{Z}^n\to\mathcal{X}^n$$.

Let $$\mathbf{X}$$ be an unknown stationary source and $$\mathbf{Z}$$ be the distribution of the corresponding noisy sequence. Then

$$ \begin{align} \lim_{n\to\infty}\mathbf{E}\left[ L_{\hat{X}^n_{DUDE}}\left( X^n,Z^n \right)  \right]= \lim_{n\to\infty}\min_{\hat{X}^n\in\mathcal{D}_n}\mathbf{E} \left[L_{\hat{X}^n}\left( X^n,Z^n   \right)\right]\,, \end{align} $$

and both limits exist. If, in addition the source $$\mathbf{X}$$ is ergodic, then

$$ \begin{align} \limsup_{n\to\infty} L_{\hat{X}^n_{DUDE}}\left( X^n,Z^n \right)  = \lim_{n\to\infty}\min_{\hat{X}^n\in\mathcal{D}_n}\mathbf{E} \left[L_{\hat{X}^n}\left( X^n,Z^n   \right)\right]\,,\,\text{ almost surely}\,. \end{align} $$

For an individual sequence
Denote by $$\mathcal{D}_{n,k}$$ the set of all $$n$$-block $$k$$-th order sliding window denoisers, namely all maps $$\hat{X}^n:\mathcal{Z}\to\mathcal{X}$$ of the form $$\hat{X}_i(z^n) = f\left( z_{i-k},\ldots,z_{i+k} \right)$$ with $$f:\mathcal{Z}^{2k+1}\to\mathcal{X}$$ arbitrary.

Let $$\mathbf{x}\in\mathcal{X}^\infty$$ be an unknown noiseless sequence stationary source and $$\mathbf{Z}$$ be the distribution of the corresponding noisy sequence. Then

$$ \begin{align} \lim_{n\to\infty} \left[ L_{\hat{X}^n_{DUDE}}\left( x^n,Z^n \right) - \min_{\hat{X}^n\in\mathcal{D}_{n,k}} L_{\hat{X}^n}\left( x^n,Z^n \right) \right ] =0 \,,\,\text{ almost surely}\,. \end{align} $$

= Non-asymptotic performance =

Let $$\hat{X}^n_{k}$$ denote the DUDE on with context length $$k$$ defined on $$n$$-blocks. Then there exist explicit constants $$A,C>0$$ and $$B>1$$ that depend on $$\left( \Pi,\Lambda \right)$$ alone, such that for any $$n,k$$ and any $$x^n\in\mathcal{X}^n$$ we have

$$ \begin{align} \frac{A}{\sqrt{n}}B^k\,\leq \mathbf{E} \left[  L_{\hat{X}^n_{k}}\left( x^n,Z^n \right) - \min_{\hat{X}^n\in\mathcal{D}_{n,k}} L_{\hat{X}^n}\left( x^n,Z^n \right) \right] \leq \sqrt{k}\frac{C}{\sqrt{n}} |\mathcal{Z}|^{k} \,, \end{align} $$

where $$Z^n$$ is the noisy sequence corresponding to $$x^n$$ (whose randomness is due to the channel alone) .

In fact holds with the same constants $$A,B$$ as above for any $$n$$-block denoiser $$\hat{X}^n\in\mathcal{D}^n$$ . The lower bound proof requires that the channel matrix $$\Pi$$ be square and the pair $$\left( \Pi,\Lambda \right)$$ satisfies a certain technical condition.

=Background=

To motivate the particular definition of the DUDE using the Bayes response to a particular vector, we now find the optimal denoiser in the non-universal case, where the unknown sequence $$x^n$$ is a realization of a random vector $$X^n$$, whose distribution is known.

Consider first the case $$n=1$$. Since the joint distribution of $$(X,Z)$$ is known, given the observed noisy symbol $$z$$, the unknown symbol $$X\in\mathcal{X}$$ is distributed according to the known distribution $$\mathbb{P}(X=x|Z=z)$$. By ordering the elements of $$\mathcal{X}$$, we can describe this conditional distribution on $$\mathcal{X}$$ using a probability vector $$\mathbf{P}_{X|z}$$, indexed by $$\mathcal{X}$$, whose $$x$$-entry is $$\mathbb{P}\left( X=x|Z=z \right)$$. Clearly the expected loss for the choice of estimated symbol $$\hat{x}$$ is $$\lambda_{\hat{x}}^\top \mathbf{P}_{X|z}$$.

Define the Bayes Envelope of a probability vector $$\mathbf{v}$$, describing a probability distribution on $$\mathcal{X}$$, as the minimal expected loss $$U(\mathbf{v}) = \min_{\hat{x}\in\mathcal{X}}\mathbf{v}^\top \lambda_{\hat{x}}$$, and the Bayes Response to $$\mathbf{v}$$ as the prediction that achieves this minimum, $$\hat{X}_{Bayes}(\mathbf{v}) = \text{argmin}_{\hat{x}\in\mathcal{X}}\mathbf{v}^\top \lambda_{\hat{x}}$$. Observe that the Bayes response is scale invariant in the sense that $$\hat{X}_{Bayes}(\mathbf{v}) = \hat{X}_{Bayes}(\alpha\mathbf{v})$$ for  $$\alpha>0$$.

For the case $$n=1$$, then, the optimal denoiser is $$\hat{X}(z)=\hat{X}_{Bayes}\left( \mathbf{P}_{X|z} \right)$$. This optimal denoiser can be expressed using the marginal distribution of $$Z$$ alone, as follows. When the channel matrix $$\Pi$$ is invertible, we have $$\mathbf{P}_{X|z} \propto \Pi^{-\top}P_Z\odot \pi_z$$ where $$\pi_z$$ is the $$z$$-th column of $$\Pi$$. This implies that the optimal denoiser is given equivalently by $$\hat{X}(z)=\hat{X}_{Bayes}\left( \Pi^{-\top}\mathbf{P}_Z\odot\pi_z \right)$$. When $$|\mathcal{X}|\leq|\mathcal{Z}|$$ and $$\Pi$$ is not invertible, under the reasonable assumption that it has full row rank, we can replace $$\Pi^{-1}$$ with its Moore-Penrose pseudo-inverse and obtain $$ \hat{X}(z)=\hat{X}_{Bayes}\left( (\Pi\Pi^\top)^{-1}\Pi\mathbf{P}_Z\odot\pi_z \right)\,. $$

Turning now to arbitrary $$n$$, the optimal denoiser $$\hat{X}^{opt}(z^n)$$ (with minimal expected loss) is therefore given by the Bayes response to $$\mathbf{P}_{X_i|z^n}$$

$$ \begin{align} \hat{X}^{opt}_i(z^n) = \hat{X}_{Bayes}\mathbf{P}_{X_i|z^n} = \text{argmin}_{\hat{x}\in\mathcal{X}}\lambda_{\hat{x}}^\top \mathbf{P}_{X_i|z^n}\,, \end{align} $$

where $$\mathbf{P}_{X_i|z^n}$$ is a vector indexed by $$\mathcal{X}$$, whose $$x$$-entry is $$\mathbb{P}\left( X_i=x | Z^n=z^n \right)$$. The conditional probability vector $$\mathbf{P}_{X_i|z^n}$$ is hard to compute. A derivation analogous to the case $$n=1$$ above shows that the optimal denoiser admits an alternative representation, namely $$\hat{X}^{opt}_i(z^n)=\hat{X}_{Bayes}\left( \Pi^{-\top}\mathbf{P}_{Z_i,z^{n\backslash i}}\odot\pi_{z_i} \right)$$, where $$z^{n \backslash i}=\left( z_1,\ldots,z_{i-1},z_{i+1},\ldots,z_n \right)\in \mathcal{Z}^{n-1}$$ is a given vector and $$\mathbf{P}_{Z_i,z^{n\backslash i}}$$ is the probability vector indexed by $$\mathcal{Z}$$ whose $$z$$-entry is $$\mathbb{P}\left( (Z_1,\ldots,Z_n) = (z_1,\ldots,z_{i-1},z,z_{i+1},\ldots,z_n) \right)\,.$$ Again, $$\Pi^{-\top}$$ is replaced by a pseudo-inverse if $$\Pi$$ is not square or not invertible.

When the distribution of $$X$$ (and therefore, of $$Z$$) is not available, the DUDE replaces the unknown vector $$\mathbf{P}_{Z_i,z^{n\backslash i}}$$ with an empirical estimate obtained along the noisy sequence $$z^n$$ itself, namely with $$\mu\left( Z_i, l^k(Z^n,i),r^k(Z^n,i) \right)$$. This leads to the above definition of the DUDE.

While the convergence arguments behind the optimality properties above are more subtle, we note that the above, combined with the Birkhoff Ergodic Theorem, is enough to prove that for a stationary ergodic source, the DUDE with context-length $$k$$ is asymptotically optimal all $$k$$-th order sliding window denoisers.

=Extensions=

The basic DUDE as described here assumes a signal with a one-dimensional index set over a finite alphabet, a known memoryless channel and a context length that is fixed in advance. Relaxations of each of these assumptions have been considered in turn. Specifically:
 * Infinite alphabets
 * Channels with memory
 * Unknown channel matrix
 * Variable context and adaptive choice of context length
 * Two-dimensional signals

=Application to image denoising=

Some applications of the DUDE approach to image denoising can be seen as generalizations or improvements of the Non-local means image denoising scheme.

=References=