Skip to content

Commit

Permalink
Some fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Samir55 committed Dec 12, 2017
1 parent eea106a commit dc0e4bf
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 14 additions & 0 deletions src/LineSegmentation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,20 @@ Chunk::find_peaks_valleys(map<int, Valley *> &map_valley) {
}
}

int peaks_average_values = 0;
vector<Peak> 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(
Expand Down
2 changes: 1 addition & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
@@ -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<cv::Mat> lines = line_segmentation.segment();
// ToDo @Samir55 Remove.
Expand Down

0 comments on commit dc0e4bf

Please sign in to comment.