Performs one-level wavelet reconstruction of an image.
IppStatus ippiWTInv_32f_C1R(const Ipp32f* pApproxSrc, int approxStep, const Ipp32f* pDetailXSrc, int detailXStep, const Ipp32f* pDetailYSrc, int detailYStep, const Ipp32f* pDetailXYSrc, int detailXYStep, IppiSize srcRoiSize, Ipp32f* pDst, int dstStep, const IppiWTInvSpec_32f_C1R* pSpec , Ipp8u* pBuffer);
IppStatus ippiWTInv_32f_C3R(const Ipp32f* pApproxSrc, int approxStep, const Ipp32f* pDetailXSrc, int detailXStep, const Ipp32f* pDetailYSrc, int detailYStep, const Ipp32f* pDetailXYSrc, int detailXYStep, IppiSize srcRoiSize, Ipp32f* pDst, int dstStep, const IppiWTInvSpec_32f_C3R* pSpec, Ipp8u* pBuffer);
The function ippiWTInv is declared in the ippi.h file. It operates with ROI (see Regions of Interest in Intel IPP ). This function performs wavelet reconstruction of the output image pDst from the four component images. See Figure “Image Division into Blocks with Overlapping Borders” for the equivalent algorithm of ippiWTInv function operation. Wavelet parameters are contained in the inverse transform context structure pSpec. It must be allocated and initialized by the function ippiWTInvInitAlloc beforehand.
The reconstruction function needs a buffer pBuffer for temporary calculations. Its size can be computed by calling the function ippiWTInvGetBufSize. The buffer size does not depend on the size of processed images, and the same buffer can be used for reconstructing images of different size. However, it is not recommended to use the same buffer in different threads in a multithreaded mode. For better performance, use an aligned memory location for this buffer, which can be allocated by the function ippiMalloc.
Optimization Notice |
---|
Intel's compilers may or may not optimize to the same degree for non-Intel microprocessors for optimizations that are not unique to Intel microprocessors. These optimizations include SSE2, SSE3, and SSSE3 instruction sets and other optimizations. Intel does not guarantee the availability, functionality, or effectiveness of any optimization on microprocessors not manufactured by Intel. Microprocessor-dependent optimizations in this product are intended for use with Intel microprocessors. Certain optimizations not specific to Intel microarchitecture are reserved for Intel microprocessors. Please refer to the applicable product User and Reference Guides for more information regarding the specific instruction sets covered by this notice. Notice revision #20110804 |
The pointers pApproxSrc, pDetailXSrc, pDetailYSrc, and pDetailXYSrc point to ROIs of source images excluding borders. All source ROIs have the same size srcRoiSize, while the destination image size is uniquely determined from the following relations:
dstWidth = 2 * srcRoiSize .width; dstHeight = 2 * srcRoiSize.height;
As source ROIs do not include border pixels required to computations, the application program have to apply a border extension model (symmetrical, wraparound or another) to ROIs of all source images filling the neighboring memory locations. Note the border sizes may be different for different source images. The following C-language expressions can be used to calculate extended image border sizes:
int leftBorderLow = (lenLow - 1 - anchorLow) / 2; int leftBorderHigh = (lenHigh - 1 - anchorHigh) / 2; int rightBorderLow = (anchorLow + 1) / 2; int rightBorderHigh = (anchorHigh + 1) / 2; int apprLeftBorder = leftBorderLow; int apprRightBorder = rightBorderLow; int apprTopBorder = leftBorderLow; int apprBottomBorder = rightBorderLow; int detxLeftBorder = leftBorderLow; int detxRightBorder = rightBorderLow; int detxTopBorder = leftBorderHigh; int detxBottomBorder = rightBorderHigh; int detyLeftBorder = leftBorderHigh; int detyRightBorder = rightBorderHigh; int detyTopBorder = leftBorderLow; int detyBottomBorder = rightBorderLow; int detxyLeftBorder = leftBorderHigh; int detxyRightBorder = rightBorderHigh; int detxyTopBorder = leftBorderHigh; int detxyBottomBorder = rightBorderHigh;
See the description of the function ippiWTInvInitAlloc for the explanation of the used parameters.
The above relations show that left and top borders always have equal size only for approximation and diagonal detail images. Right and bottom borders also have equal size only for approximation and diagonal detail images. Thus, the size of memory block allocated for each source image must be extended to accommodate for added border pixels outside ROI.
Figure “Extended Horizontal Detail Source Image for Wavelet Reconstruction” shows ROI and extended image area for the horizontal detail source image.
Sizes of source images extended by border pixels can be calculated as follows:
apprWidthWithBorders = srcWidth + apprLeftBorder + apprRightBorder; apprHeightWithBorders = srcHeight + apprTopBorder + apprBottomBorder; detxWidthWithBorders = srcWidth + detxLeftBorder + detxRightBorder; detxHeightWithBorders = srcHeight + detxTopBorder + detxBottomBorder; detyWidthWithBorders = srcWidth + detyLeftBorder + detyRightBorder; detyHeightWithBorders = srcHeight + detyTopBorder + detyBottomBorder; detxyWidthWithBorders = srcWidth + detxyLeftBorder + detxyRightBorder; detxyHeightWithBorders = srcHeight + detxyTopBorder + detxyBottomBorder;
Example 13-1 shows how to use the function ippiWTInv_32f_C1R.
The ROI concept can be used to reconstruct large images by blocks or ‘tiles'.
To accomplish this, each the source images into blocks with overlapping borders, similar to what is considered in the description of the function ippiWTFwd. Each component must be subdivided into the same pattern of rectangular blocks.
ippStsNoErr |
Indicates no error. Any other value indicates an error or a warning. |
ippStsNullPtrErr |
Indicates an error condition if any of the specified pointers is NULL. |
ippStsSizeErr |
Indicates an error condition if srcRoiSize has a field with zero or negative value. |
ippStsStepErr |
Indicates an error condition if step through any buffer is less than or equal to zero. |
ippStsContextMatchErr |
Indicates an error condition if a pointer to an invalid context structure is passed. |
void func_wavelet() {
IppiWTFwdSpec_32f_C1R* pSpec;
IppiWTInvSpec_32f_C1R* pSpecInv;
Ipp32f pTapsLow[3] = {0.25, 0.5, 0.25};
int lenLow = 3;
int anchorLow = 1;
Ipp32f pTapsHigh[3] = { 0.75, -0.25, -0.125};
int lenHigh = 3;
int anchorHigh = 1;
Ipp32f pSrc[8*8] = { 0.0, 0.0, 0.0, 11.1, 11.1, 0.0, 0.0, 0.0
0.0, 0.0, 0.0, 11.1, 11.1, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 11.1, 11.1, 0.0, 0.0, 0.0,
11.1, 11.1, 11.1, 11.1, 11.1, 11.1, 11.1, 11.1,
11.1, 11.1, 11.1, 11.1, 11.1, 11.1, 11.1, 11.1,
0.0, 0.0, 0.0, 11.1, 11.1, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 11.1, 11.1, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 11.1, 11.1, 0.0, 0.0, 0.0};
Ipp32f pSrcB[9*9];
int srcStepB = 9*sizeof(Ipp32f);
IppiSize roiSizeB = {9, 9};
int srcStep = 8*sizeof(Ipp32f);
IppiSize roiSize = {8, 8};
Ipp32f pDetailXDst[4*4];
Ipp32f pDetailYDst[4*4];
Ipp32f pDetailXYDst[4*4];
Ipp32f pApproxDst[4*4];
IppiSize dstRoiSize = {4, 4};
int bufSize, bufSizeInv;
Ipp8u* pBuffer;
Ipp8u* pBufferInv;
Ipp32f pDstInv[8*8];
Ipp32f pAppB[5*5];
Ipp32f pXB[5*5];
Ipp32f pYB[5*5];
Ipp32f pXYB[5*5];
int StepB = 5*sizeof(Ipp32f);
IppiSize roiInvSize = {4, 4};
IppiSize roiInvSizeB = {5, 5};
int stepDstInv = 8*sizeof(Ipp32f);
int approxStep, detailXStep, detailYStep, detailXYStep;
approxStep = detailXStep = detailYStep = detailXYStep = 4*sizeof(Ipp32f);
//adds border to the source image
ippiCopyWrapBorder_32s_C1R((Ipp32s*)pSrc, srcStep, roiSize, (Ipp32s*)pSrcB, srcStepB, roiSizeB, 1, 1);
//performs forward wavelet transform
ippiWTFwdInitAlloc_32f_C1R ( &pSpec, pTapsLow, lenLow, anchorLow, pTapsHigh, lenHigh, anchorHigh);
ippiWTFwdGetBufSize_C1R(pSpec, &bufSize);
pBuffer = ippsMalloc_8u(bufSize);
ippiWTFwd_32f_C1R (pSrcB + roiSizeB.width + 1, srcStepB, pApproxDst, approxStep, pDetailXDst, detailXStep, pDetailYDst, detailYStep, pDetailXYDst, detailXYStep, dstRoiSize, pSpec, pBuffer);
//------------------------------------
ippiWTInvInitAlloc_32f_C1R (&pSpecInv, pTapsLow, lenLow, anchorLow, pTapsHigh, lenHigh, anchorHigh);
ippiWTInvGetBufSize_C1R(pSpecInv, &bufSizeInv);
pBufferInv = ippsMalloc_8u(bufSizeInv);
//adds border to four images obtained after ippiWTFwd
ippiCopyWrapBorder_32s_C1R((Ipp32s*)pApproxDst, approxStep, dstRoiSize, (Ipp32s*)pAppB, StepB, roiInvSizeB, 0, 0);
ippiCopyWrapBorder_32s_C1R((Ipp32s*)pDetailXDst, detailXStep, dstRoiSize, (Ipp32s*)pXB, StepB, roiInvSizeB, 0, 0);
ippiCopyWrapBorder_32s_C1R((Ipp32s*)pDetailYDst, detailYStep, dstRoiSize, (Ipp32s*)pYB, StepB, roiInvSizeB, 0, 0);
ippiCopyWrapBorder_32s_C1R((Ipp32s*)pDetailXYDst, detailXYStep, dstRoiSize, (Ipp32s*)pXYB, StepB, roiInvSizeB, 0, 0);
//performs inverse wavelet transform
ippiWTInv_32f_C1R( pAppB, StepB, pXB, StepB, pYB, StepB, pXYB, StepB, roiInvSize, pDstInv, stepDstInv, pSpecInv, pBufferInv);
ippiWTInvFree_32f_C1R (pSpecInv);
ippiWTFwdFree_32f_C1R (pSpec);
}
Result:
After WTFwd ->
pApproxDst
0.0 2.8 8.3 0.0
2.8 4.9 9.0 2.8
8.3 9.0 10.4 8.3
0.0 2.8 8.3 0.0
pDetailXDst
0.0 1.0 3.1 0.0
8.3 7.3 5.2 8.3
-4.2 -2.1 2.1 -4.2
0.0 1.0 3.1 0.0
pDetailYDst
0.0 8.3 -4.2 0.0
1.0 7.3 -2.1 1.0
3.1 5.2 2.1 3.1
0.0 8.3 -4.2 0.0
pDetailXYDst
0.0 3.1 -1.6 0.0
3.1 0.0 4.7 3.1
-1.6 4.7 -4.7 -1.6
0.0 3.1 -1.6 0.0
After WTFinv ->
pDstInv
0.0 2.8 -0.3 -0.6 2.1 1.1 0.0 0.0
2.8 5.9 2.7 4.9 3.4 5.4 2.8 5.1
-0.3 2.7 -0.6 -1.2 2.2 0.7 -0.3 -0.5
-0.6 4.9 -1.2 -2.2 3.9 1.2 -0.6 -1.0
2.1 3.4 2.2 3.9 1.8 3.7 2.1 3.8
1.1 5.4 0.7 1.2 3.7 3.2 1.1 1.9
0.0 2.8 -0.3 -0.6 2.1 1.1 0.0 0.0
0.0 5.1 -0.5 -1.0 3.8 1.9 0.0 0.0
Copyright © 2000 - 2011, Intel Corporation. All rights reserved.