diff --git a/hough_machine.cpp b/hough_machine.cpp index 0b812fa..bf38c0a 100644 --- a/hough_machine.cpp +++ b/hough_machine.cpp @@ -59,7 +59,6 @@ class HoughMachine { }; void run(int a_steps, int r_steps) { - this->reset(); this->x_center = this->original->width()/2; this->y_center = this->original->height()/2; this->n_ang = a_steps; @@ -84,9 +83,11 @@ class HoughMachine { pixel.getHsl(&h, &s, &l); if(this->matching_threshold > 0) { int threshold = this->matching_threshold; + std::cout << "Comparing " << l << " < " << threshold << std::endl; if(l < threshold) this->doPixel(u, v); } else { int threshold = -this->matching_threshold; + std::cout << "Comparing " << l << " > " << threshold << std::endl; if(l > threshold) this->doPixel(u, v); } } diff --git a/imageviewer-qt4.cpp b/imageviewer-qt4.cpp index 79aff10..871ff53 100644 --- a/imageviewer-qt4.cpp +++ b/imageviewer-qt4.cpp @@ -771,14 +771,14 @@ void ImageViewer::doUnsharpMasking(void) { * @brief ImageViewer::runHoughTransformation */ void ImageViewer::runHoughTransformation(void) { - logFile << "Let's run a hough transformation!" << std::endl; + int threshold = hough_pixel_threshold->value(); + logFile << "Let's run a hough transformation! Threshold is " << threshold << std::endl; renewLogging(); HoughMachine* hm = new HoughMachine(original, working_copy); - hm->setMatchingThreshold(15); + hm->reset(); + hm->setMatchingThreshold(threshold); hm->run(256, 256); - - hm->drawLines(10); - + hm->drawLines(10); delete hm; updateImageDisplay(); } @@ -1126,7 +1126,15 @@ void ImageViewer::generateControlPanels() { run_hough_transformation = new QPushButton("Run hough transformation!"); QObject::connect(run_hough_transformation, SIGNAL(clicked()), this, SLOT(runHoughTransformation())); - task_tab6_scrolllayout->addWidget(new QLabel("Task #6 and stuff")); + hough_pixel_threshold = new QDoubleSpinBox(); + hough_pixel_threshold->setDecimals(0); + hough_pixel_threshold->setMinimum(-255); + hough_pixel_threshold->setMaximum(255); + hough_pixel_threshold->setValue(15); + + task_tab6_scrolllayout->addWidget(new QLabel("Pixel threshold for hough transformation:")); + task_tab6_scrolllayout->addWidget(new QLabel("[negative value -> intensity < threshold matches]")); + task_tab6_scrolllayout->addWidget(hough_pixel_threshold); task_tab6_scrolllayout->addWidget(run_hough_transformation); tabWidget->addTab(task_tab6_widget, "Task #6"); diff --git a/imageviewer-qt4.h b/imageviewer-qt4.h index 5cc117d..28422b2 100644 --- a/imageviewer-qt4.h +++ b/imageviewer-qt4.h @@ -168,6 +168,7 @@ class ImageViewer : public QMainWindow { QScrollArea* task_tab6_scrollarea; QVBoxLayout* task_tab6_scrolllayout; + QDoubleSpinBox* hough_pixel_threshold; QPushButton* run_hough_transformation; // "My" space for storing data/results