If I have a list like that:
list = {1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1}
how can I filter it in such a way that noisy input (like the 2, here) is replaced by the neighbouring values, like that:
list = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
CommonestFilter[list, 3]
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
or
MedianFilter[list, 3]
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
Also
SequenceReplace[list, {x_,y_,x_}/; y!=x:>Sequence[x,x,x]]
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}