Image Processing Toolbox | ![]() ![]() |
Separability
If a filter has separability, meaning that it can be separated into two one-dimensional filters (one column vector and one row vector), the computation speed for the filter can be greatly enhanced. Before calling conv2
to perform two-dimensional convolution, filter2
first checks whether the filter is separable. If the filter is separable, filter2
uses singular value decomposition to find the two vectors. filter2
then calls conv2
with this syntax.
conv2(A,kcol,krow);
where kcol
and krow
are the column and row vectors that the two-dimensional convolution kernel k
separates into (that is, k = kcol*krow
).
conv2
filters the columns with the column vector, and then, using the output of this operation, filters the rows using the row vector. The result is equivalent to two-dimensional convolution but is faster because it requires fewer computations.
Determining Separability
A filter is separable if its rank is 1. For example, this filter is separable.
k = 1 2 3 2 4 6 4 8 12 rank(k) ans = 1
If k
is separable (that is, it has rank 1), then you can determine the corresponding column and row vectors with
[u,s,v] = svd(k); kcol = u(:,1) * sqrt(s(1)) kcol = 0.9036 1.8072 3.6144 krow = conj(v(:,1))' * sqrt(s(1)) krow = 1.1067 2.2134 3.3200
Perform array multiplication on the separated vectors to verify your results.
kcol * krow ans = 1.0000 2.0000 3.0000 2.0000 4.0000 6.0000 4.0000 8.0000 12.0000
![]() | The filter2 Function | Higher-Dimensional Convolution | ![]() |