57
Image Filtering, Enhancement, and Restoration
The partial differentiations such as ∂f/∂x can be approximated in discrete image
simply by calculating the difference in the gray level of two neighboring pixels, i.e.,
∂f x
( , y) f x
( , y) − f ( x −1, y)
≅
∂x
x − (x −1)
f x
( , y) − f ( x −1 , y)
=
1
= f x
( , y) − f ( (x −1, y)
(3.8)
Note that since the smallest value to approximate ∂x is one pixel, we ended up
replacing this value with 1. Also note that the final value in Equation 3.7 is an
integer (positive or negative). This is due to the fact that subtraction of two integers
(i.e., f(x, y) − f(x − 1, y)) would always give an integer value. Back to the continuous
gradient, the magnitude of the gradient vector is given by
⎡
1 2
/
⎛ ∂ ⎞
2
⎛ ∂
2
f
f ⎞ ⎤
∇ =
f ⎢ ⎜ ⎟ +
⎥
⎜ ⎟
(3.9)
⎢ ⎝ ∂x ⎠ ⎝ ∂y ⎠ ⎥
⎣
⎦
Now, note that storing integers in digital computers is significantly more efficient
than storing real numbers that require floating points. In addition, performing calculations with integers are faster and more efficient than doing calculations with real
numbers. These two observations strongly encourage the use of integers for image
processing in which large images must be stored and processed. Since the result of
Equation 3.8 is almost always a real number, we need to approximate this operation
such that the resulting number stays an integer.
The approximation of Equation 3.8 typically used in image processing is as
follows:
∂f
∂f
∇ ≅
f
+
(3.10)
∂x ∂y
This approximation does not only give us a positive integer, but it also reduces the
time complexity of calculating the magnitude of the gradient vector.
In digital image processing, we often work with digital images and therefore need
to define approximation of Equation 3.9 in digital case. Specifically, in calculating
Equation 3.9, the values ∂f/∂x and ∂f/∂y are substituted with their discrete approximations, as introduced earlier. Implementing these approximations will define the masks
for spatial differentiation. In order to form these masks, we start with analyzing a
small subimage as shown in Figure 3.19. In this figure, z i s are the gray levels of the
corresponding pixels.
Image Filtering, Enhancement, and Restoration
The partial differentiations such as ∂f/∂x can be approximated in discrete image
simply by calculating the difference in the gray level of two neighboring pixels, i.e.,
∂f x
( , y) f x
( , y) − f ( x −1, y)
≅
∂x
x − (x −1)
f x
( , y) − f ( x −1 , y)
=
1
= f x
( , y) − f ( (x −1, y)
(3.8)
Note that since the smallest value to approximate ∂x is one pixel, we ended up
replacing this value with 1. Also note that the final value in Equation 3.7 is an
integer (positive or negative). This is due to the fact that subtraction of two integers
(i.e., f(x, y) − f(x − 1, y)) would always give an integer value. Back to the continuous
gradient, the magnitude of the gradient vector is given by
⎡
1 2
/
⎛ ∂ ⎞
2
⎛ ∂
2
f
f ⎞ ⎤
∇ =
f ⎢ ⎜ ⎟ +
⎥
⎜ ⎟
(3.9)
⎢ ⎝ ∂x ⎠ ⎝ ∂y ⎠ ⎥
⎣
⎦
Now, note that storing integers in digital computers is significantly more efficient
than storing real numbers that require floating points. In addition, performing calculations with integers are faster and more efficient than doing calculations with real
numbers. These two observations strongly encourage the use of integers for image
processing in which large images must be stored and processed. Since the result of
Equation 3.8 is almost always a real number, we need to approximate this operation
such that the resulting number stays an integer.
The approximation of Equation 3.8 typically used in image processing is as
follows:
∂f
∂f
∇ ≅
f
+
(3.10)
∂x ∂y
This approximation does not only give us a positive integer, but it also reduces the
time complexity of calculating the magnitude of the gradient vector.
In digital image processing, we often work with digital images and therefore need
to define approximation of Equation 3.9 in digital case. Specifically, in calculating
Equation 3.9, the values ∂f/∂x and ∂f/∂y are substituted with their discrete approximations, as introduced earlier. Implementing these approximations will define the masks
for spatial differentiation. In order to form these masks, we start with analyzing a
small subimage as shown in Figure 3.19. In this figure, z i s are the gray levels of the
corresponding pixels.
