编程环境:windows下结合opencv库
//离散Haar小波变换
/*
dst深度为IPL_DEPTH_32F
nLayer为变换尺度
*/
void HaarWavelet(IplImage* src, IplImage* dst, int nLayer);
//离散Haar小波变换
/*
dst深度为IPL_DEPTH_32F
nLayer为变换尺度
*/
void HaarWavelet(IplImage* src, IplImage* dst, int nLayer)
{
if (!dst)
{
return;
}
if (((dst->width >> nLayer) << nLayer != dst->width)
|| ((dst->height >> nLayer) << nLayer != dst->height)
|| (dst->depth != IPL_DEPTH_32F)
|| (src->nChannels != 1)
|| (dst->nChannels != 1)
|| (nLayer <= 0))
{
return;
}
int x, y;
int nWidth = dst->width;
int nHeight = dst->height;
int nHalfWidth = nWidth / 2;
int nHalfHeight = nHeight / 2;
//图像数据的起始地址
float* *pfData = (float**)(malloc(sizeof(float*) * nHeight));
//保存计算过程中用到的行列数据
float* pfRow = (float*)(malloc(sizeof(float) * nWidth));
float*