【发布时间】:2014-03-13 10:47:52
【问题描述】:
我们有一个图像数据库,我使用Dr. Neal Krawetz's method 计算了PHASH,由David Oftedal 实现。
部分示例代码计算这些 long 之间的差异在这里:
ulong hash1 = AverageHash(theImage);
ulong hash2 = AverageHash(theOtherImage);
uint BitCount(ulong theNumber)
{
uint count = 0;
for (; theNumber > 0; theNumber >>= 8) {
count += bitCounts[(theNumber & 0xFF)];
}
return count;
}
Console.WriteLine("Similarity: " + ((64 - BitCount(hash1 ^ hash2)) * 100.0) / 64.0 + "%");
挑战在于我只知道其中一个哈希值,我想查询 SOLR 以按相似度顺序查找其他哈希值。
一些注意事项:
- 在这里使用 SOLR(我唯一的选择是 HBASE)
- 希望避免将任何自定义 java 安装到 solr(很高兴安装现有插件)
- 很高兴在 C# 中进行大量预处理
- 乐于使用多个字段将数据存储为位串、长等
- 使用 SOLRNet 作为客户端
编辑,一些额外的信息(抱歉,我陷入了这个问题并开始假设它是一个广为人知的领域)。这是直接下载到 C# 控制台/示例应用程序:http://01101001.net/Imghash.zip
此控制台应用程序的示例输出为:
004143737f7f7f7f phash-test-001.jpg
0041417f7f7f7f7f phash-test-002.jpg
相似度:95.3125%
【问题讨论】:
标签: c# solr bit-manipulation solrnet phash