title: Creating a clustered image from kmeans data in OpenCV
body: <p>I am trying to create a clustered image from data being returned from the kmeans function. I try to pull out the data in a similar fashion from the OpenCV example but that seems to crash on me. After some further research I saw that someone had pulled data out by using the centers, but did nothing with that data so my trail ended there.</p>
  
  <p>I have included a snippet of my code and what I am doing below. Any help would be greatly appreciated.</p>
  
  <p><strong>EDIT</strong>
  I've reverted my code back to it's original state without any test variables. Still the above error persists. I have also added some debugging information about my image below:</p>
  
  <p>Image information:</p>
  
  <ul>
  <li>Dimensions: 2 </li>
  <li>Image data:</li>
  <li>Size 0: 256</li>
  <li>Size 1: 256</li>
  <li>Elemsize 1: 12</li>
  <li>Elemsize 2: 4</li>
  </ul>
  
  <p>While data is NULL I am still able to view the data if I call <code>cv::imshow</code> on it.</p>
  
  <pre><code>// mImage is a cv::Mat that was created from a 256 x 256 image with the depth of
  // CV_32F and 3 channels
  // labels is a cv::Mat that was created by converting the image into a 256 x 256
  // CV_8UC1 IplImage
  kmeans(mImage, 6, labels, termcrit, 3, cv::KMEANS_PP_CENTERS, centers);
  float* c = new float[6];
  memcpy(c, centers.ptr&lt;float&gt;(0), sizeof(float)*6);
  
  // Block of code that crashes when I do "mImage.at&lt;cv::Point2f&gt;(i)" with the error:
  /* OpenCV Error: Assertion failed (dims &lt;= 2 &amp;&amp; data &amp;&amp; (size.p[0] == 1 || 
         size.p[1] == 1) &amp;&amp; (unsigned)i0 &lt; (unsigned)(size.p[0] + size.p[1] - 1) &amp;&amp; 
         elemSize() == (((((DataType&lt;_Tp&gt;::type) &amp; ((512 - 1) &lt;&lt; 3)) &gt;&gt; 3) + 1) &lt;&lt; 
         ((((sizeof(size_t)/ 4+1)*16384|0x3a50) &gt;&gt; ((DataType&lt;_Tp&gt;::type) &amp; 
         ((1 &lt;&lt; 3) - 1))*2) &amp; 3))) in unknown function, file 
         c:\opencv-2.3.0\modules\core\include\opencv2\core\mat.hpp, line 583 */
  
  for(int i = 0; i &lt; list.rows; i++)
  {
      int clusterIdx = list.at&lt;int&gt;(i);
      cv::Point ipt = mImage.at&lt;cv::Point2f&gt;(i);
      circle( miplImage, ipt, 2, colorTab[clusterIdx], CV_FILLED, CV_AA );
  }
  </code></pre>