module DatasetsGdkPixbuf::CIFARPixbufable

Public Instance Methods

to_gdk_pixbuf() click to toggle source
# File lib/datasets-gdk-pixbuf/cifar.rb, line 5
def to_gdk_pixbuf
  n_channels = 3
  width = 32
  height = 32
  color_size = width * height
  rgb_data = pixels.each_slice(color_size).to_a.transpose.flatten
  rgb_data = rgb_data.pack("C*")
  GdkPixbuf::Pixbuf.new(:data => rgb_data,
                        :row_stride => width * n_channels,
                        :width => width,
                        :height => height)
end