similie 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/ext/similie.c +4 -2
- data/test/test_basic.rb +2 -2
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.2
|
data/ext/similie.c
CHANGED
@@ -78,13 +78,15 @@ uint64_t image_phash(IplImage *img) {
|
|
78
78
|
avg = (double)cvAvg(dct, 0).val[0] * 64.0 / 63.0;
|
79
79
|
|
80
80
|
uint64_t mask = 1;
|
81
|
-
for (x =
|
82
|
-
for (y =
|
81
|
+
for (x = 7; x >= 0; x--) {
|
82
|
+
for (y = 7; y >= 0; y--) {
|
83
83
|
if (cvGet2D(dct, x, y).val[0] > avg) phash |= mask;
|
84
84
|
mask = mask << 1;
|
85
85
|
}
|
86
86
|
}
|
87
87
|
|
88
|
+
phash = phash & 0xEFFFFFFFFFFFFFFF;
|
89
|
+
|
88
90
|
cvReleaseMat(&dct);
|
89
91
|
cvReleaseImage(&mono);
|
90
92
|
cvReleaseImage(&small);
|
data/test/test_basic.rb
CHANGED
@@ -12,12 +12,12 @@ describe 'Similie image load' do
|
|
12
12
|
it 'should hash image' do
|
13
13
|
img = Similie.new(File.join($testdir, 'lena1.png'))
|
14
14
|
assert img
|
15
|
-
assert_equal
|
15
|
+
assert_equal 36205409308016768, img.hash
|
16
16
|
end
|
17
17
|
|
18
18
|
it 'should hash image using class method' do
|
19
19
|
hash = Similie.phash(File.join($testdir, 'lena1.png'))
|
20
20
|
assert hash
|
21
|
-
assert_equal
|
21
|
+
assert_equal 36205409308016768, hash
|
22
22
|
end
|
23
23
|
end
|