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.
Files changed (4) hide show
  1. data/VERSION +1 -1
  2. data/ext/similie.c +4 -2
  3. data/test/test_basic.rb +2 -2
  4. metadata +2 -2
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.1
1
+ 0.2.2
@@ -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 = 0; x < 8; x++) {
82
- for (y = 0; y < 8; 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);
@@ -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 72342380518637824, img.hash
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 72342380518637824, hash
21
+ assert_equal 36205409308016768, hash
22
22
  end
23
23
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 1
9
- version: 0.2.1
8
+ - 2
9
+ version: 0.2.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Bharanee Rathna