similie 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.2.1
data/ext/similie.c CHANGED
@@ -52,20 +52,22 @@ int popcount(uint64_t x) {
52
52
  return (x * h01)>>56; //returns left 8 bits of x + (x<<8) + (x<<16) + (x<<24) + ...
53
53
  }
54
54
 
55
+ #define DCT_SIZE 32
56
+
55
57
  uint64_t image_phash(IplImage *img) {
56
58
  uint64_t phash = 0;
57
59
  int x, y;
58
60
  double avg;
59
61
 
60
- IplImage *small = cvCreateImage(cvSize(32, 32), 8, img->nChannels);
61
- IplImage *mono = cvCreateImage(cvSize(32, 32), 8, 1);
62
+ IplImage *small = cvCreateImage(cvSize(64, 64), 8, img->nChannels);
63
+ IplImage *mono = cvCreateImage(cvSize(64, 64), 8, 1);
62
64
 
63
65
  cvResize(img, small, CV_INTER_CUBIC);
64
66
  cvCvtColor(small, mono, CV_RGB2GRAY);
65
67
 
66
- CvMat *dct = cvCreateMat(8, 8, CV_32FC1);
67
- for (x = 0; x < 8; x++) {
68
- for (y = 0; y < 8; y++) {
68
+ CvMat *dct = cvCreateMat(DCT_SIZE, DCT_SIZE, CV_32FC1);
69
+ for (x = 0; x < DCT_SIZE; x++) {
70
+ for (y = 0; y < DCT_SIZE; y++) {
69
71
  cvSet2D(dct, x, y, cvScalarAll(cvGetMonoPixel(mono, x, y)));
70
72
  }
71
73
  }
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 216455360913932544, img.hash
15
+ assert_equal 72342380518637824, 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 216455360913932544, hash
21
+ assert_equal 72342380518637824, hash
22
22
  end
23
23
  end
@@ -4,14 +4,14 @@ describe 'Similie image distance' do
4
4
  it 'should work for similar images' do
5
5
  images = (1..5).map {|n| Similie.new(File.join($testdir, 'lena%d.png' % n ))}
6
6
 
7
- assert_equal 1, images[0].distance(images[1])
8
- assert_equal 2, images[1].distance(images[2])
9
- assert_equal 0, images[2].distance(images[3])
10
- assert_equal 1, images[0].distance(images[3])
11
- assert_equal 6, images[3].distance(images[4])
7
+ assert_equal 2, images[0].distance(images[1])
8
+ assert_equal 3, images[1].distance(images[2])
9
+ assert_equal 2, images[2].distance(images[3])
10
+ assert_equal 3, images[0].distance(images[3])
11
+ assert_equal 18, images[3].distance(images[4])
12
12
  end
13
13
 
14
14
  it 'should work using the singleton method' do
15
- assert_equal 6, Similie.distance(File.join($testdir, 'lena4.png'), File.join($testdir, 'lena5.png'))
15
+ assert_equal 18, Similie.distance(File.join($testdir, 'lena4.png'), File.join($testdir, 'lena5.png'))
16
16
  end
17
17
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 0
9
- version: 0.2.0
8
+ - 1
9
+ version: 0.2.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Bharanee Rathna