Description

Median Filter

Design a hardware module that computes the median value of each 5-element sliding window over an input stream. For each position in the stream (starting from position 4), output the median of the current element and the 4 preceding elements.

Example: For input stream [3, 1, 4, 1, 5], the output should be [3] (median of [3, 1, 4, 1, 5]).

Input

stream

Stream of 8-bit Unsigned Integer
Input stream.

Output

Stream of 8-bit Unsigned Integer
Median of each 5-element window.