[TASK] Add parameters to canny edge.

This commit is contained in:
Jan Philipp Timme 2015-12-20 17:46:24 +01:00
parent 04c9b4b3f4
commit a646539719
2 changed files with 31 additions and 3 deletions

View File

@ -650,8 +650,13 @@ void ImageViewer::applyBasicFilterWithOverflowHandling() {
*/
void ImageViewer::runCannyEdge(void) {
CannyEdgeMachine cem = CannyEdgeMachine(original, working_copy);
cem.setGaussFilterSize(3);
cem.setThresholdValues(2.5, 3.5); //TODO
int filter_size = gauss_filter_size->value();
double t_low = t_low_spinbox->value();
double t_high = t_high_spinbox->value();
logFile << "Canny-Edge using N*N filter size: " << filter_size << ", and thresholds: " << t_low << ", " << t_high << std::endl;
renewLogging();
cem.setGaussFilterSize(filter_size);
cem.setThresholdValues(t_low, t_high);
cem.work();
updateImageDisplay();
}
@ -919,6 +924,25 @@ void ImageViewer::generateControlPanels() {
run_canny_edge = new QPushButton("Run canny edge algorithm!");
QObject::connect(run_canny_edge, SIGNAL(clicked()), this, SLOT(runCannyEdge()));
gauss_filter_size = new QDoubleSpinBox();
gauss_filter_size->setDecimals(0);
gauss_filter_size->setMinimum(3);
gauss_filter_size->setValue(3);
t_low_spinbox = new QDoubleSpinBox();
t_low_spinbox->setDecimals(5);
t_low_spinbox->setValue(2.0);
t_high_spinbox = new QDoubleSpinBox();
t_high_spinbox->setDecimals(5);
t_high_spinbox->setValue(4.0);
task_tab5_scrolllayout->addWidget(new QLabel("Gauss filter size (NxN)"));
task_tab5_scrolllayout->addWidget(gauss_filter_size);
task_tab5_scrolllayout->addWidget(new QLabel("Low threshold value"));
task_tab5_scrolllayout->addWidget(t_low_spinbox);
task_tab5_scrolllayout->addWidget(new QLabel("High threshold value"));
task_tab5_scrolllayout->addWidget(t_high_spinbox);
task_tab5_scrolllayout->addWidget(run_canny_edge);
tabWidget->addTab(task_tab5_widget, "Task #5");

View File

@ -49,6 +49,7 @@
#include <QPushButton>
#include <QSlider>
#include <QColor>
#include <QDoubleSpinBox>
#include <math.h>
#include "fstream"
@ -145,7 +146,10 @@ class ImageViewer : public QMainWindow {
QWidget* task_tab5_scrollwidget;
QScrollArea* task_tab5_scrollarea;
QVBoxLayout* task_tab5_scrolllayout;
QDoubleSpinBox* gauss_filter_size;
QDoubleSpinBox* t_low_spinbox;
QDoubleSpinBox* t_high_spinbox;
QPushButton* run_canny_edge;
// "My" space for storing data/results