Hash代码大全

 我最近在看有关哈希图片检索的文章,看到一份不错的资料,希望能和大家一起分享微笑

注:博客转自http://blog.csdn.NET/willard_yuan/article/details/29806755

下面的这份哈希算法小结来源于本周的周报,原本并没有打算要贴出来的,不过,考虑到这些资源属于关注利用哈希算法进行大规模图像搜索的各位看官应该很有用,所以好东西本小子就不私藏了。本资源汇总最主要的收录原则是原作者主页上是否提供了源代码,为了每种方法的资料尽可能完整,本小子会尽可能的除提供源码下载地址外,还会给出PDF文章的链接、项目主页,slide等。

对哈希方法重新进行调研,右图是找到的提供有部分源码的哈希方法,这其中包含了比较经典的哈希方法,比如e2lsh、mih,同时也包含有最近几年一直到13年提出来的一些比较新的哈希算法,比如13年提出的有bpbc、opq、ksh。

上面这一段是摘自本小子的周报(本小子这周除改了篇文章,其余时间几乎都在打酱油,谁叫老板不给发工资,O(∩_∩)O~),引用中的“右图”可以略过,直接看下面不同哈希算法的链接信息。


哈希方法

公布代码的:

  1. AGH: Hashing with Graphs [Paper] [Code]
  2. BPBC: Learning Binary Codes for High-Dimensional Data Using Bilinear Projections [Paper] [Code]
  3. BRE: Learning to Hash with Binary Reconstructive Embeddings [Paper] [Code]
  4. DBQ: Double-bit quantization for hashing [Paper] [Code]
  5. E2LSH: Local Sensitive Hash [Project Page] read
  6. HDML: Hamming Distance Metric Learning [Paper] [Code]
  7. IMH: Inter-Media Hashing for Large-scale Retrieval from Heterogenous Data Sources [Project Page] [Code]
  8. ISOH: Isotropic Hashing [Paper] [Code]
  9. ITQ: Iterative Quantization: A Procrustean Approach to Learning Binary Codes [Project Page] [Paper] [Code]read
  10. KLSH: Kernelized Locality-Sensitive Hashing for Scalable Image Search [Project Page] [Paper] [Code]
  11. KMH: K-means Hashing: an Affinity-Preserving Quantization Method for Learning Binary Compact Codes[Paper] [Code] read
  12. KSH: Supervised Hashing with Kernels [Paper] [Code] read
  13. MDSH: Multidimensional Spectral Hashing [Paper] [Code]
  14. MH: Manhattan hashing for large-scale image retrieval [Paper] [Code] read
  15. MinH: Minimal Loss Hashing for Compact Binary Codes [Paper] [Code] [Slide]
  16. OPQ: Optimized Product Quantization for Approximate Nearest Neighbor Search [Paper] [Code]
  17. SH: Spectral Hashing [Paper] [Code] read
  18. IHM: Inductive Hashing on Manifolds (2013 CVPR) ProjectPage read
  19. BSPH: Semi-supervised Nonlinear Hashing Using Bootstrap Sequential Projection Learning (2012 TKDE)ProjectPage read
  20. FastHash: Fast Supervised Hashing with Decision Trees for High-Dimensional Data (2014 CVPR) [Code] read

无代码:

  1. PDHPredictable Dual-View Hashing (ICML2013) read

常用数据库

  1. LabelMe
  2. min-loss-hashing
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
int main(int argc, char *argv[]) { int i = 0; bool bOnce = true; char szPath[RH_MAX_PATH]; char szAbsPath[RH_MAX_PATH]; char szOrgPath[RH_MAX_PATH]; char szTemp[RH_MAX_BUFFER]; int iErrorCode = 0; CHashManager hashmgr; getcwd(szOrgPath, RH_MAX_PATH); //No arguments? if(argc == 1) { printInfo(); return(RH_NO_ARGS); } memset(szPath, 0, RH_MAX_PATH); bOnce = true; hashmgr.SelectAllAlgorithms(true); for(i = 1; i = RH_MAX_BUFFER) continue; // Non-parsable option argument, ignore fmtArgument(argv[i], szTemp); // Format the argument, i.e. remove all special chars if(strcmp(szTemp, "help" ) == 0) printInfo(); if(strcmp(szTemp, "h" ) == 0) printInfo(); if(strcmp(szTemp, "?" ) == 0) printInfo(); if(strcmp(szTemp, "version" ) == 0) printInfo(); if(strcmp(szTemp, "v" ) == 0) printInfo(); if(strcmp(szTemp, "fullpath") == 0) hashmgr.SetOption(OPT_FULLPATH, true); if(strcmp(szTemp, "f" ) == 0) hashmgr.SetOption(OPT_FULLPATH, true); if(strcmp(szTemp, "nopath" ) == 0) hashmgr.SetOption(OPT_FULLPATH, false); if(strcmp(szTemp, "rcrsv" ) == 0) hashmgr.SetOption(OPT_RECURSIVE, true); if(strcmp(szTemp, "norcrsv" ) == 0) hashmgr.SetOption(OPT_RECURSIVE, false); if(strcmp(szTemp, "recur" ) == 0) hashmgr.SetOption(OPT_RECURSIVE, true); if(strcmp(szTemp, "norecur" ) == 0) hashmgr.SetOption(OPT_RECURSIVE, false); if(strcmp(szTemp, "r" ) == 0) hashmgr.SetOption(OPT_RECURSIVE, true); if(strcmp(szTemp, "all" ) == 0) hashmgr.SelectAllAlgorithms(true); if(strcmp(szTemp, "a" ) == 0) hashmgr.SelectAllAlgorithms(true); if(strcmp(szTemp, "none" ) == 0) hashmgr.SelectAllAlgorithms(false); if(strcmp(s
以下是一个简单的C++实现Cuckoo Hash的示例代码: ```cpp #include <iostream> #include <vector> #include <algorithm> using namespace std; const int TABLE_SIZE = 11; const int MAX_RETRIES = 500; class CuckooHash { private: vector<int> table1; vector<int> table2; public: CuckooHash() { table1.resize(TABLE_SIZE); table2.resize(TABLE_SIZE); } int hash1(int key) { return key % TABLE_SIZE; } int hash2(int key) { return (key / TABLE_SIZE) % TABLE_SIZE; } void insert(int key) { int count = 0; while (count < MAX_RETRIES) { int index1 = hash1(key); int index2 = hash2(key); if (table1[index1] == key || table2[index2] == key) { cout << key << " already exists." << endl; return; } if (table1[index1] == 0) { table1[index1] = key; return; } else if (table2[index2] == 0) { table2[index2] = key; return; } else { int evictedKey = table1[index1]; table1[index1] = key; key = table2[index2]; table2[index2] = evictedKey; count++; } } cout << "Insertion failed." << endl; } void remove(int key) { int index1 = hash1(key); int index2 = hash2(key); if (table1[index1] == key) { table1[index1] = 0; } else if (table2[index2] == key) { table2[index2] = 0; } else { cout << key << " does not exist." << endl; } } bool search(int key) { int index1 = hash1(key); int index2 = hash2(key); return table1[index1] == key || table2[index2] == key; } }; int main() { CuckooHash hash; hash.insert(10); hash.insert(22); hash.insert(37); hash.insert(40); hash.insert(50); hash.insert(60); hash.remove(22); hash.remove(40); hash.insert(70); hash.insert(80); cout << "Search for 10: " << (hash.search(10) ? "Found" : "Not Found") << endl; cout << "Search for 37: " << (hash.search(37) ? "Found" : "Not Found") << endl; cout << "Search for 50: " << (hash.search(50) ? "Found" : "Not Found") << endl; cout << "Search for 80: " << (hash.search(80) ? "Found" : "Not Found") << endl; cout << "Search for 90: " << (hash.search(90) ? "Found" : "Not Found") << endl; return 0; } ``` 代码中使用了两个哈希表作为Cuckoo Hash的基础数据结构,其中使用了两个不同的哈希函数来计算每个键的两个哈希值。在插入键时,如果一个键已经存在于两个哈希表中的任何一个中,则插入操作失败。如果两个哈希表中有一个空闲位置,则将键插入其中一个哈希表中。如果两个哈希表中都没有空闲位置,则使用Cuckoo Hash算法将其中一个哈希表中的键替换为新插入的键,同时将被替换的键移动到另一个哈希表中。在删除键时,如果一个键存在于哈希表中,则将其从哈希表中删除。在搜索键时,如果一个键存在于两个哈希表中的任何一个中,则返回true,否则返回false。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值