# Visual-Based Localization Using Pictorial Planar Objects in Indoor Environment
## 5 PicPose: A Picture-Based Pose Method
### PicPose Feature Points Extraction
#### 5.2.2 Texture Feature Point Extraction
In that way, the influences of both distance factor and pixel difference are considered in the bilateral filter. The weight can be calculated as:  
\[W_{x,y}=exp(\frac{-\left\|P_{x,y}-\overline{P_{x,y}}\right\|^{2}}{2\sigma_{p} ^{2}})*exp(\frac{-\left\|C_{x,y}-\overline{C_{x,y}}\right\|^{2}}{2\sigma_{c} ^{2}})\]  
where \(P_{x,y}\) is the grey value of pixel (x,y), \(\overline{P_{x,y}}\) is the mean value of the neighbours of (x,y), \(C_{x,y}\) is the position of (x,y) and\(\overline{C_{x,y}}\) is the position of its neighbours. \(\sigma_{p}\) and \(\sigma_{c}\) represent the standard deviations of pixel values and distances respectively. In the flat region, the weight of each pixel in the filter is similar, and the spatial distance weight dominates the filtering effect. In the edge region, the values on the same side of the edge are similar and far greater than those on the other side of the edge. At this time, the weight of the pixels on the other side has little effect on the filtering results, and the edge information is protected. When there are noise points in the flat area, the weights of the signals around the noise points are very small. After normalization, these weights are improved, and the noise points are also filtered. Figure 9: Feature-based Localization. After obtaining the key points, we need to describe the attributes of these feature points in some way. The output of these attributes is called feature descriptor. The feature descriptor is generated by BRIEF (Binary Robust Independent Elementary Features) algorithm in ORB. The descriptor produced by BRIEF is a set of binary codes which combines the differences of M paris of points surrounding a key point.The descriptor is represented as a binary sequence containing M bits, which can be generated without the need to compute a SIFT-like feature descriptor. A small region surrounding the key point is selected by BRIEF. Then for each pair of points (Pa, Pb) in the region, its descriptor bit is represented by comparing the grayscale values of this pair of points. The bit is 1 if \(G(Pa)>G(Pb\), 0 otherwise, where G represents the greyscale value a point. Thus, all M pairs of points are compared to generate a binary vector, which can be presented as:  
\[d_{p}=\sum\limits_{i=1}^{M}2^{i-1}b_{(Pa_{i},Pb_{i})}\]  
Normally M takes the value of 128, 256 or 512, and we use 256 bits descriptor in this model. Density Aware Feature Point Reduction  
In order to guarantee the precision of pose estimation, the goal of feature point extraction is to find the location of each feature point in the ground truth library from that in the detected picture as precisely as possible. The quality feature matching highly determines the accuracy of picture pose estimation. An acceptable pair of feature points needs to meet two criteria, complexity of feature descriptor and distribution of the location of feature points. However, the FAST key point selection is applied prior to BRIEF descriptor generation. Therefore, there is no chance to know what the descriptor is when selecting key points. So the uniqueness of descriptors is hard to guarantee, especially when there are similar patterns in the same picture. Therefore, we designed a density aware optimizer to distribute the selected feature points according to the density in a small region. The picture is cropped into 16 (4 \(\times\) 4) regions in which we calculate the density of feature points. Some feature points with similar descriptors will be removed from the region if the density is higher than a threshold. We use Hamming distance to evaluate the difference of each descriptor. The optimization algorithm is shown in Figure 10. In this algorithm, _Hi_ represents the Hamming distances between the descriptor and its nearest 10 descriptors in the region. \(\alpha\) is a factor that can control the maximum density of a block. The distributed feature points with more particular descriptors are gained via this optimization algorithm.