[SciPy-user] Indexing question
Thu Dec 18 04:46:47 CST 2008
On Wed, Dec 17, 2008 at 4:52 PM, Angus McMorland <email@example.com> wrote:
> There are two tricks that will help you out here:
> (1) indexing with a list is treated differently to indexing with an array
I tend to tuple my coordinate arrays. Seems to work also with your
example. Does this function the same way, or are there hidden
> (2) indexing across the first consecutive dimensions and extracting
> latter ones is easier than extracting earlier dimensions together
> based on indices in latter dimensions
Ok. So basically it's best to implement vector images with the
coordinate dimensions first and vector dimension (RGB, gradient,
optical flow, hyperspectral data, whatever...) last, (x,y,v) IOW, to
save on transposing all the time. Good to know. Apparently it'd be
easier to implement the coordinate array in a (2, n) shape as well.
OTOH, I mainly chose (n, 2) because it's more readable in print
statements, and it allows for "for x in coordinates" statements.
Preferences, I guess.
> So, this works:
Indeed it does. Thanks!
More information about the SciPy-user