Image Segmentation 239
Since in an image, the smallest possible value of h is 1, being the difference between the
index values of two adjacent pixels, a discrete version of the derivative expression is
f(x + 1) − f(x).
Other expressions for the derivative are
lim
h→0
f(x) − f(x − h)
h
, lim
h→0
f(x + h) − f(x − h)
2h
with discrete counterparts
f(x) − f(x − 1), (f(x + 1) − f(x − 1))/2.
For an image, with two dimensions, we use partial derivatives; an important expression is
the gradient, which is the vector defined by
∂f
∂x
∂f
∂y
which for a function f(x, y) points in the direction of its greatest increase. The direction of
that increase is given by
tan
−1
∂f /∂y
∂f /∂x
and its magnitude by
∂f
∂x
2
+
∂f
∂y
2
.
Most edge detection methods are concerned with finding the magnitude of the gradient,
and then applying a threshold to the result.
Some Edge Detection Filters
Using the expression f(x + 1) − f (x − 1) for the derivative, leaving the scaling factor
out, produces horizontal and vertical filters:
−1 0 1
and
−1
0
1
These filters will find vertical and horizontal edges in an image and produce a reasonably
bright result. However, the edges in the result can be a bit “jerky”; this can be overcome
by smoothing the result in the opposite direction; by using the filters
1
1
1
and
1 1 1
Both filters can be applied at once, using the combined filter:
P
x
=
−1 0 1
−1 0 1
−1 0 1