Class: Gauguin::NoiseReducer

Inherits:
Object
  • Object
show all
Defined in:
lib/gauguin/noise_reducer.rb

Instance Method Summary collapse

Instance Method Details

#call(colors_clusters) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/gauguin/noise_reducer.rb', line 3

def call(colors_clusters)
  pivots = colors_clusters.keys.sort_by! { |key, group| key.percentage }.reverse

  percentage_sum = 0
  index = 0
  pivots.each do |color|
    percentage_sum += color.percentage
    break if percentage_sum > Gauguin.configuration.min_percentage_sum
    index += 1
  end

  reduced_clusters(colors_clusters, pivots, index)
end