opencv / opencv_contrib

Repository for OpenCV's extra modules
Apache License 2.0
9.41k stars 5.76k forks source link

ximgproc: SLIC out of bounds #623

Closed berak closed 8 years ago

berak commented 8 years ago
#include <opencv2/opencv.hpp>
#include <opencv2/ximgproc.hpp>
using namespace cv;
using namespace cv::ximgproc;

int main(int argc, char **argv)
{
    Mat image = imread("im/lena.png"); //512x512
    Ptr<SuperpixelSLIC> slic = createSuperpixelSLIC(image, SLICO, 10, 10.0f) ;
    return 0;
}

breaks here , m_numlabels=2621, m_kseedsx.size()=2601

actually, it works, when choosing a larger region, like 12

for context, see here

cbalint13 commented 8 years ago

@berak ,

cbalint13 commented 8 years ago

@berak ,

Let me know the results.

cbalint13 commented 8 years ago

@berak ,

cbalint13 commented 8 years ago

@berak ,

--- opencv_contrib/modules/ximgproc/src/slic.cpp    2015-12-23 11:30:53.359563158 +0200
+++ opencv_contrib/modules/ximgproc/src/slic.cpp    2016-04-05 17:31:29.774349783 +0300
@@ -226,11 +226,12 @@
     else
       CV_Error( Error::StsInternal, "No such algorithm" );

+    // update amount of labels now
+    m_numlabels = (int)m_kseeds[0].size();
+
     // perturb seeds given edges
     if ( perturbseeds ) PerturbSeeds( edgemag );

-    // update amount of labels now
-    m_numlabels = (int)m_kseeds[0].size();
 }

 void SuperpixelSLICImpl::iterate( int num_iterations )
berak commented 8 years ago

@cbalint13 ,

Köszönöm szépen ! (Vielen dank !)

yes, demo code + patch are working nicely now.

berak commented 8 years ago

incredibly fast ! thanks again.