sqed 0.6.0 → 0.7.0

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
  SHA256:
3
- metadata.gz: ff31f97d4d846b9112badb1fad358118d858e028cb2835050f49ca767dbfdfba
4
- data.tar.gz: 36d2dadf1291dff04b60d596b239cbbf484cf4c180182b694b103b244f8bba15
3
+ metadata.gz: bc1ae71edf574734410eb4f86efc79658fe01e416e6a8a2082a077107c9f982c
4
+ data.tar.gz: 81264b5a221c5dfdd0a2485a89dcc31962225d99de1541968a999bb10fb92e17
5
5
  SHA512:
6
- metadata.gz: 51724aa1c870b25bcfa88bb8d7954a72226e9080f64cc83e41a8263940ccf61c46d72242887b4c42adeb5f96ef3b12bf88b3c2ebdd816b0128f6839febf34ca5
7
- data.tar.gz: b6f5201476f18b8ba5ad9444f6ac63f8b9d86ff1eb0a089da55521566cf3a8b57a25a5b70eb0478b8121582c5c88b34dab05cab45630b339a8649ed23855b015
6
+ metadata.gz: a87471a1a81d33c3c56b6e996578f0de936a78e983b8eaac5c03b68a2e806adbb11a1e846deff3a8d8b7b101c1845f04f7c42fb9cd9ba323e61e172ae5ab655e
7
+ data.tar.gz: 65f21307aec7b020c7c2bb27df4aeb8802724ad16e9b18fcc87afab864a102df14e0b345ca92a97a7909507f4a1e2fb6453593acf1e81f42a8731807f8b4dd98
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.7.1
1
+ 3.0.2
data/.travis.yml CHANGED
@@ -3,7 +3,7 @@
3
3
  language: ruby
4
4
  dist: bionic
5
5
  rvm:
6
- - 2.6.3
6
+ - 2.7.1
7
7
  #before_install:
8
8
  # - sudo add-apt-repository -y ppa:moti-p/cc
9
9
  # - sudo apt-get update
@@ -16,7 +16,7 @@ before_install:
16
16
  - identify -list resource | grep Disk | grep 8GiB # Check ImageMagick setting is actually working.
17
17
  branches:
18
18
  only:
19
- - master
19
+ - main
20
20
  notifications:
21
21
  email:
22
22
  - diapriid@gmail.com
@@ -37,7 +37,7 @@ class Sqed::BoundaryFinder::ColorLineFinder < Sqed::BoundaryFinder
37
37
  # see config/sqed_config.rb
38
38
  case layout
39
39
 
40
- when :cross # 4 zones, with perfectly intersected horizontal and vertical division
40
+ when :cross # 4 windows, with perfectly intersected horizontal and vertical division
41
41
  v = self.class.new(image: @image, layout: :vertical_split, boundary_color: boundary_color, use_thumbnail: false ).boundaries
42
42
  h = self.class.new(image: @image, layout: :horizontal_split, boundary_color: boundary_color, use_thumbnail: false).boundaries
43
43
 
@@ -171,6 +171,26 @@ class Sqed::BoundaryFinder::ColorLineFinder < Sqed::BoundaryFinder
171
171
  bottom_right_left_top_bottom_split[0],
172
172
  ])
173
173
 
174
+ when :t
175
+ horizontal = self.class.new(image: @image, layout: :horizontal_split, boundary_color: boundary_color, use_thumbnail: false ).boundaries
176
+
177
+ bottom = image.crop(*horizontal.for(1), true)
178
+ btm_split = self.class.new(image: bottom, layout: :vertical_split, boundary_color: boundary_color, use_thumbnail: false ).boundaries
179
+
180
+ boundaries.set(0, horizontal.for(0))
181
+ boundaries.set(1, [ btm_split.x_for(1), horizontal.height_for(0), btm_split.width_for(1), btm_split.height_for(1) ] )
182
+ boundaries.set(2, [ 0, horizontal.height_for(0), btm_split.width_for(0), btm_split.height_for(0) ] )
183
+
184
+ when :inverted_t
185
+ horizontal = self.class.new(image: @image, layout: :horizontal_split, boundary_color: boundary_color, use_thumbnail: false ).boundaries
186
+
187
+ top = image.crop(*horizontal.for(0), true)
188
+ top_split = self.class.new(image: top, layout: :vertical_split, boundary_color: boundary_color, use_thumbnail: false ).boundaries
189
+
190
+ boundaries.set(0, [ 0,0, top_split.width_for(0), top_split.height_for(0)] )
191
+ boundaries.set(1, [ top_split.width_for(0), 0, top_split.width_for(1), top_split.height_for(1)] )
192
+ boundaries.set(2, horizontal.for(1))
193
+
174
194
  when :right_t
175
195
  vertical = self.class.new(image: @image, layout: :vertical_split, boundary_color: boundary_color, use_thumbnail: false ).boundaries
176
196
 
data/lib/sqed/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class Sqed
2
- VERSION = '0.6.0'.freeze
2
+ VERSION = '0.7.0'.freeze
3
3
  end
data/lib/sqed_config.rb CHANGED
@@ -46,7 +46,7 @@ module SqedConfig
46
46
  #
47
47
  # 0 | 1 | 2
48
48
  # --------------
49
- # | 5 | :lep_stage2
49
+ # | 5 | :lep_stage2
50
50
  # 6 |---- 3
51
51
  # | 4 |
52
52
  #
@@ -74,12 +74,24 @@ module SqedConfig
74
74
  # |
75
75
  #
76
76
  # -----
77
- # | 0 | :internal_box
77
+ # | 0 | :internal_box
78
78
  # -----
79
79
  #
80
+ # 0 | 1 :inverted_t
81
+ # -----
82
+ # 2
83
+ #
84
+ # 0 :t
85
+ # -----
86
+ # 2 | 1
87
+ #
88
+ #
89
+ #
80
90
  # Hash values are used to stub out
81
91
  # the Sqed::Boundaries instance.
82
92
  LAYOUTS = {
93
+ t: [0,1,2],
94
+ inverted_t: [0, 1, 2],
83
95
  cross: [0, 1, 2, 3],
84
96
  horizontal_offset_cross: [0, 1, 2, 3],
85
97
  horizontal_split: [0, 1],
@@ -123,6 +135,18 @@ module SqedConfig
123
135
  }.freeze
124
136
 
125
137
  EXTRACTION_PATTERNS = {
138
+ t: {
139
+ boundary_finder: Sqed::BoundaryFinder::ColorLineFinder,
140
+ layout: :t,
141
+ metadata_map: { 0 => :annotated_specimen, 1 => :identifier, 2 => :image_registration }
142
+ },
143
+
144
+ inverted_t: {
145
+ boundary_finder: Sqed::BoundaryFinder::ColorLineFinder,
146
+ layout: :inverted_t,
147
+ metadata_map: { 0 => :identifier, 1 => :image_registration, 2 => :annotated_specimen }
148
+ },
149
+
126
150
  cross: {
127
151
  boundary_finder: Sqed::BoundaryFinder::ColorLineFinder,
128
152
  layout: :cross,
@@ -7,13 +7,11 @@ describe SqedConfig do
7
7
  end
8
8
 
9
9
  specify 'layouts' do
10
- expect(SqedConfig.metadata[:layouts].keys).to contain_exactly(:cross, :horizontal_offset_cross, :horizontal_split, :lep_stage, :lep_stage2, :right_t, :seven_slot, :vertical_offset_cross, :vertical_split)
10
+ expect(SqedConfig.metadata[:layouts].keys).to contain_exactly(:t, :inverted_t, :cross, :horizontal_offset_cross, :horizontal_split, :lep_stage, :lep_stage2, :right_t, :seven_slot, :vertical_offset_cross, :vertical_split)
11
11
  end
12
12
 
13
13
  specify 'layouts are in patterns' do
14
- expect(SqedConfig.metadata[:layouts].keys + [:stage]).to contain_exactly(*SqedConfig::EXTRACTION_PATTERNS.keys)
14
+ expect(SqedConfig.metadata[:layouts].keys + [:stage]).to contain_exactly(*SqedConfig::EXTRACTION_PATTERNS.keys)
15
15
  end
16
16
 
17
-
18
-
19
17
  end
@@ -0,0 +1,61 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'handling inverted T stage images' do
4
+
5
+ let(:image) { ImageHelpers.inverted_t_stage }
6
+ let(:sqed) do
7
+ Sqed.new(
8
+ image: image,
9
+ pattern: :inverted_t,
10
+ boundary_color: :red,
11
+ has_border: false )
12
+ end
13
+
14
+ let(:m) do
15
+ { 0 => 'identifier',
16
+ 1 => 'image_registration',
17
+ 2 => 'annotated_specimen',
18
+ }
19
+ end
20
+
21
+ context 'simple boundaries - without thumbnail' do
22
+ let(:s) { Sqed.new(
23
+ image: image, metadata_map: m, use_thumbnail: false,
24
+ layout: :inverted_t,
25
+ boundary_finder: Sqed::BoundaryFinder::ColorLineFinder,
26
+ boundary_color: :red,
27
+ has_border: false ) }
28
+
29
+ specify 'boundaries are reasonable' do
30
+ s.result
31
+ c = s.boundaries.coordinates
32
+ c.each do |section, values|
33
+ c[section].each_with_index do |v, i|
34
+ msg = "section #{section}, index #{i} has a bad value '#{v}'"
35
+ expect(v > -1).to be_truthy, msg
36
+ end
37
+ end
38
+ end
39
+ end
40
+
41
+ context 'boundaries - with_thumbnail' do
42
+ let(:s) { Sqed.new(
43
+ image: image,
44
+ use_thumbnail: true,
45
+ pattern: :inverted_t,
46
+ boundary_color: :red,
47
+ has_border: false ) }
48
+
49
+ specify 'boundaries are reasonable' do
50
+ s.result
51
+ # s.result.write_images
52
+ c = s.boundaries.coordinates
53
+ c.each do |section, values|
54
+ c[section].each_with_index do |v, i|
55
+ msg = "section #{section}, index #{i} has a bad value '#{v}'"
56
+ expect(v > -1).to be_truthy, msg
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,61 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'handling T stage images' do
4
+
5
+ let(:image) { ImageHelpers.t_stage }
6
+ let(:sqed) do
7
+ Sqed.new(
8
+ image: image,
9
+ pattern: :t,
10
+ boundary_color: :red,
11
+ has_border: false )
12
+ end
13
+
14
+ let(:m) do
15
+ { 0 => 'annotated_specimen',
16
+ 1 => 'identifier',
17
+ 2 => 'image_registration'
18
+ }
19
+ end
20
+
21
+ context 'simple boundaries - without thumbnail' do
22
+ let(:s) { Sqed.new(
23
+ image: image, metadata_map: m, use_thumbnail: false,
24
+ layout: :t,
25
+ boundary_finder: Sqed::BoundaryFinder::ColorLineFinder,
26
+ boundary_color: :red,
27
+ has_border: false ) }
28
+
29
+ specify 'boundaries are reasonable' do
30
+ s.result
31
+ c = s.boundaries.coordinates
32
+ c.each do |section, values|
33
+ c[section].each_with_index do |v, i|
34
+ msg = "section #{section}, index #{i} has a bad value '#{v}'"
35
+ expect(v > -1).to be_truthy, msg
36
+ end
37
+ end
38
+ end
39
+ end
40
+
41
+ context 'boundaries - with_thumbnail' do
42
+ let(:s) { Sqed.new(
43
+ image: image,
44
+ use_thumbnail: true,
45
+ pattern: :t,
46
+ boundary_color: :red,
47
+ has_border: false ) }
48
+
49
+ specify 'boundaries are reasonable' do
50
+ s.result
51
+ c = s.boundaries.coordinates
52
+ c.each do |section, values|
53
+ c[section].each_with_index do |v, i|
54
+ msg = "section #{section}, index #{i} has a bad value '#{v}'"
55
+ expect(v > -1).to be_truthy, msg
56
+ end
57
+ end
58
+ end
59
+ end
60
+
61
+ end
@@ -9,12 +9,21 @@ module ImageHelpers
9
9
  end
10
10
 
11
11
  def of_size(width = 1024, height = 768)
12
- Magick::Image.new(width, height) {
13
- self.background_color = 'white'
12
+ Magick::Image.new(width, height) { |i|
13
+ i.background_color = 'white'
14
14
  }
15
15
  end
16
16
 
17
- # Stage images
17
+ # Stage images
18
+
19
+ def t_stage
20
+ get_image 'stage_images/t_stage.png'
21
+ end
22
+
23
+ def inverted_t_stage
24
+ get_image 'stage_images/inverted_t_stage.png'
25
+ end
26
+
18
27
  def cross_green
19
28
  get_image 'stage_images/boundary_cross_green.jpg'
20
29
  end
@@ -51,6 +60,10 @@ module ImageHelpers
51
60
  get_image 'stage_images/lep_stage2.jpg'
52
61
  end
53
62
 
63
+ def lep_stage3
64
+ get_image 'stage_images/lep_stage3.jpg'
65
+ end
66
+
54
67
  def crossy_green_line_specimen
55
68
  get_image 'stage_images/CrossyGreenLinesSpecimen.jpg'
56
69
  end
@@ -97,7 +110,7 @@ module ImageHelpers
97
110
  get_image 'barcode_images/osuc_datamatric_barcode.png'
98
111
  end
99
112
 
100
- # label (text) images
113
+ # label (text) images
101
114
 
102
115
  # NOT USED
103
116
  def black_stage_green_line_specimen_label
@@ -118,7 +131,7 @@ module ImageHelpers
118
131
 
119
132
  # Real life, black border, no internal boundaries
120
133
  def test3_image
121
- get_image 'test3.jpg'
134
+ get_image 'test3.jpg'
122
135
  end
123
136
 
124
137
  def foo3_image
data/sqed.gemspec CHANGED
@@ -19,15 +19,15 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ["lib"]
20
20
 
21
21
  spec.add_dependency 'rake', '~> 13.0'
22
- spec.add_dependency 'rmagick', '~> 4.1'
22
+ spec.add_dependency 'rmagick', '~> 4.2'
23
23
  spec.add_dependency 'rtesseract', '~> 3.1'
24
24
 
25
25
  # A qrcode reader, too many problems with compiling, dependencies
26
26
  # spec.add_dependency 'zxing_cpp', '~> 0.1.0'
27
27
 
28
- spec.add_development_dependency 'rspec', '~> 3.9'
28
+ spec.add_development_dependency 'rspec', '~> 3.11'
29
29
  spec.add_development_dependency 'bundler', '~> 2.0'
30
30
  spec.add_development_dependency 'byebug', '~> 11.0'
31
- spec.add_development_dependency 'amazing_print', '~> 1.2.1'
31
+ spec.add_development_dependency 'amazing_print', '~> 1.4'
32
32
  end
33
33
 
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sqed
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Yoder
8
8
  - Rich Flood
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-08-05 00:00:00.000000000 Z
12
+ date: 2022-05-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -31,14 +31,14 @@ dependencies:
31
31
  requirements:
32
32
  - - "~>"
33
33
  - !ruby/object:Gem::Version
34
- version: '4.1'
34
+ version: '4.2'
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
39
  - - "~>"
40
40
  - !ruby/object:Gem::Version
41
- version: '4.1'
41
+ version: '4.2'
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: rtesseract
44
44
  requirement: !ruby/object:Gem::Requirement
@@ -59,14 +59,14 @@ dependencies:
59
59
  requirements:
60
60
  - - "~>"
61
61
  - !ruby/object:Gem::Version
62
- version: '3.9'
62
+ version: '3.11'
63
63
  type: :development
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
67
  - - "~>"
68
68
  - !ruby/object:Gem::Version
69
- version: '3.9'
69
+ version: '3.11'
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: bundler
72
72
  requirement: !ruby/object:Gem::Requirement
@@ -101,14 +101,14 @@ dependencies:
101
101
  requirements:
102
102
  - - "~>"
103
103
  - !ruby/object:Gem::Version
104
- version: 1.2.1
104
+ version: '1.4'
105
105
  type: :development
106
106
  prerelease: false
107
107
  version_requirements: !ruby/object:Gem::Requirement
108
108
  requirements:
109
109
  - - "~>"
110
110
  - !ruby/object:Gem::Version
111
- version: 1.2.1
111
+ version: '1.4'
112
112
  description: A utility gem to aid in the processing of images taken in the process
113
113
  of digitizing natural history collections.
114
114
  email:
@@ -155,9 +155,11 @@ files:
155
155
  - spec/lib/sqed_spec.rb
156
156
  - spec/lib/sqed_utils_spec.rb
157
157
  - spec/lib/stage_handling/horizontal_offset_cross_spec.rb
158
+ - spec/lib/stage_handling/inverted_t_stage_spec.rb
158
159
  - spec/lib/stage_handling/lep_stage2_spec.rb
159
160
  - spec/lib/stage_handling/lep_stage_spec.rb
160
161
  - spec/lib/stage_handling/seven_slot_spec.rb
162
+ - spec/lib/stage_handling/t_stage_spec.rb
161
163
  - spec/spec_helper.rb
162
164
  - spec/support/files/barcode_images/code_128_barcode.png
163
165
  - spec/support/files/barcode_images/datamatrix_barcode.png
@@ -185,8 +187,11 @@ files:
185
187
  - spec/support/files/stage_images/inhs_7_slot2.jpg
186
188
  - spec/support/files/stage_images/inhs_7_slot3.jpg
187
189
  - spec/support/files/stage_images/inhs_four_thirds.jpg
190
+ - spec/support/files/stage_images/inverted_t_stage.png
188
191
  - spec/support/files/stage_images/lep_stage.jpg
189
192
  - spec/support/files/stage_images/lep_stage2.jpg
193
+ - spec/support/files/stage_images/lep_stage3.jpg
194
+ - spec/support/files/stage_images/t_stage.png
190
195
  - spec/support/files/test0.jpg
191
196
  - spec/support/files/test1.jpg
192
197
  - spec/support/files/test2.jpg
@@ -199,7 +204,7 @@ homepage: http://github.com/SpeciesFileGroup/sqed
199
204
  licenses:
200
205
  - NCSA
201
206
  metadata: {}
202
- post_install_message:
207
+ post_install_message:
203
208
  rdoc_options: []
204
209
  require_paths:
205
210
  - lib
@@ -214,8 +219,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
214
219
  - !ruby/object:Gem::Version
215
220
  version: '0'
216
221
  requirements: []
217
- rubygems_version: 3.1.2
218
- signing_key:
222
+ rubygems_version: 3.2.22
223
+ signing_key:
219
224
  specification_version: 4
220
225
  summary: Specimens Quickly extracted and Digitized, or just "squid". A ruby gem for
221
226
  image based specimen accessioning.
@@ -234,9 +239,11 @@ test_files:
234
239
  - spec/lib/sqed_spec.rb
235
240
  - spec/lib/sqed_utils_spec.rb
236
241
  - spec/lib/stage_handling/horizontal_offset_cross_spec.rb
242
+ - spec/lib/stage_handling/inverted_t_stage_spec.rb
237
243
  - spec/lib/stage_handling/lep_stage2_spec.rb
238
244
  - spec/lib/stage_handling/lep_stage_spec.rb
239
245
  - spec/lib/stage_handling/seven_slot_spec.rb
246
+ - spec/lib/stage_handling/t_stage_spec.rb
240
247
  - spec/spec_helper.rb
241
248
  - spec/support/files/barcode_images/code_128_barcode.png
242
249
  - spec/support/files/barcode_images/datamatrix_barcode.png
@@ -264,8 +271,11 @@ test_files:
264
271
  - spec/support/files/stage_images/inhs_7_slot2.jpg
265
272
  - spec/support/files/stage_images/inhs_7_slot3.jpg
266
273
  - spec/support/files/stage_images/inhs_four_thirds.jpg
274
+ - spec/support/files/stage_images/inverted_t_stage.png
267
275
  - spec/support/files/stage_images/lep_stage.jpg
268
276
  - spec/support/files/stage_images/lep_stage2.jpg
277
+ - spec/support/files/stage_images/lep_stage3.jpg
278
+ - spec/support/files/stage_images/t_stage.png
269
279
  - spec/support/files/test0.jpg
270
280
  - spec/support/files/test1.jpg
271
281
  - spec/support/files/test2.jpg