title: How to fill a polygon using opencv python
body: <p>I would like to fill these polygon with white color and this operation is repeated through a loop over the whole image so I would like to know the syntax and function which can be used to perform this operation using opencv in python
  This is my input image </p>
  
  <p><a href="https://i.stack.imgur.com/8sYft.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/8sYft.jpg" alt="enter image description here"></a></p>
  
  <pre><code>alist=[]
  img = cv2.imread('closing2.jpg',cv2.IMREAD_GRAYSCALE)
  imo = cv2.imread('closing2.jpg',cv2.IMREAD_GRAYSCALE)
  imr = cv2.imread('closing2.jpg',cv2.IMREAD_GRAYSCALE)*0
  imac = imr
  height , width  = imo.shape[:2]
  a,im = cv2.threshold(img,200,255,cv2.THRESH_BINARY)
  # i=100
  # p=[i,i]
  points = []
  for j in range(0,1000,50):
      for i in range(0,1000,50):
          p=[i,j]
          poly = raypoly(im,p,5)
          st = metrics(p,poly)
  
          polyc=raypolyLimit(im,p,st,30)
          # print(polyc)
          # print(len(polyc))
          # for m in range(len(polyc)):
          #     point = polyc[m]
          #     cv2.fillConvexPoly(im, point, 255)
          plotpoly(polyc,imr)
  
          plotpolypoints(polyc,imr,255,1)
          # plotray(im,p,imr)
  
          am = polyArea(polyc)
          # print(am)
          if am &gt; 5:
              alist.append(am)
              # img[(i-5):(i+5),(j-5):(j+5)]=150
              # plt.imshow(imf)
              # plt.show()
          imo = im * 0
          plotpoly(polyc,imo)
          plotpoly(polyc, im)
          # plotArea(polyc,imo)
          imf = imo*1000 +im
          a,imf = cv2.threshold(imf,100.0,255.0,cv2.THRESH_BINARY)
          cv2.imshow('Frame_1', imr)
          cv2.imshow('Frame_3', imo)
          cv2.imshow('Frame_4', imf)
          cv2.imshow('Frame_5', im)
          cv2.waitKey(1)
  </code></pre>
  
  <p>I used the following function and the result as follows:</p>
  
  <pre><code>cv2.floodFill(imo,None,(i,j),255)
  </code></pre>
  
  <p>But my problem is that it gives a white flash for the whole image after certain number of polygons and I don't know how to fix it .</p>
  
  <p><a href="https://i.stack.imgur.com/88RCN.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/88RCN.jpg" alt="enter image description here"></a></p>