Re: [Numpy-discussion] np.zeros(2, 'S') returns empty strings.

2012-01-15 Thread Nathaniel Smith
On Sat, Jan 14, 2012 at 2:12 PM, Charles R Harris charlesr.har...@gmail.com wrote: This sort of makes sense, but is it the 'correct' behavior? In [20]: zeros(2, 'S') Out[20]: array(['', ''],   dtype='|S1') I think of numpy strings as raw fixed-length byte arrays (since, well, that's

Re: [Numpy-discussion] Negative indexing.

2012-01-15 Thread Daniele Nicolodi
On 15/01/12 00:53, Nathan Faggian wrote: Hi, I am finding it less than useful to have the negative index wrapping on nd-arrays. Here is a short example: import numpy as np a = np.zeros((3, 3)) a[:,2] = 1000 print a[0,-1] print a[0,-1] print a[-1,-1] In all cases 1000 is printed

Re: [Numpy-discussion] Negative indexing.

2012-01-15 Thread David Cournapeau
On Sat, Jan 14, 2012 at 11:53 PM, Nathan Faggian nathan.fagg...@gmail.com wrote: Hi, I am finding it less than useful to have the negative index wrapping on nd-arrays. Here is a short example: import numpy as np a = np.zeros((3, 3)) a[:,2] = 1000 print a[0,-1] print a[0,-1] print

Re: [Numpy-discussion] np.zeros(2, 'S') returns empty strings.

2012-01-15 Thread josef . pktd
On Sun, Jan 15, 2012 at 3:15 AM, Nathaniel Smith n...@pobox.com wrote: On Sat, Jan 14, 2012 at 2:12 PM, Charles R Harris charlesr.har...@gmail.com wrote: This sort of makes sense, but is it the 'correct' behavior? In [20]: zeros(2, 'S') Out[20]: array(['', ''],   dtype='|S1') I think

[Numpy-discussion] Counting the Colors of RGB-Image

2012-01-15 Thread apo
Counting the Colors of RGB-Image, nameit im0 with im0.shape = 2500,3500,3 with this code: tab0 = zeros( (256,256,256) , dtype=int) tt = im0.view() tt.shape = -1,3 for r,g,b in tt: tab0[r,g,b] += 1 Question: Is there a faster way in numpy to get this result? MfG elodw

Re: [Numpy-discussion] Counting the Colors of RGB-Image

2012-01-15 Thread Tony Yu
On Sun, Jan 15, 2012 at 10:45 AM, a...@pdauf.de wrote: Counting the Colors of RGB-Image, nameit im0 with im0.shape = 2500,3500,3 with this code: tab0 = zeros( (256,256,256) , dtype=int) tt = im0.view() tt.shape = -1,3 for r,g,b in tt: tab0[r,g,b] += 1 Question: Is there a faster

Re: [Numpy-discussion] Counting the Colors of RGB-Image

2012-01-15 Thread Nadav Horesh
im_flat = im0[...,0]*65536 + im[...,1]*256 +im[...,2] colours = np.unique(im_flat) Nadav From: numpy-discussion-boun...@scipy.org [numpy-discussion-boun...@scipy.org] On Behalf Of Tony Yu [tsy...@gmail.com] Sent: 15 January 2012 18:03 To: Discussion of

[Numpy-discussion] Loading a Quicktime moive (*.mov) as series of arrays

2012-01-15 Thread Peter
Hello all, Is there a recommended (and ideally cross platform) way to load the frames of a QuickTime movie (*.mov file) in Python as NumPy arrays? I'd be happy with an iterator based approach, but random access to the frames would be a nice bonus. My aim is to try some image analysis in Python,

Re: [Numpy-discussion] Loading a Quicktime moive (*.mov) as series of arrays

2012-01-15 Thread Robert Kern
On Sun, Jan 15, 2012 at 19:10, Peter numpy-discuss...@maubp.freeserve.co.uk wrote: Hello all, Is there a recommended (and ideally cross platform) way to load the frames of a QuickTime movie (*.mov file) in Python as NumPy arrays? I'd be happy with an iterator based approach, but random