Intel® Integrated Performance Primitives
Deliberate problems developing high-performance vision, signal, security, and storage applications.
6689 Discussions

## 2D wavelet transform

Beginner
255 Views

Hello all,

I'm trying to check the 2D wavelet transform for floating point image buffers. I want to use the Biorthogonal 9/7 filters (of lengths 9 & 7). I've read the manual and the 2D wavelet example. I've sucessfully implemented the Daubechies 2 filter similat to the example. When I triedtheBiorthogonal 9/7 filterswith several anchor choises, I failed to reconstruct the image.I have 1 open question - how to determine the anchor values for both forward and inverse transform? obviously this is not an arbitrary choise as most choices fails to reconstruct (or approximatly reconstruct) the original image.

thanks,

Yoav

5 Replies
Moderator
255 Views

Hi Yoav,

By looking at the page here:

For Daubechies 9/7 filter, the lowpass Filter anchor is 4 ( the fifth coefficient in the tap), and high pass filter anchor is 3 ( the fouth coefficient).

Thanks,
Chao

Beginner
255 Views
Hi Chao,

I've tried those anchor values but couldn't reconstruct the image at all (not even close).
In addition, I've tried doing the same wavelet transform using the function
ippiWTFwdRow_D97_JPEG2K_32f_C1R according to the manual but no luck again - this time the result is close but wrong (rightmost column in completly off, other small differences in other places).

I've put my code below.
does anybody have any ideas?

thanks,

Yoav

-------------------------------------------------------------------------------------------------------

Ipp32f pSrc[8*8] = { 0.0, 0.1, 0.0, 11.0, 11.9, 0.0, 0.0, 0.0,
0.0, 0.0, 0.222, 11.0, 11.9, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 11.0, 11.0, 0.0, 0.0, 0.0,
11.0, 11.0, 11.0, 11.0, 11.0, 11.0, 11.0, 11.0,
11.0, 11.0, 11.0, 11.0, 11.0, 11.0, 11.0, 11.0,
0.0, 0.0, 0.0, 11.0, 11.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 11.0, 11.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 11.0, 11.0, 0.0, 0.0, 0.0};

Ipp32f pSrcB[15*8] = {0};
int srcStep = 8*sizeof(Ipp32f);
int srcStepB = 15*sizeof(Ipp32f);
Ipp32f pDstLow[8*4];
Ipp32f pDstLowB[8*7] = {0};
int dstLowStep = 4*sizeof(Ipp32f);
Ipp32f pDstHigh[8*4];
Ipp32f pDstHighB[8*8] = {0};
int dstHighStep = 4*sizeof(Ipp32f);
IppiSize dstRoiSize = {4, 8};
IppiSize srcRoiSize = {8, 8};
IppiSize srcRoiSizeB = {11, 8};

// adds border to the source image
ippiCopy_32f_C1R(pSrc, srcStep, pSrcB + 4, srcStepB, srcRoiSize);

ippiWTFwdRow_D97_JPEG2K_32f_C1R (pSrcB + 4, srcStepB, pDstLow, dstLowStep, pDstHigh, dstHighStep, dstRoiSize, ippWTFilterFirstLow);

//----------------------------------------------------------------------------

Ipp32f pDst[8*8] = {0};

// adds border to the source image
ippiCopy_32f_C1R(pDstLow, srcStep/2, pDstLowB+1, 7*sizeof(Ipp32f), dstRoiSize);
ippiCopy_32f_C1R(pDstHigh, srcStep/2, pDstHighB+2, 8*sizeof(Ipp32f), dstRoiSize);

ippiWTInvRow_D97_JPEG2K_32f_C1R (pDstLowB+1, 7*sizeof(Ipp32f), pDstHighB+2, 8*sizeof(Ipp32f), dstRoiSize, pDst, srcStep, ippWTFilterFirstLow);

Moderator
255 Views

Yoav,

The code does not consider border extention. The following code fix the problem:

Ipp32f pSrc[8*8] = { 0.0, 0.1, 0.0, 11.0, 11.9, 0.0, 0.0, 0.0,

0.0, 0.0, 0.222, 11.0, 11.9, 0.0, 0.0, 0.0,

0.0, 0.0, 0.0, 11.0, 11.0, 0.0, 0.0, 0.0,

11.0, 11.0, 11.0, 11.0, 11.0, 11.0, 11.0, 11.0,

11.0, 11.0, 11.0, 11.0, 11.0, 11.0, 11.0, 11.0,

0.0, 0.0, 0.0, 11.0, 11.0, 0.0, 0.0, 0.0,

0.0, 0.0, 0.0, 11.0, 11.0, 0.0, 0.0, 0.0,

0.0, 0.0, 0.0, 11.0, 11.0, 0.0, 0.0, 0.0};

Ipp32f pSrcB[16*8] = {0};

int srcStep = 8*sizeof(Ipp32f);

int srcStepB = 16*sizeof(Ipp32f);

Ipp32f pDstLow[8*4];

Ipp32f pDstLowB[8*7] = {0};

int dstLowStep = 4*sizeof(Ipp32f);

Ipp32f pDstHigh[8*4];

Ipp32f pDstHighB[8*8] = {0};

int dstHighStep = 4*sizeof(Ipp32f);

IppiSize dstRoiSize = {4, 8};

IppiSize dstRoiSize1 = {7, 8};

IppiSize dstRoiSize2 = {8, 8};

IppiSize srcRoiSize = {8, 8};

IppiSize srcRoiSize1 = {16, 8};

// IppiSize srcRoiSizeB = {11, 8};

// adds border to the source image

//ippiCopy_32f_C1R(pSrc, srcStep, pSrcB + 4, srcStepB, srcRoiSize);

ippiCopyWrapBorder_32f_C1R(pSrc,srcStep,srcRoiSize,pSrcB,srcStepB,srcRoiSize1,0,4);

ippiWTFwdRow_D97_JPEG2K_32f_C1R (pSrcB + 4, srcStepB, pDstLow, dstLowStep, pDstHigh, dstHighStep, dstRoiSize, ippWTFilterFirstLow);

//----------------------------------------------------------------------------

Ipp32f pDst[8*8] = {0};

// adds border to the source image

// ippiCopy_32f_C1R(pDstLow, srcStep/2, pDstLowB+1, 7*sizeof(Ipp32f), dstRoiSize);

// ippiCopy_32f_C1R(pDstHigh, srcStep/2, pDstHighB+2, 8*sizeof(Ipp32f), dstRoiSize);

ippiCopyWrapBorder_32f_C1R(pDstLow,srcStep/2,dstRoiSize,pDstLowB,7*sizeof(Ipp32f),dstRoiSize1,0,1);

ippiCopyWrapBorder_32f_C1R(pDstHigh,srcStep/2,dstRoiSize,pDstHighB,8*sizeof(Ipp32f),dstRoiSize2,0,2);

ippiWTInvRow_D97_JPEG2K_32f_C1R (pDstLowB+1, 7*sizeof(Ipp32f), pDstHighB+2, 8*sizeof(Ipp32f), dstRoiSize, pDst, srcStep, ippWTFilterFirstLow);

Beginner
255 Views
Hi Chao and thanks,

Your solution "does the trick" and my initial program now works.
Since I'm the first in my company to use IPP this forum is invaluable for me as a place to get answers to my questions, so thanks again!

I have 2 more related questions :
(1) I read is several places in the literature that bi-orthogonal symmtric wavelet filters (like the 9-7 irreversible filter) are best applied with symmetric border extensions. However the suggested code uses wraparound border extensions and actually, there's no ipp function to creat symmetric border extensions. can you explain it?
(2) ipp offers another way to implement the 9-7 irreversible wavelet transform - via the general functions

ippiWTFwd_32f_C1R andippiWTInv_32f_C1R (when initialized with the 9-7 irreversible filter). are those 2 implementation equivalent? what is the recommended/efficient implementation?

thanks,

Yoav

Employee
255 Views
Yoav,

We have implementation of JPEG2000 specific WT functions and general WT functions. Those implemented specifically for JPEG2000 codec were optimized in terms of API for use in JPEG2000 codec.

Regards,