ThresholdAdaptiveBox
Performs adaptive thresholding with the Box method.
Syntax
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
);
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.
- maskSize
- Size of the kernel that is used to calculate a threshold level. Width and height ofmaskSizemust be equal and odd.
- 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 betweenippBorderReplorippBorderConstand 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 theippBorderConstborder type.
- pBuffer
- Pointer to the work buffer. To calculate the size of the temporary buffer, use theThresholdAdaptiveBoxGetBufferSizefunction.
Description
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.Return Values
- ippStsNoErr
- Indicates no error.
- ippStsNullPtrErr
- Indicates an error whenpSrc,pDst,pSrcDst, orpBufferisNULL.
- ippStsSizeErr
- Indicates an error whenroiSizehas a field with a zero or negative value.
- ippStsMaskSizeErr
- Indicates an error whenmaskSizehas a field with a zero or negative value, or fields ofmaskSizeare not equal.
- ippStsBorderErr
- Indicates an error whenborderTypehas an illegal value.
Example
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