1: |
Inputs: seed set S, filtered image I
|
2: |
// Initialize data structures |
3: |
for all
p ∈ I
do
|
4: |
Compute F (p) using (10–11)
|
5: |
if
p ∈ S then
|
6: |
T (p) = 0, R(p) = 1 |
7: |
else
|
8: |
T (p) = ∞, R(p) = 0 |
9: |
S → ℒ // Begin the heap |
10: |
Tc = To = 0 |
11: |
while ℒ ≠ ∅ do
|
12: |
// Make heap’s top pixel, which has min T (p), alive |
13: |
pop(ℒ) → p, Alive(p) = TRUE |
14: |
Tc = T (p), ΔR = 0 |
15: |
// Locate pixels constituting R
|
16: |
if
Tc − To ≥ 2 then
|
17: |
TR = To + 1 |
18: |
for all
q ∈ I
such that R(q) ≠ 1 do
|
19: |
if
T (q) ≤ TR
then
|
20: |
R(q) = 1 |
21: |
exit
|
22: |
else if
Tc − To ≥ 1 then
|
23: |
TR = Tc
|
24: |
for all
q ∈ I
such that R(q) ≠ 1 do
|
25: |
if
T (q) ≤ TR
then
|
26: |
R(q) = 1, ΔR = ΔR + 1 |
27: |
if ΔR ≤ Δmin
then
|
28: |
exit // Avoid potential ROI leakage |
29: |
else
|
30: |
To = Tc
|
31: |
// Check 4-neighbors of p
|
32: |
for all
q ∈ 𝒩(p) such that ¬Alive(q) do
|
33: |
Compute T (q) using (eq:FastMarching) // Update arrival time |
34: |
if
q ∉ ℒ then
|
35: |
q → ℒ // Add to heap |
36: |
heap-sort(ℒ) // Resort the heap |
37: |
fill-holes(R) → R // Fill holes in final output |
38: |
return R |