## Developer Reference

• 2020
• 07/15/2020
• Public Content
Contents

# WTHaarFwd, WTHaarInv

Performs forward or inverse single-level discrete wavelet Haar transforms.

## Syntax

Include Files
ipps.h
Domain Dependencies
ippcore.h
,
ippvm.h
Libraries:
ippcore.lib
,
ippvm.lib
Parameters
pSrc
Pointer to the source vector for forward transform.
len
Number of elements in the vector.
pDstLow
Pointer to the array with the coarse “low frequency” components of the output for forward transform.
pDstHigh
Pointer to the array with the detail “high frequency” components of the output for forward transform.
pSrcLow
Pointer to the array with the coarse “low frequency” components of the input for inverse transform.
pSrcHigh
Pointer to the array with the detail “high frequency” components of the input for inverse transform.
pDst
Pointer to the array with the output signal for inverse transform.
scaleFactor
Scale factor, refer to Integer Scaling.
Description
These functions perform forward and inverse single-level discrete Haar transforms. These transforms are orthogonal and reconstruct the original signal perfectly.
The forward transform can be considered as wavelet signal decomposition with lowpass decimation filter coefficients {1/2, 1/2} and highpass decimation filter coefficients {1/2, -1/2}.
The inverse transform is represented as a wavelet signal reconstruction with lowpass interpolation filter coefficients {1, 1} and highpass interpolation filter coefficients {-1, 1}.
The decomposition filter coefficients are frequency response normalized to provide the same value range for both input and output signals. Thus, the amplitude of the low pass filter frequency response is 1 for zero-valued frequency, and the amplitude of the high pass filter frequency response is also 1 for the frequency value near to 0.5.
As the absolute values of the interpolation filter coefficients are equal to 1, the reconstruction of the signal requires few operations. It is well suited for usage in data compression applications. As the decomposition filter coefficients are powers of 2, the integer functions perform lossless decomposition with the
scaleFactor
value equal to -1. To avoid saturation, use higher-precision data types.
Note that the filter coefficients can be power spectral response normalized, see [Strang96] for more information. Thus, the decomposition filter coefficients are {2
-1/2
, 2
-1/2
} and {2
-1/2
, -2
-1/2
}; accordingly; the reconstruction filter coefficients are {2
-1/2
, 2
-1/2
} and {-2
-1/2
, 2
-1/2
}.
In the following definition of the forward single-level discrete Haar transform,
N
=
len
. The coarse “low-frequency” component
c
(
k
) is
pDstLow
[
k
] and the detail “high-frequency” component
d
(
k
) is
pDstHigh
[
k
]; also
x
(2
k
) and
x
(2
k
+1) are even and odd values of the input signal
pSrc
, respectively.
c
(
k
) = (
x
(2
k
) +
x
(2
k
+1 ))/2
d
(
k
) = (
x
(2
k
+1) -
x
(2
k
))/2
In the inverse direction,
N
=
len
. The coarse “low-frequency” component
c
(
k
) is
pSrcLow
[
k
] and the detail “high-frequency” component
d
(
k
) is
pSrcHigh
[
k
]; also
y
(2
i
) and
y
(2
i
+1) are even and odd values of the output signal
pDst
, respectively.
y
(2
i
) =
c
(
i
) -
d
(
i
)
y
(2
i
+1) =
c
(
i
) +
d
(
i
)
For even length
N
, 0 ≤
k
<
N
/2 and 0 ≤
i
<
N
/2. Also, “low-frequency” and “high-frequency” components are of size
N
/2 for both original and reconstructed signals. The total length of components is equal to the signal length
N
.
In case of odd length
N
, the vector is considered as a vector of the extended length
N
+1 whose two last elements are equal to each other
x
[
N
] =
x
[
N
- 1]. The last elements of the coarse and detail components of the decomposed signal are defined as follows:
c
((
N
+1 )/2 - 1) =
x
(
N
- 1)
d
((
N
+ 1)/2 - 1) = 0
Correspondingly, the last element of the reconstructed signal is defined as:
y
(
N
) =
y
(
N
- 1) =
c
((
N
+ 1)/2 - 1)
For odd length
N
, 0 ≤
k
<
N
- 1)/2 and 0 ≤
i
<
N
- 1)/2 , assuming that
c
((
N
+ 1)/2 - 1) =
x
(
N
- 1) and
y
(
N
- 1) =
c
((
N
+ 1)/2 - 1). The “low-frequency” component is of size (
N
+ 1)/2. The “high-frequency” component is of size (
N
- 1)/2, because the last element
d
((
N
+ 1)/2 - 1) is always equal to 0. The total length of components is also
N
.
Such an approach applies continuation of boundaries for filters having the symmetry properties, see [Bris94].
When performing block mode transforms, take into consideration that for decomposition and reconstruction of even-length signals no extrapolations at the boundaries is used. In case of odd-length signals, a symmetric continuation of the signal boundary with the last point replica is applied.
When it is necessary to have a continuous set of output blocks, all the input blocks are to be of even length, besides the last one (which can be either of odd or even length). Thus, if the whole amount of elements is odd, only the last block can be of odd length.
ippsWTHaarFwd
.
Thise function performs the forward single-level discrete Haar transform of a
len
-length signal
pSrc
and stores the decomposed coarse “low-frequency” components in
pDstLow
, and the detail “high-frequency” components in
pDstHigh
.
ippsWTHaarInv
.
This function performs the inverse single-level discrete Haar transform of the coarse “low-frequency” components
pSrcLow
and detail “high-frequency” components
pSrcHigh
, and stores the reconstructed signal in the
len
-length vector
pDst
.
Return Values
ippStsNoErr
Indicates no error.
ippStsNullPtrErr
Indicates an error when the
pDst
or
pSrc
pointer is
NULL
.
ippStsSizeErr
Indicates an error when
len
is less than 4 for the function
ippsWinBlackmanOpt
and less than 3 for all other functions of the family.

## Example

The example below illustrates the use of the function
ippsWTHaarFwd_32f
.
```IppStatus wthaar(void)
{     Ipp32f x, lo, hi;
IppStatus status;
ippsSet_32f(7, x, 8);
--x;
status = ippsWTHaarFwd_32f(x, 8, lo, hi);
printf_32f(“WT Haar low  =”, lo, 4, status);
printf_32f(“WT Haar high =”, hi, 4, status);
return status;  }```
Output:
```WT Haar low  =  7.000000 7.000000 6.500000 7.000000
WT Haar high =  0.000000 0.000000 0.500000 0.000000```

#### Product and Performance Information

1

Intel's compilers may or may not optimize to the same degree for non-Intel microprocessors for optimizations that are not unique to Intel microprocessors. These optimizations include SSE2, SSE3, and SSSE3 instruction sets and other optimizations. Intel does not guarantee the availability, functionality, or effectiveness of any optimization on microprocessors not manufactured by Intel. Microprocessor-dependent optimizations in this product are intended for use with Intel microprocessors. Certain optimizations not specific to Intel microarchitecture are reserved for Intel microprocessors. Please refer to the applicable product User and Reference Guides for more information regarding the specific instruction sets covered by this notice.

Notice revision #20110804