I am trying to implement circular hough transform by equation, r = sqrt((x-h)^2-(y-k)^2) for detecting circle from image.
I applied list of step like Gaussian Blur, canny. After that i am not getting how to implement above equation if radius and boundary points are available. After implementation i will get accumulator space which contain radius and center of detected circle. I want to implement with out HoughCircle function of opencv. Is there any idea which can help me?It's taking so much time.
import numpy as np
import cv2
import math
image = cv2.imread(imagepath)
h, w = image.shape[:2]
print h, w
grayimg = cv2.cvtColor(image,cv2.COLOR_BGR2GRAY)
bimg = cv2.bilateralFilter(grayimg, 5, 175, 175)
cann = cv2.Canny(bimg,100,200)
pixel = np.argwhere(cann == 255)
accum = []
ct = 0
for r in range(10,21):
for h in range(0,20):
for k in range(0,20):
for p in pixel:
print r,h,k,p
xpart = (h - p[0])**2
ypart = (k - p[1])**2
rhs = xpart + ypart
lhs = r * r
if(lhs == rhs):
accum.append((r,(h,k),p))
print len(accum)
cv2.waitKey(0)