- Function File:
**fspecial(**`type`,`arg1`,`arg2`) Create spatial filters for image processing.

`type`determines the shape of the filter and can be`"average"`

Rectangular averaging filter. The optional argument

`arg1`controls the size of the filter. If`arg1`is an integer`N`, a`N`by`N`filter is created. If it is a two-vector with elements`N`and`M`, the resulting filter will be`N`by`M`. By default a 3 by 3 filter is created.`"disk"`

Circular averaging filter. The optional argument

`arg1`controls the radius of the filter. If`arg1`is an integer`R`, a 2`R`+ 1 filter is created. By default a radius of 5 is used. If the returned matrix corresponds to a cartesian grid, each element of the matrix is weighted by how much of the corresponding grid square is covered by a disk of radius`R`and centered at the middle of the element`R`+1,`R`+1.`"gaussian"`

Gaussian filter. The optional argument

`arg1`controls the size of the filter. If`arg1`is an integer`N`, a`N`by`N`filter is created. If it is a two-vector with elements`N`and`M`, the resulting filter will be`N`by`M`. By default a 3 by 3 filter is created. The optional argument`arg2`sets spread of the filter. By default a spread of*0.5*is used.`"log"`

Laplacian of Gaussian. The optional argument

`arg1`controls the size of the filter. If`arg1`is an integer`N`, a`N`by`N`filter is created. If it is a two-vector with elements`N`and`M`, the resulting filter will be`N`by`M`. By default a 5 by 5 filter is created. The optional argument`arg2`sets spread of the filter. By default a spread of*0.5*is used.`"laplacian"`

3x3 approximation of the laplacian. The filter is approximated as

(4/(

`alpha`+1)) * [`alpha`/4 (1-`alpha`)/4`alpha`/4 (1-`alpha`)/4 -1 (1-`alpha`)/4`alpha`/4 (1-`alpha`)/4`alpha`/4 ];where

`alpha`is a number between 0 and 1. This number can be controlled via the optional input argument`arg1`. By default it is*0.2*.`"unsharp"`

Sharpening filter. The following filter is returned

(1/(

`alpha`+1)) * [-`alpha``alpha`-1 -`alpha``alpha`-1`alpha`+5`alpha`-1 -`alpha``alpha`-1 -`alpha`];where

`alpha`is a number between 0 and 1. This number can be controlled via the optional input argument`arg1`. By default it is*0.2*.`"motion"`

Moion blur filter of width 1 pixel. The optional input argument

`arg1`controls the length of the filter, which by default is 9. The argument`arg2`controls the angle of the filter, which by default is 0 degrees.`"sobel"`

Horizontal Sobel edge filter. The following filter is returned

[ 1 2 1 0 0 0 -1 -2 -1 ]

`"prewitt"`

Horizontal Prewitt edge filter. The following filter is returned

[ 1 1 1 0 0 0 -1 -1 -1 ]

- "kirsch"
Horizontal Kirsch edge filter. The following filter is returned

[ 3 3 3 3 0 3 -5 -5 -5 ]

**See also:**conv2, convn, filter2, imfilter.

Package: image