@@ -14,20 +14,71 @@ rewrite it as an extension.
14
14
Usage
15
15
-----
16
16
17
+ ### API
18
+
17
19
Seeklib.path_sig: takes a path to an image, and produces an imgseek fingerprint.
18
20
19
21
Seeklib.calc_diff: takes two imgseek fingerprints and returns the difference score.
20
22
21
- Two caveats:
23
+ Allowed image types are any that CImg handles (IIRC jpg, gif, png,
24
+ bmp, and maybe a couple others), or any that ImageMagick handles
25
+ (basically all of them) if you have the ImageMagick library installed
26
+ (CImg will call out to ImageMagick if it can't read an image itself).
27
+
28
+ ### Caveats:
22
29
23
30
1. Note that the difference score is not as straightforward as the one
24
- generated by pHash. The score is a negative integer. The more
25
- negative, the more different the images are. It's not clear what the
26
- max difference score is. You should probably look here if you really
27
- need to know:
31
+ generated by pHash. The score is a negative integer. The more
32
+ negative, the more similar the images are. Personally, I find this
33
+ annoying to think about, so I'll add 50 to the result.
34
+
35
+ 2. The score resulting from comparing two identical images is
36
+ undefined. If this is possible in your application, consider
37
+ supplementing your comparison with good old-fashion sha1 or
38
+ something.
39
+
40
+ 3. It's not clear what the max difference score is. You should
41
+ probably look here if you really need to know, and read the
42
+ authors' original paper.
28
43
29
44
http://grail.cs.washington.edu/projects/query/
30
45
31
- 2. The score resulting from comparing two identical images is
32
- undefined. If this is possible in your application, consider
33
- supplementing your comparison with good old-fashion sha1 or something.
46
+ ### Example
47
+
48
+ ```ruby
49
+ require 'seeklib'
50
+ bss = SeekLib.path_sig 'squares/blue-square.jpg' # what it sounds like
51
+ gss = SeekLib.path_sig 'squares/green-square.jpg' # pretty much same
52
+ rss = SeekLib.path_sig 'squares/red-square.jpg' # a bit different
53
+
54
+ SeekLib.calc_diff(bss, gss) + 50 # => 18.641717640766657
55
+ SeekLib.calc_diff(gss, bss) + 50 # => 18.641717640766657 (thank god)
56
+
57
+ SeekLib.calc_diff(bss, rss) + 50 # => 46.336210565558794 (whoa!)
58
+ SeekLib.calc_diff(gss, rss) + 50 # => 46.169410374857364 (similar)
59
+
60
+ SeekLib.calc_diff(bss, bss) + 50 # => 17.969999238848686
61
+ SeekLib.calc_diff(gss, gss) + 50 # => 17.969999238848686 (wait, diff(a, a) undefined?)
62
+ SeekLib.calc_diff(rss, rss) + 50 # => 9.8899996727705 (yep, unfortunately)
63
+ ```
64
+
65
+ Getting
66
+ -------
67
+
68
+ It's not actually published yet, so you have to do everything yourself.
69
+
70
+ ### Quick Way
71
+
72
+ 1. Get repo dradetsky/seeklib and build it.
73
+
74
+ 2. Place resulting libseek.so in this repo's `ext` directory.
75
+
76
+ 3. Substitute `require './lib/seeklib'` in the above script.
77
+
78
+ ### Long Way
79
+
80
+ 1. Get repo dradetsky/seeklib and build/install it. (ha ha! good luck!)
81
+
82
+ 2. `gem build seeklib.gemspec`
83
+
84
+ 3. `gem install seeklib-0.0.1.gem`
0 commit comments