[SciPy-User] Extract a segment from a 2D array

ejefree ejefree at yandex.ru
Tue Jan 25 06:30:09 EST 2011


>>> import numpy as np
>>> a = np.ones([100,100])
>>> b = a[10:43, 12:43].flatten()

2011/1/24 Xavier Gnata <xavier.gnata at gmail.com>

> Hi,
>
> Let's take an example:
> I have a 100x100 2D array.
> I want to extract all the values on a segment starting at (10,12) and
> ending at (42,42) and put them in a 1D array.
> Of course I can code the type Bresenham's line algorithm but I think I
> reinventing the wheel.
> What's the scipy way to deal with that? (If needed, I can use matplotlib)
>
>
> @+,
> Xavier
>
> _______________________________________________
> SciPy-User mailing list
> SciPy-User at scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20110125/8b3ed1bb/attachment.html>


More information about the SciPy-User mailing list