Main Content

isfilterseparable

Determine whether filter coefficients are separable

Description

isSeparable = isfilterseparable(H) returns logical 1 (true) when the filter kernel H is separable, and 0 (false) otherwise.

[isSeparable,hcol,hrow] = isfilterseparable(H) also returns the vertical coefficients hcol and horizontal coefficients hrow when the filter kernel, H, is separable. Otherwise, hcol and hrow are empty.

example

Examples

collapse all

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 = 3×1

   -0.1065
   -0.7870
   -0.1065

hrow = 1×3

   -0.1065   -0.7870   -0.1065

Input Arguments

collapse all

Filter kernel, specified as a non-sparse 2-D numeric or logical matrix.

Output Arguments

collapse all

Filter is separable, returned as logical 1 (true) when the filter is separable and 0 (false) when the filter is not separable.

Data Types: logical

Vertical coefficients when the filter kernel H is separable, returned as a numeric vector. When H is not separable, hcol is empty. If H is of data type single, then hcol is also of data type single. Otherwise, hcol is of data type double.

Horizontal coefficients when the filter kernel H is separable, returned as a numeric vector. When H is not separable, hrow is empty. If H is of data type single, then hrow is also of data type single. Otherwise, hrow is of data type double.

More About

collapse all

Separable two dimensional filters

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:

Y(m,n)=klH(k,l)U(mk,nl)

If the filter H is separable then,

H(k,l)=Hrow(k)Hcol(l)

Shifting the filter instead of the image, the two-dimensional equation becomes:

Y(m,n)=kHrow(k)lHcol(l)U(mk,nl)

This calculation requires only (width + height) number of multiplications for each pixel.

Algorithms

The isfilterseparable function uses the singular value decomposition svd function to determine the rank of the matrix.

Version History

Introduced in R2006a