Manu Jain
Manu Jain

Reputation: 41

Eliipse shaped mask in Opencv Python

I want to extract an Ellipse mask from an image in OpenCV Python. cv.ellipse draws the ellipse but I cant extract a mask out of it. Thanks.

Upvotes: 0

Views: 1638

Answers (1)

GPPK
GPPK

Reputation: 6666

This is how you would draw a blue circle, on an image, in a desired location

cv2.circle(img,(x,y), 63, (0,0,255), -1)

You will have a line of code similar to this to draw your ellipse on the image.

Draw this ellipse again on a new image:

newImg = np.zeros((height,width,3), np.uint8)
cv2.circle(newImg,(x,y), 63, (0,0,255), -1)

You will see that it is a mask! you can take those values and just keep plotting "Masks" or "Circles" or "Ellipses" (They are all the same thing in this case) to your hearts desire.

Upvotes: 1

Related Questions