[SciPy-User] numpy.histogram is slow

Jerome Kieffer Jerome.Kieffer@esrf...
Thu Oct 18 02:26:35 CDT 2012

On Tue, 16 Oct 2012 13:04:24 -0700
Chris Weisiger <cweisiger@msg.ucsf.edu> wrote:

> My use case is displaying camera image data to the user as it is
> streamed to us; this includes a histogram showing the distribution of
> intensities in the image. Thus I have a 512x512 array of pixel data
> (unsigned 16-bit ints) that I need to generate a histogram for.
> Unfortunately, numpy.histogram takes a significant amount of time --
> about 15ms per call. That's over 60% of the cost of showing an image
> to the user, which means that I can't quite display data as quickly as
> it comes in. So I'm looking for some faster option.

I implemented a 1D and 2D histogram, weighted and unweighted using cython (>=0.17) in parallel.
It is much faster than the one provided by numpy: 
4ms vs 25ms in your case on my computer

Jérôme Kieffer
On-Line Data analysis / Software Group 
tel +33 476 882 445

More information about the SciPy-User mailing list