Class: ShatteredMachine::PixelSorter

Inherits:
Object
  • Object
show all
Defined in:
lib/shattered_machine/pixel_sorter.rb

Overview

Sort pixels of a given png image. The logic for the pixel sorter come from the Rusty Engine.

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ PixelSorter

Returns a new instance of PixelSorter.

Parameters:

  • options (Hash) (defaults to: {})

    options for pixel sort algorithm



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/shattered_machine/pixel_sorter.rb', line 10

def initialize(options = {})
  @direction = options[:direction] || :vertical
  @smart_sorting = (options[:smart_sorting] || true).to_s
  @detection_type = options[:detection_type] || :lightness_range
  @detection_min = options[:detection_min] || '45'
  @detection_max = options[:detection_max] || '60'
  @multiple_ranges = (options[:multiple_ranges] || false).to_s
  @detection_min_two = options[:detection_min_two] || '75'
  @detection_max_two = options[:detection_max_two] || '90'
  @sorting_by = options[:sorting_by] || :hue
end

Instance Method Details

#call(input_image, output_image) ⇒ boolean

Returns status of pixel sort.

Parameters:

  • input_image (string)

    path for image

  • output_image (string)

    path for output pixel sorted image

Returns:

  • (boolean)

    status of pixel sort



25
26
27
28
29
# File 'lib/shattered_machine/pixel_sorter.rb', line 25

def call(input_image, output_image)
  RustyEngine.sort(input_image, output_image, rust_formatted_direction, @smart_sorting,
                   rust_formatted_detection_type, @detection_min, @detection_max, @multiple_ranges,
                   @detection_min_two, @detection_max_two, rust_formatted_sorting_by)
end