Rate This Document
Findability
Accuracy
Completeness
Readability

WTHaar

Performs forward and inverse Haar wavelet transforms.

Forward Haar wavelet transform:

This function performs forward single-level discrete Haar transform on the src signal vector whose length is len, stores coarse low-frequency components obtained after decomposition in dstLow, and stores detail high-frequency components in dstHigh.

HmppResult HMPPS_WTHaarFwd_32f(const float* src, int32_t len, float* dstLow, float* dstHigh);

HmppResult HMPPS_WTHaarFwd_64f(const double* src, int32_t len, double* dstLow, double* dstHigh);

Inverse Haar wavelet transform:

This function performs inverse single-level discrete Haar transform on the coarse low-frequency components stored in srcLow and the detail high-frequency components stored in srcHigh, and stores the reconstructed signal in the dst vector whose length is len.

HmppResult HMPPS_WTHaarInv_32f(const float* srcLow, const float* srcHigh, float* dst, int32_t len);

HmppResult HMPPS_WTHaarInv_64f(const double* srcLow, const double* srcHigh, double* dst, int32_t len);

Parameters

Parameter

Description

Value Range

Input/Output

src

Pointer to the source vector for Haar transform.

Non-null pointer

Input

srcLow

Pointer to the array holding input coarse low-frequency components for inverse transform

Non-null pointer

Input

srcHigh

Pointer to the array holding input detail high-frequency components for inverse transform

Non-null pointer

Input

len

  • Forward transform: number of elements in the source vector
  • Inverse transform: number of elements in the destination vector

Positive integer

Input

dstLow

Pointer to the array holding output coarse low-frequency components for forward transform

Non-null pointer

Output

dstHigh

Pointer to the array holding output detail high-frequency components for forward transform

Non-null pointer

Output

dst

Pointer to the array holding the output signal for inverse transform.

Non-null pointer

Output

Return Value

  • Success: HMPP_STS_NO_ERR
  • Failure: An error code is returned.

Error Codes

Error Code

Description

HMPP_STS_SIZE_ERR

The length of the source vector for Haar transform is less than 0.

HMPP_STS_NULL_PTR_ERR

Any of the specified pointers is null.

HMPPS_WTHaarFwd_32f Example

#include <stdio.h>
#include <stdint.h>
#include "hmpps.h"

#define LEN 10

int main()
{
    float src[LEN] = {0.43,1.56,2.34,-4.56,0.76,1.89,-3.41,0.58,0.61,1.92};
    float dstLow[LEN / 2];
    float dstHigh[LEN / 2];
    HmppResult result = HMPPS_WTHaarFwd_32f(src, LEN, dstLow, dstHigh);
    printf("result = %d\n", result);
    if (result != HMPP_STS_NO_ERR){
        return 0;
    }
    printf("dstLow =");
    for(int i = 0;i < LEN / 2;i++){
        printf("%.2f ", dstLow[i]);
    }
    printf("\n");
    printf("dstHigh =");
    for(int i = 0; i < LEN / 2; i++){
        printf("%.2f ", dstHigh[i]);
    }
    printf("\n");


    return 0;
}

Output:

result = 0
dstLow =0.99 -1.11 1.33 -1.42 1.26 
dstHigh =0.56 -3.45 0.56 2.00 0.65

HMPPS_WTHaarInv_32f Example

#include <stdio.h>
#include <stdint.h>
#include "hmpps.h"

#define LEN 10

int main()
{
    float srcHigh[LEN/2]={1.64,1.63,-1.09,0.71,-3.20};
    float srcLow[LEN/2]={-0.43,0.41,-4.83,5.36,-4.40};
    float dst[LEN];
    HmppResult result = HMPPS_WTHaarInv_32f(srcLow, srcHigh, dst, LEN);
    printf("result = %d\n", result);
    if (result != HMPP_STS_NO_ERR){
       return 0;
    }
    printf("dst =");
    for (int i = 0; i<LEN; i++) {
       printf(" %.2f", dst[i]);
    }
    printf("\n");


    return 0;
}

Output:

result = 0
dst = -2.07 1.21 -1.22 2.04 -3.74 -5.92 4.65 6.07 -1.20 -7.60