Skip to content

Used NumPy functions to speed up hough_circle#1

Merged
mpkuchera merged 1 commit intodevelopfrom
fast_hough_circle
Apr 6, 2016
Merged

Used NumPy functions to speed up hough_circle#1
mpkuchera merged 1 commit intodevelopfrom
fast_hough_circle

Conversation

@jbradt
Copy link
Copy Markdown
Member

@jbradt jbradt commented Apr 6, 2016

I changed the hough_circle function to use several weird NumPy functions instead of iterating. This made it ~100x faster (my test event changed from 754 ms to 6.73 ms).

The main differences are that it now only computes the differences between the points once, and it constructs Hrad in place rather than iterating over the thetas. The construction is done with np.repeat and np.tile. These functions (which I just discovered yesterday!) are different ways of repeating an array. So, for example,

>>> a = np.array([0, 1, 2])
>>> np.repeat(a, 3)
array([0, 0, 0, 1, 1, 1, 2, 2, 2])
>>> np.tile(a, 3)
array([0, 1, 2, 0, 1, 2, 0, 1, 2])

This appears to be much faster than looping in Python.

@mpkuchera mpkuchera merged commit 7759117 into develop Apr 6, 2016
@jbradt jbradt deleted the fast_hough_circle branch September 7, 2016 20:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants