WTHaar
实现小波前向哈尔变换和小波反向哈尔变换。
小波前向哈尔变换:
该函数对len长度信号src进行前向单级离散Haar变换,并将分解后的粗低频分量存储在dstLow中,将详细的高频分量存储在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);
小波反向哈尔变换:
该函数对粗“低频”分量srcLow和细“高频”分量srcHigh进行反向单级离散Haar变换,并将重构信号存储在len长度矢量dst中。
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);
参数
参数名 |
描述 |
取值范围 |
输入/输出 |
---|---|---|---|
src |
指向变换源向量的指针。 |
非空指针 |
输入 |
srcLow |
指向具有反向变换输入的粗略“低频”分量的数组的指针。 |
非空指针 |
输入 |
srcHigh |
指向具有反向变换输入的详细“高频”分量的数组的指针。 |
非空指针 |
输入 |
len |
|
正整数 |
输入 |
dstLow |
指向具有用于前向变换的输出的粗略“低频”分量的数组的指针。 |
非空指针 |
输出 |
dstHigh |
指向具有用于前向变换的输出的详细“高频”分量的数组的指针。 |
非空指针 |
输出 |
dst |
指向带有逆变换输出信号的数组的指针。 |
非空指针 |
输出 |
返回值
- 成功:返回HMPP_STS_NO_ERR。
- 失败:返回错误码。
错误码
错误码 |
描述 |
---|---|
HMPP_STS_SIZE_ERR |
变换源向量的长度小于0。 |
HMPP_STS_NULL_PTR_ERR |
出现空指针。 |
HMPPS_WTHaarFwd_32f示例
#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; }
运行结果:
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示例
#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; }
运行结果:
result = 0 dst = -2.07 1.21 -1.22 2.04 -3.74 -5.92 4.65 6.07 -1.20 -7.60