Visible to Intel only — GUID: GUID-0A896B15-8F30-4502-81BE-C5D26E380A00
Visible to Intel only — GUID: GUID-0A896B15-8F30-4502-81BE-C5D26E380A00
ThresholdAdaptiveGauss
Performs adaptive thresholding with the Gaussian method.
Syntax
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);
Include Files
ippi.h
Domain Dependencies
Headers: ippcore.h, ippvm.h, ipps.h
Libraries: ippcore.lib, ippvm.lib, ipps.lib
Parameters
- pSrc
- Pointer to the source image ROI.
- srcStep
- Distance, in bytes, between the starting points of consecutive lines in the source image.
- pDst
- Pointer to the destination image ROI.
- dstStep
- Distance, in bytes, between the starting points of consecutive lines in the destination image.
- pSrcDst
- Pointer to the source and destination image ROI (for the in-place function).
- srcDstStep
- Distance, in bytes, between the starting points of consecutive lines in the source and destination image (for the in-place function).
- roiSize
- Size of the destination image ROI, in pixels.
- delta
- Value for threshold calculation.
- valGT
- Output pixel if the source pixel value is more than threshold.
- valLE
- Output pixel if the source pixel value is less than, or equal to threshold.
- borderType
-
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:
- ippBorderInMemTop
- ippBorderInMemBottom
- ippBorderInMemLeft
- ippBorderInMemRight
- borderValue
-
Constant value(s) to assign to pixels of the constant border. This parameter is applicable only to the ippBorderConst border type.
- pSpec
-
Pointer to the adaptive threshold specification structure.
- pBuffer
- Pointer to the work buffer. To calculate the size of the temporary buffer, use the ThresholdAdaptiveGaussGetBufferSize function.
Description
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.
Return Values
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. |
Example
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