Link Copied
The following Example14-6 shows how different general pyramids functions can be used to create the Gaussian and Laplacian pyramids:
void UsePyramids(Ipp32f *pSrc, IppiSize srcRoi, int srcStep, Ipp32f *pkernel, int kerSize) {
float rate = 2.0f;
IppiPyramid *gPyr; // pointer to Gaussian pyramid structure
IppiPyramid *lPyr; // pointer to Laplacian pyramid structure
// allocate pyramid structures
ippiPyramidInitAlloc (&gPyr, 1000, srcRoi, rate);
ippiPyramidInitAlloc (&lPyr, 1000, srcRoi, rate);
{
int i;
IppiPyramidDownState_32f_C1R **gState = (IppiPyramidDownState_32f_C1R**)&(gPyr->pState);
IppiPyramidUpState_32f_C1R **lState = (IppiPyramidUpState_32f_C1R**) &(lPyr->pState);
Ipp32f **gImage = (Ipp32f**)(gPyr->pImage);
Ipp32f **lImage = (Ipp32f**)(lPyr->pImage);
IppiSize *pRoi = gPyr->pRoi;
int *gStep = gPyr->pStep;
int *lStep = lPyr->pStep;
int level = gPyr->level;
Ipp32f *ptr;
int step;
// allocate structures to calculate pyramid layers
ippiPyramidLayerDownInitAlloc_32f_C1R (gState, srcRoi, rate, pkernel, kerSize, IPPI_INTER_LINEAR);
ippiPyramidLayerUpInitAlloc_32f_C1R (lState, srcRoi, rate, pkernel, kerSize, IPPI_INTER_LINEAR);
// build Gaussian pyramid with level+1 layers
gImage[0] = pSrc;
gStep[0] = srcStep;
for (i=1; i<=level;i++) {
gImage = ippiMalloc_32f_C1(pRoi.width,pRoi.height,gStep+i);
ippiPyramidLayerDown_32f_C1R (gImage[i-1], gStep[i-1], pRoi[i-1], gImage, gStep, pRoi, *gState);
}
// build Laplacian pyramid with level layers
ptr = ippiMalloc_32f_C1(srcRoi.width,srcRoi.height,&step);
for (i=level-1; i>=0; i--) {
lImage = ippiMalloc_32f_C1(pRoi.width,pRoi.height,lStep+i);
ippiPyramidLayerUp_32f_C1R(gImage[i+1], gStep[i+1], pRoi[i+1], ptr, step, pRoi, *lState);
ippiSub_32f_C1R(ptr, step, gImage, gStep, lImage, lStep, pRoi);
}
ippiFree(ptr);
ippiPyramidLayerDownFree_32f_C1R(*gState);
ippiPyramidLayerUpFree_32f_C1R(*lState);
// use Gaussian and Laplacian pyramids
// free allocated images
for (i=1; i<=level; i++) {
ippiFree(gImage);
ippiFree(lImage[i-1]);
}
}
// free pyramid structures
ippiPyramidFree (gPyr);
ippiPyramidFree (lPyr);
}
For more complete information about compiler optimizations, see our Optimization Notice.