From b1e5a69464ac2f8d685d7f0420867e7a95d124a5 Mon Sep 17 00:00:00 2001 From: Jan Philipp Timme Date: Fri, 8 Jan 2016 15:50:18 +0100 Subject: [PATCH] [TASK] Still not done. --- hough_machine.cpp | 33 +++++++++++++++++++++++++++------ imageviewer-qt4.cpp | 5 +++-- 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/hough_machine.cpp b/hough_machine.cpp index bd4bdec..0d3330f 100644 --- a/hough_machine.cpp +++ b/hough_machine.cpp @@ -80,7 +80,7 @@ class HoughMachine { std::cout << "n_ang: " << this->n_ang << ", d_ang: " << this->d_ang << std::endl; std::cout << "n_rad: " << this->n_rad << ", d_rad: " << this->d_rad << ", r_max: " << r_max << std::endl; this->fillHoughAccumulator(); - this->debugShow(); + //this->debugShow(); }; void fillHoughAccumulator() { @@ -113,7 +113,6 @@ class HoughMachine { }; void drawLines(int n) { - n += 1; // for each value: if == 0 ignore // else check if bigger than all neighbours // if so, put it in the list @@ -121,7 +120,7 @@ class HoughMachine { int line = 0; for(int i=0; i<=this->n_ang*this->n_rad; i++) { int value = this->hough_arr[i]; - if(value == 0) continue; // Ignore zeros + if(value <= 5) continue; // Ignore small values // TODO: Check neighbours and compare! // Store value if bigger than neighbours int a = i / this->n_ang; @@ -135,7 +134,29 @@ class HoughMachine { } // Now sort it qsort((void*) lines, line, sizeof(struct hparam), HoughMachine::comp); - for(int i=0; i<10; i++) std::cout << "Top " << i << ": " << lines[i].value << std::endl; + // Draw them + double pi_half = M_PI / 2.0; + for(int i=0; i 2) y_inter *= -1; + //double x_factor = (this->x_center + x_inter) / x_inter; + //double y_factor = (this->y_center + y_inter) / y_inter; + //x_inter *= x_factor; + //y_inter *= y_factor; + int x1 = 0; int x2 = 0; int y1 = 0; int y2 = 0; + std::cout << " x: " << x_inter << ", y: " << y_inter << std::endl; + x1 = 0; y1 = y_inter; + x2 = x_inter; y2 = 0; + this->otherBresenham(x1, y1, x2, y2); + + } }; @@ -152,11 +173,11 @@ class HoughMachine { void setPixelDebug(int x, int y, int color=0) { int our_color = QColor::fromRgb(0, 255, 0).rgb(); if(color == 0) color = our_color; - std::cout << " --> SET (" << x << ", " << y << ")" << std::endl; + //std::cout << " --> SET (" << x << ", " << y << ")" << std::endl; this->working_copy->getImage()->setPixel(x, y, color); }; - void otherBresenham(int x, int x2, int y, int y2) { + void otherBresenham(int x, int y, int x2, int y2) { int width = x2 - x; int height = y2 - y; int dx1 = 0, dy1 = 0, dx2 = 0, dy2 = 0; diff --git a/imageviewer-qt4.cpp b/imageviewer-qt4.cpp index 7042cce..9781119 100644 --- a/imageviewer-qt4.cpp +++ b/imageviewer-qt4.cpp @@ -790,8 +790,9 @@ void ImageViewer::runHoughTransformation(void) { HoughMachine* hm = new HoughMachine(original, working_copy); hm->reset(); hm->setMatchingThreshold(threshold); - hm->run(256, 256); - hm->drawLines(10); + //hm->run(256, 256); + hm->run(300, 300); + hm->drawLines(40); delete hm; updateImageDisplay(); }