# How to Decompose a Separable Filter?

I have done some research on the Internet and I have found that a given 2D mask is separable if it exists only a singular value of that matrix. For example, given the following matrix:

$$A = \begin{pmatrix} 1 & 2 & 1 \\ 2 & 4 & 2 \\ 1 & 2 & 1 \end{pmatrix}$$

If I do for instance in matlab svd(A), it gives me the vector $$[0\; 0\; 6]$$, thus, the filter is separable. Nevertheless, I would like to know if it is possible to calculate the vectors that multiplied (or convolved) give raise to $$A$$. As a matter of fact, I know that:

$$\begin{pmatrix} 1 \\ 2 \\ 1 \end{pmatrix} \begin{pmatrix} 1 & 2 & 1 \end{pmatrix}= \begin{pmatrix} 1 & 2 & 1 \\ 2 & 4 & 2 \\ 1 & 2 & 1 \end{pmatrix}$$

However, I would like to calculate those vector for any separable matrix.

Thank you so much for your responses.

## 1 Answer

Indeed you can do that. You may look on my answer to How to Prove a 2D Filter Is Separable?

By the SVD for any filter $$A$$:

$$A = \sum_{i = 1}^{n} {\sigma}_{i} {u}_{i} {v}_{i}^{T}$$

Since we're talking about separable filter then:

$$A = {\sigma}_{1} {u}_{1} {v}_{1}^{T}$$

So the columns filter is $$\sqrt{\sigma}_{1} {u}_{1}$$ and the rows filter is $$\sqrt{\sigma}_{1} {v}_{1}^{T}$$.

Since what's important is that $$A = {\sigma}_{1} {u}_{1} {v}_{1}^{T}$$ you can actually choose any 2 vectors which their outer product is $${\sigma}_{1} {u}_{1} {v}_{1}^{T}$$. The choice isn't unique. For example you could take for columns $${\sigma}_{1}^{2} {u}_{1}$$ and $$\frac{1}{{\sigma}_{1}} {v}_{1}^{T}$$ for the rows.