Developer Reference for Intel® Integrated Performance Primitives 2019
Performs adaptive thresholding with the Gaussian method.
IppStatus ippiThresholdAdaptiveGauss_8u_C1R(const Ipp8u* pSrc, int srcStep, Ipp8u* pDst, int dstStep, IppiSize roiSize, Ipp32f delta, Ipp8u valGT, Ipp8u valLE, IppiBorderType borderType, Ipp8u borderValue, IppiThresholdAdaptiveSpec* pSpec, Ipp8u* pBuffer);
IppStatus ippiThresholdAdaptiveGauss_8u_C1IR(Ipp8u* pSrcDst, int srcDstStep, IppiSize roiSize, Ipp32f delta, Ipp8u valGT, Ipp8u valLE, IppiBorderType borderType, Ipp8u borderValue, IppiThresholdAdaptiveSpec* pSpec, Ipp8u* pBuffer);
ippi.h
Headers: ippcore.h, ippvm.h, ipps.h
Libraries: ippcore.lib, ippvm.lib, ipps.lib
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.
Pointer to the adaptive threshold specification structure.
This function performs adaptive thresholding of the source image ROI using the Gaussian 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 weighted sum (cross-correlation with a Gaussian window) of the maskSize.width*maskSize.height neighborhood of a (x, y) pixel minus delta.
The function uses a separable Gaussian filter. Filter coefficients are computed according to the following formula:
Gi = A * exp( - (i-(maskSize.width-1)/2)2)/(0.5 * sigma2)
where
A is a scale factor for ∑iGi = 1 (i = 0, ..., maskSize.width-1)
Before using this function, compute the size of the external work buffer and specification structure using the ThresholdAdaptiveGaussGetBufferSize function, and initialize the structure using the ThresholdAdaptiveGaussInit function.
ippStsNoErr |
Indicates no error. |
ippStsNullPtrErr |
Indicates an error when pSrc, pDst, pSrcDst, pSpec, or pBuffer is NULL. |
ippStsSizeErr |
Indicates an error when roiSize has a field with a zero or negative value. |
ippStsContextMatchErr |
Indicates an error when pSpec does not match. |
ippStsBorderErr |
Indicates an error when borderType has an illegal value. |
The code example below demonstrates how to use the ippiThresholdAdaptiveGauss_8u_C1R, ThresholdAdaptiveGaussGetBufferSize, and ThresholdAdaptiveGaussInit functions.
IppStatus threshold_adaptive_gauss_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; int specSize; IppStatus status; Ipp32f sigma = 10.0f; Ipp32f delta = 0.5f; Ipp8u valGT = 254; Ipp8u valLE = 1; IppiThresholdAdaptiveSpec *pSpec; Ipp8u *pBuffer; ippiThresholdAdaptiveGaussGetBufferSize(roiSize, maskSize, ipp8u, 1, &specSize, &bufferSize); pSpec = (IppiThresholdAdaptiveSpec *)ippsMalloc_8u(specSize); pBuffer = ippsMalloc_8u(bufferSize); ippiThresholdAdaptiveGaussInit(roiSize, maskSize, ipp8u, 1, sigma, pSpec); ippiThresholdAdaptiveGauss_8u_C1R(pSrc, srcStep, pDst, dstStep, roiSize, delta, valGT, valLE, borderType, 33, pSpec, pBuffer); ippsFree(pBuffer); ippsFree(pSpec); 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