Determine whether filter coefficients are separable
S = isfilterseparable(H)
[S, HCOL, HROW] = isfilterseparable(H)
[ uses the filter
H, to return its vertical coefficients
HROW when the filter
is separable. Otherwise,
Logical variable that is set to
Determine if the Gaussian filter created using the
fspecial function is separable.
Create a Gaussian filter.
twoDimensionalFilter = fspecial('gauss');
Test the filter.
[isseparable,hcol,hrow] = isfilterseparable(twoDimensionalFilter)
isseparable = logical 1 hcol = -0.1065 -0.7870 -0.1065 hrow = -0.1065 -0.7870 -0.1065
Separable two-dimensional filters reflect the outer product of two vectors. Separable filters help reduce the number of calculations required.
A two-dimensional convolution calculation requires a number of multiplications equal to the width height for each output pixel. The general case equation for a two-dimensional convolution is:
If the filter H is separable then,
Shifting the filter instead of the image, the two-dimensional equation becomes:
This calculation requires only (width + height) number of multiplications for each pixel.
isfilterseparable function uses the
singular value decomposition
svd function to
determine the rank of the matrix.