Kmeans based indexing and Asymmetric Distance Computation for ANN search (Binary Local Feature): par
2012-01-31 13:19
615 查看
转自: http://www.cvchina.info/2012/01/13/kmeans-based-indexing-and-asymmetric-distance-computation-for-ann-search-binary-local-feature-part1/#more-3232
受Herve Jegou的Hamming Embedding and Weak Geometric consistency for large-scale image search以及Product
quantization for nearest neighbor search的启发,将Kmeans clustering、inverted files、Asymmetric Distance Computation应用到二进制形式的局部特征的最近邻检索。
主要思路:
用Kmeans做特征的粗索引。
根据统计数据对feature进行压缩。
检索时使用非对称的方式计算索引特征与查询特征之间的距离。
使用Kmeans对欲索引的特征进行聚类,得到K个中心。对二进制形式的feature做聚类时,类别中心更新方式为:对于每一个bit,统计所有落在该类别的特征的对应bit上的1,0频率,并取高者。
对于每个cluster,统计所有落在该类别的特征的每个bit位的1,0频率,取1或者0频率靠近50%的前M个bits。(越靠近50%,熵越大)
经过训练,我们得到两组数据:
K个特征类别中心。
对于每个类别中心,都有一组“M个bit位置标示符”。这些标示符构成一个对原始feature进行压缩的依据。(本文以后将其称为投影向量)
索引:
建立倒排表
对于每一个欲索引的特征,计算其类别中心,并用该类别的投影向量对特征进行投影,得到一个M位的signature。记为sig_templ, 将该signature插入到倒排表中。
ANN检索:
计算query特征的类别中心query_cluster,并用该类别的投影向量对特征进行投影,得到一个M位的sig_query。
计算query特征与类别中心的,除去该类别投影向量对应的bit位的距离,记为dist_base.
遍历query_cluster对应的倒排表项,计算sig_query于表项中的sig_templ的距离,记为dist_sig。那么query特征与索引特征的距离dist = dist_base + dist_sig. 如此得到的最小距离,如小于某阈值,即可认为找到一个ANN。
关于时间复杂度的一点分析:
假设K = 40, M = 64,特征为32Byte
ORB(假设有1k的供索引的特征):
那么每次ANN检索只用做
40次32Byte的Hamming Distance计算 + 约25次8Byte的Hamming Distance计算。
对比穷举检索:
1000次32Byte的Hamming Distance计算
速度提升:20x
示例:
实验配置:
特征:Orb
nn/ann匹配阈值:50
K = 40
下图为穷举检索,图像匹配的结果:(无ransac)
![](http://www.cvchina.info/wp-content/uploads/2012/01/image_thumb.png)
After Ransac:
![](http://www.cvchina.info/wp-content/uploads/2012/01/image_thumb1.png)
下图为使用上述ANN检索方式,图像匹配的结果:(无ransac)
![](http://www.cvchina.info/wp-content/uploads/2012/01/image_thumb2.png)
After Ransac:
![](http://www.cvchina.info/wp-content/uploads/2012/01/image_thumb3.png)
可以看出,匹配点数会有明显下降。原因是两级索引方式固有的缺陷。(两个本身很近的feature,会被分类到不同的cluster)。也许使用Multi Assignment会有所改善。
等代码整理好再发part2.
受Herve Jegou的Hamming Embedding and Weak Geometric consistency for large-scale image search以及Product
quantization for nearest neighbor search的启发,将Kmeans clustering、inverted files、Asymmetric Distance Computation应用到二进制形式的局部特征的最近邻检索。
主要思路:
用Kmeans做特征的粗索引。
根据统计数据对feature进行压缩。
检索时使用非对称的方式计算索引特征与查询特征之间的距离。
算法:
训练:使用Kmeans对欲索引的特征进行聚类,得到K个中心。对二进制形式的feature做聚类时,类别中心更新方式为:对于每一个bit,统计所有落在该类别的特征的对应bit上的1,0频率,并取高者。
对于每个cluster,统计所有落在该类别的特征的每个bit位的1,0频率,取1或者0频率靠近50%的前M个bits。(越靠近50%,熵越大)
经过训练,我们得到两组数据:
K个特征类别中心。
对于每个类别中心,都有一组“M个bit位置标示符”。这些标示符构成一个对原始feature进行压缩的依据。(本文以后将其称为投影向量)
索引:
建立倒排表
对于每一个欲索引的特征,计算其类别中心,并用该类别的投影向量对特征进行投影,得到一个M位的signature。记为sig_templ, 将该signature插入到倒排表中。
ANN检索:
计算query特征的类别中心query_cluster,并用该类别的投影向量对特征进行投影,得到一个M位的sig_query。
计算query特征与类别中心的,除去该类别投影向量对应的bit位的距离,记为dist_base.
遍历query_cluster对应的倒排表项,计算sig_query于表项中的sig_templ的距离,记为dist_sig。那么query特征与索引特征的距离dist = dist_base + dist_sig. 如此得到的最小距离,如小于某阈值,即可认为找到一个ANN。
关于时间复杂度的一点分析:
假设K = 40, M = 64,特征为32Byte
ORB(假设有1k的供索引的特征):
那么每次ANN检索只用做
40次32Byte的Hamming Distance计算 + 约25次8Byte的Hamming Distance计算。
对比穷举检索:
1000次32Byte的Hamming Distance计算
速度提升:20x
示例:
实验配置:
特征:Orb
nn/ann匹配阈值:50
K = 40
下图为穷举检索,图像匹配的结果:(无ransac)
![](http://www.cvchina.info/wp-content/uploads/2012/01/image_thumb.png)
After Ransac:
![](http://www.cvchina.info/wp-content/uploads/2012/01/image_thumb1.png)
下图为使用上述ANN检索方式,图像匹配的结果:(无ransac)
![](http://www.cvchina.info/wp-content/uploads/2012/01/image_thumb2.png)
After Ransac:
![](http://www.cvchina.info/wp-content/uploads/2012/01/image_thumb3.png)
可以看出,匹配点数会有明显下降。原因是两级索引方式固有的缺陷。(两个本身很近的feature,会被分类到不同的cluster)。也许使用Multi Assignment会有所改善。
等代码整理好再发part2.
相关文章推荐
- Kmeans based indexing and Asymmetric Distance Computation for ANN search (Binary Local Feature):...
- Deep Learning based Large Scale Visual Recommendation and Search for E-Commerce
- 1604.Joint Detection and Identification Feature Learning for Person Search论文阅读笔记
- 文章解读:Feature selection based on FDA and F-score for multi-class classification
- 论文笔记之---Joint Detection and Identification Feature Learning for Person Search
- A Quarter-Car Vehicle Model Based Feature for Wheeled and Tracked Vehicle Classification
- 利用二叉树的中序遍历和后序遍历序列构造一个二叉树Search results for Construct Binary Tree from Inorder and Postorder Traversa
- Solaris vs. Linux: Ecosystem-based Approach and Framework for the Comparison in Large Enterprise
- 翻译:Testing And Quality Assurance For Component Based Software
- Source code for Bayesian based CS and blind debluring
- ElasticSearch-Hadoop: Indexingproductviews count andcustomer topsearch queryfrom Hadoop to ElasticSe
- Study notes for Clustering and K-means
- R-CNN:Rich feature hierarchies for accurate object detection and semantic segmentation(阅读)
- Convert Sorted Array to Binary Search Tree and Merge Two Sorted Lists
- Binary Index Tree And Segment Tree for PKU #3378 Crazy Thairs
- How to search for COM and DCOM Knowledge Base articles
- Java for LeetCode 105 Construct Binary Tree from Preorder and Inorder Traversal
- Java for LeetCode 108 Convert Sorted Array to Binary Search Tree
- Recover Binary Search Tree & Edit Distance & Reverse Nodes in k-Group
- 缓存地图 ArcGIS ——Local compact and exploded tile cache layer for WPF API