0

Integral Image

Unsolved
Computer Vision

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

Apple
Facebook
Google
Netflix

In an integral image, each pixel represents the cumulative sum of a corresponding input pixel with all pixels above and to the left of the input pixel. While calculating the integral image of an input image, the dimension h and w will be increased by 1. 

For a given input image (represented by 2D NumPy array), calculate and return the integral image. 

Sample Input:
<class 'numpy.ndarray'>
mat: [[17 24 1 8 32] [84 5 19 15 16] [ 4 6 13 20 22] [10 12 19 21 3] [11 18 25 2 9]]

Expected Output:
<class 'numpy.ndarray'>
[[ 0 0 0 0 0 0] [ 0 17 41 42 50 82] [ 0 101 130 150 173 221] [ 0 105 140 173 216 286] [ 0 115 162 214 278 351] [ 0 126 191 268 334 416]]

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

Comments
Ready.

Input Test Case

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