The Radial Sweep algorithm is a contour tracing algorithm that has been
explained in some of the literature. Unlike its fancy name, the idea behind
it is very simple. As a matter of fact, it turns out that the Radial Sweep
algorithm is **identical** to Moore-Neighbor
Tracing. So you must be asking: "Why did we bother to mention it here?".
Well...

Moore-Neighbor tracing searches the Moore neighborhood
of the current boundary pixel in a certain direction (we've chosen clockwise),
until it finds a black pixel. It then declares that pixel as the current
boundary pixel and proceeds as before.

The Radial Sweep algorithm does the exact same thing. On the other
hand, it provides an interesting method for finding the next black pixel
in the Moore neighborhood of a given boundary pixel.

The idea behind that method is the following:

every time you locate a new boundary pixel, make it your current pixel,
**P,**
and draw an **imaginary line segment** joining **P** to the **previous
**boundary
pixel. Then, **rotate** the segment about** P** in a clockwise direction
until it hits a black pixel in **P**'s Moore neighborhood. Rotating
the segment is identical to checking each pixel in the Moore neighborhood
of **P**.

We have provided the following animated demonstration in order to explain
how the Radial Sweep algorithm works and how similar it is to Moore-Neighbor
tracing.

**So... When does the Radial Sweep algorithm terminate?**

Let's examine the behavior of the algorithm when the following stopping
criteria are used...

__Stopping Criterion 1__

Let the Radial Sweep algorithm terminate when it visits the **start**
pixel for a second time.

The following is an animated demonstration explaining why it would
be a good idea to change that stopping criterion.

A point worth mentioning is that the performance of the Radial Sweep
algorithm is identical to that of Moore-Neighbor tracing when this stopping
criterion is used in both.

In the Square Tracing algorithm
and Moore-Neighbor tracing, we found
that using ** Jacob's stopping criterion **(proposed
by Jacob
Eliosoff ) greatly improved both algorithms' performance.

Unfortunately, we won't be able to use Jacob's stopping criterion in the Radial Sweep algorithm. The reason for this is the fact that the Radial Sweep algorithm doesn't define the concept of

Therefore, we will suggest another stopping criterion which doesn't depend on the direction in which you enter a certain pixel and will improve the performance of the Radial Sweep algorithm...

__Stopping Criterion 2__

Assume that each time a new boundary pixel, **P _{i}**, is
found by the algorithm, it is inserted in the

(Assume

This means that we know the previous boundary pixel,

(As for the

With the above assumptions in mind, we can define our stopping criterion:

The algorithm terminates when:

a) the current boundary pixel, **P _{i}**, has appeared

AND

b)

In other words, the algorithm terminates when it visits a boundary pixel,
P, for a **second** time provided that the boundary pixel before P (in
the sequence of boundary pixels) the second time around, is the** same
**pixel
which was before P when P was **first** visited.

If this stopping criterion was satisfied and the algorithm didn't terminate,
the Radial Sweep algorithm will proceed to trace the **same **boundary
for a second time.

The performance of the Radial Sweep algorithm using this stopping criterion
is similar to the perfomance of Moore-Neighbor
tracing using Jacob's stopping criterion.