I want to compute the integral image. for example
a=array([(1,2,3),(4,5,6)])
b = a.cumsum(axis=0)
This will generate another array b.Can I execute the cumsum
in-place. If not . Are there any other methods to do that
Python NumPy cumsum() function is used to return the cumulative sum of the array elements along the given axis.
The cumsum() method returns a DataFrame with the cumulative sum for each row. The cumsum() method goes through the values in the DataFrame, from the top, row by row, adding the values with the value from the previous row, ending up with a DataFrame where the last row contains the sum of all values for each column.
cumsum. Return the cumulative sumcumulative sumA running total is the summation of a sequence of numbers which is updated each time a new number is added to the sequence, by adding the value of the new number to the previous running total. Another term for it is partial sum.https://en.wikipedia.org › wiki › Running_totalRunning total - Wikipedia of the elements along a given axis.
You have to pass the argument out
:
np.cumsum(a, axis=1, out=a)
OBS: your array is actually a 2-D array, so you can use axis=0
to sum along the rows and axis=1
to sum along the columns.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With