ENH: add sum_angle() and sum_polar() functions to twodim_base.py #230

Open
wants to merge 1 commit into
from

Conversation

Projects
None yet
5 participants

jordens commented Mar 7, 2012

 sum_angle() computes the sum of a 2-d array along an angled axis sum_polar() along radial lines or along azimuthal circles
``` add sum_angle() and sum_polar() functions. ```
```sum_angle() computes the sum of a 2-d array along an angled axis
sum_polar() along radial lines or along azimuthal circles```
``` ba7766e ```
Member

rgommers commented Mar 7, 2012

 Hi @jordens, I can see how this would be useful, but adding new functions should really be discussed on the numpy-discussion mailing list first. Could you please bring it up there?

charris reviewed May 21, 2012

 + ``sum_angle(m, angle=0) == sum(m, axis=0)`` + ``sum_angle(m, angle=pi/2) == sum(m, axis=1)`` + aspect : float, optional + The input bin aspect ratio (second dimension/first dimension)

charris May 21, 2012

Member

Dimension or component?

jordens May 21, 2012

Dimension. Or I don`t understand what you mean by component.

Member

charris commented May 21, 2012

 Correct me if I am wrong, but this looks like it is intended to work on images. Is that the case?

jordens commented May 21, 2012

 Images are certainly a major application. But this is also interesting in the analysis of matrices that represent graphs.
Member

charris commented May 21, 2012

 I was asking because I thought this might be more appropriate for one of the image processing packages. In particular, it seems related to the Hough transform. I assume the application to graphs uses the adjacency matrix. In any case, it might be worth putting up a post on the scipy mailing list as well as here since that is where graph and image algorithms are located.
Member

teoliphant commented May 21, 2012

 The sum_angle function seems equivalent to the scipy.misc.radon function which is deprecated (but a very useful function). Because your implementation is so straightforward and well documented it could be useful in NumPy as well, but I agree with Chuck that you should ask on the SciPy list as well.

jordens commented May 21, 2012

 Yes. angle_sum is a Hough or Radon transform. The implementation in scipy has a couple of problems: It is based on PIL and does not seem to work with floats. It does not conserve the sum over all entries (independent of padding...). Finally, the interpolations used in PIL do not really make sense in this application. It is also 40% slower than this one. Scikits-image has taken the radon transform from scipy: https://github.com/scikits-image/scikits-image/blob/master/skimage/transform/radon_transform.py I believe that one does not suffer the problems the PIL-based one has. But it looks even slower. I'll raise this on the scipy/scikits list.
Contributor

stefanv commented May 21, 2012

 @jordens Could we use your sum_angle in scikits-image? I'd love to improve the execution speed of the radon and hough transforms (actually, I think the hough tf already uses the bincount trick, so it may not benefit). Perhaps you would be interested in working on a PR together?

jordens commented May 21, 2012

 @stefanv Sure. Feel free. I will help if I can find the time. OTOH I would still love to see these added to numpy and agree with Travis' reasoning.