title: How to generate the coordinate of an object on the grid?
body: <p>I am new to python Opencv and i had this problem of generating the coordinates for the object of this image in two case:</p>
  
  <ol>
  <li><p>If the image is already marked with x-y coordinates like 1,2,3,4...and so on and i have to tell the coordinate at which their is an object how to do that.</p></li>
  <li><p>if i want to generate pixel coordinate how to do that.</p>
  
  <pre><code>img=cv2.imread(image_filename,cv2.IMREAD_COLOR)
  imgray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
  x,y=imgray.shape
  print x,y
  col=x/10
  row=y/10
  i=0
  j=0
  t=()
  
  while i&lt;=x :
          while j&lt;=y :
                  roi=imgray[i+10:i+col-10,j+10:j+row-10]
                  if roi!=[255,255,255]:
                          t=t+((i/col,j/row),)
                          j=j+row
                  else:
                          j=j+row
          i=i+col
  for x in t:
          print (x),
  </code></pre></li>
  </ol>
  
  <p>This is my code sample,but it is not generating correct output ie
  [(7,1),(5,2),(6,3),(4,4),(8,5),(1,6),(5,6),(3,7)]</p>
  
  <p><img src="https://i.stack.imgur.com/VGnbO.jpg" alt=""></p>