2D Wavelet transform with different border extension

2D Wavelet transform with different border extension

Hello all,

I'm implementing image compression tool using IPP 2D wavelet transform.
After establishing the forward and inverse transform (using the 9/7 filter) with wraparound border extension and acheiving perfect reconstruction with various decomposition levels, I tried to check the algorithm with different kind of border extension. to my surprise, I could not reconstruct the image with"Replicate" border extension (ippiCopyReplicateBorder_32f_C1R) nor with symmetric extension that I wrote myself.
the different IPP "copy+extension" functions receive the same arguments, so I can't see what's wrong.

hope you can help me. I'v pasted my forward wavelet transform code below.
and another question - why isn't there a symmetric "copy+extension" function in ippi?

thanks,

Yoav

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

bool WT::ForwardWT (const float* pSrc, int srcStep, int width, int height,
float* pSrcB, int srcStepWBorder, int srcWidthWBorder, int srcHeightWBorder, int leftTopBorder,
IppiWTFwdSpec_32f_C1R* pSpec, Ipp8u* pBuffer,
float* pApproxDst, float* pDetailXDst, float* pDetailYDst, float* pDetailXYDst, int dstStep,
BorderExtensionType extType) {

if (srcStep % 4 != 0 || srcStepWBorder % 4 != 0 || dstStep % 4 != 0)
return false;

// adds borders to the source buffer:

IppiSize srcRoi = {width, height};
IppiSize srcWBorderRoi = {srcWidthWBorder, srcHeightWBorder};

switch (extType) {
case eWRAP:
{
if (ippStsNoErr != ippiCopyWrapBorder_32f_C1R (pSrc, srcStep, srcRoi, pSrcB, srcStepWBorder, srcWBorderRoi, leftTopBorder, leftTopBorder))
return false;
}
break;
case eSYM:
{
if (!WT::CopySymmBorder_32f_C1R (pSrc, srcStep, srcRoi, pSrcB, srcStepWBorder, srcWBorderRoi, leftTopBorder, leftTopBorder))
return false;
}
break;
case eCONST:
{
if (ippStsNoErr != ippiCopyReplicateBorder_32f_C1R (pSrc, srcStep, srcRoi, pSrcB, srcStepWBorder, srcWBorderRoi, leftTopBorder, leftTopBorder))
return false;
}
break;
default:
return false; // a border extension must be dealt with.
}

// perform the forward transform:

IppiSize dstRoi = {width/2, height/2};
int srcROIOffset = leftTopBorder * srcStepWBorder/4 + leftTopBorder;
if (ippStsNoErr != ippiWTFwd_32f_C1R (pSrcB + srcROIOffset, srcStepWBorder, pApproxDst, dstStep, pDetailXDst,
dstStep, pDetailYDst, dstStep, pDetailXYDst, dstStep, dstRoi, pSpec, pBuffer)) {
return false;
}

return true;
}

2 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Hi Yoav,

I think ReplicateBorder cannot create a perfect reconstruction, because the wavelet filtered data cannot be replicated. For example,

If we have input data: {1 2 3 4}

and filter tap{ 1 1 1 }, suppose anchor is 0.

if we extern it data to with Replicated Border { 1, 2,3,4, 4,4.}. After the filtering the data, it will be { 6,9,11,12,12.}

If you use replicated border extension: extent the data of { 6,9,10}, it will be { 6,9,11, 11,11..}

The border actually is not consistent with the data after the filtering.

Symmetric and wraparound (periodic) extension is fine. For the symmetric problem, could you attach you full test code here? So we can run the test code here.

Thanks,
Chao

Leave a Comment

Please sign in to add a comment. Not a member? Join today