diff --git a/main.cpp b/main.cpp index dd12c63..e2e6301 100644 --- a/main.cpp +++ b/main.cpp @@ -61,7 +61,7 @@ int main( int argc, char** argv ) //t = (double)cvGetTickCount(); for (int i=0; i & regions); + + // return true if use 8-connected, otherwise false. + bool connect8(){ return eight_; } private: // Helper method diff --git a/region.cpp b/region.cpp index 573ceef..d023646 100644 --- a/region.cpp +++ b/region.cpp @@ -152,7 +152,7 @@ All rights reserved. The function is part of the VLFeat library and is made available under the terms of the BSD license (see the COPYING file). */ -void Region::er_fill(Mat& _grey_img) +void Region::er_fill(Mat& _grey_img, bool _eight ) { const uint8_t *src = (uint8_t*)_grey_img.data; @@ -254,7 +254,7 @@ void Region::er_fill(Mat& _grey_img) 4 - the pixel has not been visited yet */ if(good - && nindex != index + && (nindex != index && (_eight || !(nsubs_pt[0] & nsubs_pt[1]))) && ((!invert && I_pt [nindex] <= value) || ( invert && I_pt [nindex] >= value)) && ! visited_pt [nindex] ) { diff --git a/region.h b/region.h index e5bde03..7256d5b 100644 --- a/region.h +++ b/region.h @@ -31,7 +31,7 @@ class Region /// Fills an Extremal Region (ER) by region growing from the Index of the initial pixel(pixel_). /// @param[in] grey_img Grey level image - void er_fill(cv::Mat& _grey_img); + void er_fill(cv::Mat& _grey_img, bool _eight = false); std::vector pixels_; ///< list pf all pixels indexes (y * width + x) of the region