alyssaq / hough_transform

Hough Transform implementation in Python
127 stars 53 forks source link

transformation is taking too long #2

Closed knasim closed 2 years ago

knasim commented 6 years ago

width, height = img.shape ( this returns tuple of 3) how are you expecting only 2 ?
according to my calculation this loo shall run approx. 3 million times (too long)

  for i in range(len(x_idxs)):
    x = x_idxs[i]
    y = y_idxs[i]

    for t_idx in range(num_thetas):
      #print("looping ", t_idx)
      rho = round(x * cos_t[t_idx] + y * sin_t[t_idx]) + diag_len
      accumulator[rho.astype(np.uint64), t_idx] += 1
alyssaq commented 6 years ago

The jpg black values were showing up as 1 values rather than 0 and so the entire image became the search space. I've added a minimum threshold value to ignore values <5 in https://github.com/alyssaq/hough_transform/commit/5114918e6e060b85d0d14be56591318155fde4ba and it should finish much faster. Please do try it out 😄

knasim commented 6 years ago

@alyssaq - thanks I'll give it shot and let you know.