title: Error in changing the background color from white to black
body: <p>I am trying to change the background color from white to black. So i am trying to go through all the pixels and check whether its white or no if so change the value to 0. But something went wrong.</p>
  
  <p><strong>Here is my code</strong></p>
  
  <pre><code>Mat img = imread("t.PNG");
  for (int x = 0; x &lt; img.rows; x++)
  {
      for (int y = 0; y &lt; img.cols; y++)
      {
          if (img.at&lt;Vec3b&gt;(Point(x, y))[0] &gt;=245 &amp;&amp; img.at&lt;Vec3b&gt;(Point(x, y))[1] &gt;= 245 &amp;&amp; img.at&lt;Vec3b&gt;(Point(x, y))[2] &gt;= 245)
          {
  
              img.at&lt;Vec3b&gt;(Point(x, y)) = { 0,0,0 };
          }       
      }   
  }
  imwrite("img.png",img);
  imshow(" ",img);
  waitKey(0);
  </code></pre>
  
  <p><strong>here is the image i am trying to convert</strong></p>
  
  <p><a href="https://i.stack.imgur.com/rRT05.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rRT05.png" alt="enter image description here"></a></p>