Draw a Circle Ona Image by Given Cooridnates Python

OpenCV circle

Introduction to OpenCV circle

Whenever nosotros are trying to solve problems related to computer vision, it is frequently necessary to draw unlike geometric shapes similar circle, rectangle etc. and in order to draw a circumvolve on a given prototype, nosotros brand use of a function called circle() function in OpenCV using which a circle of required radius from a given ten coordinate and y coordinate at the center of required border line color and required border line thickness can be fatigued on a given image and the image with the circle drawn on information technology is returned as the output past making use of the circumvolve() function.

The syntax to define circle() office in OpenCV is equally follows:

circumvolve(sourceimage, (x coordinate, y coordinate), radius, color. thickness)

where sourceimage is the epitome on which the circumvolve is to be drawn,
ten coordinate and y coordinate represents the center coordinates of the circumvolve to be drawn on the given epitome,
radius is the radius of the circle to be fatigued on the given image,
color is the border line color of the circle to exist fatigued on the given image and
thickness is the edge line thickness of the circumvolve to be drawn on the given image.

Working of circle() function in OpenCV

  • Whenever we are trying to solve problems related to reckoner vision, it is often necessary to draw different geometric shapes like circumvolve, rectangle etc.
  • In society to draw a circle on a given image, we brand employ of a function called circle() part in OpenCV.
  • The circle() function takes 5 parameters namely sourceimage, (10 coordinate, y coordinate), radius, color and thickness.
  • The parameter sourceimage is the epitome on which the circle is to be fatigued.
  • The parameter 10 coordinate and y coordinate represents the center coordinates of the circumvolve to be drawn on the given image.
  • The parameter radius is the radius of the circumvolve to be drawn on the given epitome.
  • The parameter colour is the border line colour of the circumvolve to exist drawn on the given epitome.
  • The parameter thickness is the border line thickness of the circle to be fatigued on the given image.
  • The circle() function returns an image on which the circumvolve is drawn from the specified ten coordinate and y coordinate, of specified radius, of specified edge line color, and of specified edge line thickness.

Examples of OpenCV circle

Hither are the following examples mention below

Example #1

OpenCV program in python to demonstrate circle() office using which a circle is drawn from the specified x coordinate and y coordinate, of specified radius, of specified border line color, and of specified borderline thickness on a given image and returned as the output on the screen:

#importing the module cv2
import cv2
#reading the prototype from a given path on which the circle is to be fatigued
imageread = cv2.imread('C:/Users/admin/Desktop/logo.png')
#using circumvolve() function to draw a circle on the given paradigm
imagecircle = cv2.circle(imageread, (120, l), twenty, (255, 0, 0), two)
#displaying the prototype with circle drawn on information technology every bit the output on the screen
cv2.imwrite("C:/Users/admin/Desktop/logo1.png", imagecircle)

The output of the given plan is shown in the snapshot below:

OpenCV circle output 1

In the above program, nosotros are importing the module cv2. Then we are reading the image on which a circle is to be drawn using imread() function. Then we making use of circle() function by specifying the sourceimage, x coordinate and y coordinate, radius, border line color and border line circumvolve to draw a circle on the given image. The circle() role returns the prototype with the circle drawn on information technology as the output on the screen. The output is shown in the snapshot above.

Example #ii

OpenCV program in python to demonstrate circle() function using which a circumvolve is drawn from the specified x coordinate and y coordinate, of specified radius, of specified edge line color, and of specified border line thickness on a given image and returned as the output on the screen:

#importing the module cv2
import cv2
#reading the image from a given path on which the circle is to be drawn
imageread = cv2.imread('C:/Users/admin/Desktop/plane.jpg')
#using circle() function to describe a circle on the given image
imagecircle = cv2.circumvolve(imageread, (200, 100), 100, (0, 255, 0), 2)
#displaying the image with circle drawn on it as the output on the screen
cv2.imwrite("C:/Users/admin/Desktop/logo1.png", imagecircle)

The output of the given program is shown in the snapshot below:

OpenCV circle output 2

In the above program, we are importing the module cv2. Then we are reading the image on which a circle is to be drawn using imread() function. Then we making use of circle() function past specifying the sourceimage, x coordinate and y coordinate, radius, edge line color and edge line circle to describe a circle on the given image. The circle() office returns the image with the circle drawn on it as the output on the screen. The output is shown in the snapshot higher up.

Example #iii

OpenCV program in python to demonstrate circle() office using which a circle is drawn from the specified 10 coordinate and y coordinate, of specified radius, of specified border line color, and of specified border line thickness on a given image and returned equally the output on the screen:

#importing the module cv2
import cv2
#reading the prototype from a given path on which the circumvolve is to exist drawn
imageread = cv2.imread('C:/Users/admin/Desktop/educba.jpg')
#using circle() role to draw a circle on the given image
imagecircle = cv2.circle(imageread, (150, 50), 50, (0, 0, 255), two)
#displaying the paradigm with circumvolve drawn on it every bit the output on the screen
cv2.imwrite("C:/Users/admin/Desktop/logo1.png", imagecircle)

The output of the given plan is shown in the snapshot below:

output 3

In the above program, we are importing the module cv2. And then we are reading the image on which a circle is to exist drawn using imread() function. And then we making use of circle() function by specifying the sourceimage, x coordinate and y coordinate, radius, border line color and edge line circumvolve to draw a circle on the given image. The circle() function returns the paradigm with the circumvolve fatigued on it as the output on the screen. The output is shown in the snapshot above.

Conclusion

In this commodity, nosotros take learned the concept of circle() function in OpenCV through definition, syntax, and working of circumvolve() function in OpenCV with respective programming examples and their outputs to demonstrate them.

Recommended Articles

This is a guide to OpenCV circle. Here we hash out the concept of circumvolve() function in OpenCV through definition, syntax, and working of circumvolve() function. Y'all may also accept a await at the post-obit articles to acquire more –

  1. Open up CV resize()
  2. OpenCV kmeans
  3. Open Source Software
  4. Advantages of Python

vasquezsuir1995.blogspot.com

Source: https://www.educba.com/opencv-circle/

Belum ada Komentar untuk "Draw a Circle Ona Image by Given Cooridnates Python"

Posting Komentar

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel