# A Collaborative Human-Robot Framework for Visual Topological Mapping of Coral Reefs
## 2 Method
### Matching Sequences of Images  
As seen in Figure 3, the obtained similarity matrix is sparse, as only a few entries contain non-zero values. It can be seen that line-like patterns tend to appear in the matrix. Lines out of the main diagonal indicate sequences of different images taken from the same place. Looking for those line-like patterns is the core idea to match sequences of images in some approaches, for example, in SeqSLAM [18], a set of lines, defined by a range of slopes (determined by a minimum and a maximum slope as well as an increment), is utilized to look for possible sequences in the similarity matrix. These slopes are related to the speed of the camera traversing the environment. However, in imagery obtained from underwater explorations the speed of the camera is more difficult to enclose in a range, as it can be significantly affected by external forces such as strong currents (either when attached to a robot or held by a diver) in the environment. Additionally, when the camera is looking downwards and the exploring agent travels through the same place in the opposite direction that it previously did, the generated images in the sequence will have a reversed order. Therefore, it may be necessary to define the set of lines to look for in a different way. Other approaches use graph-searching techniques to find the sequences of images in the similarity matrix that minimize a certain cost function [36; 37]. By doing this, they can look for other more general patterns for sequences of similar images instead of just lines, however, the computational cost of searching for the shortest path in graph-based solutions is higher than simply evaluating a predefined set of lines, as in SeqSLAM. For this work, we have followed the approach presented in SeqSLAM in respect of looking for lines, but instead of using a set of lines defined in a range of slopes, we look for all the possible set of lines starting at a certain point in the similarity matrix. This way we can search for line-like independently of the speed of the camera or its direction when traversing the environment. To do this, we treat the similarity matrix as a raster image and use [PERSON]'s line algorithm [31] to define the set of lines representing the possible sequences of similar images. [PERSON]'s line is a computer graphics algorithm that is used to draw lines efficiently between two points in a raster image. To reduce the computational cost of calculating the lines every time they are needed, we generate them at the beginning of the algorithm. To do this, a grid of \(d+1\) rows and \(2\times d+1\) columns is defined with the \((0,0)\) coordinate in the middle of the bottom row as shown in Figure 4. The value of \(d\) indicates the length of the sequence to be found. Then, we apply the Bresenham algorithm to the pair of points defined by \((0,0)\) and every point \((x_{w},y_{w})\) in the perimeter of the grid. The Bresenham  
Figure 3: Comparison of a similarity matrix computed by matching directly the visual features and using the voting scheme propose in this work. Each entry \((i,j)\) in this matrix indicates the similarity between image \(i\) and \(j\). The darker an entry is, the more similar the associated images are. The main diagonals were eliminated from these matrices as they only indicate that the same image is similar to itself. algorithm will generate a sequence of integer coordinates \(c^{w}=\{(x_{0}^{w},y_{0}^{w}),...\}\) for every pair of points. The set of all base lines \(c^{w}\) will be denoted as \(C\). To incrementally find a matching sequence of images in \(\tilde{S}\), it is only necessary to find lines starting in the last row of the similarity matrix. Only the entries \((i_{sp_{k}},j_{sp_{k}})\) in the last row with similarity values higher than a threshold \(\mu\) are taken into account as starting points. Let \(C_{sp}=\big{\{}C_{sp_{k}}\big{\}}\) be the set of sequences obtained from translating \(C\) to every starting point \((i_{sp_{k}},j_{sp_{k}})\).