Home > database >  How to draw a blurred circle in opencv Python?
How to draw a blurred circle in opencv Python?

Time:07-20

I want to draw multiple circle on a specific image, There is a way to draw them blurred?

example:

cv2.circle(img,center,20,color,-1)

is possible to draw that circle blurred?

CodePudding user response:

There is nothing in-built in OpenCV but you can get creative. enter image description here

CodePudding user response:

That's my final solution. First, create a mask image drawing a white circle at the point location on a black image.

Then blur the whole image.

Finally copy blurred content to the original image only where mask is > 0

mask_img = np.zeros(img.shape, dtype='uint8')
cv2.circle(mask_img,center,20,color,-1)

img_all_blurred = cv2.medianBlur(img, 99)
img = np.where(mask_img > 0, img_all_blurred, img)
  • Related