
356 A Computational Introduction to Digital Image Processing, Second Edition
2. Traverse the 3 × 3 neighborhood of the current pixel in an anticlockwise direction,
beginning the search at the pixel in direction
dir + 7 (mod 8) if dir is even
dir + 6 (mod 8) if
dir is odd
This simp ly sets the current direction to the first direction anticlockwise from
dir
:
dir 0 1 2 3 4 5 6 7
dir + 7 (mod 8) 7 0 1 2 3 4 5 6
dir + 6 (mod 8) 6 7 0 1 2 3 4 5
The first foreground pixel will be the new boundary element. Update
dir.
3. Stop when the current boundary element P
n
is equal to the second element P
1
and
the previous boundary pixel P
n−1
is equal to the first boundary element ...