From 229aaf8d5d4b8b2b12d866f20b798ceb5b8b64d5 Mon Sep 17 00:00:00 2001 From: Jan Philipp Timme Date: Thu, 7 Jan 2016 18:45:22 +0100 Subject: [PATCH] [TASK] Parametrize threshold for pixel matchin in hough machine. --- hough_machine.cpp | 22 ++++++++++++++++++++-- imageviewer-qt4.cpp | 4 ++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/hough_machine.cpp b/hough_machine.cpp index aed2d7d..0b812fa 100644 --- a/hough_machine.cpp +++ b/hough_machine.cpp @@ -24,6 +24,8 @@ class HoughMachine { int n_rad; double d_rad; int* hough_arr; + + int matching_threshold; public: HoughMachine(LazyImage* original, LazyImage* working_copy) { @@ -47,6 +49,13 @@ class HoughMachine { free(this->hough_arr); this->hough_arr = NULL; } + this->matching_threshold = 0; + }; + + void setMatchingThreshold(int matching_threshold) { + // If negative, pixels greater than the absolute value match. + // If positive, pixels less than the absolute value match. + this->matching_threshold = matching_threshold; }; void run(int a_steps, int r_steps) { @@ -73,8 +82,12 @@ class HoughMachine { QColor pixel = QColor::fromRgb(this->original->getPixel(u, v, LazyImage::DEFAULT)); int h, s, l; pixel.getHsl(&h, &s, &l); - if(l < 15) { // TODO: parameterize this - this->doPixel(u, v); + if(this->matching_threshold > 0) { + int threshold = this->matching_threshold; + if(l < threshold) this->doPixel(u, v); + } else { + int threshold = -this->matching_threshold; + if(l > threshold) this->doPixel(u, v); } } } @@ -92,6 +105,11 @@ class HoughMachine { } }; + void drawLines(int n) { + // TODO: Sort stuff in hough_arr by value, get the n top values and draw them using bresenham. + + }; + void debugShow() { std::cout << "Dimensions: " << this->n_ang << " x " << this->n_rad << " | " << std::endl; diff --git a/imageviewer-qt4.cpp b/imageviewer-qt4.cpp index e3081f1..79aff10 100644 --- a/imageviewer-qt4.cpp +++ b/imageviewer-qt4.cpp @@ -774,7 +774,11 @@ void ImageViewer::runHoughTransformation(void) { logFile << "Let's run a hough transformation!" << std::endl; renewLogging(); HoughMachine* hm = new HoughMachine(original, working_copy); + hm->setMatchingThreshold(15); hm->run(256, 256); + + hm->drawLines(10); + delete hm; updateImageDisplay(); }