fspecial

Creates a filter that can be used for image processing.

Syntax

R = fspecial(type)

R = fspecial(type, size)

R = fspecial('gaussian', size, sigma)

Inputs

type
Type of filter. Valid values are 'average', 'gaussian', 'kirsch', 'prewit' and 'sobel'
Type: string
size
Optional argument that determines the size of the filter created. Applicable only to filter types of 'average' and 'gaussian'. Must be a real integer or a real vector of size 2. Default value is 3 and a size by size filter is created. If size is a real vector, a filter of size(1) by size(2) is created.
Type: integer | vec
property
Optional argument for 'gaussian' filter specifying the standard deviation. Has a default value of 0.5.
Type: scalar

Outputs

R
Resulting filter.
Type: matrix

Example

Create a Gaussian filter:
R = fspecial('gaussian', 5, 0.7)
R = [Matrix] 5 x 5
0.00009  0.00198  0.00548  0.00198  0.00009
0.00198  0.04220  0.11707  0.04220  0.00198
0.00548  0.11707  0.32480  0.11707  0.00548
0.00198  0.04220  0.11707  0.04220  0.00198
0.00009  0.00198  0.00548  0.00198  0.00009