Visible to Intel only — GUID: GUID-4C5D13EA-23F1-4379-A3C7-D175632EB905
Visible to Intel only — GUID: GUID-4C5D13EA-23F1-4379-A3C7-D175632EB905
PyramidLayerDown
Creates a lower pyramid layer.
Syntax
IppStatus ippiPyramidLayerDown_<mod>(const Ipp<datatype>* pSrc, int srcStep, IppiSize srcRoiSize, Ipp<datatype>* pDst, int dstStep, IppiSize dstRoiSize, IppiPyramidDownState_<mod>* pState);
Supported values for mod:
8u_C1R |
16u_C1R |
32f_C1R |
8u_C3R |
16u_C3R |
32f_C3R |
Platform-aware functions
IppStatus ippiPyramidLayerDown_32f_C1R_L(const Ipp32f* pSrc, IppiSizeL srcStep, IppiSizeL srcRoiSize, Ipp32f* pDst, IppiSizeL dstStep, IppiSizeL dstRoiSize, IppiPyramidDownState_32f_C1R_L* pState);
Include Files
ippcv.h
Flavors with the _L suffix: ippcv_l.h
Domain Dependencies
Headers: ippcore.h, ippvm.h, ipps.h, ippi.h
Libraries: ippcore.lib, ippvm.lib, ipps.lib, ippi.lib
Parameters
- pSrc
- Pointer to the source image ROI.
- srcStep
- Distance, in bytes, between the starting points of consecutive lines in the source image.
- srcRoiSize
- Size of the source image ROI, in pixels.
- pDst
- Pointer to the destination image ROI.
- dstStep
- Distance, in bytes, between the starting points of consecutive lines in the destination image.
- dstRoiSize
- Size of the destination image ROI, in pixels.
- pState
- Pointer to the pyramid layer structure.
Description
This function operates with ROI (see Regions of Interest in Intel IPP).
This function creates a lower pyramid layer pDst from the source image pSrc. The function applies the convolution kernel to the source image using the mirror border and then performs downsampling. Before calling ippiPyramidLayerDown, compute the size of the pState structure and work buffer using the PyramidLayerDownGetSize function and initialize the structure using the PyramidLayerDownInit function. The function can process images with srcRoiSize not greater than the srcRoi parameter specified in the PyramidLayerDownInit function.
This function uses the mirrored border.
Return Values
ippStsNoErr |
Indicates no error. |
ippStsNullPtrErr |
Indicates an error if one of the specified pointers is NULL. |
ippStsSizeErr |
Indicates an error condition if srcRoiSize or dstRoiSize has a field with zero or negative value. |
ippStsStepErr |
Indicates an error condition if srcStep is less than srcRoiSize.width * <pixelSize> , or dstStep is less than dstRoiSize.width * <pixelSize>. |
ippStsNotEvenStepErr |
Indicates an error condition if one of the step values is not divisible by 4 for floating-point images, or by 2 for short-integer images. |
ippStsBadArgErr |
Indicates an error condition if pState->rate has wrong value. |
Example
/*******************************************************************************
* Copyright 2015 Intel Corporation.
*
*
* This software and the related documents are Intel copyrighted materials, and your use of them is governed by
* the express license under which they were provided to you ('License'). Unless the License provides otherwise,
* you may not use, modify, copy, publish, distribute, disclose or transmit this software or the related
* documents without Intel's prior written permission.
* This software and the related documents are provided as is, with no express or implied warranties, other than
* those that are expressly stated in the License.
*******************************************************************************/
// A simple example of downsampling of the image with
// 5x5 Gaussian kernel using Intel(R) Integrated Primitives (Intel(R) IPP) functions:
// ippiPyramidGetSize
// ippiPyramidInit
// ippiPyramidLayerDownGetSize_32f_C1R
// ippiPyramidLayerDownInit_32f_C1R
// ippiPyramidLayerDown_32f_C1R
#include <stdio.h>
#include "ipp.h"
#define WIDTH 128 /* Image width */
#define HEIGHT 128 /* Image height */
#define KERSIZE 3 /* Kernel size */
/* Next two defines are created to simplify code reading and understanding */
#define EXIT_MAIN exitLine: /* Label for Exit */
#define check_sts(st) if((st) != ippStsNoErr) goto exitLine; /* Go to Exit if Intel(R) IPP function returned status different from ippStsNoErr */
/* Results of ippMalloc() are not validated because Intel(R) IPP functions perform bad arguments check and will return an appropriate status */
int main(void)
{
IppStatus status = ippStsNoErr;
Ipp32f* pSrc = NULL; /* Pointer to source image */
int srcStep; /* Step, in bytes, through the source image */
IppiSize roiSize = { WIDTH, HEIGHT }; /* Size of source/destination ROI in pixels */
Ipp32f rate = 2.f; /* Neighbor levels ratio */
int level = 1000; /* Maximal number pyramid level */
int i = 0;
int pyrBufferSize = 0;
int pyrStructSize = 0;
IppiPyramid *pPyrStruct = NULL;
Ipp8u *pPyrBuffer = NULL;
Ipp8u *pPyrStrBuffer = NULL;
int pyrLStateSize = 0;
int pyrLBufferSize = 0;
Ipp8u *pPyrLStateBuf = NULL;
Ipp8u *pPyrLBuffer = NULL;
Ipp32f **pPyrImage = NULL;
Ipp32f kernel[KERSIZE] = { 1.f, 1.f, 1.f }; /* Separable symmetric kernel of odd length */
pSrc = ippiMalloc_32f_C1(roiSize.width, roiSize.height, &srcStep);
/* Build Gaussian pyramid */
{
/* Computes the temporary work buffer size */
check_sts( status = ippiPyramidGetSize(&pyrStructSize, &pyrBufferSize, level, roiSize, rate) )
pPyrBuffer = ippsMalloc_8u(pyrBufferSize);
pPyrStrBuffer = ippsMalloc_8u(pyrStructSize);
/* Initializes Gaussian structure for pyramids */
check_sts( status = ippiPyramidInit(&pPyrStruct, level, roiSize, rate, pPyrStrBuffer, pPyrBuffer) )
/* Correct maximum scale level */
level = pPyrStruct->level;
/* Allocate structures to calculate pyramid layers */
check_sts( status = ippiPyramidLayerDownGetSize_32f_C1R(roiSize, rate, KERSIZE, &pyrLStateSize, &pyrLBufferSize) )
pPyrLStateBuf = ippsMalloc_8u(pyrLStateSize);
pPyrLBuffer = ippsMalloc_8u(pyrLBufferSize);
/* Initialize the structure for creating a lower pyramid layer */
check_sts( status = ippiPyramidLayerDownInit_32f_C1R((IppiPyramidDownState_32f_C1R**)&pPyrStruct->pState, roiSize, rate,
kernel, KERSIZE, IPPI_INTER_LINEAR, pPyrLStateBuf, pPyrLBuffer) )
/* Allocate pyramid layers */
pPyrImage = (Ipp32f**)pPyrStruct->pImage;
pPyrImage[0] = pSrc;
pPyrStruct->pStep[0] = srcStep;
for(i = 1; i <= level; i++)
{
pPyrImage[i] = ippiMalloc_32f_C1(pPyrStruct->pRoi[i].width, pPyrStruct->pRoi[i].height, &pPyrStruct->pStep[i]);
}
/* Perform downsampling of the image with 5x5 Gaussian kernel */
for(i = 1; i <= level; i++)
{
check_sts( status = ippiPyramidLayerDown_32f_C1R(pPyrImage[i - 1], pPyrStruct->pStep[i - 1], pPyrStruct->pRoi[i - 1],
pPyrImage[i], pPyrStruct->pStep[i], pPyrStruct->pRoi[i], (IppiPyramidDownState_32f_C1R*)pPyrStruct->pState) )
}
}
EXIT_MAIN
if (pPyrImage)
for(i = 1; i <= level; i++)
ippiFree(pPyrImage[i]);
ippiFree(pPyrLStateBuf);
ippiFree(pPyrLBuffer);
ippiFree(pPyrStrBuffer);
ippiFree(pPyrBuffer);
ippiFree(pSrc);
printf("Exit status %d (%s)\n", (int)status, ippGetStatusString(status));
return status;
}