Re: [Numpy-discussion] Matlab/Numpy index order

2009-05-12 Thread Robert Kern
On Tue, May 12, 2009 at 15:32, Chris Colbert wrote: > This is interesting. > > I have always done RGB imaging with numpy using arrays of shape (height, > width, 3). In fact, this is the form that PIL gives when calling > np.asarray() on a PIL image. > > It does seem more efficient to be able to do

Re: [Numpy-discussion] Matlab/Numpy index order

2009-05-12 Thread Chris Colbert
This is interesting. I have always done RGB imaging with numpy using arrays of shape (height, width, 3). In fact, this is the form that PIL gives when calling np.asarray() on a PIL image. It does seem more efficient to be able to do a[0],a[1],a[2] to get the R, G, and B channels respectively. Thi

Re: [Numpy-discussion] Matlab/Numpy index order

2009-05-12 Thread David Warde-Farley
On 12-May-09, at 3:55 PM, Ryan May wrote: > > It's going to be faster to do it without the transpose. Besides, > for numpy, > that imshow becomes: > >imshow(b[0]) > > Which, IMHO, looks better than Matlab. You're right, that is better, odd how I never thought of doing it like that. I've

Re: [Numpy-discussion] Matlab/Numpy index order

2009-05-12 Thread Robert Kern
On Tue, May 12, 2009 at 14:55, Ryan May wrote: > On Tue, May 12, 2009 at 2:51 PM, brechmos wrote: >> >> So, in Numpy I have to reshape it so the "slices" are in the first >> dimension.  Obviously, I can do a b.transpose( (1,2,0) ) to get it to look >> like Matlab, but... >> >> I don't understand

Re: [Numpy-discussion] Matlab/Numpy index order

2009-05-12 Thread brechmos
Ah, hah. In [3]: c = b.reshape((256,256,150), order='F') Ok, I needed more coffee. If I do it this way (without the transpose), it should be as fast as c=b.reshape((150,256,256)), right? It is just changing the stride (or something like that)? Or is it going to be faster without changing th

Re: [Numpy-discussion] Matlab/Numpy index order

2009-05-12 Thread Ryan May
On Tue, May 12, 2009 at 2:51 PM, brechmos wrote: > So, in Numpy I have to reshape it so the "slices" are in the first > dimension. Obviously, I can do a b.transpose( (1,2,0) ) to get it to look > like Matlab, but... > > I don't understand why the index ordering is different between Matlab and >

[Numpy-discussion] Matlab/Numpy index order

2009-05-12 Thread brechmos
I am very new to Numpy and relatively new to Python. I have used Matlab for 15+ years now. But, I am starting to lean toward using Numpy for all my work. One thing that I am not understanding is the order of data when read in from a file. Let's say I have a 256x256x150 uint16 dataset (MRI, 150