banner



How To Draw Concentric Circles In Java

Drawing over Images

                import cv2
import numpy every bit np
# Create a black prototype
image = np.zeros((512,512,3), np.uint8)
# Tin nosotros make this in black and white?
image_bw = np.zeros((512,512), np.uint8)
cv2.imshow("Black Rectangle (Color)", image)
cv2.imshow("Black Rectangle (B&W)", image_bw)
cv2.waitKey(0)
cv2.destroyAllWindows()

Python Functions for Drawing

                # Describe a diagonal blue line of thickness of five pixels
image = np.zeros((512,512,3), np.uint8) # black sail
cv2.line(prototype, (0,0), (511,511), (255,127,0), five)
cv2.imshow("Blue Line", epitome)
cv2.waitKey(0)
cv2.destroyAllWindows()

                                  # drawing a line                                cv2.line(imageLine,                  # image
(322, 179), # starting point
(400, 183), # terminate signal
(0, 255, 0), # color
thickness=two, # thickness
lineType=cv2.LINE_AA # line type
)
cv2.imshow("imageLine", imageLine)
cv2.imwrite("imageLine.jpg", imageLine)

                                  # Describe a rectangle (thickness is a positive integer)                                cv2.rectangle(imageRectangle,                  # source epitome
(208, 55), # upper left corner vertex
(450, 355), # lower right corner vertex
(0, 255, 0), # color
thickness=2, # line thickness
lineType=cv2.LINE_8 # line blazon
)
cv2.imshow("rectangle", imageRectangle)
cv2.imwrite("imageRectangle.jpg", imageRectangle)

                # Draw a Rectangle in
image = np.zeros((512,512,3), np.uint8)
cv2.rectangle(paradigm, (100,100), (300,250), (127,50,127), -ane)
cv2.imshow("Rectangle", image)
cv2.waitKey(0)
cv2.destroyAllWindows()

                cv2.circumvolve(imageCircle,                  # source image
(350, 200), # center
150, # radius
(0, 255, 0), # colour or border
thickness=two, # line thickness
lineType=cv2.LINE_AA # line type
)
cv2.imshow("imageCircle", imageCircle)
cv2.imwrite("imageCircle.jpg", imageCircle)

                image = np.zeros((512,512,iii), np.uint8)                cv2.circle(paradigm, (350, 350), 100, (15,75,fifty), -i)                  
cv2.imshow("Circle", image)
cv2.waitKey(0)
cv2.destroyAllWindows()

                # draw concentric white circles
# calculate the middle point of sheet
# generate circles using for loop
canvas = np.zeros((300,300,three), dtype ="uint8")
white = (255,255,255)
(centerX, centerY) =
(sheet.shape[1]//2, sail.shape[0]//ii) # width, peak
for r in range(0, 175, 25):
cv2.circle(canvas, (centerX, centerY), r, white)
cv2.imshow("concentric circles", canvas)
cv2.waitKey(0)
cv2.destroyAllWindows()

                # generate random radius, middle signal, color
# depict circles in for loop
canvass = np.zeros((300,300,3), dtype ="uint8")
for i in range(0, 25):
radius = np.random.randint(5, high = 200)
color = np.random.randint(0, high = 256, size = (3,)).tolist()
pt = np.random.randint(0, high = 300, size = (2,))
cv2.circle(canvas, tuple(pt), radius, colour, -1)
cv2.imshow("Sail", sheet)
cv2.waitKey(0)
cv2.destroyAllWindows()

                prototype = np.zeros((512,512,3), np.uint8)                # Let's define four points
pts = np.array( [[ten,50], [400,fifty], [ninety,200], [fifty,500]], np.int32)
# Let's now reshape our points in grade required by polylines
pts = pts.reshape((-one,1,2))
cv2.polylines(image, [pts], True, (0,0,255), iii)
cv2.imshow("Polygon", image)
cv2.waitKey(0)
cv2.destroyAllWindows()

                image = np.zeros((512,512,3), np.uint8)                cv2.putText(image, 'Hello World!', (75,290), cv2.FONT_HERSHEY_COMPLEX, 2, (100,170,0), 3)
cv2.imshow("Hello World!", image)
cv2.waitKey(0)
cv2.destroyAllWindows()

                import cv2
import numpy as np
prototype = cv2.imread('../information/images/mark.jpg') # Draw a line
imageLine = image.re-create()
cv2.line(imageLine, (322, 179), (400, 183), (0, 255, 0),
thickness=2, lineType=cv2.LINE_AA)
cv2.imshow("imageLine", imageLine)
cv2.imwrite("imageLine.jpg", imageLine)
# Draw a circle
imageCircle = image.copy()
cv2.circle(imageCircle, (350, 200), 150, (0, 255, 0),
thickness=two, lineType=cv2.LINE_AA)
cv2.imshow("imageCircle", imageCircle)
cv2.imwrite("imageCircle.jpg", imageCircle)
# Describe an ellipse
# IMP Note: Ellipse Centers and Centrality lengths must exist integers
imageEllipse = image.copy()
cv2.ellipse(imageEllipse, (360, 200), (100, 170), 45, 0, 360,
(255, 0, 0), thickness=2, lineType=cv2.LINE_AA)
cv2.ellipse(imageEllipse, (360, 200), (100, 170), 135, 0, 360,
(0, 0, 255), thickness=2, lineType=cv2.LINE_AA)
cv2.imshow("ellipse", imageEllipse)
cv2.imwrite("imageEllipse.jpg", imageEllipse)
# Describe a rectangle (thickness is a positive integer)
imageRectangle = image.copy()
cv2.rectangle(imageRectangle, (208, 55), (450, 355), (0, 255, 0),
thickness=two, lineType=cv2.LINE_8)
cv2.imshow("rectangle", imageRectangle)
cv2.imwrite("imageRectangle.jpg", imageRectangle)
# Put text into image
imageText = image.re-create()
cv2.putText(imageText, "Mark Zuckerberg", (205, 50),
cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 255, 0), 2)
cv2.imshow("text", imageText)
cv2.imwrite("imageText.jpg", imageText)
cv2.waitKey(0)
cv2.destroyAllWindows()

Source: https://medium.com/@rndayala/drawing-over-images-9789838ef558

Posted by: greenlyharsecy.blogspot.com

0 Response to "How To Draw Concentric Circles In Java"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel