[Numpy-discussion] np.histogram on arrays.

Éric Depagne eric at depagne.org
Wed Mar 30 03:04:39 EDT 2011


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], 
        for i in range(self.data.shape[1]):
	    # Do the same, along the rows.
            self.countsR[i], self.boundsR[i] = np.histogram(data[:,i], 

And data.shape is (4000,4000).

If histogram  had an axis parameter, I could avoid the loop and I guess it 
would be faster.

> 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 at depagne.org

More information about the NumPy-Discussion mailing list