梯度霍夫变换圆检测

import  cv2 as cv
import matplotlib.pyplot as plt
img=cv.imread(r'C:\Users\51102\Desktop\tradition\1.jpg',0)
print('img.shape=',img.shape)
circles=cv.HoughCircles(img,cv.HOUGH_GRADIENT,1,100,200,param1=60,param2=20,minRadius=15,maxRadius=150)
print(circles.shape)
for i in range(circles.shape[1]):
    center=(int(circles[0,i,0]),int(circles[0,i,1]))
    r=circles[0,i,2]
    cv.circle(img,center,r,255,4)
plt.imshow(img,cmap='gray')
plt.show()

 

 

 结果显示:


 

 






posted @ 2023-03-03 09:55  tangjunjun  阅读(32)  评论(0编辑  收藏  举报
https://rpc.cnblogs.com/metaweblog/tangjunjun