python opencv 霍夫圆变换

import cv2
import numpy as np

img = cv2.imread('touxiang.jpg',0)
img = cv2.medianBlur(img,5)
cimg = cv2.cvtColor(img,cv2.COLOR_GRAY2BGR)

circles = cv2.HoughCircles(img,cv2.HOUGH_GRADIENT,1,20,param1=50,param2=30,minRadius=100,maxRadius=200)
print(circles[0])
circles = np.uint16(np.around(circles))
for i in circles[0,:]:
    # draw the outer circle
    cv2.circle(cimg,(i[0],i[1]),i[2],(0,255,0),2)
    # draw the center of the circle
    cv2.circle(cimg,(i[0],i[1]),2,(0,0,255),3)

cv2.imshow('detected circles',cimg) 
cv2.waitKey(0)
cv2.destroyAllWindows()


[[329.5 140.5 111.4]
 [310.5 132.5 121.3]
 [289.5 178.5 156.5]
 [253.5 254.5 143.3]
 [296.5 207.5 131.2]
 [289.5 151.5 143.3]
 [325.5 186.5 155.4]
 [338.5 160.5 133.4]
 [314.5 108.5 103.6]
 [258.5 182.5 141.1]
 [232.5 234.5 171.9]
 [316.5 165.5 142.2]
 [252.5 397.5 192.8]
 [281.5 125.5 143.3]
 [372.5 209.5 192.8]
 [367.5 238.5 171.9]
 [246.5 132.5 173. ]
 [265.5 271.5 125.6]
 [319.5 218.5 105.9]
 [282.5 420.5 157.6]
 [271.5 199.5 133.4]
 [292.5 455.5 115.7]
 [301.5 233.5 105.9]
 [218.5 173.5 126.8]
 [253.5 435.5 170.8]
 [267.5 143.5 160.9]
 [297.5 435.5 135.6]
 [344.5 125.5 108.1]
 [309.5 413.5 160.8]
 [363.5 145.5 101.5]
 [240.5 172.5 118. ]
 [274.5 389.5 178.5]
 [367.5 355.5 191.7]
 [359.5 328.5 154.3]
 [345.5 179.5 103.7]
 [330.5 411.5 190.6]
 [232.5 114.5 160.9]
 [281.5  80.5 111.3]
 [294.5 109.5 104.8]
 [239.5 152.5 127.9]
 [243.5  97.5 187.3]
 [300.5 392.5 178.5]
 [257.5 215.5 112.5]
 [337.5 105.5 100.4]
 [337.5 208.5 136.7]
 [289.5 273.5 102.6]
 [338.5 258.5 141.1]
 [298.5 360.5 181.8]
 [202.5  94.5 157.6]
 [235.5 206.5 112.5]
 [272.5 163.5 109.2]
 [391.5 173.5 141.1]
 [268.5 237.5 101.5]
 [234.5 425.5 178.5]
 [327.5  84.5 111.4]
 [ 69.5 383.5 159.8]
 [374.5 162.5 121.3]
 [254.5  62.5 143.3]
 [415.5 211.5 185.1]
 [236.5  72.5 156.5]
 [178.5 120.5 141.1]
 [356.5 267.5 141.1]
 [408.5 135.5 112.3]
 [372.5 117.5 108. ]
 [269.5 460.5 123.5]
 [225.5  41.5 178.5]
 [353.5 288.5 123.5]
 [327.5 295.5 101.5]
 [342.5 311.5 130.1]
 [404.5 192.5 159.8]
 [215.5 140.5 111.4]
 [261.5 114.5 101.5]
 [394.5 115.5 130.1]
 [306.5  88.5 111.3]
 [101.5 344.5 123.4]
 [316.5 455.5 112.4]
 [274.5 440.5 135.6]
 [325.5 432.5 155.4]
 [365.5 185.5 119.1]
 [433.5 136.5 134.5]
 [263.5  92.5 124.5]
 [106.5 321.5 116.9]
 [131.5 190.5 115.7]
 [384.5 140.5 105.9]
 [ 85.5 332.5 139.9]
 [215.5 215.5 101.5]
 [411.5 157.5 102.6]
 [364.5  97.5 103.5]
 [ 96.5 367.5 109.2]
 [ 23.5 331.5 187.3]
 [207.5 117.5 105.9]
 [272.5  51.5 103.6]
 [299.5 474.5 103.5]
 [278.5 478.5 121.1]
 [431.5 159.5 108. ]
 [ 58.5 348.5 135.6]
 [203.5  72.5 104.8]
 [126.5 217.5 109.2]]
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值