Image Processing Reference
In-Depth Information
points(rad,no,xc,yc):= for s
∈
0..no-1
xc+floor rad cos
s2
no
⋅ ⋅
x
+0.5
s
yc+floor rad sin
s2
no
y
+0.5
s
0.5
s
0.5
s
γ
s
←
1
x
y
s
s
point
s
s
s
s
point
Code 6.1
Specifying in initial contour
as evaluated from the
x
and
y
co-ordinates of the adjacent snake point (
x
s+
1
,
y
s+
1
) and the
co-ordinates of the point currently inspected (
x
s
,
y
s
). Clearly, the first-order differential, as
evaluated from Equation 6.13, drops to zero when the contour is evenly spaced, as required.
This is implemented by the function
Econt
in Code
6.2
which uses a function
diff
to
evaluate the average spacing and a function
diff
2 to evaluate the Euclidean distance
between the currently searched point (
v
s
) and the next contour point (
v
s
+1
). The arguments
to
E
cont
are the
x
and
y
co-ordinates of the point currently being inspected,
x
and
y
, the
index of the contour point currently under consideration,
s
, and the contour itself,
cont
.
dist(s,contour):=
s1
mod(s,rows(contour))
s2
mod(s+1,rows(contour))
2
2
[(contour ) -(contour ) ] +[(contour ) -(contour ) ]
s1 0
s2 0
s1 1
s2 1
←
mod(s+1,rows(contour))
[(contour ) -x] +[(contour ) -y]
dist2(x,y,s,contour):= s2
2
2
s2 0
s2 1
rows(cont)-1
1
rows(cont)
Econt(x,y,s,cont) :=
D
dist(s1,cont)
s1=0
|D-dist2(x,y,s,cont)|
Code 6.2
Evaluating the contour energy