class Gauguin::NoiseReducer
Public Instance Methods
call(colors_clusters)
click to toggle source
# 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
Private Instance Methods
reduced_clusters(colors_clusters, pivots, cut_off_index)
click to toggle source
# File lib/gauguin/noise_reducer.rb, line 19 def reduced_clusters(colors_clusters, pivots, cut_off_index) reduced_pivots = pivots[0..cut_off_index] colors_clusters.select do |c| !c.transparent? && reduced_pivots.include?(c) end end