【问题标题】:Jagged edges around the circle in OpenCV - PythonOpenCV中圆圈周围的锯齿状边缘 - Python
【发布时间】:2018-06-14 12:51:47
【问题描述】:

正如标题所说,我正在尝试修复我在 OpenCV 中创建的圆圈周围的锯齿状边缘。

我尝试了一些方法,例如 cv2.blur()cv2.filter2D(),但它们没有成功。

import numpy as np
import cv2
import random

for i in range(5):
    img = np.zeros((512,512,3), np.uint8)
    H = random.choice(list(range(100,500)))
    V = random.choice(list(range(100,500)))
    S = random.choice(list(range(30,150)))

    cv2.circle(img,(H,V), S, (0,0,255), -1)

    img = cv2.resize(img,(750,750))
    f = (3-len(str(i)))*'0'+str(i)
    cv2.imwrite('circle%s.jpg' % f, img)

cv2.destroyAllWindows()

【问题讨论】:

    标签: python opencv cv2


    【解决方案1】:

    我认为您正在寻找抗锯齿轮廓。您可以通过设置 lineType 参数来做到这一点:

    cv2.circle(img,(H,V), S, (0,0,255), -1, lineType=cv2.LINE_AA)
    

    【讨论】:

    • 太棒了!非常感谢。圆圈现在看起来很棒。
    • ..thickness=cv2.FILLED..(没有参数名称的魔术常数-1是不好的编码习惯)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-09-14
    • 2019-04-30
    • 1970-01-01
    • 2019-07-22
    • 1970-01-01
    相关资源
    最近更新 更多