Combining Sebastian and Jae-Joon's suggestions, I have something that
might work:
>>> timeit numpy.bincount(array.flat)
10 loops, best of 3: 28.2 ms per loop
This is close enough to video-rate... And I can then combine bins as
needed to get a particular bin count/range after the fact.
Thank
Hello,
>> But even if indices = array, one still needs to do something like:
>> for index in indices: histogram[index] += 1
> numpy.bincount?
That is indeed what I was looking for! I knew I'd seen such a function.
However, the speed is a bit disappointing. I guess the sorting isn't
too much of
Hi Zach,
I have a similar loop which I wrote using scipy.weave. This was my first
foray into weave, and I had to dig through the intermediate C sources to
find the macros that did the indexing in the way I make use of here, but
this snipped may get you started. There are 2 functions, which each do
On 17/04/2008, Zachary Pincus wrote:
> But even if indices = array, one still needs to do something like:
> for index in indices: histogram[index] += 1
>
> Which is slow in python and fast in C.
>
I haven't tried this, but if you want the sum in C you could do
for x in unique(indices):
his
> But even if indices = array, one still needs to do something like:
> for index in indices: histogram[index] += 1
>
> Which is slow in python and fast in C.
>
> I'm guessing that there's no utility function in numpy that does a
> loop like this? If so, that would be handy, but if now, I think
>> But even if indices = array, one still needs to do something like:
>> for index in indices: histogram[index] += 1
>>
>> Which is slow in python and fast in C.
>>
>>
> I thought of a broadcasting approach... what are the chances that a
> simple
>
> bins[:] = 0
> bins[ img.flat ] += 1
That does
On Thu, Apr 17, 2008 at 6:54 PM, Zachary Pincus <[EMAIL PROTECTED]> wrote:
> Hi, and thanks for the suggestion!
>
>
> > How many bits per pixel does your camera actually generate !?
> > If its for example a 12 bit camera, you could just fill in directly
> > into 4096 preallocated bins.
> > You
Hi, and thanks for the suggestion!
> How many bits per pixel does your camera actually generate !?
> If its for example a 12 bit camera, you could just fill in directly
> into 4096 preallocated bins.
> You would not need any sorting !!
> That's what I did for a 16 bit camera -- but I wrote it in C
Hi,
> How about a combination of sort, followed by searchsorted right/left
> using the bin boundaries as keys? The difference of the two
> resulting vectors is the bin value. Something like:
>
> In [1]: data = arange(100)
>
> In [2]: bins = [0,10,50,70,100]
>
> In [3]: lind = data.searchsorted
On Thu, Apr 17, 2008 at 6:18 PM, Charles R Harris
<[EMAIL PROTECTED]> wrote:
>
>
> On Thu, Apr 17, 2008 at 10:02 AM, Zachary Pincus <[EMAIL PROTECTED]>
> wrote:
> > Hi folks,
> >
> > I'm working on a live-video display for some microscope control tools
> > I'm building. For this, I need a fast his
On Thu, Apr 17, 2008 at 10:02 AM, Zachary Pincus <[EMAIL PROTECTED]>
wrote:
> Hi folks,
>
> I'm working on a live-video display for some microscope control tools
> I'm building. For this, I need a fast histogram function to work on
> large-ish images (1000x2000 or so) at video rate, with cycles l
Hi folks,
I'm working on a live-video display for some microscope control tools
I'm building. For this, I need a fast histogram function to work on
large-ish images (1000x2000 or so) at video rate, with cycles left
over for more interesting calculations (like autofocus).
Now, numpy.histogr
12 matches
Mail list logo