Game Development Reference
InDepth Information
J
ρ
(
x
). The eigenvalues are real, since
J
ρ
(
x
) is symmetric, and nonnegative, since
J
ρ
(
x
) is positive semidefinite. The major eigenvalue measures the squared rate
of change in the direction of the major eigenvector. Its square root can thus be
regarded as a generalized gradient strength. The minor eigenvalue, on the other
hand, can be regarded as a measure for the error of the approximation.
Up to now, only the case of grayscale images has been considered. The most
straightforward way to extend the previous discussion to color images is by solving
Equation (5.1) jointly for all color channels, resulting in the following generaliza
tion of Equation (5.3):
n
1
g
i
(
y
)
g
i
(
y
)
T
,
J
ρ
(
x
)=
·
G
ρ
(
y
−
x
)

G
ρ

y
∈N
(
x
)
i
=1
where
n
is the number of color channels (i.e.,
n
= 3 for RGB images) and
g
i
(
y
)
denotes the gradient of the
i
th color channel. Another convenient way to express
the sum of outer products is as the scalar product of the partial derivatives:
=
i
=1
(
g
i
)
2
i
=1
g
i
=
.
g
i
2
g
1
,g
1
g
1
,g
2
n
1
1
g
i
(
y
)
g
i
(
y
)
T
i
=1
g
i
i
=1
(
g
i
g
i
2
)
2
g
1
,g
2
g
2
,g
2
i
=1
1
2
5.2.2 Eigenanalysis of the Structure Tensor
In this section, the way in which the eigenvalues and eigenvectors of the structure
tensor, or more generally of a symmetric positive semidefinite 2
×
2matrix
J
=
EF
FG
,
can be computed in a numerically stable way will be discussed. Although a
straightforward implementation leads to reasonable results, a carefully crafted
implementation, as shown in
Listing 5.1
,
is able to achieve much better accuracy
by taking care of the numerical subtleties of floatingpoint calculations [Gold
berg 91].
Being positive semidefinite implies that
E, G
F
2
. Hence, from
E
+
G
= 0, it follows that
F
= 0, which means that the matrix is zero. Let us
now assume that
E
+
G>
0. Computation of the eigenvalues requires solving the
characteristic polynomial det(
A
≥
0and
EG
≥
Iλ
) = 0, which is a quadratic equation, and the
solution can be obtained using the monic form of the popular quadratic formula:
−
E
+
G
F
2
)
.
(
E
+
G
)
2
−
1
2
λ
1
,
2
=
±
4(
EG
−
The quadratic formula is known to have numerical issues when implemented in
a straightforward manner. The subtractions are problematic, as they may result
Search Nedrilad ::
Custom Search