title: How to mark the center and calculate the diameter of an image using opencv - python?
body: <p>I am working on the recognition of the center and the image rendering. I'm using <code>cv2.findContours</code> to delimit the edges of the image of interest. And using <code>cv.minEnclosingCircle (cnt)</code> to circumnavigate my region of interest. The code below I can identify the center of each ROI, but I am not able to mark in the output of the image the circle corresponding to the image that I want to calculate and also I want to mark with a pqno point the exact location where the algorithm identified the center.</p>
  <pre><code>import cv2
  import numpy as np
  import matplotlib.pyplot as plt
  from matplotlib.offsetbox import AnchoredText
  
  
  thresh = cv2.imread('IMD044.png',0)
  _, contours,hierarchy = cv2.findContours(thresh,2,1)
  print (len(contours))
  cnt = contours
  
  for i in range (len(cnt)):
      (x,y),radius = cv2.minEnclosingCircle(cnt[i])
      center = (int(x),int(y))
      radius = int(radius)
      cv2.circle(thresh,center,radius,(0,255,0),2)
      print ('Circle: ' + str(i) + ' - Center: ' + str(center) + ' -     Radius: ' + str(radius))
  plt.text(x-15, y+10, '+', fontsize=25, color = 'red')
  plt.text(10, -10, 'Centro: '+str(center), fontsize=11, color = 'red')
  plt.text(340, -10, 'Diametro: '+str((radius*2)/100)+'mm', fontsize=11, color = 'red')
  plt.Circle(x, y, color='red', fill=False)
  plt.imshow(thresh, cmap='gray')
  plt.show()
  </code></pre>
  <p>I used the <a href="https://docs.opencv.org/3.4/dd/d49/tutorial_py_contour_features.html" rel="nofollow noreferrer">Opencv</a> documentation to demarcate the contours and get the regions, but the green circle mark does not appear.</p>
  <p>Exit:</p>
  <p><a href="https://i.stack.imgur.com/LrxxA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LrxxA.png" alt="enter image description here" /></a></p>
  <p>Exit expected:
  <a href="https://i.stack.imgur.com/tfWoF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tfWoF.png" alt="enter image description here" /></a></p>
  <p>updating the question I was able to add the information, it's only necessary to add the circle and check if the diameter is correct.</p>