\def\real{I\!\!R}

{\em owave2} computes the two-dimensional discrete wavelet transform\index{wavelet!transform!orthogonal}
of the floating point image stored in the file {\em Image}, 
according to the pyramidal algorithm of S. Mallat \cite{mallat:theory}. 

This module is a generalisation to the 2D case of the {\em owave1} module. 
This generalisation is done in the same way as in \cite{mallat:theory}, i.e. 
{\em owave2}  performs a semi-separable transform. More precisely, 
it can be decomposed at each level in two one-level and one-dimensional 
wavelet transforms applied successively on the lines and on the columns 
of the image (at level 1) or of the average sub-image (at level 2, 3, ...). 
It corresponds to a separable multiresolution analysis 
and a semi-separable wavelet basis on \( L^{2}(\real^{2}) \) 
(here semi-separable means that each 2D wavelet is the tensor product 
of two 1D wavelets or scaling functions, but that the whole 2D basis 
is not the tensor product of two 1D bases). 
The one-dimensional algorithm is the one that is implemented in {\em owave1}, 
and the reader is refered to the documentation of this module 
for its description. Here, only the multidimensional aspect of the algorithm 
is developed. 

Suppose that \( \{V_{j}\} \) is a multiresolution analysis on $L^{2}(\real)$. 
Then ${ V}_{j} = V_{j} \otimes V_{j}$ is a multiresolution 
analysis on $L^{2}(\real^{2})$. If $\varphi$ is the scaling function 
associated to $V_{j}$ then $\Phi(x,y) = \varphi(x) \varphi(y)$ 
is the scaling function associated to ${ V}_{j}$, 
and $\{ 2^{-j} \Phi(2^{-j}. - k, 2^{-j}. - l)\}_{k,l \in Z}$ is an orthonormal 
basis of ${ V}_{j}$.

As for the one-dimensional case, the projection $P_{{ V}_{j}} f$ 
of a function $f$ of $L^{2}(\real^{2})$ onto ${ V}_{j}$ represents 
the approximation of \( f \) at scale \( 2^{j} \). Here again the coordinates 
of $f$ in the basis  $\{ 2^{-j} \Phi(2^{-j}. - k, 2^{-j}. - l)\}_{k,l \in Z}$ 
are noted \( A_{j}[k,l] \). $A_j$ can be considered as an average 
of the original image at resolution $2^j$.


As in one-dimensional case, the space of details ${ W}_{j}$ 
is the orthogonal complement of ${ V}_{j}$ in ${ V}_{j-1}$. 
Now it can be decomposed as a direct sum of three orthogonal subspaces 
${ W}^{1}_{j}$, ${ W}^{2}_{j}$, and ${ W}^{3}_{j}$. 
Each of these subspaces can be generated by a mother wavelet :
\begin{itemize}
\item
\( \Psi^{1}(x,y) = \varphi(x) \psi(y) \).
\item
\( \Psi^{2}(x,y) = \psi(x) \varphi(y) \).
\item
\( \Psi^{3}(x,y) = \psi(x) \psi(y) \).
\end{itemize}
Indeed \( \{ 2^{-j} \Psi^{i}(2^{-j}. - k, 2^{-j}. - l)\}_{k,l \in Z} \) 
is an orthonormal basis of ${ W}^{i}_{j}$, $i=1,2,3$.

The coordinates of the function \( f \) in each of these basis are noted 
respectively $D^{1}_{j}[k,l]$, $D^{2}_{j}[k,l]$, and $D^{3}_{j}[k,l]$. 
$D^{1}_{j}[k,l]$ represents the details of $f$ in the horizontal direction 
(it is an average in the vertical direction). \( D^{2}_{j}[k,l] \) represents 
the details in the vertical direction (it is an average in the horizontal 
direction). \( D^{3}_{j}[k,l] \) represents details in both directions, 
and in some sense the corners in the image. 

If $f$ is in ${ V}_{0}$ and its coordinates 
$\{A_{0}[k,l]\}_{0 \leq k \leq K-1, 0 \leq l \leq L-1}$ are stored in the file 
{\em Image}, then {\em owave2} computes the wavelet representation of $f$, 
i.e. the sequence of details and average 2D signals or ``sub-images'' 
$D^{1}_{1}, D^{1}_{2}, \ldots, D^{1}_{J}, D^{2}_{1}, \ldots D^{2}_{J}, 
D^{3}_{1}, \ldots, D^{3}_{J}, A_{J}$, 
where $J$ is a positive integer. This is done recursively, 
at each step the one level one-dimensional wavelet transform is applied 
to each line of \( A_{j} \), resulting in two sub-images. Then the one level 
one-dimensional wavelet transform is applied to each sub-images' column. 

The different methods for computing the edge coefficients are the same as 
for the univariate case (see {\em owave1}), unless the dimensions 
of the image are not multiples of $2^J$ and the invertible mode (option -i) 
is not activated. Suppose that at some level $j$
of the decomposition, the dimensions of the average are not even, say for 
instance that the number of columns is $2n+1$ for some integer $n$. 
Then for the 1D wavelet transforms along the lines, only the first $2n$ 
coefficients are used, and the last coefficients are multiplied by a constant 
(equal to the sum of the I.R. coefficients) and concatenated 
to the resulting average subsignals at level $j+1$. Thus the resulting 
subimages $A_{j+1}$ and $D^{1}_{j+1}$ have $n+1$ columns, while 
$D^{2}_{j+1}$ and $D^{3}_{j+1}$ have $n$ columns.


Because of the down-sampling, the size of the sub-images is divided by two 
in both directions at each step. So the total size of the sub-image 
is divided by four. As a consequence, if the problem of edges is omitted, 
the size of the wavelet decomposition, obtained by adding the size of all 
the sub-images composing it, is equal to the size of the original sub-image. 
Moreover the parameter $J$ is upperbounded. 

The complexity of the algorithm is $2(2 - 2^{-J+1}) N \, dx \, dy$ 
multiplications and additions, where \( dx \) and \( dy \) are respectively 
the number of columns and the number of lines in the original image. 

The resulting sub-images $A_{J}$, $D^{1}_{1}, D^{1}_{2}, \ldots, D^{1}_{J}$, 
$D^{2}_{1}, D^{2}_{2}, \ldots, D^{2}_{J}$, and 
$D^{3}_{1}, D^{3}_{2}, \ldots, D^{3}_{J}$ are stored in files having 
all the same prefix {\em Wavtrans}. The name of the file is 
{\em prefix\_j\_A.wtrans2d} for \( A_{j} \) and {\em prefix\_j\_D.wtrans2d} 
for \( D_{j} \).

The coefficients \( h_{k} \) of the filter's impulse response are read 
in the file {\em ImpulseResponse}. The coefficients of the filter's impulse 
response for computing the edge coefficients are read 
in the file {\em EdgeIR}. 


\begin{itemize}
\item
The -r option specifies the number of levels in the decomposition 
({\em Nlevel} is equal to $J$ in the above description).
\item
The -h option enables to continue the decomposition up to level 
{\em HaarNLevel} with the Haar filter. In other words the filter 
contained in {\em ImpulseResponse} is replaced by the Haar filter 
for the decomposition from level {\em NLevel + 1} up to level 
{\em HaarNLevel}. It may happen that the decomposition with the 
Haar filter begins at a lower level ({\em NLevel, NLevel - 1}) 
if the size of the filter in {\em ImpulseResponse} is too large 
compared to the size of the image. In this case, the decompistion 
with {\em ImpulseResponse} is performed as far as possible, 
and then {\em ImpulseResponse} is replaced by the Haar filter. 
This option enables to get wavelet transforms with a larger 
number of levels. 
\item
The -e option specifies the edge processing mode (see {\em owave1}).
\item
The -p option specifies the preconditionning mode (see {\em owave1}).
\item
The -i option enables to have invertible transform. Since the transform is invertible when EdgeMode is equal to 1 or 3, this only makes sense when EdgeMode is equal to 0 or 2. 
\item
The -n option specifies the normalisation mode of the filter impulse responses' coefficients. If selected the coefficients $h_{k}$ are multiplied by a constant so that their sum is $1.0$. If -n is not selected the coefficients are normalized so that the decomposition is orthogonal. 
\end{itemize}


