The Python Oracle

Drawing true filled circle on an image

--------------------------------------------------
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------

Music by Eric Matyas
https://www.soundimage.org
Track title: City Beneath the Waves Looping

--

Chapters
00:00 Drawing True Filled Circle On An Image
01:01 Accepted Answer Score 2
01:31 Answer 2 Score 4
01:42 Thank you

--

Full question
https://stackoverflow.com/questions/4953...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#python #matplotlib #plot #geometry #scikitimage

#avk47



ANSWER 1

Score 4


draw circles in the img.

import cv2
import numpy as np

img = np.zeros([474, 474])

cv2.circle(img, (100,100), 5, 255, -1)
cv2.circle(img, (200,200), 30, 255, -1)

cv2.imshow('image', img)
cv2.waitKey(0)
cv2.destroyAllWindows()



ACCEPTED ANSWER

Score 2


When drawing a circle in OpenCV, there are several parameters that can be chosen, one of them is used to define the type of the circle boundary, you have 4 types:

  • Filled
  • 4-connected line
  • 8-connected line
  • antialiased line

You can see the different effect on the following image (in same order) enter image description here

An example code (in C++)

circle(src,cv::Point(300,300), 10, Scalar(0,0,255), 1, FILLED);