integral image for each depth in a three dimensional array
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
Hi Masa, actually you can pass a 3D 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
@Emmanuelle: didn't know about that, thanks for pointing that out! Johannes Schönberger Am 06.08.2013 um 11:43 schrieb Emmanuelle Gouillart <emmanuelle.gouillart@nsup.org>:
Hi Masa,
actually you can pass a 3D 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
 You received this message because you are subscribed to the Google Groups "scikitimage" group. To unsubscribe from this group and stop receiving emails from it, send an email to scikitimage+unsubscribe@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
On Tue, Aug 06, 2013 at 11:45:31AM +0200, Johannes SchÃ¯Â¿Â½nberger wrote:
@Emmanuelle: didn't know about that, thanks for pointing that out!
Johannes SchÃ¯Â¿Â½nberger
Didn't know either, but I had a look at the code: return x.cumsum(1).cumsum(0) so additional dimensions are "transparent" Emma
Am 06.08.2013 um 11:43 schrieb Emmanuelle Gouillart <emmanuelle.gouillart@nsup.org>:
Hi Masa,
actually you can pass a 3D 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
 You received this message because you are subscribed to the Google Groups "scikitimage" group. To unsubscribe from this group and stop receiving emails from it, send an email to scikitimage+unsubscribe@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Hi, That's the way to do it, but I'd directly save the result in the output array:
ret = np.empty_like(image) for i in range(depth): ret[:,:,i] = integral_image(image[:,:,i])
Johannes Schönberger Am 06.08.2013 um 11:36 schrieb masa <masahi129@gmail.com>:
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
 You received this message because you are subscribed to the Google Groups "scikitimage" group. To unsubscribe from this group and stop receiving emails from it, send an email to scikitimage+unsubscribe@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
participants (3)

Emmanuelle Gouillart

Johannes Schönberger

masa