Median Filter
Library:
DSP System Toolbox /
Filtering /
Filter Designs
DSP System Toolbox /
Statistics
Description
The Median Filter block computes the moving median of the input signal
along each channel independently over time. The block uses the sliding window method to
compute the moving median. In this method, a window of specified length moves over each
channel sample by sample, and the block computes the median of the data in the window.
This block performs median filtering on the input data over time. For more details, see
Algorithms.
Ports
Input
Port_1 — Data input
column vector | row vector | matrix
Data over which the block computes moving median. The block accepts
real-valued or complex-valued multichannel inputs, that is,
m-by-n size inputs, where
m ≥ 1, and n ≥ 1. The block
also accepts variable-size inputs. During simulation, you can change the
size of each input channel. However, the number of channels cannot
change.
Data Types:single | double
Complex Number Support:Yes
Output
Port_1 — Moving median output
column vector | row vector | matrix
The size of the moving median output matches the size of the input.
The block uses the sliding window method to compute the moving median.
For more details, see Algorithms.
Data Types:single | double
Complex Number Support:Yes
Parameters
Window length — Length of the sliding window
5 (default) | positive scalar integer
Window length specifies the length of the sliding
window in samples.
Simulate using — Type of simulation to run
Code generation (default) | Interpreted execution
Code generation
Simulate model using generated C code. The first time you run
a simulation, Simulink® generates C code for the block. The C code is
reused for subsequent simulations, as long as the model does not
change. This option requires additional startup time but
provides faster simulation speed
than Interpreted
execution.
Interpreted execution
Simulate model using the MATLAB® interpreter. This option shortens startup
time but has slower simulation speed than Code
generation.
Block Characteristics
Data Typesdouble | single
Multidimensional SignalsNo
Variable-Size SignalsYes
Algorithms
Sliding Window Method
In the sliding window method, the output for each input sample is the median of the current
sample and the Len - 1 previous samples. Len is the
length of the window in samples. To compute the first Len - 1 outputs,
when the window does not have enough data yet, the algorithm fills the window with zeros. As
an example, to compute the median value when the second input sample comes in, the algorithm
fills the window with Len - 2 zeros. The data vector,
x, is then the two data samples followed by Len -
2 zeros. This object performs median filtering on the input data over time.
Consider an example of computing the moving median of a streaming
input data using the sliding window method. The algorithm uses a window
length of 4. With each input sample that comes in, the window of length
4 moves along the data.
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.
Introduced in R2016b