Skip to content

Commit

Permalink
Some fixes to find_peaks_valleys.
Browse files Browse the repository at this point in the history
  • Loading branch information
Samir55 committed Dec 13, 2017
1 parent 0e47d7e commit f90901f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
10 changes: 5 additions & 5 deletions src/LineSegmentation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -423,14 +423,14 @@ Chunk::find_peaks_valleys(map<int, Valley *> &map_valley) {
this->calculate_histogram();

// Detect Peaks.
for (int i = 1; i < this->histogram.size() - 1; i++) {
int left_val = this->histogram[i - 1], right_val = this->histogram[i], centre_val = this->histogram[i + 1];
if (centre_val > left_val && centre_val > right_val) { // Peak detected.
if (!peaks.empty() && i - peaks.back().position <= avg_height / 2 &&
for (int i = 1; i + 1< this->histogram.size(); i++) {
int left_val = this->histogram[i - 1], centre_val = this->histogram[i], right_val = this->histogram[i+1];
if (centre_val >= left_val && centre_val >= right_val) { // Peak detected.
if (!peaks.empty() && i - peaks.back().position <= avg_height/2 &&
centre_val >= peaks.back().value) { // Try to get the largest peak in same region.
peaks.back().position = i;
peaks.back().value = centre_val;
} else if (peaks.size() > 0 && i - peaks.back().position <= avg_height / 2 &&
} else if (peaks.size() > 0 && i - peaks.back().position <= avg_height/2 &&
centre_val < peaks.back().value) {}
else {
peaks.push_back(Peak(i, centre_val));
Expand Down
5 changes: 3 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#include "LineSegmentation.hpp"

int main() {
string img_path = "../img/RR.jpg";
int main(int argc, char *argv[]) {
cout << argv[1] << endl;
string img_path = argv[1];
LineSegmentation line_segmentation(img_path);
vector<cv::Mat> lines = line_segmentation.segment();
// ToDo @Samir55 Remove.
Expand Down

0 comments on commit f90901f

Please sign in to comment.