4 SALMON
Our algorithm is modeled on the incredible journey
of a salmon downstream to the ocean, returning the
same spot as an adult
1
: our salmon leaves a trail of
points behind it as it traces the contour and returns to
its starting place.
For any given contour at disparity p, choose the first
ML point from the first scan line with a point at dis-
parity p in the linked list generated when C states
were assigned.
Denote the salmon’s current location by P
c
and the
disparity at P
c
by p
c
. The salmon states during con-
tour generation are designated ON − EDGE, INSIDE
or OUTSIDE. Table 1 defines these states.
The salmon’s full state is defined by a 4-tuple:
(s, p
s
, up, r
max
)
where s ∈ {ON − EDGE, INSIDE, OUTSIDE} is
the salmon state, p
s
is the disparity for which the
salmon is constructing a contour, up is either true
(tracing MR contour) or false (tracing ML contour)
and r
max
is maximum extent of the salmon’s sight -
a measure of how many neighbours the salmon will
examine in this iteration. For sight, j| j = 1, ..., r
max
,
the salmon will examine N = 4 j + 1 neighbours. The
directions of the neighbours, φ
i
are defined by:
φ
0
= when (up = true) 0 else π
φ
i
= φ
i−1
+
π
4 j
, i = 1, 2, . . . , N
where φ = 0 represents the direction along the x axis
and φ increases in an anti-clockwise direction.
The salmon’s initial state will be ON-EDGE. Our
salmon then follows the p
s
contour and returns to
where it started: it uses rules derived from the vis-
ibility constraints (Gimel’farb, 1991). From an MR
pixel, the salmon moves up - 0 ≤ φ ≤ π. From an ML
pixel, the salmon moves down so that π ≤ φ ≤ 2π. The
salmon uses steps j = 1, .., r
max
to decide in which di-
rection it should move. If it can not decide at step j
then it tries step j + 1.
4.1 General Rules
1. Any point in C state is ignored.
2. A neighbour at j always has higher priority than
neighbours at j + 1.
1
”Salmon make an incredible journey downstream
from the fresh water where they are born, to the
ocean, and then back upstream again as adults,
finding the exact location where they began sev-
eral years earlier.” (U.S. Bureau of Land Manage-
ment http://www.blm.gov/education/00_resources/
articles/Columbia_river_basin/posterback.html)
3. Transition to an ON-EDGE state always has high-
est priority.
4. Transition to an INSIDE state always takes prior-
ity over transition to an OUTSIDE state.
5. If there are two or more possible transitions to IN-
SIDE neighbours than the neighbour with closest
disparity will be chosen.
6. If there are two or more possible transitions to
OUTSIDE neighbours than the neighbour with
closest disparity will be chosen.
7. If the current state is ON-EDGE or INSIDE then
ML or MR is chosen over B with same disparity.
8. If the current state is OUTSIDE then B is chosen
over ML or MR with the same disparity.
4.2 Search Priority
For each salmon state, the order in which the neigh-
bours are searched is different: the priorities for the
salmon moving down and for j = 1 are shown in Fig-
ure 2.
4.3 Expanding the Search Region
If all the neighbours of a point are marked C or have
been visited, then we increment j and search in a
wider region. To prevent the salmon from selecting
the wrong neighbour, a maximum iteration count is
specified. If this count reaches a predefined limit or
the salmon returns to its starting point, the contour
will be terminated and added to the contour list.
4.4 Salmon Operation
An example salmon run is shown in Figure 3. The
salmon starts in the (7,ML) pixel at the top and works
down, trying to stay on the (7,ML) ‘edge’.
However, it is not possible always: in row 2, the
salmon is ON-EDGE, but there is no (7,ML) neigh-
bour, so the salmon will use the priority scheme
shown in Figure 2 and go INSIDE to (8,B) attempting
to find another (7, ML) point.
In row 4 at (7, ML), again there is no adjacent (7, ML)
so the salmon will go OUTSIDE to (6, B) and follow
the priorities shown in Figure 2 to find (7,ML) again.
Then a sequence of (7,ML) pixels are followed until
at row 9, the salmon is facing a continuous wall of C
pixels. It is forced to go INSIDE and swim through
a sequence of (7,B) pixels (a horizontal edge), even-
tually finding a (7, MR) one. At this point, it reverses
the direction and ‘climbs’ the (7, MR) edge back to
the starting point.
INTELLIGENT VISION FOR MOBILE AGENTS - Contour Maps in Real Time
393