FilterMedian

Performs direct median filtering of a vector.

Syntax

Intel IPP style:

IppStatus ippsqFilterMedianDirect_32f (const Ipp32f *pSrc, Ipp32f *pDst, Ipp32u srcLen, Ipp32u maskSize, Ipp32f* pDlySrc, Ipp32f* pBuffer);

IppStatus ippsqFilterMedianDirectQ15_16s (const Ipp16s *pSrc, Ipp16s *pDst, Ipp32u srcLen, Ipp32u maskSize, Ipp16s* pDlySrc, Ipp16s* pBuffer);

IppStatus ippsqFilterMedianDirectQ31_32s (const Ipp32s *pSrc, Ipp32s *pDst, Ipp32u srcLen, Ipp32u maskSize, Ipp32s* pDlySrc, Ipp32s* pBuffer);

DSP style:

typedef struct {
    Ipp32u  maskSize;
    Ipp32f *pState;
    Ipp32f *pBuffer;
} ippsq_median_instance_f32;

void ippsq_median_init_f32 (ippsq_median_instance_f32 *S, Ipp32u maskSize, Ipp32f *pState, Ipp32f *pBuffer);

void ippsq_median_f32 (const ippsq_median_instance_f32 *S, Ipp32f *pSrc, Ipp32f *pDst, Ipp32u blockSize);

typedef struct {
    Ipp32u  maskSize;
    Ipp16s *pState;
    Ipp16s *pBuffer;
} ippsq_median_instance_q15;

void ippsq_median_init_q15 (ippsq_median_instance_q15 *S, Ipp32u maskSize, Ipp16s *pState, Ipp16s *pBuffer);

void ippsq_median_q15 (const ippsq_median_instance_q15 *S, Ipp16s *pSrc, Ipp16s *pDst, Ipp32u blockSize);

typedef struct {
    Ipp32u  maskSize;
    Ipp32s *pState;
    Ipp32s *pBuffer;
} ippsq_median_instance_q31;

void ippsq_median_init_q31 (ippsq_median_instance_q31 *S, Ipp32u maskSize, Ipp32s *pState, Ipp32s *pBuffer);

void ippsq_median_q31 (const ippsq_median_instance_q31 *S, Ipp32s *pSrc, Ipp32s *pDst, Ipp32u blockSize);

Include Files

ippsq.h

dsp.h

Parameters

pSrc

Pointer to the source vector.

pDst

Pointer to the destination vector.

srcLen, blockSize

Number of elements in the source/destination vectors.

maskSize

Size of the median filter mask. If the specified value is even, the function subtracts 1 to get the odd value for the filter mask.

pDlySrc, pState

Pointer to the array containing the delay line of source values, of length maskSize-1. The pointer value can be NULL.

pState

Pointer to the additional buffer, of length maskSize*2.

Description

These functions perform median filtering of the source vector by replacing each element of the vector with the median value, which is taken over the fixed neighborhood (mask) of the processed element.

Median filtering removes impulsive noise, while keeping the signal blurring to a minimum. Median filters are extensively used in image and signal processing applications.

To simplify functions' implementation and ensure low bias of the output signal, set the maskSize parameter to an odd value. In the Intel IPP for Microcontrollers implementation of the median filter, filter's mask is always centered at the input element for which the median value is computed. You can use an even mask size as well, but internally it will be changed to odd by subtracting 1.

For one-frame median filtering, you can set pDlySrc and pState to NULL. In this case, elements which are outside of the source vector, but needed to compute the median value for border elements, are set to be equal to the corresponding edge element of the source vector. The value of the non-existent point is equal to the first point value, for example, x[-2]=x[-1]=x[0].

For internal calculations, these functions require an additional buffer pBuffer of size maskSize*2.

Intel IPP style:

This function computes median values for each element of the source vector pSrc and stores the result in pDst. The number of elements in the pDlySrc array should be at least maskSize-1. If pDlySrc is set, you need to initialize pDlyLine with 0 or any other initial values.

When using Intel IPP-style APIs, you do not need to call any initialization functions. Intel IPP-style functions directly get all necessary parameters as arguments.

DSP style: Each function type (f32, q15, and q31) has its own state structure, which must be initialized with the corresponding initialization function. The initialization function copies arguments into the state structure and sets the pState array to zero. The number of elements in the pState array should be at least maskSize – 1.

Return Values

ippStsNoErr

Indicates no error.

ippStsSizeErr

Indicates an error when maskSize is equal to zero.

ippStsNullPtrErr

Indicates an error when any of the specified pointers is NULL.

ippStsIncompleteOperation

Indicates a warning when the maskSize value is even.
For more complete information about compiler optimizations, see our Optimization Notice.