diff --git a/canny_edge_machine.cpp b/canny_edge_machine.cpp index 5af5737..7192919 100644 --- a/canny_edge_machine.cpp +++ b/canny_edge_machine.cpp @@ -8,6 +8,7 @@ #include #include +#include "lazy_image.cpp" class CannyEdgeMachine { @@ -79,20 +80,20 @@ class CannyEdgeMachine { } // apply gauss filter int filter_offset = (filter_width+1)/2; - for(int x=0+filter_offset; xwidth-filter_offset; x++) { - for(int y=0+filter_offset; ywidth-filter_offset; y++) { + for(int x=(0+filter_offset); x<(this->width-filter_offset); x++) { + for(int y=(0+filter_offset); y<(this->height-filter_offset); y++) { int sum_intensity = 0; int h, s, l; for(int fx=0; fxoriginal->getImage()->pixel(x+dx, y+dy)); + QColor color = QColor::fromRgb(this->original->getPixel(x+dx, y+dy, LazyImage::DEFAULT)); color.getHsl(&h, &s, &l); sum_intensity += (l * filter[fy*filter_width + fx]); } } - QColor color = QColor::fromRgb(original->getImage()->pixel(x, y)); + QColor color = QColor::fromRgb(this->original->getPixel(x, y, LazyImage::DEFAULT)); color.getHsl(&h, &s, &l); l = qRound((1.0*sum_intensity) / (1.0*sum_weights)); if(l > 255) l = 255; @@ -106,13 +107,12 @@ class CannyEdgeMachine { void work() { this->reset(); - - for(int x=0; xwidth; x++) { + this->doGaussBlur(); + /*for(int x=0; xwidth; x++) { for(int y=0; yheight; y++) { //this->gradient_magnitude = sqrt(...) } - } - + }*/ }; diff --git a/imageviewer-qt4.cpp b/imageviewer-qt4.cpp index b8aef9d..63343ec 100644 --- a/imageviewer-qt4.cpp +++ b/imageviewer-qt4.cpp @@ -658,7 +658,7 @@ void ImageViewer::runCannyEdge(void) { CannyEdgeMachine cem = CannyEdgeMachine(original, working_copy); cem.setThresholdValues(0, 0); //TODO cem.work(); - + updateImageDisplay(); } /**************************************************************************************** * diff --git a/lazy_image.cpp b/lazy_image.cpp index 701b6fa..2d28a38 100644 --- a/lazy_image.cpp +++ b/lazy_image.cpp @@ -118,7 +118,7 @@ class LazyImage { public: - enum overflowMode {ZERO_PADDING, CONSTANT, MIRRORED, CONTINUOUS}; + enum overflowMode {DEFAULT, ZERO_PADDING, CONSTANT, MIRRORED, CONTINUOUS}; LazyImage(QImage* img) { this->histogramm_normal_image = NULL; @@ -219,6 +219,8 @@ class LazyImage { bool return_result = false; QRgb result; switch(mode) { + case DEFAULT: + break; case ZERO_PADDING: // Return black for all out of bound requests if(x < 0 || x >= width || y < 0 || y >= height) { result = qRgb(0, 0, 0);