ssimsort 0.2.2 → 0.2.4

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 098b1f416f484a7e9825eaba05efd9921adb4762
4
- data.tar.gz: 6a8642c0e3a3a709f511e98f9d28f92be589c3ce
3
+ metadata.gz: 56e74c120dfb6ade8bf5451397f96e45dd8b19e4
4
+ data.tar.gz: 4b63e87ae981190ed13d16d6001c0a8433edeae2
5
5
  SHA512:
6
- metadata.gz: 68bd6de183fd3be771afa5b9763265edef9664016e6390d27b69c7925e219fe954e101d05616596269bacc5478e243e0cdb30130069dd9edfe0e98d73fd64076
7
- data.tar.gz: cb910a92351ceaa88b500b02a037e4fe5000c8f777c8cb215e72df758f223f0277f549610d86b39c8078d5c25cf2f0d999cc6701eed978cdf2a3cdca9ecedb73
6
+ metadata.gz: 1ab581499c1fb273fd4d50c1a8cf64fe53d50ac856494bce19e165cae3480b981247d601745f7f6ab90fb86a89fb881f6a4d0e08648a2668e8a60a030bee21ec
7
+ data.tar.gz: cb84a92d6d867353dec37e641ad899c0c7fdf0e2555c8b6a0550c304ff3f046cef1546f72924255529a61a4fded9882c22e08c98df095a918868ee663fac220f
data/bin/ssimsort CHANGED
@@ -4,9 +4,10 @@ root = File.expand_path("../..", __FILE__)
4
4
  require "#{root}/lib/ssimsort.rb"
5
5
 
6
6
  case ARGV[0]
7
- when "-c" then p SsimSort.ssim(ARGV[1],ARGV[2])
8
- when "-dc" then p SsimSort.ssim_dir(ARGV[1])
9
- when "-s" then SsimSort.sort(ARGV[1],ARGV[2],*ARGV[3])
10
- when "-sc" then SsimSort.sort_comp(ARGV[1],ARGV[2],ARGV[3])
7
+ when "-m" then SsimSort.ssim_dir_mean(ARGV[1]) #Mean
8
+ when "-c" then p SsimSort.ssim(ARGV[1],ARGV[2]) #Compare
9
+ when "-dc" then p SsimSort.ssim_dir(ARGV[1]) #Directory Compare
10
+ when "-s" then SsimSort.sort(ARGV[1],ARGV[2],*ARGV[3]) #Sort
11
+ when "-sc" then SsimSort.sort_comp(ARGV[1],ARGV[2],ARGV[3]) #Sort by comparison to another image
11
12
  else puts "SSIMSORT:\n-s <input_dir>,<output_dir>,[<tolerance>]\n-sc <base_file>,<input_dir>,<output_dir>\n-c <file_1>,<file_2>\n-dc <input_dir>\n"
12
13
  end
data/lib/ssimsort.rb CHANGED
@@ -9,6 +9,7 @@ module SsimSort
9
9
  require "fileutils"
10
10
  include Magick
11
11
 
12
+ @formats = /(.jpg$|.png$|.JPG$|.jpeg$|.PNG$|.gif$|.bmp$|.BMP$)/
12
13
 
13
14
  def SsimSort.cov(x,y)
14
15
  return x.zip(y).covariance
@@ -36,10 +37,10 @@ module SsimSort
36
37
 
37
38
 
38
39
  def SsimSort.ssim_dir(input_path)
39
- formats = /(.jpg$|.png$|.JPG$|.jpeg$|.PNG$|.gif$|.bmp$|.BMP$)/
40
+
40
41
  files = Dir.entries(input_path).map {|file| File.absolute_path("#{input_path}/#{file}")}
41
42
  files.shift(2) #Remove . and ..
42
- files.select!{|f| formats=~ f}
43
+ files.select!{|f| @formats=~ f}
43
44
  set = files.product(files)
44
45
  set.each do |file1,file2|
45
46
  simil = SsimSort.ssim(file1,file2)
@@ -47,11 +48,18 @@ module SsimSort
47
48
  end
48
49
  end
49
50
 
51
+ def SsimSort.ssim_dir_mean(input_path)
52
+ files = Dir.entries(input_path).map {|file| File.absolute_path("#{input_path}/#{file}")}
53
+ files.shift(2) #Remove . and ..
54
+ files.select!{|f| @formats=~ f}
55
+ set = files.product(files)
56
+ l = set.map {|file1,file2| SsimSort.ssim(file1,file2)}.mean
57
+ end
58
+
50
59
  def SsimSort.sort(input_path,output_path,tolerance=0.8)
51
- formats = /(.jpg$|.png$|.JPG$|.jpeg$|.PNG$|.gif$|.bmp$|.BMP$)/
52
60
  files = Dir.entries(input_path).map {|file| File.absolute_path("#{input_path}/#{file}")}
53
61
  files.shift(2) #Remove . and ..
54
- files.select!{|f| formats=~ f}
62
+ files.select!{|f| @formats=~ f}
55
63
  set = files.product(files)
56
64
  set.each do |file1,file2|
57
65
  path = "#{output_path}/#{file1.split("/").last}/"
@@ -64,12 +72,11 @@ module SsimSort
64
72
  end
65
73
 
66
74
  def SsimSort.sort_comp(filecomp_path,input_path,output_path)
67
- formats = /(.jpg$|.png$|.JPG$|.jpeg$|.PNG$|.gif$|.bmp$|.BMP$)/
68
75
  filecomp = File.absolute_path(filecomp_path)
69
76
  output_path = File.absolute_path(output_path+"/")
70
77
  files = Dir.entries(input_path).map {|file| File.absolute_path("#{input_path}/#{file}")}
71
78
  files.shift(2) #Remove . and ..
72
- files.select!{|f| formats=~ f}
79
+ files.select!{|f| @formats=~ f}
73
80
  sim_dict = {}
74
81
  FileUtils.mkdir(output_path) unless File.exists?(output_path)
75
82
  files.each do |file|
data/ssimsort.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'ssimsort'
3
- s.version = '0.2.2'
3
+ s.version = '0.2.4'
4
4
  s.date = '2013-11-27'
5
5
  s.summary = "SsimSort"
6
6
  s.description = "Sort images easily by their similarity"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ssimsort
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Galaad Gauthier