title: OpenCV Error: Assertion failed ((unsigned)i0 < (unsigned)size.p[0]) in cv::Mat::at
body: <p>I am trying to plot the points on a white 500x500 background image.</p>
  
  <pre><code>void Lab1() {
  
      float px[500];
      float py[500];
      float x, y;
      int nrPoints;
          //citire puncte din fisier
      FILE *pfile;
      pfile = fopen("points0.txt", "r");
  
          //punere in variabila
      fscanf(pfile, "%d", &amp;nrPoints);
  
         //facem o imagine de 500/500 alba
      Mat whiteImg(500, 500, CV_8UC3);
  
      for (int i = 0; i &lt; 500; i++) {
          for (int j = 0; j &lt; 500; j++) {
              whiteImg.at&lt;Vec3b&gt;(i, j)[0] = 255; // b
              whiteImg.at&lt;Vec3b&gt;(i, j)[1] = 255; // g
              whiteImg.at&lt;Vec3b&gt;(i, j)[2] = 255; // r
  
          }
      }
  
  
        //punem punctele intr-un vector,pentru a le putea pozitiona ulterior in imaginea alba.
  
      for (int i = 0; i &lt; nrPoints; i++) {
          fscanf(pfile, "%f%f", &amp;x, &amp;y);
  
          px[i] = x;
          py[i] = y;
          //afisam punctele
          printf("%f ", px[i]);
          printf("%f\n", py[i]);
      }
  
        //punem punctele pe imagine
  
      for (int i = 0; i &lt; nrPoints; i++) {
          whiteImg.at&lt;Vec3b&gt;(px[i],py[i]) = 0;
      }
  
      imshow("img",whiteImg);
      fclose(pfile);
       //system("pause");
      waitKey();
  }
  </code></pre>
  
  <p>and the problem is here: </p>
  
  <pre><code>whiteImg.at&lt;Vec3b&gt;(px[i],py[i]) = 0;
  </code></pre>
  
  <p>I can't avoid this error: </p>
  
  <blockquote>
    <p>OpenCV Error: Assertion failed ((unsigned)i0 &lt; (unsigned)size.p[0]) in cv::Mat::at, file c:\users\toder\desktop\anul4\srf\laburi_srf\opencvapplication-vs2015_31_basic\opencv\include\opencv2\core\mat.inl.hpp, line 917</p>
  </blockquote>