lib/sqed/boundary_finder.rb in sqed-0.4.1 vs lib/sqed/boundary_finder.rb in sqed-0.4.2

- old
+ new

@@ -117,12 +117,13 @@ # - when nil the cutoff defaults to the maximum of the pairwise difference between hit counts # # @param scan # (:rows|:columns), :rows finds vertical borders, :columns finds horizontal borders # + # + # image: image, sample_subdivision_size: nil, sample_cutoff_factor: nil, scan: :rows, boundary_color: :green) def self.color_boundary_finder(**opts) - # image: image, sample_subdivision_size: nil, sample_cutoff_factor: nil, scan: :rows, boundary_color: :green) image = opts[:image] sample_subdivision_size = opts[:sample_subdivision_size] sample_cutoff_factor = opts[:sample_cutoff_factor] scan = opts[:scan] || :rows boundary_color = opts[:boundary_color] || :green @@ -220,57 +221,9 @@ # return the position exactly in the middle of the array [hit_ranges.first, hit_ranges[(hit_ranges.length / 2).to_i], hit_ranges.last] end - # @return [Array] - # like `[0,1,2]` - # If median-min or max-median * width_factor are different from one another (by more than width_factor) then replace the larger wth the median +/- 1/2 the smaller - # Given [10, 12, 20] and width_factor 2 the result will be [10, 12, 13] - # - def corrected_frequency(frequency_stats, width_factor = 3.0, max_width = nil) - v0 = frequency_stats[0] - m = frequency_stats[1] - v2 = frequency_stats[2] - - width_pct = nil - - # If the width of the detected line is > 5 percent then - # assume the center is good measure, and use an arbitrary percentage width. - if !max_width.nil? - width_pct = (v2 - v0).to_f / max_width.to_f - end - - if !width_pct.nil? && width_pct >= 0.05 - half_width = max_width * 0.025 - z = [m - half_width, m, m + half_width] - return z - end - - # a = m - v0 - # b = v2 - m - - # largest = (a > b ? a : b) - - # c = a * width_factor - # d = b * width_factor - - # if c > largest || d > largest - # e = c > largest ? ((m - b) / 2).to_i : v0 - # f = d > largest ? ((m + a) / 2).to_i : v2 - # [e, m, f] - # else - # frequency_stats - # end - - if a * width_factor > largest - [(m - (v2 - m) / 2).to_i, m, v2] - elsif b * width_factor > largest - [v0, m, (m + (m - v0) / 2).to_i] - else - frequency_stats - end - end # Returns an Integer, the maximum of the pairwise differences of the values in the array # For example, given # [1,2,3,9,6,2,0] # The resulting pairwise array is