I'm reading through a digital signal processing textbook, which says "It should be noted that the square two-dimensional median mask is a non-separable mask" but gives no explanation as to why this is true. I can see why mean filters are separable (a $3\times 3$ matrix of ones can come from the convolution of $[1 1 1] * [1 1 1]^T$), but why is a median filter non-separable? Specifically, why are square median filters non-separable? And does this mean that all non-square median filters are separable?
[Math] Why are median filters non-separable
image processingsignal processing
Related Solutions
The frequency domain graph shows that your signal (a part of which is shown in the time domain graph) contains frequencies up to a maximum of about $f_s/3$. Assuming that $f_s$ denotes the sampling frequency this shows that it satisfies the condition for the Nyquist-Shannon sampling theorem (Basically that the sampling rate is high enough to process the sampled signal without introducing aliasing. More precisely that the sampling rate is sufficiently high to allow the exact reconstruction of the time domain signal from the samples).
The linkage between the graphs is the the frequency domain graph is the amplitude information in the Fourier Transform (FT) of the time domain signal (the other thing you need from the FT to reconstruct the original signal is the phase information, which you do not have here).
You do it by writing every function involved as a distinct function of $t$ only (as you did with $h$), and only then applying your formula for a convolution. Let me also write $f_{t_0} (t) := f(t-t_0)$. Then \begin{align} f(t) * \delta(t-t_0)=f(t)*h(t) &= \int_{-\infty}^\infty f(\tau) h(t-\tau) d\tau \\&= \int_{-\infty}^\infty f(\tau) \delta(t-\tau-t_0) d\tau \\&= \int_{-\infty}^\infty f(\tau) \delta(t-(\tau+t_0)) d\tau \\&= \int_{-\infty}^\infty f(\tau-t_0) \delta(t-\tau) d\tau \\&= \int_{-\infty}^\infty f_{t_0}(\tau) \delta(t-\tau) d\tau \\&=f_{t_0}(t) \\&=f(t-t_0)\end{align}
I want to point out that there is a notation nightmare happening. (Nevermind that you introduce $x$ and $f$ to mean the same thing). The object on the left has $t$s that indicate that the whole expression is evaluated at some yet unspecified value $t$, but beware that if you just e.g. replaced $t=1$, $f(1)$ would be a number, maybe $6$, $\delta(1-t_0)$ only barely makes a little sense if at all, and who knows what $6*\delta(1-t_0)$ would be, probably not equal to $$\big(f(t) * \delta(t-t_0)\big)\big|_{t=1} = f(1-t_0).$$
This notation landmine explains why your attempt failed. If we now subscript by $z$ to mean translation by $z$, so that $f_z(t) = f(t-z), \ \delta_z(t) = \delta(t-z) $, etc. (in particular what you called $f_d$, I call $f_{-t_0}$ and $h = \delta_{t_0}$), then by applying the above correct result at the point marked ✅ for the function $f=g_{t_0}$, $$ g(t-t_0)* \delta(t-t_0)=g_{t_0}(t) * \delta_{t_0}(t) \overset{✅}= g_{t_0}(t-t_0) = g(t-2t_0)$$ We see that in general, $g(t-t_0)* \delta(t-t_0) \neq g(t-t_0)$. This happened because you cannot treat the $t$ on the left as something that can be substituted with $t-t_0$.
Its unambiguous if one writes something like $$ [f*\delta(\cdot-t_0)](t), [f*\delta(\cdot-t_0)](1), \text{etc}.$$ but there is a certain naturality to writing it in the way you did, which is OK if you "know the rules of the game".
Best Answer
A median filter is non-linear, since it consists of a median function that has no equivalent sum-product form, so it cannot be separated into a product of two vectors for any length larger than 2. Doesn't matter whether it has square mask or not.
For example, mean can be formed as sum product $\frac{1}{n}\sum_{i=1}^n 1\cdot x_i$, but median requires an operator that sorts and finds the middle, which is beyond any linear algebraic operations.