title: Get coordinates of white pixels (OpenCV)
body: <p>In OpenCV (C++) I have a b&amp;w image where some shapes appear filled with white (255). Knowing this, how can I get the coordinate points in the image where theses objects are? I'm interested on getting all the white pixels coordinates.</p>
  
  <p>Is there a cleaner way than this?</p>
  
  <pre><code>std::vector&lt;int&gt; coordinates_white; // will temporaly store the coordinates where "white" is found 
  for (int i = 0; i&lt;img_size.height; i++) {
      for (int j = 0; j&lt;img_size.width; j++) {
          if (img_tmp.at&lt;int&gt;(i,j)&gt;250) {
              coordinates_white.push_back(i);
              coordinates_white.push_back(j);
          }
      }
  }
  // copy the coordinates into a matrix where each row represents a *(x,y)* pair
  cv::Mat coordinates = cv::Mat(coordinates_white.size()/2,2,CV_32S,&amp;coordinates_white.front());
  </code></pre>