I am following a tutorial on writing a Hough algorithm in Python: to my understanding it is very well written but I am new to computer graphic algorithms (not really used to thinking in terms of graphs at all).

For most other bits I have a flimsy understanding but I really cannot wrap my head around the last part of code where the highest voted line is extracted from the Hough space:

# Easiest peak finding based on max votes
idx = np.argmax(accumulator)
rho = rhos[idx / accumulator.shape[1]]
theta = thetas[idx % accumulator.shape[1]]

This is the final code of the script (from the link above) operating on a returned accumulator space from a Hough algorithm function. What I don't understand is why the appropriate index is divided, and then 'modulus-ed' by the range of theta values (that is the return of accumulator.shape[1]), out of the two, perhaps the modulus makes the most sense to me. I verify that it works - I have tested it, but nonetheless I don't understand it

Really this is an implementation detail but I am pretty stuck so I wanted to ask here


Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.