fspecial - Create predefined 2-D filter

Syntax

h = fspecial(type)
h = fspecial(type, parameters)

Description

h = fspecial(type) creates a two-dimensional filter h of the specified type. fspecial returns h as a correlation kernel, which is the appropriate form to use with imfilter. type is a string having one of these values.

Value

Description

'average'

Averaging filter

'disk'

Circular averaging filter (pillbox)

'gaussian'

Gaussian lowpass filter

'laplacian'

Approximates the two-dimensional Laplacian operator

'log'

Laplacian of Gaussian filter

'motion'

Approximates the linear motion of a camera

'prewitt'

Prewitt horizontal edge-emphasizing filter

'sobel'

Sobel horizontal edge-emphasizing filter

'unsharp'

Unsharp contrast enhancement filter

h = fspecial(type, parameters) accepts the filter specified by type plus additional modifying parameters particular to the type of filter chosen. If you omit these arguments, fspecial uses default values for the parameters.

The following list shows the syntax for each filter type. Where applicable, additional parameters are also shown.

Class Support

h is of class double.

Examples

I = imread('cameraman.tif');
subplot(2,2,1); 
imshow(I); title('Original Image');

H = fspecial('motion',20,45);
MotionBlur = imfilter(I,H,'replicate');
subplot(2,2,2); 
imshow(MotionBlur);title('Motion Blurred Image');

H = fspecial('disk',10);
blurred = imfilter(I,H,'replicate');
subplot(2,2,3); 
imshow(blurred); title('Blurred Image');

H = fspecial('unsharp');
sharpened = imfilter(I,H,'replicate');
subplot(2,2,4); 
imshow(sharpened); title('Sharpened Image');

Algorithms

fspecial creates Gaussian filters using

fspecial creates Laplacian filters using

fspecial creates Laplacian of Gaussian (LoG) filters using

fspecial creates averaging filters using

ones(n(1),n(2))/(n(1)*n(2))

fspecial creates unsharp filters using

See Also

conv2, edge, filter2, fsamp2, fwind1, fwind2, imfilter

del2 in the MATLAB Function Reference

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS