Ich benötige ein Hough-Transformation, die Kreise findet - die lineare habe ich schon und sie ist wie folgt implementiert:
Code: Alles auswählen
def houghtf_lin(self, img, angles=None):
"""Perform the straight line Hough transform.
Input:
img - a boolean array
angles - in degrees
Output:
H - the Hough transform coefficients
distances
angles
"""
if img.ndim != 2:
raise ValueError("Input must be a two-dimensional array")
img = img.astype(bool)
if not angles:
angles = np.linspace(-90,90,180)
theta = angles / 180. * np.pi
d = np.ceil(np.hypot(*img.shape))
nr_bins = 2*d - 1
bins = np.linspace(-d,d,nr_bins)
out = np.zeros((nr_bins,len(theta)),dtype=itype)
rows,cols = img.shape
x,y = np.mgrid[:rows,:cols]
for i,(cT,sT) in enumerate(zip(np.cos(theta),np.sin(theta))):
rho = np.round_(cT*x[img] + sT*y[img]) - bins[0] + 1
rho = rho.astype(itype)
rho[(rho < 0) | (rho > nr_bins)] = 0
bc = np.bincount(rho.flat)[1:]
out[:len(bc),i] = bc
return out,angles,bins
Wie kann ich diese Hough-Transformation umschreiben, sodass sie auch Kreise erkennt?
Wahrscheinlich muss ich die Gleichung r = x*sin(a) + y*cos(a) umschreiben in die Form r^2 = (x-a)^2 + (y-b)^2..
Aber dann habe ich eine Dimension mehr?
Viele Grüße
-yiiit-