integral image for each depth in a three dimensional array

Emmanuelle Gouillart emmanuelle.gouillart at nsup.org
Tue Aug 6 05:43:05 EDT 2013


Hi Masa,

actually you can pass a 3-D array to integral_image :

>>> from skimage import transform
>>> a = np.arange(27).reshape((3, 3, 3))
>>> a
array([[[ 0,  1,  2],
        [ 3,  4,  5],
        [ 6,  7,  8]],

       [[ 9, 10, 11],
        [12, 13, 14],
        [15, 16, 17]],

       [[18, 19, 20],
        [21, 22, 23],
        [24, 25, 26]]])
>>> transform.integral_image(a)
array([[[  0,   1,   2],
        [  3,   5,   7],
        [  9,  12,  15]],

       [[  9,  11,  13],
        [ 24,  28,  32],
        [ 45,  51,  57]],

       [[ 27,  30,  33],
        [ 63,  69,  75],
        [108, 117, 126]]])


Would this do the trick?
Cheers,
Emmanuelle

On Tue, Aug 06, 2013 at 02:36:32AM -0700, masa wrote:
> Hi all,

> I want to calculate integral images for each depth in a three dimensional
> array.
> My code is something like this:

> ret = np.empty(height, width, depth)
> int_imgs = [integral_image(image[:,:,i]) for i in range(depth)]
> for i in range(depth):
>       ret[:,:,i] = int_imgs[i]

> Is there better way to do this?

> Thanks,
> masa



More information about the scikit-image mailing list