Intel® Integrated Performance Primitives (Intel® IPP) Developer Guide and Reference

ID 790148
Date 3/22/2024
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

Threshold

Performs thresholding of pixel values in an image buffer.

Syntax

Case 1: Not-in-place operation on one-channel data

IppStatus ippiThreshold_<mod>(const Ipp<datatype>* pSrc, int srcStep, Ipp<datatype>* pDst, int dstStep, IppiSize roiSize, Ipp<datatype> threshold, IppCmpOp ippCmpOp);

Supported values for mod:

8u_C1R

16u_C1R

16s_C1R

32f_C1R

Case 2: Not-in-place operation on multi-channel data

IppStatus ippiThreshold_<mod>(const Ipp<datatype>* pSrc, int srcStep, Ipp<datatype>* pDst, int dstStep, IppiSize roiSize, const Ipp<datatype> threshold[3], IppCmpOp ippCmpOp);

Supported values for mod:

8u_C3R

16u_C3R

16s_C3R

32f_C3R

8u_AC4R

16u_AC4R

16s_AC4R

32f_AC4R

Case 3: In-place operation on one-channel data

IppStatus ippiThreshold_<mod>(Ipp<datatype>* pSrcDst, int srcDstStep, IppiSize roiSize, Ipp<datatype> threshold, IppCmpOp ippCmpOp);

Supported values for mod:

8u_C1IR

16u_C1IR

16s_C1IR

32f_C1IR

Case 4: In-place operation on multi-channel data

IppStatus ippiThreshold_<mod>(Ipp<datatype>* pSrcDst, int srcDstStep, IppiSize roiSize, const Ipp<datatype> threshold[3], IppCmpOp ippCmpOp);

Supported values for mod:

8u_C3IR

16u_C3IR

16s_C3IR

32f_C3IR

8u_AC4IR

16u_AC4IR

16s_AC4IR

32f_AC4IR

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 starts of consecutive lines in the source image.

pDst

Pointer to the destination image ROI.

dstStep

Distance in bytes between starts of consecutive lines in the destination image.

pSrcDst

Pointer to the source and destination image ROI (for the in-place operation).

srcDstStep

Distance in bytes between starts of consecutive lines in the source and destination image buffer (for the in-place operation).

roiSize

Size of the source and destination ROI in pixels.

threshold

The threshold level value to use for each pixel. In case of multi-channel data, an array of threshold values for each color channel is used.

ippCmpOp

The operation specified for comparing pixel values and the threshold. Comparison for either “less than” or “greater than” can be used.

Description

This function operates with ROI (see Regions of Interest in Intel IPP).

This function thresholds pixels in the source image pSrc using the specified level threshold. Pixel values in the source image are compared to the threshold value according to the type of comparison operation specified in the ippCmpOp. The following values for ippCmpOp are possible:

  • ippCmpLess specifies the “less than” comparison and defines the threshold value as a lower bound. Comparison is performed by the following formula:



  • ippCmpGreater specifies the “greater than” comparison and defines the threshold value as an upper bound. Comparison is performed by the following formula:



If the result of comparison is true, the corresponding output pixel is set to the threshold value. Otherwise, it is set to the source pixel value.

Return Values

ippStsNoErr

Indicates no error. Any other value indicates an error or a warning.

ippStsNullPtrErr

Indicates an error condition if one of the specified pointer is NULL.

ippStsSizeErr

Indicates an error condition if roiSize has a field with zero or negative value.

ippStsStepErr

Indicates an error condition if srcStep, dstStep, or srcDstStep has a zero or negative value

ippStsNotSupportedModeErr

Indicates an error if the comparison mode is not supported.

Example

The code example below shows how to use the ippiThreshold_8u_C1R function.

void func_threshold()
{
    IppiSize ROI = {5,4};
    Ipp8u src[9*4] = {1, 2, 4, 8, 16, 8, 4, 2, 1,
                      1, 2, 4, 8, 16, 8, 4, 2, 1,                     
                      1, 2, 4, 8, 16, 8, 4, 2, 1,                     
                      1, 2, 4, 8, 16, 8, 4, 2, 1};
    Ipp8u dst[9*4];
    Ipp8u threshold = 6;
    ippiThreshold_8u_C1R(src, 9, dst, 9, ROI, threshold, ippCmpGreater);

}

Result:

      dst
1  2  4  6  6  8  4  2  1
1  2  4  6  6  8  4  2  1
1  2  4  6  6  8  4  2  1
1  2  4  6  6  8  4  2  1