From 04c9b4b3f46898e489bdf33db28d2d4df7ed4ceb Mon Sep 17 00:00:00 2001 From: Jan Philipp Timme Date: Sun, 20 Dec 2015 17:24:40 +0100 Subject: [PATCH] [TASK] Parameterize gauss filter size. --- canny_edge_machine.cpp | 11 ++++++++--- imageviewer-qt4.cpp | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/canny_edge_machine.cpp b/canny_edge_machine.cpp index 464cf21..12688ae 100644 --- a/canny_edge_machine.cpp +++ b/canny_edge_machine.cpp @@ -26,6 +26,7 @@ class CannyEdgeMachine { int* gradient_y; // Params + int filter_size; double t_low; double t_high; @@ -53,6 +54,10 @@ class CannyEdgeMachine { free(this->gradient_y); }; + void setGaussFilterSize(int filter_size) { + this->filter_size = filter_size; + }; + void setThresholdValues(double t_low, double t_high) { this->t_low = t_low; this->t_high = t_high; @@ -68,9 +73,9 @@ class CannyEdgeMachine { } }; - void doGaussBlur(int filter_width=3) { + void doGaussBlur(int filter_width) { // build the gauss filter - int* filter = (int*) malloc(sizeof(int) * filter_width* filter_width); + int* filter = (int*) malloc(sizeof(int) * filter_width * filter_width); int sum_weights = 0; int filter_middle = (filter_width)/2; for(int x=0; xreset(); - this->doGaussBlur(); + this->doGaussBlur(this->filter_size); this->doGradiants(); this->doGradiantMagnitude(); this->filterLocalMaxima(); diff --git a/imageviewer-qt4.cpp b/imageviewer-qt4.cpp index b903564..316b6f6 100644 --- a/imageviewer-qt4.cpp +++ b/imageviewer-qt4.cpp @@ -649,8 +649,8 @@ void ImageViewer::applyBasicFilterWithOverflowHandling() { * @brief ImageViewer::runCannyEdge */ void ImageViewer::runCannyEdge(void) { - //TODO CannyEdgeMachine cem = CannyEdgeMachine(original, working_copy); + cem.setGaussFilterSize(3); cem.setThresholdValues(2.5, 3.5); //TODO cem.work(); updateImageDisplay();