Method: RTKIT::Selection.create_from_array
- Defined in:
- lib/rtkit/selection.rb
.create_from_array(indices, bin_image) ⇒ Object
Creates a new Selection instance from an Array (or NArray) of (general) indices. Returns the Selection instance.
Parameters
-
arr– An Array/NArray of general indices (Integers). -
slice– The BinImage instance that this Selection belongs to.
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/rtkit/selection.rb', line 28 def self.create_from_array(indices, bin_image) raise ArgumentError, "Invalid argument 'indices'. Expected Array/NArray, got #{indices.class}." unless [NArray, Array].include?(indices.class) raise ArgumentError, "Invalid argument 'bin_image'. Expected BinImage, got #{bin_image.class}." unless bin_image.is_a?(BinImage) raise ArgumentError, "Invalid argument 'indices'. Expected Array to contain only integers, got #{indices.collect{|i| i.class}.uniq}." if indices.is_a?(Array) and not indices.collect{|i| i.class}.uniq == [Fixnum] # Create the Selection: s = self.new(bin_image) # Set the indices: s.add_indices(indices) return s end |