[SciPy-User] Bresenham algorithm?
Xavier Gnata
xavier.gnata at gmail.com
Mon Sep 21 21:08:45 EDT 2009
David Warde-Farley wrote:
> On 21-Sep-09, at 2:42 AM, Sebastian Haase wrote:
>
>
>> If you comment out the list/tuples handling - assuming you want to
>> plug in numpy arrays here, you have to know the number of points up
>> front.
>> (To be able to pre-allocate the array correctly)
>> Is this easy ? (rounding errors ?)
>>
>
> Yes, notice that the loop termination condition. You'd simply need to
> allocate two arrays, each 'dx' long. But in his case, he'd be better
> off taking the image array as an argument and accessing each pixel as
> he goes in order to sum them. Assuming the image is reasonably scaled
> and he uses an appropriate precision accumulator, that seems like the
> best way to approach the problem rather than allocating space for
> indices only to use them once (a more general purpose implementation,
> of course, would have to accumulate/return indices).
>
> David
> _______________________________________________
> SciPy-User mailing list
> SciPy-User at scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>
Your answers are perfect because they also provide me with a nice cython
example.
Thanks!
More information about the SciPy-User
mailing list