sqed 0.4.0 → 0.4.1

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: 97003b6e21e84313180a638df393052b18a7eb25
4
- data.tar.gz: e125134f5ed864b06fd4b8280228261e7d1eac40
3
+ metadata.gz: d47942c64d4e9dfee4eefdb864de8b537aad0166
4
+ data.tar.gz: e6a282b0b85f83615315c291bf2cbf66fe26b15c
5
5
  SHA512:
6
- metadata.gz: cd0e7287ef11ba6fef8784be32c24898784125dde881e2b8082b15d1f19a5995c55e434924057f2bdd8ef27419a51b9e118351f20ebbff594b9a7d7e4f500a6b
7
- data.tar.gz: 2e87fa5f7e6cd1bb0f5db13158e6c5e41e812a547cd2f90f44ce5104de8105d6595a60c86a2794ff5804615a5a5659da51c9daaed5ede8236661d0a85fb39c0b
6
+ metadata.gz: e53e4bbc42260cd2723eaa4ef917a2f8b1c99b8947bb3af3675beeffcee07ad6567c753a601a38b82e0ae86d27e103bd6b06de06d8517d38394b228dc606c64b
7
+ data.tar.gz: 861e69ad4e87e8e7261f3020f4d9aef5c1ce1a2bf3962dae1ac4eef898ac5ddf27f85d3a53c3a448e04bd401305be79c5a014a0f5f9b099ea9f8fb94b1f23261
@@ -2,7 +2,7 @@
2
2
  #bundler_args: --without development
3
3
  language: ruby
4
4
  rvm:
5
- - 2.3.1
5
+ - 2.4.3
6
6
  #before_install:
7
7
  # - sudo add-apt-repository -y ppa:moti-p/cc
8
8
  # - sudo apt-get update
@@ -223,19 +223,44 @@ class Sqed
223
223
  end
224
224
 
225
225
  # @return [Array]
226
- # like [0,1,2]
226
+ # like `[0,1,2]`
227
227
  # 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
228
228
  # Given [10, 12, 20] and width_factor 2 the result will be [10, 12, 13]
229
229
  #
230
- def corrected_frequency(frequency_stats, width_factor = 3.0)
230
+ def corrected_frequency(frequency_stats, width_factor = 3.0, max_width = nil)
231
231
  v0 = frequency_stats[0]
232
232
  m = frequency_stats[1]
233
233
  v2 = frequency_stats[2]
234
234
 
235
- a = m - v0
236
- b = v2 - m
235
+ width_pct = nil
237
236
 
238
- largest = (a > b ? a : b)
237
+ # If the width of the detected line is > 5 percent then
238
+ # assume the center is good measure, and use an arbitrary percentage width.
239
+ if !max_width.nil?
240
+ width_pct = (v2 - v0).to_f / max_width.to_f
241
+ end
242
+
243
+ if !width_pct.nil? && width_pct >= 0.05
244
+ half_width = max_width * 0.025
245
+ z = [m - half_width, m, m + half_width]
246
+ return z
247
+ end
248
+
249
+ # a = m - v0
250
+ # b = v2 - m
251
+
252
+ # largest = (a > b ? a : b)
253
+
254
+ # c = a * width_factor
255
+ # d = b * width_factor
256
+
257
+ # if c > largest || d > largest
258
+ # e = c > largest ? ((m - b) / 2).to_i : v0
259
+ # f = d > largest ? ((m + a) / 2).to_i : v2
260
+ # [e, m, f]
261
+ # else
262
+ # frequency_stats
263
+ # end
239
264
 
240
265
  if a * width_factor > largest
241
266
  [(m - (v2 - m) / 2).to_i, m, v2]
@@ -41,19 +41,18 @@ class Sqed::BoundaryFinder::ColorLineFinder < Sqed::BoundaryFinder
41
41
  right_top_image = image.crop( left_right_split[2], 0, image.columns - left_right_split[2], top_bottom_split[0] , true) # sections 1,2
42
42
  right_bottom_image = image.crop(left_right_split[2], top_bottom_split[2], image.columns - left_right_split[2], image.rows - top_bottom_split[2], true) # sections 3,4,5
43
43
 
44
- right_top_split = corrected_frequency(Sqed::BoundaryFinder.color_boundary_finder(image: right_top_image, boundary_color: boundary_color)) # vertical line b/w 1 & 2, use "corrected_frequency" to account for color bleed from previous crop
44
+ right_top_split = corrected_frequency(Sqed::BoundaryFinder.color_boundary_finder(image: right_top_image, boundary_color: boundary_color), 1.8, right_top_image.columns) # vertical line b/w 1 & 2, use "corrected_frequency" to account for color bleed from previous crop
45
45
 
46
- boundaries.set(1, [left_right_split[2], 0, right_top_split[0], top_bottom_split[0] ])
46
+ boundaries.set(1, [left_right_split[2], 0, right_top_split[0], top_bottom_split[0]] )
47
47
  boundaries.set(2, [left_right_split[2] + right_top_split[2], 0, right_top_image.columns - right_top_split[2], top_bottom_split[0]])
48
48
 
49
- right_bottom_split = corrected_frequency(Sqed::BoundaryFinder.color_boundary_finder(image: right_bottom_image, 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
49
+ right_bottom_split = corrected_frequency(Sqed::BoundaryFinder.color_boundary_finder(image: right_bottom_image, scan: :columns, sample_subdivision_size: 2, boundary_color: boundary_color), 1.8, right_bottom_image.rows) # horizontal line b/w (5,3) & 4, use "corrected_frequency" to account for color bleed from previous crop
50
50
 
51
51
  bottom_right_top_image = right_bottom_image.crop(0,0, image.columns - left_right_split[2], right_bottom_split[0], true) # 3,5
52
52
 
53
- 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_image.rows ])
54
- boundaries.set(5, [ left_right_split[2], top_bottom_split[2], right_top_split[0], bottom_right_top_image.rows])
53
+ 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_image.rows ])
54
+ boundaries.set(5, [left_right_split[2], top_bottom_split[2], right_top_split[0], bottom_right_top_image.rows])
55
55
 
56
- # ! not high enough
57
56
  boundaries.set(4, [left_right_split[2], top_bottom_split[2] + right_bottom_split[2], image.columns - left_right_split[2], right_bottom_image.rows ])
58
57
 
59
58
  when :vertical_split
@@ -1,3 +1,3 @@
1
1
  class Sqed
2
- VERSION = '0.4.0'.freeze
2
+ VERSION = '0.4.1'.freeze
3
3
  end
@@ -36,7 +36,7 @@ describe 'handling 7 slot stages' do
36
36
 
37
37
  specify 'boundaries are reasonable' do
38
38
  s.result
39
- c = s.boundaries.coordinates
39
+ c = s.boundaries.coordinates
40
40
  c.each do |section, values|
41
41
  c[section].each_with_index do |v, i|
42
42
  msg = "section #{section}, index #{i} has a bad value '#{v}'"
@@ -49,9 +49,10 @@ describe 'handling 7 slot stages' do
49
49
  context 'trickier boundaries - with_thumbnail' do
50
50
  let(:s) { Sqed.new(image: ImageHelpers.inhs_stage_7_slot2, use_thumbnail: true, pattern: :seven_slot, boundary_color: :red, has_border: false ) }
51
51
 
52
+
52
53
  specify 'boundaries are reasonable' do
53
54
  s.result
54
- c = s.boundaries.coordinates
55
+ c = s.boundaries.coordinates
55
56
  c.each do |section, values|
56
57
  c[section].each_with_index do |v, i|
57
58
  msg = "section #{section}, index #{i} has a bad value '#{v}'"
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.4.0
4
+ version: 0.4.1
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: 2018-03-21 00:00:00.000000000 Z
12
+ date: 2018-03-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake