sqed 0.1.8 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sqed/boundary_finder.rb +30 -3
- data/lib/sqed/boundary_finder/color_line_finder.rb +6 -6
- data/lib/sqed/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e5f4d8affdf54fbd1921fd0d0ab561017a8f4afc
|
4
|
+
data.tar.gz: 1faccf4ba6649eaceb6a4c4aadc0a4eb21efb574
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1cd78f97cf39d56ddbee8ef065e7a2cc8a5fe4ca6cd318e966cb1e50afc9a3b24291361216de4223a946e8e5fef3ea379fd8675c3aae69f1aa969b7e6975e6d4
|
7
|
+
data.tar.gz: 7f7b7f8d30d060f889080733e49dce6d34af01e190cf6ab33e21955f01d0dd55ac31f6f365bb2888ff8a732db41ba3d44fb0a3260fae9b9f86e36b57ea3f5c3c
|
data/lib/sqed/boundary_finder.rb
CHANGED
@@ -4,6 +4,7 @@
|
|
4
4
|
class Sqed::BoundaryFinder
|
5
5
|
|
6
6
|
THUMB_SIZE = 100
|
7
|
+
COLOR_DELTA = 1.3 # color (e.g. red) must be this much be *COLOR_DELTA > than other values (e.g. blue/green)
|
7
8
|
|
8
9
|
# the passed image
|
9
10
|
attr_reader :img
|
@@ -161,15 +162,15 @@ class Sqed::BoundaryFinder
|
|
161
162
|
end
|
162
163
|
|
163
164
|
def self.is_green?(pixel)
|
164
|
-
(pixel.green > pixel.red*
|
165
|
+
(pixel.green > pixel.red*COLOR_DELTA) && (pixel.green > pixel.blue*COLOR_DELTA)
|
165
166
|
end
|
166
167
|
|
167
168
|
def self.is_blue?(pixel)
|
168
|
-
(pixel.blue > pixel.red*
|
169
|
+
(pixel.blue > pixel.red*COLOR_DELTA) && (pixel.blue > pixel.green*COLOR_DELTA)
|
169
170
|
end
|
170
171
|
|
171
172
|
def self.is_red?(pixel)
|
172
|
-
(pixel.red > pixel.blue*
|
173
|
+
(pixel.red > pixel.blue*COLOR_DELTA) && (pixel.red > pixel.green*COLOR_DELTA)
|
173
174
|
end
|
174
175
|
|
175
176
|
def self.is_black?(pixel)
|
@@ -210,6 +211,32 @@ class Sqed::BoundaryFinder
|
|
210
211
|
[hit_ranges.first, hit_ranges[(hit_ranges.length / 2).to_i], hit_ranges.last]
|
211
212
|
end
|
212
213
|
|
214
|
+
# @return [Array]
|
215
|
+
# like [0,1,2]
|
216
|
+
# If median-min or max-median * width_factor are different from one another (by more than width_factor) then replace the larger wth the median +/- 1/2 the smaller
|
217
|
+
# Given [10, 12, 20] and width_factor 2 the result will be [10, 12, 13]
|
218
|
+
#
|
219
|
+
def corrected_frequency(frequency_stats, width_factor = 3.0 )
|
220
|
+
v0 = frequency_stats[0]
|
221
|
+
m = frequency_stats[1]
|
222
|
+
v2 = frequency_stats[2]
|
223
|
+
|
224
|
+
a = m - v0
|
225
|
+
b = v2 - m
|
226
|
+
|
227
|
+
largest = (a > b ? a : b)
|
228
|
+
|
229
|
+
if a * width_factor > largest
|
230
|
+
[(m - (v2 - m)/2).to_i, m, v2]
|
231
|
+
elsif b * width_factor > largest
|
232
|
+
[ v0, m, (m + (m - v0)/2).to_i ]
|
233
|
+
else
|
234
|
+
frequency_stats
|
235
|
+
end
|
236
|
+
end
|
237
|
+
|
238
|
+
|
239
|
+
|
213
240
|
# Returns an Integer, the maximum of the pairwise differences of the values in the array
|
214
241
|
# For example, given
|
215
242
|
# [1,2,3,9,6,2,0]
|
@@ -32,17 +32,17 @@ class Sqed::BoundaryFinder::ColorLineFinder < Sqed::BoundaryFinder
|
|
32
32
|
right_top_img = img.crop( left_right_split[2], 0, img.columns - left_right_split[2], top_bottom_split[0] , true) # sections 1,2
|
33
33
|
right_bottom_img = img.crop(left_right_split[2], top_bottom_split[2], img.columns - left_right_split[2], img.rows - top_bottom_split[2], true) # sections 3,4,5
|
34
34
|
|
35
|
-
right_top_split = Sqed::BoundaryFinder.color_boundary_finder(image: right_top_img, boundary_color: @boundary_color) # vertical line b/w 1 & 2
|
36
|
-
|
37
|
-
boundaries.set(1, [left_right_split[2], 0,
|
35
|
+
right_top_split = corrected_frequency(Sqed::BoundaryFinder.color_boundary_finder(image: right_top_img, boundary_color: @boundary_color)) # vertical line b/w 1 & 2, use "corrected_frequency" to account for color bleed from previous crop
|
36
|
+
|
37
|
+
boundaries.set(1, [left_right_split[2], 0, right_top_split[0], top_bottom_split[0] ])
|
38
38
|
boundaries.set(2, [left_right_split[2] + right_top_split[2], 0, right_top_img.columns - right_top_split[2], top_bottom_split[0] ] )
|
39
39
|
|
40
|
-
right_bottom_split = Sqed::BoundaryFinder.color_boundary_finder(image: right_bottom_img, scan: :columns, sample_subdivision_size: 2, boundary_color: @boundary_color) # horizontal line b/w (5,3) & 4
|
40
|
+
right_bottom_split = corrected_frequency(Sqed::BoundaryFinder.color_boundary_finder(image: right_bottom_img, scan: :columns, sample_subdivision_size: 2, boundary_color: @boundary_color)) # horizontal line b/w (5,3) & 4, use "corrected_frequency" to account for color bleed from previous crop
|
41
41
|
|
42
|
-
bottom_right_top_img = right_bottom_img.crop(0,0, img.columns - left_right_split[2], right_bottom_split[
|
42
|
+
bottom_right_top_img = right_bottom_img.crop(0,0, img.columns - left_right_split[2], right_bottom_split[2], true) # 3,5
|
43
43
|
|
44
44
|
boundaries.set(3, [ left_right_split[2] + right_top_split[2], top_bottom_split[2], left_right_split[2] + right_top_split[2], bottom_right_top_img.rows ] )
|
45
|
-
boundaries.set(5, [ left_right_split[2], top_bottom_split[2],
|
45
|
+
boundaries.set(5, [ left_right_split[2], top_bottom_split[2], right_top_split[0], bottom_right_top_img.rows ] )
|
46
46
|
|
47
47
|
boundaries.set(4, [ left_right_split[2], top_bottom_split[2] + right_top_split[2], img.columns - left_right_split[2], right_bottom_img.rows - right_top_split[2] ] )
|
48
48
|
|
data/lib/sqed/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sqed
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Yoder
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-12-
|
12
|
+
date: 2015-12-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|