Create predefined 2-D filter
returns a rotationally symmetric Gaussian lowpass filter of size
h
= fspecial('gaussian',hsize
,sigma
)hsize
with standard deviation sigma
.
Not recommended. Use imgaussfilt
or imgaussfilt3
instead.
returns a filter to approximate, once convolved with an image, the linear motion of
a camera. h
= fspecial('motion',len
,theta
)len
specifies the length of the motion and
theta
specifies the angle of motion in degrees in a
counter-clockwise direction. The filter becomes a vector for horizontal and vertical
motions. The default len
is 9
and the default
theta
is 0
, which corresponds to a
horizontal motion of nine pixels.
returns a 3-by-3
filter that emphasizes horizontal edges by approximating a vertical gradient. To
emphasize vertical edges, transpose the filter h
= fspecial('prewitt')h'
.
[ 1 1 1 0 0 0 -1 -1 -1 ]
returns a 3-by-3 filter that emphasizes horizontal edges using the smoothing effect
by approximating a vertical gradient. To emphasize vertical edges, transpose the
filter h
= fspecial('sobel'
)h'
.
[ 1 2 1 0 0 0 -1 -2 -1 ]
Averaging filters:
ones(n(1),n(2))/(n(1)*n(2))
Gaussian filters:
Laplacian filters:
Laplacian of Gaussian (LoG) filters:
Note that fspecial
shifts the equation to ensure that the sum of
all elements of the kernel is zero (similar to the Laplace kernel) so that the
convolution result of homogeneous regions is always zero.
Motion filters:
Construct an ideal line segment with the length and angle specified by the
arguments len
and theta
, centered at
the center coefficient of h
.
For each coefficient location (i,j)
, compute the nearest
distance between that location and the ideal line segment.
h = max(1 - nearest_distance,0);
Normalize h
: h = h/(sum(h(:)))