title: How to thresholding image by ourselves without using fucntion in OpenCV
body: <p>I'm new in OpenCV, and I want to thresholding the image by myself without using Threshold function in opencv, because the time spend on function threshold is to high for me.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>Mat src = imread("D:\\DataBox\\7.jpg", 0);
  for (int i = 0; i &lt; src.cols; i++) {
      cout &lt;&lt; i &lt;&lt; endl;
      for (int j = 0; j &lt; src.rows; j++) {
          if (src.at&lt;uchar&gt;(i, j) &gt; 70) {
              src.at&lt;uchar&gt;(i, j) = 0;
              cout &lt;&lt; j &lt;&lt; endl;
          }
          else
              src.at&lt;uchar&gt;(i, j) = 255;
      }
  }
  </code></pre>
  
  <p>but it still says:</p>
  
  <blockquote>
    <p>"OpenCV Error: Assertion failed (dims &lt;= 2 &amp;&amp; data &amp;&amp; (unsigned)i0 &lt; (unsigned)size.p[0] &amp;&amp; (unsigned)(i1 * DataType&lt;_Tp>::channels) &lt; (unsigned)(size.p[1] * channels()) &amp;&amp; ((((sizeof(size_t)&lt;&lt;28)|0x8442211) >> ((DataType&lt;_Tp>::depth) &amp; ((1 &lt;&lt; 3) - 1))*4) &amp; 15) == elemSize1()) in cv::Mat::at, file C:\Program Files\opencv\build\include\opencv2/core/mat.inl.hpp, line 894"</p>
  </blockquote>
  
  <p>I can print j from 0~719(since the size of the image is 720*960), but as long as the parameter i want to become 2 from 1, the error occurs.</p>