From 000a2be162adb5e6cb94d0ee0fd6e380c6461a46 Mon Sep 17 00:00:00 2001 From: Jan Philipp Timme Date: Sun, 20 Dec 2015 17:13:58 +0100 Subject: [PATCH] [TASK] Finish up very first working version of canny edge algorithm. --- canny_edge_machine.cpp | 16 ++++++++++++++++ imageviewer-qt4.cpp | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/canny_edge_machine.cpp b/canny_edge_machine.cpp index 19f6c37..ccfbd59 100644 --- a/canny_edge_machine.cpp +++ b/canny_edge_machine.cpp @@ -244,6 +244,21 @@ class CannyEdgeMachine { } }; + void showEdges(void) { + QRgb black = QColor::fromRgb(0, 0, 0).rgb(); + QRgb white = QColor::fromRgb(255, 255, 255).rgb(); + for(int x=0; xwidth; x++) { + for(int y=0; yheight; y++) { + int pixel = this->binary_edge_pixels[y*this->width + x]; + if(pixel > 0) { + this->working_copy->getImage()->setPixel(x, y, white); + } else { + this->working_copy->getImage()->setPixel(x, y, black); + } + } + } + }; + void work() { this->reset(); this->doGaussBlur(); @@ -251,6 +266,7 @@ class CannyEdgeMachine { this->doGradiantMagnitude(); this->filterLocalMaxima(); this->workLocalMaxima(); + this->showEdges(); }; }; diff --git a/imageviewer-qt4.cpp b/imageviewer-qt4.cpp index ee96fb9..b903564 100644 --- a/imageviewer-qt4.cpp +++ b/imageviewer-qt4.cpp @@ -651,7 +651,7 @@ void ImageViewer::applyBasicFilterWithOverflowHandling() { void ImageViewer::runCannyEdge(void) { //TODO CannyEdgeMachine cem = CannyEdgeMachine(original, working_copy); - cem.setThresholdValues(0, 0); //TODO + cem.setThresholdValues(2.5, 3.5); //TODO cem.work(); updateImageDisplay(); }