Re: [Numpy-discussion] 3 dim array unpacking

2010-07-12 Thread Anne Archibald
On 12 July 2010 13:24, K.-Michael Aye  wrote:
> Dear numpy hackers,
>
> I can't find the syntax for unpacking the 3 dimensions of a rgb array.
> so i have a MxNx3 image array 'img' and would like to do:
>
> red, green, blue = img[magical_slicing]
>
> Which slicing magic do I need to apply?

Not slicing exactly; unpacking happens along the first dimension, so
you need to reorder your axes so your array is 3xMxN. np.rollaxis is
handy for this, as it pulls the axis you specify to the front:

red, green, blue = np.rollaxis(img,2)

Anne
> Thanks for your help!
>
> BR,
> Michael
>
>
> ___
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


[Numpy-discussion] 3 dim array unpacking

2010-07-12 Thread K . -Michael Aye
Dear numpy hackers,

I can't find the syntax for unpacking the 3 dimensions of a rgb array.
so i have a MxNx3 image array 'img' and would like to do:

red, green, blue = img[magical_slicing]

Which slicing magic do I need to apply?

Thanks for your help!

BR,
Michael


___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion