Summed Area Table - Viola Jones Object Detection

Computer Vision

Difficulty: 6 | Problem written by mesakarghm
Problem reported in interviews at


The value at any point (x,y) in the summed area table is the sum of all the pixels above and to the left of (x,y). 

\(I(x,y) = \sum_{x',y'<= x,y } i(x',y')\)

where i(x,y) is the value of the pixel at (x,y).

For a 2D input array, calculate and return the value of the summed area table. 

Sample Input:
<class 'numpy.ndarray'>
img: [[ 17 24 15 58 15] [ 23 55 47 114 216] [ 4 6 13 220 22] [ 10 12 19 21 3] [ 11 18 25 12 19]]

Expected Output:
<class 'numpy.ndarray'>
[[ 17 41 56 114 129] [ 40 119 181 353 584] [ 44 129 204 596 849] [ 54 151 245 658 914] [ 65 180 299 724 999]]

This is a premium problem, to view more details of this problem please sign up for MLPro Premium. MLPro premium offers access to actual machine learning and data science interview questions and coding challenges commonly asked at tech companies all over the world

MLPro Premium also allows you to access all our high quality MCQs which are not available on the free tier.

Not able to solve a problem? MLPro premium brings you access to solutions for all problems available on MLPro

Get access to Premium only exclusive educational content available to only Premium users.

Have an issue, the MLPro support team is available 24X7 to Premium users.

This is a premium feature.
To access this and other such features, click on upgrade below.

Log in to post a comment

Jump to comment-206
sapna_sharma • 3¬†weeks, 3¬†days ago


1 out of 4 test case is not passing. Please make provision to show the test case input for which the test is not passing.

The result for the sample test case is correct for my code.


Input Test Case

Please enter only one test case at a time
numpy has been already imported as np (import numpy as np)