pro*_*jit 7 opencv image python-3.x
我有一张图像和一个坐标(X,Y)。如何在此坐标上绘制点。我想使用Python OpenCV。
小智 39
您可以使用 cv2.circle() 函数 opencv 模块:
image = cv.circle(image, centerOfCircle, radius, color, thickness)
Run Code Online (Sandbox Code Playgroud)
保持半径为 0 以绘制单个点,厚度为负数以绘制实心圆
import cv2
image = cv2.circle(image, (x,y), radius=0, color=(0, 0, 255), thickness=-1)
Run Code Online (Sandbox Code Playgroud)
Mar*_*ell 10
I'm learning the Python bindings to OpenCV too. Here's one way:
#!/usr/local/bin/python3
import cv2
import numpy as np
w=40
h=20
# Make empty black image
image=np.zeros((h,w,3),np.uint8)
# Fill left half with yellow
image[:,0:int(w/2)]=(0,255,255)
# Fill right half with blue
image[:,int(w/2):w]=(255,0,0)
# Create a named colour
red = [0,0,255]
# Change one pixel
image[10,5]=red
# Save
cv2.imwrite("result.png",image)
Run Code Online (Sandbox Code Playgroud)
这是结果-放大后可以看到。
这是非常简洁但不太有趣的答案:
#!/usr/local/bin/python3
import cv2
import numpy as np
# Make empty black image
image=np.zeros((20,40,3),np.uint8)
# Make one pixel red
image[10,5]=[0,0,255]
# Save
cv2.imwrite("result.png",image)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
11996 次 |
| 最近记录: |