How a mean filter is called as linear filter and a median filter is called as non linear filter? I understand how a mean and median filter operates, but I was not able to relate with the term linear and non-linear. Please explain me with an example.
Nonlinear filters are those for which the linearity relationship breaks down. Consider two signals $A$ and $B$, for linear filter such as mean filter $F_m$,you have $F_m(A+\lambda B) = F_m(A) + \lambda F_m(B)$, but the equation is not satisfied for an nonlinear filter such as the median filter.
In application, the median filter removes outliers and shot noise that is independent of magnitude, while mean filter serves as smoothing purpose.
In a linear filter, the output will change linearly with a change in the input. You could plot some sort of straight line from the relationship between the two.
A median filter can change non-linearly with certain input changes. e.g. take an input vector where all the data values are different: a change in a non-middle value won't affect the median output at all, until when that value rises or falls enough to become the middle item, when it can suddenly completely affect the output. Thus producing a kinked line (non-linear), instead of a straight line (linear) when the relationship is plotted.
To understand the linearity property more easily.Let us consider the above diagram,here we have 2 sequences namely
$ mean(Xn)+mean(Yn)= mean(Xn+Yn), \\ \\ 5/3 + 1 = 8/3 $
hence we called mean filter as linear filter.
In case of median filter, if we calculate median value for sequence
$median(Xn)+median(Yn) \neq median(Xn+Yn).\\ \\ 1 + 1 \neq 3 $
hence we call median filter as non-linear filter