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

ID 790148
Date 3/22/2024
Public
Document Table of Contents

HarrisCorner

Implements Harris corner detection algorithm.

Syntax

IppStatus ippiHarrisCorner_8u32f_C1R(const Ipp8u* pSrc, int srcStep, Ipp32f* pDst, int dstStep, IppiSize roiSize, IppiDifferentialKernel filterType, IppiMaskSize filterMask, Ipp32u avgWndSize, float k, float scale, IppiBorderType borderType, Ipp8u borderValue, Ipp8u* pBuffer);

IppStatus ippiHarrisCorner_32f_C1R(const Ipp32f* pSrc, int srcStep, Ipp32f* pDst, int dstStep, IppiSize roiSize, IppiDifferentialKernel filterType, IppiMaskSize filterMask, Ipp32u avgWndSize, float k, float scale, IppiBorderType borderType, Ipp32f borderValue, Ipp8u* pBuffer);

Include Files

ippcv.h

Domain Dependencies

Headers: ippcore.h, ippvm.h, ipps.h, ippi.h

Libraries: ippcore.lib, ippvm.lib, ipps.lib, ippi.lib

Parameters

pSrc
Pointer to the source image.
srcStep
Distance, in bytes, between the starting points of consecutive lines in the source image.
pDst
Pointer to the destination image.
dstStep
Distance, in bytes, between the starting points of consecutive lines in the destination image.
roiSize
Size of the source and destination image ROI in pixels.
filterType
Type of the derivative operator. Possible values are:

ippKernelSobel

Sobel filter

ippKernelScharr

Scharr filter

ippKernelCentralDiff

Central differences operator
filterMask
Size of the derivative filter aperture. The list of possible values depends on the filterType value:
Filter Type Filter Mask
ippKernelSobel ippMskSize3x3, ippMskSize5x5
ippKernelScharr ippMskSize3x3
ippKernelCentralDiff ippMskSize3x3
avgWndSize

Linear size of a neighborhood block for averaging.

k

Harris detector free coefficient.

scale

Destination image scale factor.

borderType

Type of border. Possible values are:

ippBorderConst

Values of all border pixels are set to constant.

ippBorderRepl

Border is replicated from the edge pixels.

ippBorderInMem

Border is obtained from the source image pixels in memory.

ippBorderMirror

Border pixels are mirrored from the source image boundary pixels.

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
Each of these flags means that for the corresponding border the outside pixels of the source image are in memory.

borderValue

Constant value(s) to assign to pixels of the constant border. This parameter is applicable only to the ippBorderConst border type. The ippiHarrisCorner function uses the specified constant value only at the first stage of the algorithm. At the third stage, the function uses zero constant border.

pBuffer
Pointer to the pre-allocated temporary buffer. To calculate the size of the temporary buffer, use the HarrisCornerGetBufferSize function.

Description

This function goes through the following stages to implement the Harris corner detection algorithm:

  1. Computes I(x, y)x and I(x, y)y gradients for each (x, y) pixel of the image. The function computes gradients using the derivative operator specified by the filterType and filterMask parameters.

  2. Computes products of the gradients at each (x, y) pixel of the image:

  3. Performs averaging of the products of gradients over a rectangular neighborhood block at each pixel of the image. The block size is specified by the avgWndSize value.

  4. Defines 2x2 gradient covariance matrix H(x , y) over a rectangular neighborhood block for each (x, y) pixel of the image.

  5. Computes the corner response at each pixel of the image:

    where

    k is the Harris detector free parameter

The first and third stages of the function algorithm are filtering operations; they use border processing approach that is specified by the borderType parameter.

The scale parameter is applied to the output image.

Before using this function, compute the size of the temporary work buffer using the HarrisCornerGetBufferSize function.

Return Values

ippStsNoErr

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

ippStsNullPtrErr

Indicates an error when pSrc, pDst, or pBufferSize is NULL.

ippStsSizeErr

Indicates an error in the following cases:
  • when roiSize is less than, or equal to zero

  • when avgWndSize is equal to zero

ippStsNotEvenStepErr

Indicates an error when one of the step values is not divisible by 4 for floating point images.

ippStsFilterTypeErr

Indicates an error when filterType has an illegal value.

ippStsMaskSizeErr

Indicates an error when filterMask has an illegal value.

ippStsBorderErr

Indicates an error when borderType has an illegal value.

ippStsStepErr

Indicates an error when srcStep or dstStep has a negative value.

ippStsInplaceModeNotSupportedErr

Indicates an error when pSrc and pDst point to the same image.

Example

The code example below demonstrates how to use the ippiHarrisCorner_8u32f_C1R and ippiHarrisCornerGetBufferSize functions.

    ...
    int    bufSize = 0;
    Ipp8u* pBuffer  = 0;
    Ipp32u numChannels = 1;
    IppStatus status = ippStsNoErr;
    IppiBorderType borderType = ippBorderRepl;
    IppiDifferentialKernel filterType = ippFilterSobel;
    IppiMaskSize filterMask = ippMskSize5x5;
    Ipp32u avgWndSize = 3;
    Ipp32f scale = 1.0f;

    /* Computes the temporary work buffer size */
    status = ippiHarrisCornerGetBufferSize(roiSize, filterMask, avgWndSize, ipp8u, numChannels, &bufSize);

    /* Memory allocation */
    if (status != ippStsNoErr) pBuffer = ippsMalloc_8u(bufSize);

    if (pBuffer != NULL)
    {
        /* Harris Corner processing */
        status = ippiHarrisCorner_8u32f_C1R(pSrc, srcStep, pDst, dstStep, roiSize, filterType, filterMask, avgWndSize, 0.04f,
            scale, borderType, 0, pBuffer);

        ippsFree(pBuffer);
    }
    ...

See Also