Method: RTKIT::BinImage#initialize

Defined in:
lib/rtkit/bin_image.rb

#initialize(narray, image) ⇒ BinImage

Creates a new BinImage instance.

Parameters

  • narray – A binary, two-dimensional NArray.

  • image – The Image instance that this BinImage is associated with.

Raises:

  • (ArgumentError)


53
54
55
56
57
58
59
60
61
# File 'lib/rtkit/bin_image.rb', line 53

def initialize(narray, image)
  raise ArgumentError, "Invalid argument 'narray'. Expected NArray, got #{narray.class}." unless narray.is_a?(NArray)
  raise ArgumentError, "Invalid argument 'image'. Expected Image, got #{image.class}." unless image.is_a?(Image)
  raise ArgumentError, "Invalid argument 'narray'. Expected two-dimensional NArray, got #{narray.shape.length} dimensions." unless narray.shape.length == 2
  raise ArgumentError, "Invalid argument 'narray'. Expected NArray of element size 1 byte, got #{narray.element_size} bytes (per element)." unless narray.element_size == 1
  raise ArgumentError, "Invalid argument 'narray'. Expected binary NArray with max value 1, got #{narray.max} as max." if narray.max > 1
  self.narray = narray
  @image = image
end