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

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

FilterMedian

MODIFIED API. Computes median values for each source vector element.

Syntax

IppStatus ippsFilterMedian_8u(const Ipp8u* pSrc, Ipp8u* pDst, int len, int maskSize, const Ipp8u* pDlySrc, Ipp8u* pDlyDst, Ipp8u* pBuffer);

IppStatus ippsFilterMedian_16s(const Ipp16s* pSrc, Ipp16s* pDst, int len, int maskSize, const Ipp16s* pDlySrc, Ipp16s* pDlyDst, Ipp8u* pBuffer);

IppStatus ippsFilterMedian_32s(const Ipp32s* pSrc, Ipp32s* pDst, int len, int maskSize, const Ipp32s* pDlySrc, Ipp32s* pDlyDst, Ipp8u* pBuffer);

IppStatus ippsFilterMedian_32f(const Ipp32f* pSrc, Ipp32f* pDst, int len, int maskSize, const Ipp32f* pDlySrc, Ipp32f* pDlyDst, Ipp8u* pBuffer);

IppStatus ippsFilterMedian_64f(const Ipp64f* pSrc, Ipp64f* pDst, int len, int maskSize, const Ipp64f* pDlySrc, Ipp64f* pDlyDst, Ipp8u* pBuffer);

IppStatus ippsFilterMedian_8u_I(Ipp8u* pSrcDst, int len, int maskSize, const Ipp8u* pDlySrc, Ipp8u* pDlyDst, Ipp8u* pBuffer);

IppStatus ippsFilterMedian_16s_I(Ipp16s* pSrcDst, int len, int maskSize, const Ipp16s* pDlySrc, Ipp16s* pDlyDst, Ipp8u* pBuffer);

IppStatus ippsFilterMedian_32s_I(Ipp32s* pSrcDst, int len, int maskSize, const Ipp32s* pDlySrc, Ipp32s* pDlyDst, Ipp8u* pBuffer);

IppStatus ippsFilterMedian_32f_I(Ipp32f* pSrcDst, int len, int maskSize, const Ipp32f* pDlySrc, Ipp32f* pDlyDst, Ipp8u* pBuffer);

IppStatus ippsFilterMedian_64f_I(Ipp64f* pSrcDst, int len, int maskSize, const Ipp64f* pDlySrc, Ipp64f* pDlyDst, Ipp8u* pBuffer);

Include Files

ipps.h

Domain Dependencies

Headers: ippcore.h, ippvm.h

Libraries: ippcore.lib, ippvm.lib

Parameters

pSrcDst

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

pSrc

Pointer to the source vector.

pDst

Pointer to the destination vector.

len

Number of elements in the vector.

maskSize

Median mask size, must be a positive integer. If an even value is specified, the function subtracts 1 and uses the odd value of the filter mask for median filtering.

pDlySrc

Pointer to the array containing values for the source delay lines.

pDlyDst

Pointer to the array containing values for the destination delay lines.

pBuffer

Pointer to the work buffer. To compute the size of the buffer, use the FilterMedianGetBufferSize function.

Description

IMPORTANT:
The API of this function has been modified in Intel IPP 9.0 release.

This function computes median values for each element of the source vector pSrc or pSrcDst, and stores the result in pDst or pSrcDst, respectively.

NOTE:

The values for non-existent elements are stored in pDlySrc (if it is not NULL). The last (maskSize-1) elements of vectors are stored in pDlyDst (if it is not NULL). For example, if maskSize is equal to 3, then:

pDst[0] = median(pDlySrc[0], pDlySrc[1], pSrc[0]);
pDst[1] = median(pDlySrc[1], pSrc[0], pSrc[1]);
pDst[2] = median(pSrc[0], pSrc[1], pSrc[2]);
...
pDlyDst[0] = pSrc[len-2];
pDlyDst[1] = pSrc[len-1]

If pDlySrc is NULL, the value of a non-existent element is equal to the value of the first vector element:

pDst[0] = median(pSrc[0], pSrc[0], pSrc[0]);
pDst[1] = median(pSrc[0], pSrc[0], pSrc[1]);
pDst[2] = median(pSrc[0], pSrc[1], pSrc[2]);
...

If pDlyDst is NULL, the operation of storing the last (maskSize-1) elements of vectors is not performed.

Return Values

ippStsNoErr

Indicates no error.

ippStsNullPtrErr

Indicates an error when one of thepSrcDst, pSrc, pDst, pBuffer pointers is NULL.

ippStsSizeErr

Indicates an error when len is less than or equal to 0.

ippStsEvenMedianMaskSize

Indicates a warning when the median mask length is even.

Example

The example below illustrates using ippsFilterMedian_16s_I for single-rate filtering.

void median(void) {
      Ipp16s x[8] = {1,2,127,4,5,0,7,8};
      IppStatus status = ippsFilterMedian_16s_I(x, 8, 3);
      printf_16s("median =", x,8, status); 
} 

Output:

    median =  1 1 2 4 5 4 5 7 
Matlab* Analog: 
    >> x = [1 2 127 4 5 0 7 8]; medfilt1(x)