First, chose a moving window with odd length, which is composed of the current sample of the input signal and make the window centers around the current sample.
(3)
Next, for the each current window data, its standard deviation and local median would be computed.
where is the scale factor which is given by .
describes the median absolute deviation (MAD). For a normally distributed data, the scale factor is equal to 1.4826, which makes the standard deviation estimate a unbiased for Gaussian data.
(4)
Recent sample would be compared with , where threshold value is given by .
(5)
If the filter identifies the current sample, , then the HF replaces the median with current samples as follows:
With the increase of , we can reduce the effect of HF over the signal. If is 0, then the HF behaves as a regular median filter.