Admin Production ni-theme
Current Publication

MedianFilter

LabWindows/CVI

MedianFilter

Advanced Analysis Library Only

AnalysisLibErrType MedianFilter (double xArray[], ssize_t numberOfXAndYElements, ssize_t leftRank, ssize_t rightRank, double y[]);

Purpose

Filters the input array using a median filter. MedianFilter can perform the operation in place; that is, the input and output arrays can be the same. MedianFilter filters the input array xArray using the following equation:

Yi = Median(Ji) for i = 0, 1, 2, ..., n – 1

Where Y represents the output sequence of filtered data y, n is the number of elements in xArray, Ji is a subset of the input xArray centered about the ith element of xArray, and the indexed elements outside the range of xArray equal zero. The following equation describes Ji.

Ji = {xi–rl, xi–rl+1, ..., xi–1, xi, xi+1, ..., xi+rr–1, xi+rr},

Where rl is the left rank and rr is the right rank.

The following illustration shows the computation of yi.

loc_eps_medfilter.gif

Example Code

/* Generate a random signal and filter it using a median filter. */
double x[256], y[256];
ssize_t n, leftrank, rightrank;
int status;
n = 256;
leftrank = 2;
rightrank = 3;
Uniform (n, 17, x);
status = MedianFilter(x, n, leftrank, rightrank, y);

Parameters

Input
Name Type Description
xArray double [] Array containing the raw data to filter.
numberOfXAndYElements ssize_t Number of elements in both the input and output array.
leftRank ssize_t Number of elements used to compute the median filter to the left side. leftRank must be greater than or equal to 0.
rightRank ssize_t Number of elements used to compute the median filter to the right side. rightRank must be less than leftRank.

If rightRank is less than 0, rightRank is equal to leftRank.
Output
Name Type Description
y double [] Filtered data.

Return Value

Name Type Description
status AnalysisLibErrType A value that specifies the type of error that occurred. Refer to analysis.h for definitions of these constants.

Additional Information

Library: Advanced Analysis Library

Include file: analysis.h

LabWindows/CVI compatibility: LabWindows/CVI 2012 and later