Class: NonStructuralFeature::Map
- Inherits:
-
Object
- Object
- NonStructuralFeature::Map
- Defined in:
- lib/kvg_character_recognition/non_structural_feature.rb
Overview
This class can be used for storing heatmap count and directional feature densities basically it is a nxm matrix with an initial value in each cell
Instance Attribute Summary collapse
-
#initial_value ⇒ Object
Returns the value of attribute initial_value.
Instance Method Summary collapse
-
#[](i, j) ⇒ Object
Access value in the cell of i-th row and j-th column e.g.
-
#[]=(i, j, value) ⇒ Object
Store value in the cell of i-th row and j-th column e.g.
-
#initialize(n, m, initial_value) ⇒ Map
constructor
- Make a new map with Params:
n - row length
m - column length
initial_value -
for heatmap initial_value = 0 and for directional feature densities initial_value = [0, 0, 0, 0] <= [weight in e1, weight in e2, …].
- column length
- row length
- Make a new map with Params:
-
#size ⇒ Object
Normaly n is the same as m.
- #to_a ⇒ Object
Constructor Details
#initialize(n, m, initial_value) ⇒ Map
Make a new map with Params:
n-
row length
m-
column length
initial_value-
for heatmap initial_value = 0 and for directional feature densities initial_value = [0, 0, 0, 0] <= [weight in e1, weight in e2, …]
11 12 13 14 15 16 |
# File 'lib/kvg_character_recognition/non_structural_feature.rb', line 11 def initialize n, m, initial_value @array = Array.new(n * m, initial_value) @n = n @m = m @initial_value = initial_value end |
Instance Attribute Details
#initial_value ⇒ Object
Returns the value of attribute initial_value.
5 6 7 |
# File 'lib/kvg_character_recognition/non_structural_feature.rb', line 5 def initial_value @initial_value end |
Instance Method Details
#[](i, j) ⇒ Object
Access value in the cell of i-th row and j-th column e.g. map
20 21 22 |
# File 'lib/kvg_character_recognition/non_structural_feature.rb', line 20 def [](i, j) @array[j*@n + i] end |
#[]=(i, j, value) ⇒ Object
Store value in the cell of i-th row and j-th column e.g. map = value
26 27 28 |
# File 'lib/kvg_character_recognition/non_structural_feature.rb', line 26 def []=(i, j, value) @array[j*@n + i] = value end |
#size ⇒ Object
Normaly n is the same as m
35 36 37 |
# File 'lib/kvg_character_recognition/non_structural_feature.rb', line 35 def size @n end |
#to_a ⇒ Object
30 31 32 |
# File 'lib/kvg_character_recognition/non_structural_feature.rb', line 30 def to_a @array end |