[Numpy-discussion] efficient sum of "sparse" 2D arrays?
hinsen at cnrs-orleans.fr
Mon Jan 26 00:17:01 CST 2004
On 26.01.2004, at 07:14, RJS wrote:
> The problem: I have a "stack" of 8, 640 x 480 integer image arrays
> from a FITS cube concatenated into a 3D array, and I want to sum each
> pixel such that the result ignores clipped values (255+); i.e., if two
> images have clipped pixels at (x,y) the result along z will be the sum
> of the other 6.
Memory doesn't seem critical for such small arrays, so you can just do
sum([where(a < 255, a, 0) for a in images])
More information about the Numpy-discussion