[Numpy-discussion] np.histogram on arrays.

eat e.antero.tammi@gmail....
Wed Mar 30 05:26:38 CDT 2011


Hi,

On Wed, Mar 30, 2011 at 10:04 AM, Éric Depagne <eric@depagne.org> wrote:

> Hi.
>
> Sorry for not having been clearer. I'll explain a little bit.
>
> I have 4k x 4k images that I want to analyse. I turn them into numpy arrays
> so
> I have 4k x 4k np.array.
>
> My analysis starts with determining the bias level. To do that, I compute
> for
> each line, and then for each row, an histogram.
> So I compute 8000 histograms.
>
> Here is the code I've used sofar:
>
>        for i in range(self.data.shape[0]):
>           #Compute an histogram along the columns
>           # Gets counts and bounds
>            self.countsC[i], self.boundsC[i] = np.histogram(data[i],
> bins=self.bins)
>        for i in range(self.data.shape[1]):
>            # Do the same, along the rows.
>            self.countsR[i], self.boundsR[i] = np.histogram(data[:,i],
> bins=self.bins)
>
> And data.shape is (4000,4000).
>
> If histogram  had an axis parameter, I could avoid the loop and I guess it
> would be faster.
>
Well I guess, for a slight performance improvement, you could create your
own streamlined histogrammer.

But, in order to better grasp your situation it would be beneficial to know
how the counts and bounds are used later on. Just wondering if this kind
massive histogramming could be somehow avoided totally.

Regards,
eat

>
> Éric.
> > So it seems that you give your array directly to histogramdd (asking a
> > 4000D histogram!). Surely that's not what you are trying to achieve. Can
> > you elaborate more on your objectives? Perhaps some code (slow but
> > working) to demonstrate the point.
> >
> > Regards,
> > eat
> >
>
> Un clavier azerty en vaut deux
> ----------------------------------------------------------
> Éric Depagne                            eric@depagne.org
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20110330/0fe70269/attachment.html 


More information about the NumPy-Discussion mailing list