# Brain-Like Navigation Scheme based on MEMS-INS and Place Recognition
## 3 Algorithm
### Scanlines Intensity Algorithm  
The scanlines intensity (SI) algorithm is for identifying the place by comparing the similarity of the intensity profile of two image scanlines. In detail, the algorithm is to make the template image shift above the reference image, and calculate the difference between the normalized values of the two intensities, then sum them up. The smaller the sum of the differences, the more similar the two images are.  
Figure 4: System composition and simulation trajectory map.  
For template image T and reference image \(B\), T(_x,y_) and \(B\)(_x,y_) are the intensity values (grayscale value) of corresponding pixel points on the image respectively. Taking the reference image \(B\) as an example, the sum of the intensity values of the _j-th_ column is calculated as \(S_{j}\)  
\[S_{j}=\sum\limits_{i=0}^{m}B(i,j) \tag{8}\]  
where \(m\) represents the number of rows.  
The intensity of each column is normalized to obtain the normalized set \(\mathbf{I}\) of the reference image.  
\[I_{j}=\frac{S_{j}}{\sum\limits_{j=1}^{n}S_{j}}, \tag{9}\]  
\[\mathbf{I}=\{I_{1},I_{2},I_{3},\cdots,I_{n}\}, \tag{10}\]  
where \(I_{j}\) represents the normalized result of the j-th columns, \(n\) represents the number of columns.  
The normalized set \(\mathbf{I^{\prime}}\)(\(\mathbf{I^{\prime}}=\{I^{\prime}{}_{1},I^{\prime}{}_{2},I^{\prime}{}_{3},\cdots,I^{ \prime}{}_{n}\}\)) of template image \(T\) can be obtained similarly.  
The similarity of two images is represented by \(\beta\).  
\[\beta=\sum\limits_{i=1}^{n}\text{abs}\Big{(}I_{i}-I^{\prime}_{i}\Big{)}. \tag{11}\]  
The smaller the \(\beta\), the more similar the two images are.  
When the camera is applied to a UAV, if the relative height and inclination of the camera remain the same as that of the ground, two different images taken at the same location, but different times can be considered as having horizontal deviation without vertical deviation. Therefore, the region of interest (ROI) of the template image can shift above the reference image, the similarity of the corresponding region of the two images after each shift can thus be calculated, and the value of \(\beta^{\prime}\), which is the minimum value of all similarity values calculated after each shift, is taken as the final similarity of the two images.  
\[\beta^{\prime}=\min\left\{\min_{0\leq s\leq offset}\left[\frac{\sum\limits_{i= 1+s}^{W}\text{abs}\big{(}I_{i}-I^{\prime}_{i-s}\big{)}}{W-s}\right],\min_{0 \leq t\leq offset}\left[\frac{\sum\limits_{j=1+t}^{W}\text{abs}\Big{(}I^{ \prime}_{j-t}-I^{\prime}_{j}\Big{)}}{W-t}\right]\right\}\, \tag{12}\]  
where \(\beta^{\prime}\) is the final similarity of the two images, \(offset\) is the maximum shift, and \(W\) is the width of ROI.  
The threshold is set as h, if \(\beta^{\prime}\leq h\), then the two images are considered to be matched successfully.  
As shown in Figure 5, the picture on the left and the picture in the middle are two images taken at different times in the same place, whereas the picture on the right is taken in another different place. Taking the image in the middle as the template, it can be seen that the scanline profile of the template image is similar to the image on the left, but different to the image on the right.  
The advantages of this algorithm are that little computation is required and the real-time processing requirements can be met. The disadvantage is that the accuracy is not high enough, and environmental variation factors including light, pedestrians and other vehicles may lead to misjudgment and low reliability.