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 +4 -4
- data/bin/ssimsort +5 -4
- data/lib/ssimsort.rb +13 -6
- data/ssimsort.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 56e74c120dfb6ade8bf5451397f96e45dd8b19e4
|
4
|
+
data.tar.gz: 4b63e87ae981190ed13d16d6001c0a8433edeae2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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 "-
|
8
|
-
when "-
|
9
|
-
when "-
|
10
|
-
when "-
|
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
|
-
|
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