diff --git a/src/LineSegmentation.cpp b/src/LineSegmentation.cpp index cdf2a35..3f2edca 100755 --- a/src/LineSegmentation.cpp +++ b/src/LineSegmentation.cpp @@ -441,6 +441,20 @@ Chunk::find_peaks_valleys(map &map_valley) { } } + int peaks_average_values = 0; + vector new_peaks; + for (auto peak : peaks) { + peaks_average_values += peak.value; + } + peaks_average_values /= max(1, int(peaks.size())); + + for (auto peak : peaks) { + if (peak.value >= peaks_average_values/4) { + new_peaks.push_back(peak); + } + } + lines_count = int (new_peaks.size()); + peaks = new_peaks; // Sort peaks by max value and remove the outliers (the ones with less foreground pixels). sort(peaks.begin(), peaks.end()); peaks.resize( diff --git a/src/main.cpp b/src/main.cpp index d2722a6..8e23470 100755 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,7 +1,7 @@ #include "LineSegmentation.hpp" int main() { - string img_path = "../img/2min.png"; + string img_path = "../img/AA.jpg"; LineSegmentation line_segmentation(img_path); vector lines = line_segmentation.segment(); // ToDo @Samir55 Remove.