An introduction to the algorithm
Median filtering is a commonly used preprocessing technique in digital signal processing and digital image processing.
two code
import random
import numpy as np
import scipy.signal as signal
x = np.arange(0,100,10)
random.shuffle(x)#打乱顺序
print(x)
print(signal.medfilt(x,3))#中值滤波
Three running results
[30 0 20 60 70 40 50 80 90 10]
[ 0. 20. 20. 60. 60. 50. 50. 80. 80. 10.]