1

Box Blur

Unsolved
Computer Vision

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

Amazon
Apple
Facebook
Google
Netflix

Box blurring is a spatial domain linear filter which calculates the average value of neighboring pixels from the input image. A 3 x 3 box blur kernel can be written as: 

\({1\over9}\begin{bmatrix} 1 & 1 & 1\\ 1 & 1 & 1 \\ 1 & 1 & 1 \end{bmatrix} \)

Write a function box_blur(image) which performs the box blur operation on given grayscale image (represented as numpy 2D array) and returns the resultant blurred image.  

Sample Input:
<class 'numpy.ndarray'>
image: [[ 1 7 119 13 12] [ 11 21 61 81 91] [ 5 66 6 5 5] [ 5 66 166 145 155] [ 5 66 136 145 155]]

Expected Output:
<class 'numpy.ndarray'>
[[ 4.44444444 24.44444444 33.55555556 41.88888889 21.88888889] [ 12.33333333 33. 42.11111111 43.66666667 23. ] [ 19.33333333 45.22222222 68.55555556 79.44444444 53.55555556] [ 23.66666667 57.88888889 89. 102. 67.77777778] [ 15.77777778 49.33333333 80.44444444 100.22222222 66.66666667]]

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Quis assumenda pariatur consequuntur minus at, deserunt ducimus cumque error quod blanditiis, qui corrupti adipisci labore, ipsam nihil praesentium qui asperiores veritatis eligendi odio iure temporibus dignissimos corrupti? Suscipit voluptates est perspiciatis, labore reiciendis sunt dolore neque iste animi assumenda praesentium ad est quam? Accusamus accusantium fugiat quas reiciendis vitae voluptatum. Neque nemo voluptates?

Maiores alias facilis enim, odio placeat error, eveniet aspernatur corrupti obcaecati.

Voluptas amet ea? Molestias natus nesciunt alias, nostrum beatae eos pariatur quisquam placeat consequuntur consectetur soluta dolore atque repellat, modi officia deserunt vel sint culpa tempora, labore voluptas aliquam, rerum commodi nobis distinctio iste quo velit quibusdam hic excepturi? Est iste minima aperiam consequatur blanditiis debitis consequuntur officia dolor sunt recusandae?

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

Ready.

Input Test Case

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