## 4 Hierarchical Incremental Maps
### Centroid Condition  
As detailed in the previous subsections, the node Level Loop Closure selects first \(N^{*}\) candidate nodes. Among them, the Image Level Loop Closure finds the most similar image which closes the loop and helps select the final node. In order for a selected node to be accepted as the final node, it must fulfil the condition of Equation (9) below. This condition evaluates how the position of the node representative shifts when the new candidate image is added to the selected node. In the condition, the distance between the node representative before (\(\mu^{N_{i}}\)) and node representative after adding the descriptor of the new image (\(\mu^{N_{i}\cup\{\tilde{d}_{q}\}}\)) has to be lower or equal to the maximum influence on the node representative effected by the images already contained in the node.  
\[\left|\vec{\mu}^{N_{i}}-\vec{\mu}^{N_{i}\cup\{\tilde{d}_{q}\}}\right|\leq \max_{j}(\left|\vec{\mu}^{N_{i}-\{\tilde{d}_{j}\}}-\vec{\mu}^{N_{i}}\right|) \tag{9}\]  
where \(\vec{d}_{j}\) denote all descriptors of the images contained in the node \(N_{i}\).  
The process presented in Sections 4.1-4.4 is summarized in the pseudocode Algorithm 1. Starting from the current set of clusters in the map \(N^{C}=\{N_{1},N_{2}...,N_{C}\}\), their associated data (\(N_{l},\vec{\mu}^{N_{l}}\)_and_\(\sum\limits_{d}^{N_{l}}\) for \(l=1,2,...,C\)) and the descriptors of each previous image \(\vec{d}_{k}\), it is possible to determine if a new image \(I_{q}\), whose descriptor is \(\vec{d}_{q}\), has to be assigned to any previous node or not.  
```
1:NodeLevelLoopClosure(\(\vec{d}_{q}\))
2:\(N^{\text{C}}=\{N_{l},N_{2}...,N_{\text{C}}\}\) initial set of clusters
3:\(\vec{\mu}^{N_{l}},\sum\limits_{d}^{N_{l}}\) mean descriptor and covariance matrix of cluster \(N_{l}\)
4:for l=1 to number of clusters Cdo
5:\(\Delta_{\vec{d}_{q}}^{N_{l}}=(\vec{d}_{q}-\vec{\mu}^{N_{l}})^{T}(\sum\limits_{ d}^{N_{l}})^{-1}(\vec{d}_{q}-\vec{\mu}^{N_{l}})\) (Equation (3))
6:if\(\left|\Delta_{\vec{d}_{q}}^{N_{l}}-\mu_{N}^{N}\right|\leq\left|x\sigma_{ns}^{N_{l}}\right|\)then (Equation (4))
7:\(N^{*}\gets N_{l}\);
8:endif
9:endfor
10:endNodeLevelLoopClosure
11:ImageLevelLoopClosure(\(\vec{d}_{q}\), \(\vec{d}_{k}\), \(N^{*}\))
12:for k= 1 to images in \(N^{*}\)do
13:\(dist_{\vec{d}_{q}}^{\vec{d}_{k}}=\)\(\sqrt{\sum\
olimits_{j=1}^{t}{((\vec{d}_{q}(j)-\vec{d}_{k}(j))^{2}}}\) (Equation (5));
14: find the most similar image \(I_{i}\) using Equation (7);
15:if\(I_{i}\) meets \(P_{I_{i}}\geq 7*\mu(P_{I_{*}})\)then (Equation (8), Prominence Condition)
16:if\(I_{i}\) meets \(\left|\vec{\mu}^{N_{i}}-\vec{\mu}^{N_{i}\cup\{\vec{d}_{q}\}}\right|\leq\max_{ j}(\left|\vec{\mu}^{N_{i}-\{\vec{d}_{j}\}}-\vec{\mu}^{N_{i}}\right|)\)then (Equation (9) Centroid Condition)
17:\(I_{i}\) and its node \(N_{i}\) close the loop;
18:\(I_{q}\) is included in \(N_{i}\);
19:\(N_{i}\), \(\mu^{N_{i}}\) and \(\sum_{d}^{N_{i}}\) are updated;
20:else
21:\(I_{i}\) does not meet Equation (9);
22:\(I_{q}\) is not included in \(N_{i}\);
23:endif
24:else
25:\(I_{i}\) does not meet Equation (8);
26:\(I_{q}\) is not included in \(N_{i}\);
27:endif
28:endfor
29:if\(N^{*}=\emptyset\)then
30:\(I_{q}\) is not assigned to any node;
31: The existing nodes are not updated and \(I_{q}\) will be evaluated in subsequent steps;
32:endif
33:endImageLevelLoopClosure
```  
**Algorithm 1** Pseudocode for Node and Image Level Loop Closure, applying Prominence and Centroid Conditions.