public class LocalitySensitiveHashing
extends java.lang.Object
Each feature vector v with dimension d gets k hashes from a hash bundle h(v) = (h^1(v), h^2(v), ..., h^k(v)) with
h^i(v) = (a^i*v + b^i)/w (rounded down), with a^i from R^d and b^i in [0,w)
If m of the k hashes match, then we assume that the feature vectors belong to similar images. Note that m*k has to be bigger than d!
If a^i is drawn from a normal (Gaussian) distribution LSH approximates L2.
| 限定符和类型 | 字段和说明 |
|---|---|
static double |
binLength |
static int |
numFunctionBundles |
| 构造器和说明 |
|---|
LocalitySensitiveHashing() |
| 限定符和类型 | 方法和说明 |
|---|---|
static int[] |
generateHashes(double[] histogram)
Generates the hashes from the given hash bundles.
|
static void |
generateHashFunctions()
Writes a new file to disk to be read for hashing with LSH.
|
static void |
generateHashFunctions(java.lang.String name) |
static void |
main(java.lang.String[] args) |
static double[][] |
readHashFunctions()
Reads a file from disk and sets the hash functions.
|
static double[][] |
readHashFunctions(java.io.InputStream in) |
public static int numFunctionBundles
public static double binLength
public static void generateHashFunctions()
throws java.io.IOException
java.io.IOExceptionpublic static void generateHashFunctions(java.lang.String name)
throws java.io.IOException
java.io.IOExceptionpublic static double[][] readHashFunctions()
throws java.io.IOException
java.io.IOExceptiongenerateHashFunctions()public static double[][] readHashFunctions(java.io.InputStream in)
throws java.io.IOException
java.io.IOExceptionpublic static int[] generateHashes(double[] histogram)
histogram - public static void main(java.lang.String[] args)