Note: This page has been translated by MathWorks. Please click here

To view all translated materials including this page, select Japan from the country navigator on the bottom of this page.

To view all translated materials including this page, select Japan from the country navigator on the bottom of this page.

Median filter

The `dsp.MedianFilter`

System
object™ computes
the moving median of the input signal along each channel, independently
over time. The object uses the sliding window method to compute the
moving median. In this method, a window of specified length is moved
over each channel, sample by sample, and the object computes the median
of the data in the window. For more details, see Algorithms.

The object accepts multichannel inputs, that is, *m*-by-*n* size
inputs, where *m* ≥ 1, and *n* >
1. *m* is the number of samples in each frame (or
channel), and *n* is the number of channels. The
object also accepts variable-size inputs. Once the object is locked,
you can change the size of each input channel. However, the number
of channels cannot change. This object supports C and C++ code generation.

To compute the moving median of the input:

Create a

`dsp.MedianFilter`

object and set the properties of the object.Call

`step`

to compute the moving median.

Alternatively, instead of using the `step`

method
to perform the operation defined by the System
object, you can
call the object with arguments, as if it were a function. For example, ```
y
= step(obj,x)
```

and `y = obj(x)`

perform
equivalent operations.

`medFilt = dsp.MedianFilter`

returns a median
filter object, `medFilt`

, using the default properties.

`medFilt = dsp.MedianFilter(Len)`

sets the `WindowLength`

property
to `Len`

.

`medFilt = dsp.MedianFilter(Name,Value)`

specifies
properties using `Name,Value`

pairs. Unspecified
properties have default values.

**Example**:

`movMin = dsp.MedianFilter('WindowLength',5);`

reset | Reset internal states of System object |

step | Moving median of input signal |

Common to All System Objects | |
---|---|

`clone` | Create System object with same property values |

`getNumInputs` | Expected number of inputs to a System object |

`getNumOutputs` | Expected number of outputs of a System object |

`isLocked` | Check locked states of a System object (logical) |

`release` | Allow System object property value changes |

[1] Bodenham, Dean. “Adaptive Filtering and Change Detection for Streaming Data.” PH.D. Thesis. Imperial College, London, 2012.

`dsp.Median`

|`dsp.MovingAverage`

|`dsp.MovingMaximum`

|`dsp.MovingMinimum`

|`dsp.MovingRMS`

|`dsp.MovingStandardDeviation`

|`dsp.MovingVariance`

Was this topic helpful?