Developer Reference for Intel® Integrated Performance Primitives 2019
Performs adaptive thresholding with the Box method.
IppStatus ippiThresholdAdaptiveBox_8u_C1R(const Ipp8u* pSrc, int srcStep, Ipp8u* pDst, int dstStep, IppiSize roiSize, IppiSize maskSize, Ipp32f delta, Ipp8u valGT, Ipp8u valLE, IppiBorderType borderType, Ipp8u borderValue, Ipp8u* pBuffer);
IppStatus ippiThresholdAdaptiveBox_8u_C1IR(Ipp8u* pSrcDst, int srcDstStep, IppiSize roiSize, IppiSize maskSize, Ipp32f delta, Ipp8u valGT, Ipp8u valLE, IppiBorderType borderType, Ipp8u borderValue, Ipp8u* pBuffer);
ippi.h
Headers: ippcore.h, ippvm.h, ipps.h
Libraries: ippcore.lib, ippvm.lib, ipps.lib
Size of the kernel that is used to calculate a threshold level. Width and height of maskSize must be equal and odd.
Type of border. Possible values are:
ippBorderConst |
Values of all border pixels are set to a constant. |
ippBorderRepl |
Border is replicated from the edge pixels. |
ippBorderInMem |
Border is obtained from the source image pixels in memory. |
Mixed borders are also supported. They can be obtained by the bitwise operation OR between ippBorderRepl or ippBorderConst and the following flags:
Constant value(s) to assign to pixels of the constant border. This parameter is applicable only to the ippBorderConst border type.
This function performs adaptive thresholding of the source image ROI using the Box method. Output pixels are calculated according to the following formulas:
pDst(x,y) = valGT, if pSrc(x,y) > T(x,y)
pDst(x,y) = valLE, if pSrc(x,y) <= T(x,y)
where
T(x,y) is a mean of the maskSize.width*maskSize.height neighborhood of a (x, y) pixel minus delta.
Before using this function, compute the size of the external work buffer using the ThresholdAdaptiveBoxGetBufferSize function.
ippStsNoErr |
Indicates no error. |
ippStsNullPtrErr |
Indicates an error when pSrc, pDst, pSrcDst, or pBuffer is NULL. |
ippStsSizeErr |
Indicates an error when roiSize has a field with a zero or negative value. |
ippStsMaskSizeErr |
Indicates an error when maskSize has a field with a zero or negative value, or fields of maskSize are not equal. |
ippStsBorderErr |
Indicates an error when borderType has an illegal value. |
The code example below demonstrates how to use the ippiThresholdAdaptiveBox_8u_C1R and ThresholdAdaptiveBoxGetBufferSize functions.
IppStatus threshold_adaptive_box_8u_c1( void ) { Ipp8u pSrc[8*8] = { 0, 255, 1, 254, 2, 253, 3, 252, 251, 4, 250, 5, 249, 6, 248, 7, 8, 247, 9, 246, 10, 245, 11, 244, 243, 12 , 242, 13, 241, 14, 240, 15, 16, 239, 17, 238, 18, 237, 19, 236, 235, 20, 234, 21, 233, 22, 232, 23, 24, 231, 25, 230, 26, 229, 26, 228, 227, 27, 226, 28, 225, 29, 224, 30 }; Ipp8u pDst[8*8]; IppiSize roiSize = {8, 8}; IppiSize maskSize = {3, 3}; IppiBorderType borderType = ippBorderConst; int srcStep = 8 * sizeof(Ipp8u); int dstStep = 8 * sizeof(Ipp8u); int bufferSize; IppStatus status; Ipp32f delta = 0.5f; Ipp8u valGT = 254; Ipp8u valLE = 1; Ipp8u *pBuffer; ippiThresholdAdaptiveBoxGetBufferSize(roiSize, maskSize, ipp8u, 1, &bufferSize); pBuffer = ippsMalloc_8u(bufferSize); ippiThresholdAdaptiveBox_8u_C1R(pSrc, srcStep, pDst, dstStep, roiSize, maskSize, delta, valGT, valLE, borderType, 33, pBuffer); ippsFree(pBuffer); return status; }
pDst after function execution:
1 254 1 254 1 254 1 254 254 1 254 1 254 1 254 1 1 254 1 254 1 254 1 254 254 1 254 1 254 1 254 1 1 254 1 254 1 254 1 254 254 1 254 1 254 1 254 1 1 254 1 254 1 254 1 254 254 1 254 1 254 1 254 1