class Rbmnist::ImageWrapper
Constants
- HEIGHT
- WIDTH
Attributes
data[R]
Public Class Methods
new(data)
click to toggle source
# File lib/rbmnist/image_wrapper.rb, line 8 def initialize(data) @data = data end
Public Instance Methods
[](arg)
click to toggle source
# File lib/rbmnist/image_wrapper.rb, line 20 def [](arg) @data[arg] end
[]=(val, newval)
click to toggle source
# File lib/rbmnist/image_wrapper.rb, line 24 def []=(val, newval) @data[val] = newval end
each(&block)
click to toggle source
# File lib/rbmnist/image_wrapper.rb, line 28 def each(&block) @data.each(&block) end
map(&block)
click to toggle source
# File lib/rbmnist/image_wrapper.rb, line 32 def map(&block) @data.map(&block) end
pixels()
click to toggle source
# File lib/rbmnist/image_wrapper.rb, line 12 def pixels @data end
to_a()
click to toggle source
# File lib/rbmnist/image_wrapper.rb, line 16 def to_a return data end
to_a_2d()
click to toggle source
# File lib/rbmnist/image_wrapper.rb, line 36 def to_a_2d Array.new(HEIGHT) do |row| rowstart = row * WIDTH rowend = rowstart + WIDTH @data[rowstart...rowend] end end
to_png()
click to toggle source
# File lib/rbmnist/image_wrapper.rb, line 44 def to_png Rbimg::PNG.new(pixels: @data, type: :greyscale, width: WIDTH, height: HEIGHT) end