Digital Signal Processing Reference
In-Depth Information
four at coordinates (6, 6) Figure 19.3 (a). First we will add or
integrate the values around the square, and normalize by dividing
by the total number of pixels:
S(4)
¼
(12
1) / 12
¼
1
Where:
S(n)
¼
Sum of all the pixel values around a square with sides of
length n.
Similarly for template squares of size 8 and 12:
S(8)
¼
((11
1)
þ
(17
0)) / 28
¼
0.36
S(12)
0
Now we calculate the maximum gradient of the integral sums:
G(4,8)
¼
(44
0) / 44
¼
¼j
1
0.36
0.64
G(8,12)
¼j
0.36
0
0.36
Where:
G(n,m)
¼
The gradient between squares of with sides length n,
and m.
Thus for expanding squares with origin (6, 6) the maximum
gradient is 0.64.
Now we will shift the origin to (5, 6) as shown in Figure 19.3 (b).
First we calculate the integrals:
S(4)
¼
(12
1) / 12
¼
1
¼
þ
¼
S(8)
((6
1)
(22
0)) / 28
0.21
¼
¼
S(12)
0
And now the gradients:
G(4, 8)
(44
0) / 44
¼j
1
0.21
0.79
0.21
Notice that the peak gradient is higher for the second position,
where the expanding circles are centered at (5, 6). This tells us that
(5, 6) is more likely to be the origin of the square than (6, 6). That is
x
G(8,12)
¼j
0.21
0
5 is the best candidate for the x coordinate of the origin.
We can perform the same shifting operation in the y direction,
and thus find the optimal y coordinate as illustrated in
Figure 19.4 . If we calculate the gradients we get a similar result to
that for the x shifting, and in this case we find that (6, 7) is a better
candidate than (6, 6) and thus y
¼
7 is the best candidate for the y
coordinate of the origin. Our best estimate so far for the origin of
the target square is x
¼
7 or (5, 7). If we check again we will
see that (5, 7) is indeed the origin of the square. In a real example
we would not be so lucky, and we would need to repeat the
operation a number of times. In each iteration, we would use the
¼
5, y
¼
Search WWH ::




Custom Search